Commit 91d79dfd authored by James Cook's avatar James Cook Committed by Chromium LUCI CQ

lacros: Delete crosapi::Bitmap C++ class

We now use SkBitmap and its mojo serializer for image transport. This
class is now unused.

This CL deletes everything but the bitmap.mojom file itself. I can't
delete that because there are [Stable] mojo APIs that have optional
Bitmap? deprecated fields.

Bug: 1166395
Change-Id: I7ed76babb7e59101a041d97bfd5221da6cd09792
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2633202Reviewed-by: default avatarErik Chen <erikchen@chromium.org>
Reviewed-by: default avatarJorge Lucangeli Obes <jorgelo@chromium.org>
Auto-Submit: James Cook <jamescook@chromium.org>
Commit-Queue: James Cook <jamescook@chromium.org>
Cr-Commit-Position: refs/heads/master@{#845168}
parent 78ebf066
......@@ -14,8 +14,6 @@
#include "base/bind.h"
#include "base/files/file_path.h"
#include "base/strings/utf_string_conversions.h"
#include "chromeos/crosapi/cpp/bitmap.h"
#include "chromeos/crosapi/cpp/bitmap_util.h"
#include "ui/aura/window_observer.h"
#include "ui/snapshot/snapshot.h"
......
......@@ -10,8 +10,6 @@ config("crosapi_implementation") {
component("cpp") {
output_name = "crosapi_public_cpp"
sources = [
"bitmap_util.cc",
"bitmap_util.h",
"crosapi_constants.cc",
"crosapi_constants.h",
"keystore_service_util.cc",
......@@ -24,21 +22,9 @@ component("cpp") {
"//base",
"//chromeos/crosapi/mojom",
"//mojo/public/cpp/bindings",
"//skia",
]
}
# chromeos/crosapi/mojom depends on this component.
component("cpp_internal") {
output_name = "crosapi_private_cpp"
sources = [
"bitmap.cc",
"bitmap.h",
]
configs += [ ":crosapi_implementation" ]
deps = [ "//base" ]
}
source_set("unit_tests") {
testonly = true
deps = [
......
include_rules = [
"+third_party/skia/include/core",
]
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chromeos/crosapi/cpp/bitmap.h"
namespace crosapi {
Bitmap::Bitmap() = default;
Bitmap::Bitmap(Bitmap&& other) = default;
Bitmap& Bitmap::operator=(Bitmap&& other) = default;
Bitmap::~Bitmap() = default;
} // namespace crosapi
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROMEOS_CROSAPI_CPP_BITMAP_H_
#define CHROMEOS_CROSAPI_CPP_BITMAP_H_
#include <stdint.h>
#include <vector>
#include "base/component_export.h"
namespace crosapi {
// A 4-byte RGBA bitmap representation. Its size must be exactly equal to
// width * height * 4. Move-only because copying |pixels| is expensive.
struct COMPONENT_EXPORT(CROSAPI) Bitmap {
Bitmap();
Bitmap(const Bitmap&) = delete;
Bitmap& operator=(const Bitmap&) = delete;
Bitmap(Bitmap&& other);
Bitmap& operator=(Bitmap&& other);
~Bitmap();
uint32_t width = 0;
uint32_t height = 0;
std::vector<uint8_t> pixels;
};
} // namespace crosapi
#endif // CHROMEOS_CROSAPI_CPP_BITMAP_H_
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chromeos/crosapi/cpp/bitmap_util.h"
#include <vector>
#include "base/check_op.h"
#include "base/numerics/checked_math.h"
#include "base/numerics/safe_conversions.h"
#include "chromeos/crosapi/cpp/bitmap.h"
#include "third_party/skia/include/core/SkBitmap.h"
namespace crosapi {
Bitmap BitmapFromSkBitmap(const SkBitmap& sk_bitmap) {
int size;
size = base::CheckMul(sk_bitmap.width(), sk_bitmap.height()).ValueOrDie();
size = base::CheckMul(size, 4).ValueOrDie();
CHECK_EQ(sk_bitmap.computeByteSize(), base::checked_cast<size_t>(size));
uint8_t* base = static_cast<uint8_t*>(sk_bitmap.getPixels());
std::vector<uint8_t> bytes(base, base + sk_bitmap.computeByteSize());
crosapi::Bitmap snapshot;
snapshot.width = sk_bitmap.width();
snapshot.height = sk_bitmap.height();
snapshot.pixels.swap(bytes);
return snapshot;
}
} // namespace crosapi
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROMEOS_CROSAPI_CPP_BITMAP_UTIL_H_
#define CHROMEOS_CROSAPI_CPP_BITMAP_UTIL_H_
#include "base/component_export.h"
class SkBitmap;
namespace crosapi {
struct Bitmap;
// Converts an SkBitmap to a crosapi::Bitmap. Assumes that the bitmap is
// unpadded, and uses 4 bytes per pixel. CHECK fails if the bitmap has an
// invalid size (e.g. its size is not equal to width * height * 4).
COMPONENT_EXPORT(CROSAPI) Bitmap BitmapFromSkBitmap(const SkBitmap& sk_bitmap);
} // namespace crosapi
#endif // CHROMEOS_CROSAPI_CPP_BITMAP_UTIL_H_
......@@ -25,23 +25,6 @@ mojom("mojom") {
]
disable_variants = true
cpp_typemaps = [
{
types = [
{
mojom = "crosapi.mojom.Bitmap"
cpp = "crosapi::Bitmap"
move_only = true
},
]
traits_headers = [ "//chromeos/crosapi/mojom/bitmap_mojom_traits.h" ]
traits_public_deps = [
":mojom_traits",
"//chromeos/crosapi/cpp:cpp_internal",
]
},
]
public_deps = [
"//mojo/public/mojom/base",
"//services/device/public/mojom:mojom",
......@@ -50,20 +33,3 @@ mojom("mojom") {
"//url/mojom:url_mojom_gurl",
]
}
component("mojom_traits") {
output_name = "crosapi_mojom_traits"
sources = [
"bitmap_mojom_traits.cc",
"bitmap_mojom_traits.h",
]
defines = [ "IS_CROSAPI_MOJOM_TRAITS_IMPL" ]
public_deps = [
":mojom_shared",
"//chromeos/crosapi/cpp:cpp_internal",
"//mojo/public/cpp/base:shared_typemap_traits",
]
}
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chromeos/crosapi/mojom/bitmap_mojom_traits.h"
#include "base/numerics/checked_math.h"
namespace mojo {
// static
bool StructTraits<crosapi::mojom::BitmapDataView, crosapi::Bitmap>::Read(
crosapi::mojom::BitmapDataView data,
crosapi::Bitmap* out) {
out->width = data.width();
out->height = data.height();
ArrayDataView<uint8_t> pixels;
data.GetPixelsDataView(&pixels);
uint32_t size;
size = base::CheckMul(out->width, out->height).ValueOrDie();
size = base::CheckMul(size, 4).ValueOrDie();
if (pixels.size() != base::checked_cast<size_t>(size))
return false;
const uint8_t* base = pixels.data();
out->pixels.assign(base, base + pixels.size());
return true;
}
} // namespace mojo
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROMEOS_CROSAPI_MOJOM_BITMAP_MOJOM_TRAITS_H_
#define CHROMEOS_CROSAPI_MOJOM_BITMAP_MOJOM_TRAITS_H_
#include "base/component_export.h"
#include "chromeos/crosapi/cpp/bitmap.h"
#include "chromeos/crosapi/mojom/bitmap.mojom-shared.h"
#include "mojo/public/cpp/bindings/struct_traits.h"
namespace mojo {
template <>
struct COMPONENT_EXPORT(CROSAPI_MOJOM_TRAITS)
StructTraits<crosapi::mojom::BitmapDataView, crosapi::Bitmap> {
static uint32_t width(const crosapi::Bitmap& bitmap) { return bitmap.width; }
static uint32_t height(const crosapi::Bitmap& bitmap) {
return bitmap.height;
}
static const std::vector<uint8_t>& pixels(const crosapi::Bitmap& bitmap) {
return bitmap.pixels;
}
static bool Read(crosapi::mojom::BitmapDataView, crosapi::Bitmap* out);
};
} // namespace mojo
#endif // CHROMEOS_CROSAPI_MOJOM_BITMAP_MOJOM_TRAITS_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment