OLD | NEW |
(Empty) | |
| 1 // 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 // Multiply-included message file, hence no include guard here, but see below |
| 6 // for a much smaller-than-usual include guard section. |
| 7 |
| 8 #include "build/build_config.h" |
| 9 #include "content/common/content_export.h" |
| 10 #include "content/common/content_param_traits.h" |
| 11 #include "content/common/gpu/establish_channel_params.h" |
| 12 #include "content/common/gpu/gpu_memory_uma_stats.h" |
| 13 #include "content/common/gpu/gpu_process_launch_causes.h" |
| 14 #include "content/public/common/common_param_traits.h" |
| 15 #include "content/public/common/gpu_memory_stats.h" |
| 16 #include "gpu/command_buffer/common/sync_token.h" |
| 17 #include "gpu/command_buffer/common/value_state.h" |
| 18 #include "gpu/config/gpu_info.h" |
| 19 #include "ipc/ipc_channel_handle.h" |
| 20 #include "ipc/ipc_message_macros.h" |
| 21 #include "ipc/ipc_message_start.h" |
| 22 #include "ui/gfx/gpu_memory_buffer.h" |
| 23 #include "ui/gfx/ipc/gfx_param_traits.h" |
| 24 #include "ui/gfx/native_widget_types.h" |
| 25 #include "url/gurl.h" |
| 26 |
| 27 #if defined(OS_MACOSX) |
| 28 #include "content/common/gpu/accelerated_surface_buffers_swapped_params_mac.h" |
| 29 #include "content/common/gpu/buffer_presented_params_mac.h" |
| 30 #include "ui/base/cocoa/remote_layer_api.h" |
| 31 #include "ui/gfx/mac/io_surface.h" |
| 32 #endif |
| 33 |
| 34 #undef IPC_MESSAGE_EXPORT |
| 35 #define IPC_MESSAGE_EXPORT CONTENT_EXPORT |
| 36 |
| 37 #define IPC_MESSAGE_START GpuMsgStart |
| 38 |
| 39 IPC_ENUM_TRAITS_MAX_VALUE(content::CauseForGpuLaunch, |
| 40 content::CAUSE_FOR_GPU_LAUNCH_MAX_ENUM - 1) |
| 41 |
| 42 IPC_STRUCT_TRAITS_BEGIN(content::GPUMemoryUmaStats) |
| 43 IPC_STRUCT_TRAITS_MEMBER(bytes_allocated_current) |
| 44 IPC_STRUCT_TRAITS_MEMBER(bytes_allocated_max) |
| 45 IPC_STRUCT_TRAITS_END() |
| 46 |
| 47 IPC_STRUCT_TRAITS_BEGIN(content::GPUVideoMemoryUsageStats) |
| 48 IPC_STRUCT_TRAITS_MEMBER(process_map) |
| 49 IPC_STRUCT_TRAITS_MEMBER(bytes_allocated) |
| 50 IPC_STRUCT_TRAITS_MEMBER(bytes_allocated_historical_max) |
| 51 IPC_STRUCT_TRAITS_END() |
| 52 |
| 53 IPC_STRUCT_TRAITS_BEGIN(content::GPUVideoMemoryUsageStats::ProcessStats) |
| 54 IPC_STRUCT_TRAITS_MEMBER(video_memory) |
| 55 IPC_STRUCT_TRAITS_MEMBER(has_duplicates) |
| 56 IPC_STRUCT_TRAITS_END() |
| 57 |
| 58 IPC_STRUCT_BEGIN(GpuMsg_CreateGpuMemoryBuffer_Params) |
| 59 IPC_STRUCT_MEMBER(gfx::GpuMemoryBufferId, id) |
| 60 IPC_STRUCT_MEMBER(gfx::Size, size) |
| 61 IPC_STRUCT_MEMBER(gfx::BufferFormat, format) |
| 62 IPC_STRUCT_MEMBER(gfx::BufferUsage, usage) |
| 63 IPC_STRUCT_MEMBER(int32_t, client_id) |
| 64 IPC_STRUCT_MEMBER(gfx::PluginWindowHandle, surface_handle) |
| 65 IPC_STRUCT_END() |
| 66 |
| 67 IPC_STRUCT_BEGIN(GpuMsg_CreateGpuMemoryBufferFromHandle_Params) |
| 68 IPC_STRUCT_MEMBER(gfx::GpuMemoryBufferHandle, handle) |
| 69 IPC_STRUCT_MEMBER(gfx::GpuMemoryBufferId, id) |
| 70 IPC_STRUCT_MEMBER(gfx::Size, size) |
| 71 IPC_STRUCT_MEMBER(gfx::BufferFormat, format) |
| 72 IPC_STRUCT_MEMBER(int32_t, client_id) |
| 73 IPC_STRUCT_END() |
| 74 |
| 75 IPC_STRUCT_TRAITS_BEGIN(content::EstablishChannelParams) |
| 76 IPC_STRUCT_TRAITS_MEMBER(client_id) |
| 77 IPC_STRUCT_TRAITS_MEMBER(client_tracing_id) |
| 78 IPC_STRUCT_TRAITS_MEMBER(preempts) |
| 79 IPC_STRUCT_TRAITS_MEMBER(allow_view_command_buffers) |
| 80 IPC_STRUCT_TRAITS_MEMBER(allow_real_time_streams) |
| 81 IPC_STRUCT_TRAITS_END() |
| 82 |
| 83 #if defined(OS_MACOSX) |
| 84 IPC_STRUCT_TRAITS_BEGIN(content::AcceleratedSurfaceBuffersSwappedParams) |
| 85 IPC_STRUCT_TRAITS_MEMBER(surface_id) |
| 86 // Only one of ca_context_id or io_surface may be non-0. |
| 87 IPC_STRUCT_TRAITS_MEMBER(ca_context_id) |
| 88 IPC_STRUCT_TRAITS_MEMBER(io_surface) |
| 89 IPC_STRUCT_TRAITS_MEMBER(size) |
| 90 IPC_STRUCT_TRAITS_MEMBER(scale_factor) |
| 91 IPC_STRUCT_TRAITS_MEMBER(latency_info) |
| 92 IPC_STRUCT_TRAITS_END() |
| 93 |
| 94 IPC_STRUCT_TRAITS_BEGIN(content::BufferPresentedParams) |
| 95 // The vsync parameters, to synchronize presentation with the display. |
| 96 IPC_STRUCT_TRAITS_MEMBER(surface_id) |
| 97 IPC_STRUCT_TRAITS_MEMBER(vsync_timebase) |
| 98 IPC_STRUCT_TRAITS_MEMBER(vsync_interval) |
| 99 IPC_STRUCT_TRAITS_END() |
| 100 #endif |
| 101 |
| 102 //------------------------------------------------------------------------------ |
| 103 // GPU Messages |
| 104 // These are messages from the browser to the GPU process. |
| 105 |
| 106 // Tells the GPU process to initialize itself. The browser explicitly |
| 107 // requests this be done so that we are guaranteed that the channel is set |
| 108 // up between the browser and GPU process before doing any work that might |
| 109 // potentially crash the GPU process. Detection of the child process |
| 110 // exiting abruptly is predicated on having the IPC channel set up. |
| 111 IPC_MESSAGE_CONTROL0(GpuMsg_Initialize) |
| 112 |
| 113 // Tells the GPU process to shutdown itself. |
| 114 IPC_MESSAGE_CONTROL0(GpuMsg_Finalize) |
| 115 |
| 116 // Tells the GPU process to create a new channel for communication with a |
| 117 // given client. The channel name is returned in a |
| 118 // GpuHostMsg_ChannelEstablished message. The client ID is passed so |
| 119 // that |
| 120 // the GPU process reuses an existing channel to that process if it exists. |
| 121 // This ID is a unique opaque identifier generated by the browser process. |
| 122 // The client_tracing_id is a unique ID used for the purposes of tracing. |
| 123 IPC_MESSAGE_CONTROL1(GpuMsg_EstablishChannel, |
| 124 content::EstablishChannelParams /* params */) |
| 125 |
| 126 // Tells the GPU process to close the channel identified by IPC channel |
| 127 // handle. If no channel can be identified, do nothing. |
| 128 IPC_MESSAGE_CONTROL1(GpuMsg_CloseChannel, |
| 129 IPC::ChannelHandle /* channel_handle */) |
| 130 |
| 131 // Tells the GPU process to create a new gpu memory buffer. |
| 132 IPC_MESSAGE_CONTROL1(GpuMsg_CreateGpuMemoryBuffer, |
| 133 GpuMsg_CreateGpuMemoryBuffer_Params) |
| 134 |
| 135 // Tells the GPU process to create a new gpu memory buffer from an existing |
| 136 // handle. |
| 137 IPC_MESSAGE_CONTROL1(GpuMsg_CreateGpuMemoryBufferFromHandle, |
| 138 GpuMsg_CreateGpuMemoryBufferFromHandle_Params) |
| 139 |
| 140 // Tells the GPU process to destroy buffer. |
| 141 IPC_MESSAGE_CONTROL3(GpuMsg_DestroyGpuMemoryBuffer, |
| 142 gfx::GpuMemoryBufferId, /* id */ |
| 143 int32_t, /* client_id */ |
| 144 gpu::SyncToken /* sync_token */) |
| 145 |
| 146 // Tells the GPU process to create a context for collecting graphics card |
| 147 // information. |
| 148 IPC_MESSAGE_CONTROL0(GpuMsg_CollectGraphicsInfo) |
| 149 |
| 150 // Tells the GPU process to report video_memory information for the task manager |
| 151 IPC_MESSAGE_CONTROL0(GpuMsg_GetVideoMemoryUsageStats) |
| 152 |
| 153 #if defined(OS_MACOSX) |
| 154 // Tells the GPU process that the browser process has handled the swap |
| 155 // buffers or post sub-buffer request. |
| 156 IPC_MESSAGE_CONTROL1(AcceleratedSurfaceMsg_BufferPresented, |
| 157 content::BufferPresentedParams) |
| 158 #endif |
| 159 |
| 160 #if defined(OS_ANDROID) |
| 161 // Tells the GPU process to wake up the GPU because we're about to draw. |
| 162 IPC_MESSAGE_CONTROL0(GpuMsg_WakeUpGpu) |
| 163 #endif |
| 164 |
| 165 // Tells the GPU process to remove all contexts. |
| 166 IPC_MESSAGE_CONTROL0(GpuMsg_Clean) |
| 167 |
| 168 // Tells the GPU process to crash. |
| 169 IPC_MESSAGE_CONTROL0(GpuMsg_Crash) |
| 170 |
| 171 // Tells the GPU process to hang. |
| 172 IPC_MESSAGE_CONTROL0(GpuMsg_Hang) |
| 173 |
| 174 // Tells the GPU process to disable the watchdog thread. |
| 175 IPC_MESSAGE_CONTROL0(GpuMsg_DisableWatchdog) |
| 176 |
| 177 // Tells the GPU process that the browser has seen a GPU switch. |
| 178 IPC_MESSAGE_CONTROL0(GpuMsg_GpuSwitched) |
| 179 |
| 180 // Sends an input event to the gpu service. |
| 181 IPC_MESSAGE_CONTROL3(GpuMsg_UpdateValueState, |
| 182 int, /* client_id */ |
| 183 unsigned int, /* target */ |
| 184 gpu::ValueState /* valuestate */) |
| 185 |
| 186 //------------------------------------------------------------------------------ |
| 187 // GPU Host Messages |
| 188 // These are messages to the browser. |
| 189 |
| 190 // A renderer sends this when it wants to create a connection to the GPU |
| 191 // process. The browser will create the GPU process if necessary, and will |
| 192 // return a handle to the channel via a GpuChannelEstablished message. |
| 193 IPC_SYNC_MESSAGE_CONTROL1_3(GpuHostMsg_EstablishGpuChannel, |
| 194 content::CauseForGpuLaunch, |
| 195 int /* client id */, |
| 196 IPC::ChannelHandle /* handle to channel */, |
| 197 gpu::GPUInfo /* stats about GPU process*/) |
| 198 |
| 199 // A renderer sends this when it wants to know whether a gpu process exists. |
| 200 IPC_SYNC_MESSAGE_CONTROL0_1(GpuHostMsg_HasGpuProcess, bool /* result */) |
| 201 |
| 202 // Response from GPU to a GputMsg_Initialize message. |
| 203 IPC_MESSAGE_CONTROL2(GpuHostMsg_Initialized, |
| 204 bool /* result */, |
| 205 ::gpu::GPUInfo /* gpu_info */) |
| 206 |
| 207 // Response from GPU to a GpuHostMsg_EstablishChannel message. |
| 208 IPC_MESSAGE_CONTROL1(GpuHostMsg_ChannelEstablished, |
| 209 IPC::ChannelHandle /* channel_handle */) |
| 210 |
| 211 // Message from GPU to notify to destroy the channel. |
| 212 IPC_MESSAGE_CONTROL1(GpuHostMsg_DestroyChannel, int32_t /* client_id */) |
| 213 |
| 214 // Message to cache the given shader information. |
| 215 IPC_MESSAGE_CONTROL3(GpuHostMsg_CacheShader, |
| 216 int32_t /* client_id */, |
| 217 std::string /* key */, |
| 218 std::string /* shader */) |
| 219 |
| 220 // Message to the GPU that a shader was loaded from disk. |
| 221 IPC_MESSAGE_CONTROL1(GpuMsg_LoadedShader, std::string /* encoded shader */) |
| 222 |
| 223 // Response from GPU to a GpuMsg_CreateGpuMemoryBuffer message. |
| 224 IPC_MESSAGE_CONTROL1(GpuHostMsg_GpuMemoryBufferCreated, |
| 225 gfx::GpuMemoryBufferHandle /* handle */) |
| 226 |
| 227 // Response from GPU to a GpuMsg_CollectGraphicsInfo. |
| 228 IPC_MESSAGE_CONTROL1(GpuHostMsg_GraphicsInfoCollected, |
| 229 gpu::GPUInfo /* GPU logging stats */) |
| 230 |
| 231 // Response from GPU to a GpuMsg_GetVideoMemory. |
| 232 IPC_MESSAGE_CONTROL1(GpuHostMsg_VideoMemoryUsageStats, |
| 233 content::GPUVideoMemoryUsageStats /* GPU memory stats */) |
| 234 |
| 235 #if defined(OS_MACOSX) |
| 236 // Tells the browser that an accelerated surface has swapped. |
| 237 IPC_MESSAGE_CONTROL1(GpuHostMsg_AcceleratedSurfaceBuffersSwapped, |
| 238 content::AcceleratedSurfaceBuffersSwappedParams) |
| 239 #endif |
| 240 |
| 241 #if defined(OS_WIN) |
| 242 IPC_MESSAGE_CONTROL2(GpuHostMsg_AcceleratedSurfaceCreatedChildWindow, |
| 243 gfx::PluginWindowHandle /* parent_window */, |
| 244 gfx::PluginWindowHandle /* child_window */) |
| 245 #endif |
| 246 |
| 247 IPC_MESSAGE_CONTROL1(GpuHostMsg_DidCreateOffscreenContext, GURL /* url */) |
| 248 |
| 249 IPC_MESSAGE_CONTROL3(GpuHostMsg_DidLoseContext, |
| 250 bool /* offscreen */, |
| 251 gpu::error::ContextLostReason /* reason */, |
| 252 GURL /* url */) |
| 253 |
| 254 IPC_MESSAGE_CONTROL1(GpuHostMsg_DidDestroyOffscreenContext, GURL /* url */) |
| 255 |
| 256 // Tells the browser about GPU memory usage statistics for UMA logging. |
| 257 IPC_MESSAGE_CONTROL1(GpuHostMsg_GpuMemoryUmaStats, |
| 258 content::GPUMemoryUmaStats /* GPU memory UMA stats */) |
| 259 |
| 260 // Tells the browser that a context has subscribed to a new target and |
| 261 // the browser should start sending the corresponding information |
| 262 IPC_MESSAGE_CONTROL2(GpuHostMsg_AddSubscription, |
| 263 int32_t /* client_id */, |
| 264 unsigned int /* target */) |
| 265 |
| 266 // Tells the browser that no contexts are subscribed to the target anymore |
| 267 // so the browser should stop sending the corresponding information |
| 268 IPC_MESSAGE_CONTROL2(GpuHostMsg_RemoveSubscription, |
| 269 int32_t /* client_id */, |
| 270 unsigned int /* target */) |
| 271 |
| 272 // Message from GPU to add a GPU log message to the about:gpu page. |
| 273 IPC_MESSAGE_CONTROL3(GpuHostMsg_OnLogMessage, |
| 274 int /*severity*/, |
| 275 std::string /* header */, |
| 276 std::string /* message */) |
OLD | NEW |