OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef UI_GFX_IMAGE_MOJO_IMAGE_SKIA_STRUCT_TRAITS_H_ |
| 6 #define UI_GFX_IMAGE_MOJO_IMAGE_SKIA_STRUCT_TRAITS_H_ |
| 7 |
| 8 #include <stdint.h> |
| 9 |
| 10 #include <vector> |
| 11 |
| 12 #include "third_party/skia/include/core/SkBitmap.h" |
| 13 #include "ui/gfx/image/image_skia.h" |
| 14 #include "ui/gfx/image/image_skia_rep.h" |
| 15 #include "ui/gfx/image/mojo/image.mojom-shared.h" |
| 16 |
| 17 namespace mojo { |
| 18 |
| 19 template <> |
| 20 struct StructTraits<gfx::mojom::SharedBufferSkBitmapDataView, SkBitmap> { |
| 21 struct Context { |
| 22 Context(); |
| 23 ~Context(); |
| 24 |
| 25 mojo::ScopedSharedBufferHandle shared_buffer_handle; |
| 26 uint64_t buffer_byte_size = 0; |
| 27 }; |
| 28 |
| 29 static void* SetUpContext(const SkBitmap& input); |
| 30 static void TearDownContext(const SkBitmap& input, void* context); |
| 31 static mojo::ScopedSharedBufferHandle shared_buffer_handle( |
| 32 const SkBitmap& input, |
| 33 void* context); |
| 34 static uint64_t buffer_byte_size(const SkBitmap& input, void* context); |
| 35 |
| 36 static bool IsNull(const SkBitmap& input) { return input.isNull(); } |
| 37 static void SetToNull(SkBitmap* out) { out->reset(); } |
| 38 |
| 39 static bool Read(gfx::mojom::SharedBufferSkBitmapDataView data, |
| 40 SkBitmap* out); |
| 41 }; |
| 42 |
| 43 template <> |
| 44 struct StructTraits<gfx::mojom::ImageSkiaRepDataView, gfx::ImageSkiaRep> { |
| 45 static SkBitmap bitmap(const gfx::ImageSkiaRep& input) { |
| 46 return input.sk_bitmap(); |
| 47 } |
| 48 static float scale(const gfx::ImageSkiaRep& input); |
| 49 |
| 50 static bool IsNull(const gfx::ImageSkiaRep& input) { return input.is_null(); } |
| 51 static void SetToNull(gfx::ImageSkiaRep* out) { *out = gfx::ImageSkiaRep(); } |
| 52 |
| 53 static bool Read(gfx::mojom::ImageSkiaRepDataView data, |
| 54 gfx::ImageSkiaRep* out); |
| 55 }; |
| 56 |
| 57 template <> |
| 58 struct StructTraits<gfx::mojom::ImageSkiaDataView, gfx::ImageSkia> { |
| 59 static void* SetUpContext(const gfx::ImageSkia& input); |
| 60 static void TearDownContext(const gfx::ImageSkia& input, void* context); |
| 61 static const std::vector<gfx::ImageSkiaRep>& image_reps( |
| 62 const gfx::ImageSkia& input, |
| 63 void* context); |
| 64 |
| 65 static bool IsNull(const gfx::ImageSkia& input) { |
| 66 return input.image_reps().empty(); |
| 67 } |
| 68 static void SetToNull(gfx::ImageSkia* out) { *out = gfx::ImageSkia(); } |
| 69 |
| 70 static bool Read(gfx::mojom::ImageSkiaDataView data, gfx::ImageSkia* out); |
| 71 }; |
| 72 |
| 73 } // namespace mojo |
| 74 |
| 75 #endif // UI_GFX_IMAGE_MOJO_IMAGE_SKIA_STRUCT_TRAITS_H_ |
OLD | NEW |