1 // Copyright 2015 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 // Singly or multiply-included shared traits file depending upon circumstances.
6 // This allows the use of IPC serialization macros in more than one IPC message
7 // file.
8 #ifndef UI_GFX_IPC_GFX_PARAM_TRAITS_MACROS_H_
9 #define UI_GFX_IPC_GFX_PARAM_TRAITS_MACROS_H_
10 
11 #include "build/build_config.h"
12 #include "ipc/ipc_message_macros.h"
13 #include "ui/gfx/ca_layer_params.h"
14 #include "ui/gfx/gpu_fence_handle.h"
15 #include "ui/gfx/gpu_memory_buffer.h"
16 #include "ui/gfx/ipc/gfx_ipc_export.h"
17 #include "ui/gfx/presentation_feedback.h"
18 #include "ui/gfx/selection_bound.h"
19 #include "ui/gfx/swap_result.h"
20 
21 #if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_BSD)
22 #include "ui/gfx/native_pixmap_handle.h"
23 #endif
24 
25 #undef IPC_MESSAGE_EXPORT
26 #define IPC_MESSAGE_EXPORT GFX_IPC_EXPORT
27 
28 IPC_ENUM_TRAITS_MAX_VALUE(gfx::GpuMemoryBufferType,
29                           gfx::GPU_MEMORY_BUFFER_TYPE_LAST)
30 
31 IPC_ENUM_TRAITS_MAX_VALUE(gfx::SwapResult, gfx::SwapResult::SWAP_RESULT_LAST)
32 
33 IPC_ENUM_TRAITS_MAX_VALUE(gfx::SelectionBound::Type, gfx::SelectionBound::LAST)
34 
35 IPC_STRUCT_TRAITS_BEGIN(gfx::CALayerParams)
36   IPC_STRUCT_TRAITS_MEMBER(is_empty)
37 #if defined(OS_MAC)
38   IPC_STRUCT_TRAITS_MEMBER(ca_context_id)
39   IPC_STRUCT_TRAITS_MEMBER(io_surface_mach_port)
40   IPC_STRUCT_TRAITS_MEMBER(pixel_size)
41   IPC_STRUCT_TRAITS_MEMBER(scale_factor)
42 #endif
43 IPC_STRUCT_TRAITS_END()
44 
45 IPC_STRUCT_TRAITS_BEGIN(gfx::GpuMemoryBufferHandle)
46   IPC_STRUCT_TRAITS_MEMBER(id)
47   IPC_STRUCT_TRAITS_MEMBER(type)
48   IPC_STRUCT_TRAITS_MEMBER(region)
49   IPC_STRUCT_TRAITS_MEMBER(offset)
50   IPC_STRUCT_TRAITS_MEMBER(stride)
51 #if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_FUCHSIA) || defined(OS_BSD)
52   IPC_STRUCT_TRAITS_MEMBER(native_pixmap_handle)
53 #elif defined(OS_APPLE)
54   IPC_STRUCT_TRAITS_MEMBER(io_surface)
55 #elif defined(OS_WIN)
56   IPC_STRUCT_TRAITS_MEMBER(dxgi_handle)
57 #elif defined(OS_ANDROID)
58   IPC_STRUCT_TRAITS_MEMBER(android_hardware_buffer)
59 #endif
60 IPC_STRUCT_TRAITS_END()
61 
62 IPC_STRUCT_TRAITS_BEGIN(gfx::GpuMemoryBufferId)
63   IPC_STRUCT_TRAITS_MEMBER(id)
64 IPC_STRUCT_TRAITS_END()
65 
66 #if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_FUCHSIA) || defined(OS_BSD)
67 IPC_STRUCT_TRAITS_BEGIN(gfx::NativePixmapPlane)
68   IPC_STRUCT_TRAITS_MEMBER(stride)
69   IPC_STRUCT_TRAITS_MEMBER(offset)
70   IPC_STRUCT_TRAITS_MEMBER(size)
71 #if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_BSD)
72   IPC_STRUCT_TRAITS_MEMBER(fd)
73 #elif defined(OS_FUCHSIA)
74   IPC_STRUCT_TRAITS_MEMBER(vmo)
75 #endif
76 IPC_STRUCT_TRAITS_END()
77 
78 IPC_STRUCT_TRAITS_BEGIN(gfx::NativePixmapHandle)
79   IPC_STRUCT_TRAITS_MEMBER(planes)
80 #if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_BSD)
81   IPC_STRUCT_TRAITS_MEMBER(modifier)
82 #endif
83 #if defined(OS_FUCHSIA)
84   IPC_STRUCT_TRAITS_MEMBER(buffer_collection_id)
85   IPC_STRUCT_TRAITS_MEMBER(buffer_index)
86   IPC_STRUCT_TRAITS_MEMBER(ram_coherency)
87 #endif
88 IPC_STRUCT_TRAITS_END()
89 #endif
90 
91 IPC_STRUCT_TRAITS_BEGIN(gfx::SwapTimings)
92   IPC_STRUCT_TRAITS_MEMBER(swap_start)
93   IPC_STRUCT_TRAITS_MEMBER(swap_end)
94 IPC_STRUCT_TRAITS_END()
95 
96 IPC_STRUCT_TRAITS_BEGIN(gfx::SwapResponse)
97   IPC_STRUCT_TRAITS_MEMBER(swap_id)
98   IPC_STRUCT_TRAITS_MEMBER(result)
99   IPC_STRUCT_TRAITS_MEMBER(timings)
100 IPC_STRUCT_TRAITS_END()
101 
102 IPC_STRUCT_TRAITS_BEGIN(gfx::PresentationFeedback)
103   IPC_STRUCT_TRAITS_MEMBER(timestamp)
104   IPC_STRUCT_TRAITS_MEMBER(interval)
105   IPC_STRUCT_TRAITS_MEMBER(flags)
106 IPC_STRUCT_TRAITS_END()
107 
108 IPC_STRUCT_TRAITS_BEGIN(gfx::GpuFenceHandle)
109 #if defined(OS_POSIX)
110   IPC_STRUCT_TRAITS_MEMBER(owned_fd)
111 #endif
112 #if defined(OS_WIN)
113   IPC_STRUCT_TRAITS_MEMBER(owned_handle)
114 #endif
115 IPC_STRUCT_TRAITS_END()
116 
117 #undef IPC_MESSAGE_EXPORT
118 #define IPC_MESSAGE_EXPORT
119 
120 #endif  // UI_GFX_IPC_GFX_PARAM_TRAITS_MACROS_H_
121