Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(156)

Unified Diff: skia/public/interfaces/bitmap_skbitmap_struct_traits.h

Issue 2014013002: Add SkBitmap StructTraits for skia::mojo::Bitmap. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sync and rebase. Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « skia/public/BUILD.gn ('k') | skia/public/interfaces/bitmap_skbitmap_struct_traits.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_
« no previous file with comments | « skia/public/BUILD.gn ('k') | skia/public/interfaces/bitmap_skbitmap_struct_traits.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698