| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2010 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 #include <vector> | |
| 6 #include <string> | |
| 7 | |
| 8 #include "base/shared_memory.h" | |
| 9 #include "chrome/common/gpu_info.h" | |
| 10 #include "chrome/common/gpu_video_common.h" | |
| 11 #include "ipc/ipc_message_macros.h" | |
| 12 | |
| 13 #define IPC_MESSAGE_START GpuMsgStart | |
| 14 | |
| 15 namespace gfx { | |
| 16 class Size; | |
| 17 } | |
| 18 | |
| 19 namespace IPC { | |
| 20 struct ChannelHandle; | |
| 21 } | |
| 22 | |
| 23 struct GPUCreateCommandBufferConfig; | |
| 24 struct GPUInfo; | |
| 25 | |
| 26 //------------------------------------------------------------------------------ | |
| 27 // GPU Messages | |
| 28 // These are messages from the browser to the GPU process. | |
| 29 | |
| 30 // Tells the GPU process to initialize itself. The browser explicitly | |
| 31 // requests this be done so that we are guaranteed that the channel is set | |
| 32 // up between the browser and GPU process before doing any work that might | |
| 33 // potentially crash the GPU process. Detection of the child process | |
| 34 // exiting abruptly is predicated on having the IPC channel set up. | |
| 35 IPC_MESSAGE_CONTROL0(GpuMsg_Initialize) | |
| 36 | |
| 37 // Tells the GPU process to create a new channel for communication with a | |
| 38 // given renderer. The channel name is returned in a | |
| 39 // GpuHostMsg_ChannelEstablished message. The renderer ID is passed so that | |
| 40 // the GPU process reuses an existing channel to that process if it exists. | |
| 41 // This ID is a unique opaque identifier generated by the browser process. | |
| 42 IPC_MESSAGE_CONTROL1(GpuMsg_EstablishChannel, | |
| 43 int /* renderer_id */) | |
| 44 | |
| 45 // Tells the GPU process to close the channel identified by IPC channel | |
| 46 // handle. If no channel can be identified, do nothing. | |
| 47 IPC_MESSAGE_CONTROL1(GpuMsg_CloseChannel, | |
| 48 IPC::ChannelHandle /* channel_handle */) | |
| 49 | |
| 50 // Provides a synchronization point to guarantee that the processing of | |
| 51 // previous asynchronous messages (i.e., GpuMsg_EstablishChannel) has | |
| 52 // completed. (This message can't be synchronous because the | |
| 53 // GpuProcessHost uses an IPC::ChannelProxy, which sends all messages | |
| 54 // asynchronously.) Results in a GpuHostMsg_SynchronizeReply. | |
| 55 IPC_MESSAGE_CONTROL0(GpuMsg_Synchronize) | |
| 56 | |
| 57 // Tells the GPU process to create a new command buffer that renders directly | |
| 58 // to a native view. A corresponding GpuCommandBufferStub is created. | |
| 59 IPC_MESSAGE_CONTROL4(GpuMsg_CreateViewCommandBuffer, | |
| 60 gfx::PluginWindowHandle, /* view */ | |
| 61 int32, /* render_view_id */ | |
| 62 int32, /* renderer_id */ | |
| 63 GPUCreateCommandBufferConfig /* init_params */) | |
| 64 | |
| 65 // Tells the GPU process to create a context for collecting graphics card | |
| 66 // information. | |
| 67 IPC_MESSAGE_CONTROL1(GpuMsg_CollectGraphicsInfo, | |
| 68 GPUInfo::Level /* level */) | |
| 69 | |
| 70 #if defined(OS_MACOSX) | |
| 71 // Tells the GPU process that the browser process handled the swap | |
| 72 // buffers request with the given number. Note that it is possible | |
| 73 // for the browser process to coalesce frames; it is not guaranteed | |
| 74 // that every GpuHostMsg_AcceleratedSurfaceBuffersSwapped message | |
| 75 // will result in a buffer swap on the browser side. | |
| 76 IPC_MESSAGE_CONTROL3(GpuMsg_AcceleratedSurfaceBuffersSwappedACK, | |
| 77 int /* renderer_id */, | |
| 78 int32 /* route_id */, | |
| 79 uint64 /* swap_buffers_count */) | |
| 80 | |
| 81 // Tells the GPU process that the IOSurface of the buffer belonging to | |
| 82 // |renderer_route_id| a given id was destroyed, either by the user closing the | |
| 83 // tab hosting the surface, or by the renderer navigating to a new page. | |
| 84 IPC_MESSAGE_CONTROL2(GpuMsg_DidDestroyAcceleratedSurface, | |
| 85 int /* renderer_id */, | |
| 86 int32 /* renderer_route_id */) | |
| 87 #endif | |
| 88 | |
| 89 // Tells the GPU process to crash. | |
| 90 IPC_MESSAGE_CONTROL0(GpuMsg_Crash) | |
| 91 | |
| 92 // Tells the GPU process to hang. | |
| 93 IPC_MESSAGE_CONTROL0(GpuMsg_Hang) | |
| 94 | |
| 95 //------------------------------------------------------------------------------ | |
| 96 // GPU Host Messages | |
| 97 // These are messages to the browser. | |
| 98 | |
| 99 // A renderer sends this when it wants to create a connection to the GPU | |
| 100 // process. The browser will create the GPU process if necessary, and will | |
| 101 // return a handle to the channel via a GpuChannelEstablished message. | |
| 102 IPC_MESSAGE_CONTROL0(GpuHostMsg_EstablishGpuChannel) | |
| 103 | |
| 104 // A renderer sends this to the browser process to provide a synchronization | |
| 105 // point for GPU operations, in particular to make sure the GPU channel has | |
| 106 // been established. | |
| 107 IPC_SYNC_MESSAGE_CONTROL0_0(GpuHostMsg_SynchronizeGpu) | |
| 108 | |
| 109 // A renderer sends this to the browser process when it wants to | |
| 110 // create a GL context associated with the given view_id. | |
| 111 IPC_SYNC_MESSAGE_CONTROL2_1(GpuHostMsg_CreateViewCommandBuffer, | |
| 112 int32, /* render_view_id */ | |
| 113 GPUCreateCommandBufferConfig, /* init_params */ | |
| 114 int32 /* route_id */) | |
| 115 | |
| 116 // Response from GPU to a GpuHostMsg_EstablishChannel message. | |
| 117 IPC_MESSAGE_CONTROL2(GpuHostMsg_ChannelEstablished, | |
| 118 IPC::ChannelHandle, /* channel_handle */ | |
| 119 GPUInfo /* GPU logging stats */) | |
| 120 | |
| 121 // Respond from GPU to a GpuMsg_CreateViewCommandBuffer message. | |
| 122 IPC_MESSAGE_CONTROL1(GpuHostMsg_CommandBufferCreated, | |
| 123 int32 /* route_id */) | |
| 124 | |
| 125 // Request from GPU to free the browser resources associated with the | |
| 126 // command buffer. | |
| 127 IPC_MESSAGE_CONTROL3(GpuHostMsg_DestroyCommandBuffer, | |
| 128 gfx::PluginWindowHandle, /* view */ | |
| 129 int32, /* render_view_id */ | |
| 130 int32 /* renderer_id */) | |
| 131 | |
| 132 // Response from GPU to a GpuMsg_CollectGraphicsInfo. | |
| 133 IPC_MESSAGE_CONTROL1(GpuHostMsg_GraphicsInfoCollected, | |
| 134 GPUInfo /* GPU logging stats */) | |
| 135 | |
| 136 // Message from GPU to add a GPU log message to the about:gpu page. | |
| 137 IPC_MESSAGE_CONTROL3(GpuHostMsg_OnLogMessage, | |
| 138 int /*severity*/, | |
| 139 std::string /* header */, | |
| 140 std::string /* message */) | |
| 141 | |
| 142 // Response from GPU to a GpuMsg_Synchronize message. | |
| 143 IPC_MESSAGE_CONTROL0(GpuHostMsg_SynchronizeReply) | |
| 144 | |
| 145 #if defined(OS_LINUX) && !defined(TOUCH_UI) | |
| 146 // Resize the window that is being drawn into. It's important that this | |
| 147 // resize be synchronized with the swapping of the front and back buffers. | |
| 148 IPC_SYNC_MESSAGE_CONTROL2_1(GpuHostMsg_ResizeXID, | |
| 149 unsigned long, /* xid */ | |
| 150 gfx::Size, /* size */ | |
| 151 bool /* success */) | |
| 152 #elif defined(OS_MACOSX) | |
| 153 // This message, used on Mac OS X 10.6 and later (where IOSurface is | |
| 154 // supported), is sent from the GPU process to the browser to indicate that a | |
| 155 // new backing store was allocated for the given "window" (fake | |
| 156 // PluginWindowHandle). The renderer ID and render view ID are needed in | |
| 157 // order to uniquely identify the RenderWidgetHostView on the browser side. | |
| 158 IPC_MESSAGE_CONTROL1(GpuHostMsg_AcceleratedSurfaceSetIOSurface, | |
| 159 GpuHostMsg_AcceleratedSurfaceSetIOSurface_Params) | |
| 160 | |
| 161 // This message notifies the browser process that the renderer | |
| 162 // swapped the buffers associated with the given "window", which | |
| 163 // should cause the browser to redraw the compositor's contents. | |
| 164 IPC_MESSAGE_CONTROL1(GpuHostMsg_AcceleratedSurfaceBuffersSwapped, | |
| 165 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params) | |
| 166 #elif defined(OS_WIN) | |
| 167 IPC_MESSAGE_CONTROL2(GpuHostMsg_ScheduleComposite, | |
| 168 int32, /* renderer_id */ | |
| 169 int32 /* render_view_id */) | |
| 170 #endif | |
| 171 | |
| 172 //------------------------------------------------------------------------------ | |
| 173 // GPU Channel Messages | |
| 174 // These are messages from a renderer process to the GPU process. | |
| 175 | |
| 176 // Initialize a channel between a renderer process and a GPU process. The | |
| 177 // renderer passes its process handle to the GPU process, which gives gives the | |
| 178 // GPU process the ability to map handles from the renderer process. This must | |
| 179 // be the first message sent on a newly connected channel. | |
| 180 IPC_MESSAGE_CONTROL1(GpuChannelMsg_Initialize, | |
| 181 base::ProcessHandle /* renderer_process_for_gpu */) | |
| 182 | |
| 183 // Tells the GPU process to create a new command buffer that renders to an | |
| 184 // offscreen frame buffer. If parent_route_id is not zero, the texture backing | |
| 185 // the frame buffer is mapped into the corresponding parent command buffer's | |
| 186 // namespace, with the name of parent_texture_id. This ID is in the parent's | |
| 187 // namespace. | |
| 188 IPC_SYNC_MESSAGE_CONTROL4_1(GpuChannelMsg_CreateOffscreenCommandBuffer, | |
| 189 int32, /* parent_route_id */ | |
| 190 gfx::Size, /* size */ | |
| 191 GPUCreateCommandBufferConfig, /* init_params */ | |
| 192 uint32, /* parent_texture_id */ | |
| 193 int32 /* route_id */) | |
| 194 | |
| 195 // The CommandBufferProxy sends this to the GpuCommandBufferStub in its | |
| 196 // destructor, so that the stub deletes the actual CommandBufferService | |
| 197 // object that it's hosting. | |
| 198 // TODO(apatrick): Implement this. | |
| 199 IPC_SYNC_MESSAGE_CONTROL1_0(GpuChannelMsg_DestroyCommandBuffer, | |
| 200 int32 /* instance_id */) | |
| 201 | |
| 202 // Create hardware video decoder && associate it with the output |decoder_id|; | |
| 203 // We need this to be control message because we had to map the GpuChannel and | |
| 204 // |decoder_id|. | |
| 205 IPC_MESSAGE_CONTROL2(GpuChannelMsg_CreateVideoDecoder, | |
| 206 int32, /* context_route_id */ | |
| 207 int32) /* decoder_id */ | |
| 208 | |
| 209 // Release all resource of the hardware video decoder which was assocaited | |
| 210 // with the input |decoder_id|. | |
| 211 // TODO(hclam): This message needs to be asynchronous. | |
| 212 IPC_SYNC_MESSAGE_CONTROL1_0(GpuChannelMsg_DestroyVideoDecoder, | |
| 213 int32 /* decoder_id */) | |
| 214 | |
| 215 //------------------------------------------------------------------------------ | |
| 216 // GPU Command Buffer Messages | |
| 217 // These are messages between a renderer process to the GPU process relating to | |
| 218 // a single OpenGL context. | |
| 219 // Initialize a command buffer with the given number of command entries. | |
| 220 // Returns the shared memory handle for the command buffer mapped to the | |
| 221 // calling process. | |
| 222 IPC_SYNC_MESSAGE_ROUTED2_1(GpuCommandBufferMsg_Initialize, | |
| 223 base::SharedMemoryHandle /* ring_buffer */, | |
| 224 int32 /* size */, | |
| 225 bool /* result */) | |
| 226 | |
| 227 // Get the current state of the command buffer. | |
| 228 IPC_SYNC_MESSAGE_ROUTED0_1(GpuCommandBufferMsg_GetState, | |
| 229 gpu::CommandBuffer::State /* state */) | |
| 230 | |
| 231 // Get the current state of the command buffer asynchronously. State is | |
| 232 // returned via UpdateState message. | |
| 233 IPC_MESSAGE_ROUTED0(GpuCommandBufferMsg_AsyncGetState) | |
| 234 | |
| 235 // Synchronize the put and get offsets of both processes. Caller passes its | |
| 236 // current put offset. Current state (including get offset) is returned. | |
| 237 IPC_SYNC_MESSAGE_ROUTED1_1(GpuCommandBufferMsg_Flush, | |
| 238 int32 /* put_offset */, | |
| 239 gpu::CommandBuffer::State /* state */) | |
| 240 | |
| 241 // Asynchronously synchronize the put and get offsets of both processes. | |
| 242 // Caller passes its current put offset. Current state (including get offset) | |
| 243 // is returned via an UpdateState message. | |
| 244 IPC_MESSAGE_ROUTED1(GpuCommandBufferMsg_AsyncFlush, | |
| 245 int32 /* put_offset */) | |
| 246 | |
| 247 // Return the current state of the command buffer following a request via | |
| 248 // an AsyncGetState or AsyncFlush message. (This message is sent from the | |
| 249 // GPU process to the renderer process.) | |
| 250 IPC_MESSAGE_ROUTED1(GpuCommandBufferMsg_UpdateState, | |
| 251 gpu::CommandBuffer::State /* state */) | |
| 252 | |
| 253 // Indicates that a SwapBuffers call has been issued. | |
| 254 IPC_MESSAGE_ROUTED0(GpuCommandBufferMsg_SwapBuffers) | |
| 255 | |
| 256 // Create a shared memory transfer buffer. Returns an id that can be used to | |
| 257 // identify the transfer buffer from a comment. | |
| 258 IPC_SYNC_MESSAGE_ROUTED1_1(GpuCommandBufferMsg_CreateTransferBuffer, | |
| 259 int32 /* size */, | |
| 260 int32 /* id */) | |
| 261 | |
| 262 // Register an existing shared memory transfer buffer. Returns an id that can be | |
| 263 // used to identify the transfer buffer from a command buffer. | |
| 264 IPC_SYNC_MESSAGE_ROUTED2_1(GpuCommandBufferMsg_RegisterTransferBuffer, | |
| 265 base::SharedMemoryHandle /* transfer_buffer */, | |
| 266 size_t /* size */, | |
| 267 int32 /* id */) | |
| 268 | |
| 269 // Destroy a previously created transfer buffer. | |
| 270 IPC_SYNC_MESSAGE_ROUTED1_0(GpuCommandBufferMsg_DestroyTransferBuffer, | |
| 271 int32 /* id */) | |
| 272 | |
| 273 // Get the shared memory handle for a transfer buffer mapped to the callers | |
| 274 // process. | |
| 275 IPC_SYNC_MESSAGE_ROUTED1_2(GpuCommandBufferMsg_GetTransferBuffer, | |
| 276 int32 /* id */, | |
| 277 base::SharedMemoryHandle /* transfer_buffer */, | |
| 278 uint32 /* size */) | |
| 279 | |
| 280 // Send from command buffer stub to proxy when window is invalid and must be | |
| 281 // repainted. | |
| 282 IPC_MESSAGE_ROUTED0(GpuCommandBufferMsg_NotifyRepaint) | |
| 283 | |
| 284 // Tells the GPU process to resize an offscreen frame buffer. | |
| 285 IPC_MESSAGE_ROUTED1(GpuCommandBufferMsg_ResizeOffscreenFrameBuffer, | |
| 286 gfx::Size /* size */) | |
| 287 | |
| 288 #if defined(OS_MACOSX) | |
| 289 // On Mac OS X the GPU plugin must be offscreen, because there is no | |
| 290 // true cross-process window hierarchy. For this reason we must send | |
| 291 // resize events explicitly to the command buffer stub so it can | |
| 292 // reallocate its backing store and send the new one back to the | |
| 293 // browser. This message is currently used only on 10.6 and later. | |
| 294 IPC_MESSAGE_ROUTED1(GpuCommandBufferMsg_SetWindowSize, | |
| 295 gfx::Size /* size */) | |
| 296 #endif | |
| 297 | |
| 298 //------------------------------------------------------------------------------ | |
| 299 // GPU Video Decoder Messages | |
| 300 // These messages are sent from Renderer process to GPU process. | |
| 301 // Initialize and configure GpuVideoDecoder asynchronously. | |
| 302 IPC_MESSAGE_ROUTED1(GpuVideoDecoderMsg_Initialize, | |
| 303 GpuVideoDecoderInitParam) | |
| 304 | |
| 305 // Destroy and release GpuVideoDecoder asynchronously. | |
| 306 IPC_MESSAGE_ROUTED0(GpuVideoDecoderMsg_Destroy) | |
| 307 | |
| 308 // Start decoder flushing operation. | |
| 309 IPC_MESSAGE_ROUTED0(GpuVideoDecoderMsg_Flush) | |
| 310 | |
| 311 // Tell the decoder to start prerolling. | |
| 312 IPC_MESSAGE_ROUTED0(GpuVideoDecoderMsg_Preroll) | |
| 313 | |
| 314 // Send input buffer to GpuVideoDecoder. | |
| 315 IPC_MESSAGE_ROUTED1(GpuVideoDecoderMsg_EmptyThisBuffer, | |
| 316 GpuVideoDecoderInputBufferParam) | |
| 317 | |
| 318 // Ask the GPU process to produce a video frame with the ID. | |
| 319 IPC_MESSAGE_ROUTED1(GpuVideoDecoderMsg_ProduceVideoFrame, | |
| 320 int32) /* Video Frame ID */ | |
| 321 | |
| 322 // Sent from Renderer process to the GPU process to notify that textures are | |
| 323 // generated for a video frame. | |
| 324 IPC_MESSAGE_ROUTED2(GpuVideoDecoderMsg_VideoFrameAllocated, | |
| 325 int32, /* Video Frame ID */ | |
| 326 std::vector<uint32>) /* Textures for video frame */ | |
| 327 | |
| 328 //------------------------------------------------------------------------------ | |
| 329 // GPU Video Decoder Host Messages | |
| 330 // These messages are sent from GPU process to Renderer process. | |
| 331 // Inform GpuVideoDecoderHost that a GpuVideoDecoder is created. | |
| 332 IPC_MESSAGE_ROUTED1(GpuVideoDecoderHostMsg_CreateVideoDecoderDone, | |
| 333 int32) /* decoder_id */ | |
| 334 | |
| 335 // Confirm GpuVideoDecoder had been initialized or failed to initialize. | |
| 336 // TODO(hclam): Change this to Done instead of ACK. | |
| 337 IPC_MESSAGE_ROUTED1(GpuVideoDecoderHostMsg_InitializeACK, | |
| 338 GpuVideoDecoderInitDoneParam) | |
| 339 | |
| 340 // Confrim GpuVideoDecoder had been destroyed properly. | |
| 341 // TODO(hclam): Change this to Done instead of ACK. | |
| 342 IPC_MESSAGE_ROUTED0(GpuVideoDecoderHostMsg_DestroyACK) | |
| 343 | |
| 344 // Confirm decoder had been flushed. | |
| 345 // TODO(hclam): Change this to Done instead of ACK. | |
| 346 IPC_MESSAGE_ROUTED0(GpuVideoDecoderHostMsg_FlushACK) | |
| 347 | |
| 348 // Confirm preroll operation is done. | |
| 349 IPC_MESSAGE_ROUTED0(GpuVideoDecoderHostMsg_PrerollDone) | |
| 350 | |
| 351 // GpuVideoDecoder has consumed input buffer from transfer buffer. | |
| 352 // TODO(hclam): Change this to Done instead of ACK. | |
| 353 IPC_MESSAGE_ROUTED0(GpuVideoDecoderHostMsg_EmptyThisBufferACK) | |
| 354 | |
| 355 // GpuVideoDecoder require new input buffer. | |
| 356 IPC_MESSAGE_ROUTED0(GpuVideoDecoderHostMsg_EmptyThisBufferDone) | |
| 357 | |
| 358 // GpuVideoDecoder reports that a video frame is ready to be consumed. | |
| 359 IPC_MESSAGE_ROUTED4(GpuVideoDecoderHostMsg_ConsumeVideoFrame, | |
| 360 int32, /* Video Frame ID */ | |
| 361 int64, /* Timestamp in microseconds */ | |
| 362 int64, /* Duration in microseconds */ | |
| 363 int32) /* Flags */ | |
| 364 | |
| 365 // Allocate video frames for output of the hardware video decoder. | |
| 366 IPC_MESSAGE_ROUTED4(GpuVideoDecoderHostMsg_AllocateVideoFrames, | |
| 367 int32, /* Number of video frames to generate */ | |
| 368 uint32, /* Width of the video frame */ | |
| 369 uint32, /* Height of the video frame */ | |
| 370 int32 /* Format of the video frame */) | |
| 371 | |
| 372 // Release all video frames allocated for a hardware video decoder. | |
| 373 IPC_MESSAGE_ROUTED0(GpuVideoDecoderHostMsg_ReleaseAllVideoFrames) | |
| 374 | |
| 375 // GpuVideoDecoder report output format change. | |
| 376 IPC_MESSAGE_ROUTED1(GpuVideoDecoderHostMsg_MediaFormatChange, | |
| 377 GpuVideoDecoderFormatChangeParam) | |
| 378 | |
| 379 // GpuVideoDecoder report error. | |
| 380 IPC_MESSAGE_ROUTED1(GpuVideoDecoderHostMsg_ErrorNotification, | |
| 381 GpuVideoDecoderErrorInfoParam) | |
| OLD | NEW |