blob: e9964c6fce3865ed6c9c27f99078382c3aebc5e7 [file] [log] [blame]
fsamuel6ee49c42016-06-01 11:16:551// Copyright 2016 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 CC_IPC_TRANSFERABLE_RESOURCE_STRUCT_TRAITS_H_
6#define CC_IPC_TRANSFERABLE_RESOURCE_STRUCT_TRAITS_H_
7
xlai8f405382016-09-01 19:46:228#include "cc/ipc/transferable_resource.mojom-shared.h"
fsamuel6ee49c42016-06-01 11:16:559#include "cc/resources/transferable_resource.h"
hubbece990b12017-04-18 22:53:3210#include "ui/gfx/ipc/color/gfx_param_traits.h"
fsamuel6ee49c42016-06-01 11:16:5511
12namespace mojo {
13
14template <>
yzshen1764bb92016-08-24 01:44:1215struct StructTraits<cc::mojom::TransferableResourceDataView,
16 cc::TransferableResource> {
fsamuel6ee49c42016-06-01 11:16:5517 static uint32_t id(const cc::TransferableResource& resource) {
18 return resource.id;
19 }
20
21 static cc::mojom::ResourceFormat format(
22 const cc::TransferableResource& resource) {
23 return static_cast<cc::mojom::ResourceFormat>(resource.format);
24 }
25
dcastagna84093542017-03-14 02:11:1326 static gfx::mojom::BufferFormat buffer_format(
27 const cc::TransferableResource& resource) {
28 return static_cast<gfx::mojom::BufferFormat>(resource.buffer_format);
29 }
30
fsamuel6ee49c42016-06-01 11:16:5531 static uint32_t filter(const cc::TransferableResource& resource) {
32 return resource.filter;
33 }
34
35 static gfx::Size size(const cc::TransferableResource& resource) {
36 return resource.size;
37 }
38
fsamuel605998f2016-06-08 20:22:3839 static const gpu::MailboxHolder& mailbox_holder(
fsamuel6ee49c42016-06-01 11:16:5540 const cc::TransferableResource& resource) {
41 return resource.mailbox_holder;
42 }
43
44 static bool read_lock_fences_enabled(
45 const cc::TransferableResource& resource) {
46 return resource.read_lock_fences_enabled;
47 }
48
49 static bool is_software(const cc::TransferableResource& resource) {
50 return resource.is_software;
51 }
52
fsamuel6ee49c42016-06-01 11:16:5553 static bool is_overlay_candidate(const cc::TransferableResource& resource) {
54 return resource.is_overlay_candidate;
55 }
56
liberato304dc192016-12-09 20:55:2657 static bool is_backed_by_surface_texture(
58 const cc::TransferableResource& resource) {
59#if defined(OS_ANDROID)
60 // TransferableResource has this in an #ifdef, but mojo doesn't let us.
61 // TODO(https://crbug.com/671901)
62 return resource.is_backed_by_surface_texture;
63#else
64 return false;
65#endif
66 }
67
68 static bool wants_promotion_hint(const cc::TransferableResource& resource) {
69#if defined(OS_ANDROID)
70 // TransferableResource has this in an #ifdef, but mojo doesn't let us.
71 // TODO(https://crbug.com/671901)
72 return resource.wants_promotion_hint;
73#else
74 return false;
75#endif
76 }
77
hubbece990b12017-04-18 22:53:3278 static const gfx::ColorSpace& color_space(
79 const cc::TransferableResource& resource) {
80 return resource.color_space;
81 }
82
fsamuel6ee49c42016-06-01 11:16:5583 static bool Read(cc::mojom::TransferableResourceDataView data,
fsamuelce098fb2016-06-27 16:43:0684 cc::TransferableResource* out);
fsamuel6ee49c42016-06-01 11:16:5585};
86
87} // namespace mojo
88
89#endif // CC_IPC_TRANSFERABLE_RESOURCE_STRUCT_TRAITS_H_