OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef UI_GFX_IMAGE_MOJO_IMAGE_SKIA_STRUCT_TRAITS_H_ | 5 #ifndef UI_GFX_IMAGE_MOJO_IMAGE_SKIA_STRUCT_TRAITS_H_ |
6 #define UI_GFX_IMAGE_MOJO_IMAGE_SKIA_STRUCT_TRAITS_H_ | 6 #define UI_GFX_IMAGE_MOJO_IMAGE_SKIA_STRUCT_TRAITS_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "third_party/skia/include/core/SkBitmap.h" | |
13 #include "ui/gfx/image/image_skia.h" | 12 #include "ui/gfx/image/image_skia.h" |
14 #include "ui/gfx/image/image_skia_rep.h" | 13 #include "ui/gfx/image/image_skia_rep.h" |
15 #include "ui/gfx/image/mojo/image.mojom-shared.h" | 14 #include "ui/gfx/image/mojo/image.mojom-shared.h" |
16 | 15 |
17 namespace mojo { | 16 namespace mojo { |
18 | 17 |
19 template <> | 18 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> { | 19 struct StructTraits<gfx::mojom::ImageSkiaRepDataView, gfx::ImageSkiaRep> { |
45 static SkBitmap bitmap(const gfx::ImageSkiaRep& input) { | 20 static SkBitmap bitmap(const gfx::ImageSkiaRep& input) { |
46 return input.sk_bitmap(); | 21 return input.sk_bitmap(); |
47 } | 22 } |
48 static float scale(const gfx::ImageSkiaRep& input); | 23 static float scale(const gfx::ImageSkiaRep& input); |
49 | 24 |
50 static bool IsNull(const gfx::ImageSkiaRep& input) { return input.is_null(); } | 25 static bool IsNull(const gfx::ImageSkiaRep& input) { return input.is_null(); } |
51 static void SetToNull(gfx::ImageSkiaRep* out) { *out = gfx::ImageSkiaRep(); } | 26 static void SetToNull(gfx::ImageSkiaRep* out) { *out = gfx::ImageSkiaRep(); } |
52 | 27 |
53 static bool Read(gfx::mojom::ImageSkiaRepDataView data, | 28 static bool Read(gfx::mojom::ImageSkiaRepDataView data, |
(...skipping 12 matching lines...) Expand all Loading... |
66 return input.image_reps().empty(); | 41 return input.image_reps().empty(); |
67 } | 42 } |
68 static void SetToNull(gfx::ImageSkia* out) { *out = gfx::ImageSkia(); } | 43 static void SetToNull(gfx::ImageSkia* out) { *out = gfx::ImageSkia(); } |
69 | 44 |
70 static bool Read(gfx::mojom::ImageSkiaDataView data, gfx::ImageSkia* out); | 45 static bool Read(gfx::mojom::ImageSkiaDataView data, gfx::ImageSkia* out); |
71 }; | 46 }; |
72 | 47 |
73 } // namespace mojo | 48 } // namespace mojo |
74 | 49 |
75 #endif // UI_GFX_IMAGE_MOJO_IMAGE_SKIA_STRUCT_TRAITS_H_ | 50 #endif // UI_GFX_IMAGE_MOJO_IMAGE_SKIA_STRUCT_TRAITS_H_ |
OLD | NEW |