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 CC_IPC_COPY_OUTPUT_RESULT_STRUCT_TRAITS_H_ | 5 #ifndef CC_IPC_COPY_OUTPUT_RESULT_STRUCT_TRAITS_H_ |
6 #define CC_IPC_COPY_OUTPUT_RESULT_STRUCT_TRAITS_H_ | 6 #define CC_IPC_COPY_OUTPUT_RESULT_STRUCT_TRAITS_H_ |
7 | 7 |
8 #include "cc/ipc/copy_output_result.mojom-shared.h" | 8 #include "cc/ipc/copy_output_result.mojom-shared.h" |
9 #include "cc/ipc/texture_mailbox_releaser.mojom.h" | |
9 #include "cc/ipc/texture_mailbox_struct_traits.h" | 10 #include "cc/ipc/texture_mailbox_struct_traits.h" |
10 #include "cc/output/copy_output_result.h" | 11 #include "cc/output/copy_output_result.h" |
11 #include "skia/public/interfaces/bitmap_skbitmap_struct_traits.h" | 12 #include "skia/public/interfaces/bitmap_skbitmap_struct_traits.h" |
12 #include "ui/gfx/geometry/mojo/geometry_struct_traits.h" | 13 #include "ui/gfx/geometry/mojo/geometry_struct_traits.h" |
13 | 14 |
15 namespace cc { | |
16 | |
17 struct TextureMailboxWithRelease { | |
18 TextureMailbox texture_mailbox; | |
19 mojom::TextureMailboxReleaserPtr releaser; | |
20 | |
21 DISALLOW_COPY_AND_ASSIGN(TextureMailboxWithRelease); | |
22 }; | |
23 | |
24 } // namespace cc | |
25 | |
14 namespace mojo { | 26 namespace mojo { |
15 | 27 |
16 template <> | 28 template <> |
17 struct StructTraits<cc::mojom::CopyOutputResultDataView, | 29 struct StructTraits<cc::mojom::CopyOutputResultDataView, |
18 std::unique_ptr<cc::CopyOutputResult>> { | 30 std::unique_ptr<cc::CopyOutputResult>> { |
31 static bool IsNull(const std::unique_ptr<cc::CopyOutputResult>& result) { | |
danakj
2017/02/13 18:41:05
What do these have to do with having the sub type?
| |
32 return result->IsEmpty(); | |
33 } | |
34 | |
35 static void SetToNull(std::unique_ptr<cc::CopyOutputResult>* out) { | |
36 *out = cc::CopyOutputResult::CreateEmptyResult(); | |
37 } | |
38 | |
19 static const gfx::Size& size( | 39 static const gfx::Size& size( |
20 const std::unique_ptr<cc::CopyOutputResult>& result) { | 40 const std::unique_ptr<cc::CopyOutputResult>& result) { |
21 return result->size_; | 41 return result->size_; |
22 } | 42 } |
23 | 43 |
24 static const SkBitmap& bitmap( | 44 static const SkBitmap& bitmap( |
25 const std::unique_ptr<cc::CopyOutputResult>& result); | 45 const std::unique_ptr<cc::CopyOutputResult>& result); |
26 | 46 |
27 static const cc::TextureMailbox& texture_mailbox( | 47 static const cc::TextureMailboxWithRelease& texture_mailbox( |
28 const std::unique_ptr<cc::CopyOutputResult>& result) { | 48 const std::unique_ptr<cc::CopyOutputResult>& result); |
29 return result->texture_mailbox_; | |
30 } | |
31 | 49 |
32 static bool Read(cc::mojom::CopyOutputResultDataView data, | 50 static bool Read(cc::mojom::CopyOutputResultDataView data, |
33 std::unique_ptr<cc::CopyOutputResult>* out_p); | 51 std::unique_ptr<cc::CopyOutputResult>* out_p); |
34 }; | 52 }; |
35 | 53 |
54 template <> | |
55 struct StructTraits<cc::mojom::TextureMailboxWithReleaseDataView, | |
56 cc::TextureMailboxWithRelease> { | |
57 static const cc::TextureMailbox& texture_mailbox( | |
58 const cc::TextureMailboxWithRelease& input) { | |
59 return input.texture_mailbox; | |
60 } | |
61 | |
62 static cc::mojom::TextureMailboxReleaserPtr releaser( | |
63 const cc::TextureMailboxWithRelease& input) { | |
64 return std::move(input.releaser); | |
65 } | |
66 | |
67 static bool Read(cc::mojom::TextureMailboxWithReleaseDataView data, | |
68 cc::TextureMailboxWithRelease* out_p); | |
69 }; | |
70 | |
36 } // namespace mojo | 71 } // namespace mojo |
37 | 72 |
38 #endif // CC_IPC_COPY_OUTPUT_RESULT_STRUCT_TRAITS_H_ | 73 #endif // CC_IPC_COPY_OUTPUT_RESULT_STRUCT_TRAITS_H_ |
OLD | NEW |