| Index: skia/public/interfaces/bitmap_skbitmap_struct_traits.h
|
| diff --git a/skia/public/interfaces/bitmap_skbitmap_struct_traits.h b/skia/public/interfaces/bitmap_skbitmap_struct_traits.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..b7e72af9fb2a2efb1ee2cafdb53266486e7776f0
|
| --- /dev/null
|
| +++ b/skia/public/interfaces/bitmap_skbitmap_struct_traits.h
|
| @@ -0,0 +1,50 @@
|
| +// Copyright 2016 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 SKIA_PUBLIC_INTERFACES_BITMAP_SKBITMAP_STRUCT_TRAITS_H_
|
| +#define SKIA_PUBLIC_INTERFACES_BITMAP_SKBITMAP_STRUCT_TRAITS_H_
|
| +
|
| +#include "mojo/public/cpp/bindings/array_traits.h"
|
| +#include "skia/public/interfaces/bitmap.mojom.h"
|
| +#include "third_party/skia/include/core/SkBitmap.h"
|
| +
|
| +namespace mojo {
|
| +
|
| +// A buffer used to read pixel data directly from BitmapDataView to SkBitmap.
|
| +struct BitmapBuffer {
|
| + uint8_t* data = nullptr;
|
| + size_t size = 0;
|
| +};
|
| +
|
| +// ArrayTraits needed for ReadPixelData use with BitmapBuffer.
|
| +template <>
|
| +struct ArrayTraits<BitmapBuffer> {
|
| + using Element = uint8_t;
|
| + static size_t GetSize(const BitmapBuffer& b);
|
| + static uint8_t* GetData(BitmapBuffer& b);
|
| + static const uint8_t* GetData(const BitmapBuffer& b);
|
| + static uint8_t& GetAt(BitmapBuffer& b, size_t i);
|
| + static const uint8_t& GetAt(const BitmapBuffer& b, size_t i);
|
| + static void Resize(BitmapBuffer& b, size_t size);
|
| +};
|
| +
|
| +// Struct traits to use SkBitmap for skia::mojom::Bitmap in Chrome C++ code.
|
| +template <>
|
| +struct StructTraits<skia::mojom::Bitmap, SkBitmap> {
|
| + static bool IsNull(const SkBitmap& b);
|
| + static void SetToNull(SkBitmap* b);
|
| + static skia::mojom::ColorType color_type(const SkBitmap& b);
|
| + static skia::mojom::AlphaType alpha_type(const SkBitmap& b);
|
| + static skia::mojom::ColorProfileType profile_type(const SkBitmap& b);
|
| + static uint32_t width(const SkBitmap& b);
|
| + static uint32_t height(const SkBitmap& b);
|
| + static BitmapBuffer pixel_data(const SkBitmap& b);
|
| + static bool Read(skia::mojom::BitmapDataView data, SkBitmap* b);
|
| + static void* SetUpContext(const SkBitmap& b);
|
| + static void TearDownContext(const SkBitmap& b, void* context);
|
| +};
|
| +
|
| +} // namespace mojo
|
| +
|
| +#endif // SKIA_PUBLIC_INTERFACES_BITMAP_SKBITMAP_STRUCT_TRAITS_H_
|
|
|