164052e644446df8ba2d2972e9fb04f132a06841
[platform/framework/web/crosswalk.git] / src / content / common / gpu / gpu_messages.h
1 // Copyright (c) 2012 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 <string>
9 #include <vector>
10
11 #include "base/memory/shared_memory.h"
12 #include "content/common/content_export.h"
13 #include "content/common/gpu/gpu_memory_uma_stats.h"
14 #include "content/common/gpu/gpu_process_launch_causes.h"
15 #include "content/common/gpu/gpu_result_codes.h"
16 #include "content/public/common/common_param_traits.h"
17 #include "content/public/common/gpu_memory_stats.h"
18 #include "gpu/command_buffer/common/capabilities.h"
19 #include "gpu/command_buffer/common/command_buffer.h"
20 #include "gpu/command_buffer/common/constants.h"
21 #include "gpu/command_buffer/common/gpu_memory_allocation.h"
22 #include "gpu/command_buffer/common/mailbox.h"
23 #include "gpu/config/gpu_info.h"
24 #include "gpu/ipc/gpu_command_buffer_traits.h"
25 #include "ipc/ipc_channel_handle.h"
26 #include "ipc/ipc_message_macros.h"
27 #include "media/base/video_frame.h"
28 #include "media/video/video_decode_accelerator.h"
29 #include "media/video/video_encode_accelerator.h"
30 #include "ui/events/latency_info.h"
31 #include "ui/gfx/gpu_memory_buffer.h"
32 #include "ui/gfx/native_widget_types.h"
33 #include "ui/gfx/size.h"
34 #include "ui/gl/gpu_preference.h"
35
36 #if defined(OS_ANDROID)
37 #include "content/common/android/surface_texture_peer.h"
38 #endif
39
40 #undef IPC_MESSAGE_EXPORT
41 #define IPC_MESSAGE_EXPORT CONTENT_EXPORT
42
43 #define IPC_MESSAGE_START GpuMsgStart
44
45 IPC_ENUM_TRAITS_MAX_VALUE(content::CauseForGpuLaunch,
46                           content::CAUSE_FOR_GPU_LAUNCH_MAX_ENUM - 1)
47 IPC_ENUM_TRAITS_MAX_VALUE(content::CreateCommandBufferResult,
48                           content::CREATE_COMMAND_BUFFER_RESULT_LAST)
49 IPC_ENUM_TRAITS_MAX_VALUE(gfx::GpuPreference,
50                           gfx::GpuPreferenceLast)
51 IPC_ENUM_TRAITS_MAX_VALUE(gfx::SurfaceType,
52                           gfx::SURFACE_TYPE_LAST)
53 IPC_ENUM_TRAITS_MAX_VALUE(gpu::MemoryAllocation::PriorityCutoff,
54                           gpu::MemoryAllocation::CUTOFF_LAST)
55 IPC_ENUM_TRAITS_MAX_VALUE(gpu::error::ContextLostReason,
56                           gpu::error::kContextLostReasonLast)
57 IPC_ENUM_TRAITS_MAX_VALUE(media::VideoEncodeAccelerator::Error,
58                           media::VideoEncodeAccelerator::kErrorMax)
59 IPC_ENUM_TRAITS_MAX_VALUE(media::VideoFrame::Format,
60                           media::VideoFrame::FORMAT_MAX)
61 IPC_ENUM_TRAITS_MIN_MAX_VALUE(media::VideoCodecProfile,
62                               media::VIDEO_CODEC_PROFILE_MIN,
63                               media::VIDEO_CODEC_PROFILE_MAX)
64
65 IPC_STRUCT_BEGIN(GPUCreateCommandBufferConfig)
66   IPC_STRUCT_MEMBER(int32, share_group_id)
67   IPC_STRUCT_MEMBER(std::vector<int>, attribs)
68   IPC_STRUCT_MEMBER(GURL, active_url)
69   IPC_STRUCT_MEMBER(gfx::GpuPreference, gpu_preference)
70 IPC_STRUCT_END()
71
72 IPC_STRUCT_BEGIN(GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params)
73   IPC_STRUCT_MEMBER(int32, surface_id)
74   IPC_STRUCT_MEMBER(uint64, surface_handle)
75   IPC_STRUCT_MEMBER(int32, route_id)
76   IPC_STRUCT_MEMBER(gpu::Mailbox, mailbox)
77   IPC_STRUCT_MEMBER(gfx::Size, size)
78   IPC_STRUCT_MEMBER(float, scale_factor)
79   IPC_STRUCT_MEMBER(std::vector<ui::LatencyInfo>, latency_info)
80 IPC_STRUCT_END()
81
82 IPC_STRUCT_BEGIN(GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params)
83   IPC_STRUCT_MEMBER(int32, surface_id)
84   IPC_STRUCT_MEMBER(uint64, surface_handle)
85   IPC_STRUCT_MEMBER(int32, route_id)
86   IPC_STRUCT_MEMBER(int, x)
87   IPC_STRUCT_MEMBER(int, y)
88   IPC_STRUCT_MEMBER(int, width)
89   IPC_STRUCT_MEMBER(int, height)
90   IPC_STRUCT_MEMBER(gpu::Mailbox, mailbox)
91   IPC_STRUCT_MEMBER(gfx::Size, surface_size)
92   IPC_STRUCT_MEMBER(float, surface_scale_factor)
93   IPC_STRUCT_MEMBER(std::vector<ui::LatencyInfo>, latency_info)
94 IPC_STRUCT_END()
95
96 IPC_STRUCT_BEGIN(GpuHostMsg_AcceleratedSurfaceRelease_Params)
97   IPC_STRUCT_MEMBER(int32, surface_id)
98 IPC_STRUCT_END()
99
100 IPC_STRUCT_BEGIN(AcceleratedSurfaceMsg_BufferPresented_Params)
101   IPC_STRUCT_MEMBER(gpu::Mailbox, mailbox)
102   IPC_STRUCT_MEMBER(uint32, sync_point)
103 #if defined(OS_MACOSX)
104   IPC_STRUCT_MEMBER(int32, renderer_id)
105 #endif
106 #if defined(OS_WIN)
107   IPC_STRUCT_MEMBER(base::TimeTicks, vsync_timebase)
108   IPC_STRUCT_MEMBER(base::TimeDelta, vsync_interval)
109 #endif
110 IPC_STRUCT_END()
111
112 IPC_STRUCT_BEGIN(GPUCommandBufferConsoleMessage)
113   IPC_STRUCT_MEMBER(int32, id)
114   IPC_STRUCT_MEMBER(std::string, message)
115 IPC_STRUCT_END()
116
117 #if defined(OS_ANDROID)
118 IPC_STRUCT_BEGIN(GpuStreamTextureMsg_MatrixChanged_Params)
119   IPC_STRUCT_MEMBER(float, m00)
120   IPC_STRUCT_MEMBER(float, m01)
121   IPC_STRUCT_MEMBER(float, m02)
122   IPC_STRUCT_MEMBER(float, m03)
123   IPC_STRUCT_MEMBER(float, m10)
124   IPC_STRUCT_MEMBER(float, m11)
125   IPC_STRUCT_MEMBER(float, m12)
126   IPC_STRUCT_MEMBER(float, m13)
127   IPC_STRUCT_MEMBER(float, m20)
128   IPC_STRUCT_MEMBER(float, m21)
129   IPC_STRUCT_MEMBER(float, m22)
130   IPC_STRUCT_MEMBER(float, m23)
131   IPC_STRUCT_MEMBER(float, m30)
132   IPC_STRUCT_MEMBER(float, m31)
133   IPC_STRUCT_MEMBER(float, m32)
134   IPC_STRUCT_MEMBER(float, m33)
135 IPC_STRUCT_END()
136 #endif
137
138   IPC_STRUCT_TRAITS_BEGIN(gpu::DxDiagNode)
139   IPC_STRUCT_TRAITS_MEMBER(values)
140   IPC_STRUCT_TRAITS_MEMBER(children)
141 IPC_STRUCT_TRAITS_END()
142
143 IPC_STRUCT_TRAITS_BEGIN(gpu::GpuPerformanceStats)
144   IPC_STRUCT_TRAITS_MEMBER(graphics)
145   IPC_STRUCT_TRAITS_MEMBER(gaming)
146   IPC_STRUCT_TRAITS_MEMBER(overall)
147 IPC_STRUCT_TRAITS_END()
148
149 IPC_STRUCT_TRAITS_BEGIN(gpu::GPUInfo::GPUDevice)
150   IPC_STRUCT_TRAITS_MEMBER(vendor_id)
151   IPC_STRUCT_TRAITS_MEMBER(device_id)
152   IPC_STRUCT_TRAITS_MEMBER(active)
153   IPC_STRUCT_TRAITS_MEMBER(vendor_string)
154   IPC_STRUCT_TRAITS_MEMBER(device_string)
155 IPC_STRUCT_TRAITS_END()
156
157 IPC_STRUCT_TRAITS_BEGIN(gpu::GPUInfo)
158   IPC_STRUCT_TRAITS_MEMBER(finalized)
159   IPC_STRUCT_TRAITS_MEMBER(initialization_time)
160   IPC_STRUCT_TRAITS_MEMBER(optimus)
161   IPC_STRUCT_TRAITS_MEMBER(amd_switchable)
162   IPC_STRUCT_TRAITS_MEMBER(lenovo_dcute)
163   IPC_STRUCT_TRAITS_MEMBER(gpu)
164   IPC_STRUCT_TRAITS_MEMBER(secondary_gpus)
165   IPC_STRUCT_TRAITS_MEMBER(adapter_luid)
166   IPC_STRUCT_TRAITS_MEMBER(driver_vendor)
167   IPC_STRUCT_TRAITS_MEMBER(driver_version)
168   IPC_STRUCT_TRAITS_MEMBER(driver_date)
169   IPC_STRUCT_TRAITS_MEMBER(pixel_shader_version)
170   IPC_STRUCT_TRAITS_MEMBER(vertex_shader_version)
171   IPC_STRUCT_TRAITS_MEMBER(machine_model_name)
172   IPC_STRUCT_TRAITS_MEMBER(machine_model_version)
173   IPC_STRUCT_TRAITS_MEMBER(gl_version)
174   IPC_STRUCT_TRAITS_MEMBER(gl_vendor)
175   IPC_STRUCT_TRAITS_MEMBER(gl_renderer)
176   IPC_STRUCT_TRAITS_MEMBER(gl_extensions)
177   IPC_STRUCT_TRAITS_MEMBER(gl_ws_vendor)
178   IPC_STRUCT_TRAITS_MEMBER(gl_ws_version)
179   IPC_STRUCT_TRAITS_MEMBER(gl_ws_extensions)
180   IPC_STRUCT_TRAITS_MEMBER(gl_reset_notification_strategy)
181   IPC_STRUCT_TRAITS_MEMBER(can_lose_context)
182   IPC_STRUCT_TRAITS_MEMBER(performance_stats)
183   IPC_STRUCT_TRAITS_MEMBER(software_rendering)
184   IPC_STRUCT_TRAITS_MEMBER(direct_rendering)
185   IPC_STRUCT_TRAITS_MEMBER(sandboxed)
186   IPC_STRUCT_TRAITS_MEMBER(process_crash_count)
187 #if defined(OS_WIN)
188   IPC_STRUCT_TRAITS_MEMBER(dx_diagnostics)
189 #endif
190 IPC_STRUCT_TRAITS_END()
191
192 IPC_STRUCT_TRAITS_BEGIN(gpu::Capabilities)
193   IPC_STRUCT_TRAITS_MEMBER(post_sub_buffer)
194   IPC_STRUCT_TRAITS_MEMBER(egl_image_external)
195   IPC_STRUCT_TRAITS_MEMBER(texture_format_bgra8888)
196   IPC_STRUCT_TRAITS_MEMBER(texture_format_etc1)
197   IPC_STRUCT_TRAITS_MEMBER(texture_rectangle)
198   IPC_STRUCT_TRAITS_MEMBER(iosurface)
199   IPC_STRUCT_TRAITS_MEMBER(texture_usage)
200   IPC_STRUCT_TRAITS_MEMBER(texture_storage)
201   IPC_STRUCT_TRAITS_MEMBER(discard_framebuffer)
202   IPC_STRUCT_TRAITS_MEMBER(sync_query)
203   IPC_STRUCT_TRAITS_MEMBER(map_image)
204 IPC_STRUCT_TRAITS_END()
205
206 IPC_STRUCT_TRAITS_BEGIN(content::GPUVideoMemoryUsageStats::ProcessStats)
207   IPC_STRUCT_TRAITS_MEMBER(video_memory)
208   IPC_STRUCT_TRAITS_MEMBER(has_duplicates)
209 IPC_STRUCT_TRAITS_END()
210
211 IPC_STRUCT_TRAITS_BEGIN(content::GPUVideoMemoryUsageStats)
212   IPC_STRUCT_TRAITS_MEMBER(process_map)
213   IPC_STRUCT_TRAITS_MEMBER(bytes_allocated)
214   IPC_STRUCT_TRAITS_MEMBER(bytes_allocated_historical_max)
215 IPC_STRUCT_TRAITS_END()
216
217 IPC_STRUCT_TRAITS_BEGIN(content::GPUMemoryUmaStats)
218   IPC_STRUCT_TRAITS_MEMBER(bytes_allocated_current)
219   IPC_STRUCT_TRAITS_MEMBER(bytes_allocated_max)
220   IPC_STRUCT_TRAITS_MEMBER(bytes_limit)
221 IPC_STRUCT_TRAITS_END()
222
223 IPC_STRUCT_TRAITS_BEGIN(gpu::MemoryAllocation)
224   IPC_STRUCT_TRAITS_MEMBER(bytes_limit_when_visible)
225   IPC_STRUCT_TRAITS_MEMBER(priority_cutoff_when_visible)
226 IPC_STRUCT_TRAITS_END()
227
228 IPC_STRUCT_TRAITS_BEGIN(gfx::GLSurfaceHandle)
229   IPC_STRUCT_TRAITS_MEMBER(handle)
230   IPC_STRUCT_TRAITS_MEMBER(transport_type)
231   IPC_STRUCT_TRAITS_MEMBER(parent_client_id)
232 IPC_STRUCT_TRAITS_END()
233
234 //------------------------------------------------------------------------------
235 // GPU Messages
236 // These are messages from the browser to the GPU process.
237
238 // Tells the GPU process to initialize itself. The browser explicitly
239 // requests this be done so that we are guaranteed that the channel is set
240 // up between the browser and GPU process before doing any work that might
241 // potentially crash the GPU process. Detection of the child process
242 // exiting abruptly is predicated on having the IPC channel set up.
243 IPC_MESSAGE_CONTROL0(GpuMsg_Initialize)
244
245 // Tells the GPU process to create a new channel for communication with a
246 // given client.  The channel name is returned in a
247 // GpuHostMsg_ChannelEstablished message.  The client ID is passed so that
248 // the GPU process reuses an existing channel to that process if it exists.
249 // This ID is a unique opaque identifier generated by the browser process.
250 IPC_MESSAGE_CONTROL3(GpuMsg_EstablishChannel,
251                      int /* client_id */,
252                      bool /* share_context */,
253                      bool /* allow_future_sync_points */)
254
255 // Tells the GPU process to close the channel identified by IPC channel
256 // handle.  If no channel can be identified, do nothing.
257 IPC_MESSAGE_CONTROL1(GpuMsg_CloseChannel,
258                      IPC::ChannelHandle /* channel_handle */)
259
260 // Tells the GPU process to create a new command buffer that renders directly
261 // to a native view. A corresponding GpuCommandBufferStub is created.
262 IPC_MESSAGE_CONTROL5(GpuMsg_CreateViewCommandBuffer,
263                      gfx::GLSurfaceHandle, /* compositing_surface */
264                      int32, /* surface_id */
265                      int32, /* client_id */
266                      GPUCreateCommandBufferConfig, /* init_params */
267                      int32 /* route_id */)
268
269 // Tells the GPU process to create a new gpu memory buffer for |handle|.
270 IPC_MESSAGE_CONTROL4(GpuMsg_CreateGpuMemoryBuffer,
271                      gfx::GpuMemoryBufferHandle, /* handle */
272                      gfx::Size, /* size */
273                      unsigned, /* internalformat */
274                      unsigned /* usage */)
275
276 // Tells the GPU process to destroy buffer.
277 IPC_MESSAGE_CONTROL2(GpuMsg_DestroyGpuMemoryBuffer,
278                      gfx::GpuMemoryBufferHandle, /* handle */
279                      int32 /* sync_point */)
280
281 // Tells the GPU process to create a context for collecting graphics card
282 // information.
283 IPC_MESSAGE_CONTROL0(GpuMsg_CollectGraphicsInfo)
284
285 // Tells the GPU process to report video_memory information for the task manager
286 IPC_MESSAGE_CONTROL0(GpuMsg_GetVideoMemoryUsageStats)
287
288 // Tells the GPU process that the browser process has handled the swap
289 // buffers or post sub-buffer request. A non-zero sync point means
290 // that we should wait for the sync point. The surface_handle identifies
291 // that buffer that has finished presented, i.e. the buffer being returned.
292 IPC_MESSAGE_ROUTED1(AcceleratedSurfaceMsg_BufferPresented,
293                     AcceleratedSurfaceMsg_BufferPresented_Params)
294
295 // Tells the GPU process to wake up the GPU because we're about to draw.
296 IPC_MESSAGE_ROUTED0(AcceleratedSurfaceMsg_WakeUpGpu)
297
298 // Tells the GPU process to remove all contexts.
299 IPC_MESSAGE_CONTROL0(GpuMsg_Clean)
300
301 // Tells the GPU process to crash.
302 IPC_MESSAGE_CONTROL0(GpuMsg_Crash)
303
304 // Tells the GPU process to hang.
305 IPC_MESSAGE_CONTROL0(GpuMsg_Hang)
306
307 // Tells the GPU process to disable the watchdog thread.
308 IPC_MESSAGE_CONTROL0(GpuMsg_DisableWatchdog)
309
310 //------------------------------------------------------------------------------
311 // GPU Host Messages
312 // These are messages to the browser.
313
314 // A renderer sends this when it wants to create a connection to the GPU
315 // process. The browser will create the GPU process if necessary, and will
316 // return a handle to the channel via a GpuChannelEstablished message.
317 IPC_SYNC_MESSAGE_CONTROL1_3(GpuHostMsg_EstablishGpuChannel,
318                             content::CauseForGpuLaunch,
319                             int /* client id */,
320                             IPC::ChannelHandle /* handle to channel */,
321                             gpu::GPUInfo /* stats about GPU process*/)
322
323 // A renderer sends this to the browser process when it wants to
324 // create a GL context associated with the given view_id.
325 IPC_SYNC_MESSAGE_CONTROL3_1(GpuHostMsg_CreateViewCommandBuffer,
326                             int32, /* surface_id */
327                             GPUCreateCommandBufferConfig, /* init_params */
328                             int32, /* route_id */
329                             content::CreateCommandBufferResult /* result */)
330
331 // Response from GPU to a GputMsg_Initialize message.
332 IPC_MESSAGE_CONTROL2(GpuHostMsg_Initialized,
333                      bool /* result */,
334                      ::gpu::GPUInfo /* gpu_info */)
335
336 // Response from GPU to a GpuHostMsg_EstablishChannel message.
337 IPC_MESSAGE_CONTROL1(GpuHostMsg_ChannelEstablished,
338                      IPC::ChannelHandle /* channel_handle */)
339
340 // Message from GPU to notify to destroy the channel.
341 IPC_MESSAGE_CONTROL1(GpuHostMsg_DestroyChannel,
342                      int32 /* client_id */)
343
344 // Message to cache the given shader information.
345 IPC_MESSAGE_CONTROL3(GpuHostMsg_CacheShader,
346                      int32 /* client_id */,
347                      std::string /* key */,
348                      std::string /* shader */)
349
350 // Message to the GPU that a shader was loaded from disk.
351 IPC_MESSAGE_CONTROL1(GpuMsg_LoadedShader,
352                      std::string /* encoded shader */)
353
354 // Respond from GPU to a GpuMsg_CreateViewCommandBuffer message.
355 IPC_MESSAGE_CONTROL1(GpuHostMsg_CommandBufferCreated,
356                      content::CreateCommandBufferResult /* result */)
357
358 // Request from GPU to free the browser resources associated with the
359 // command buffer.
360 IPC_MESSAGE_CONTROL1(GpuHostMsg_DestroyCommandBuffer,
361                      int32 /* surface_id */)
362
363 // Response from GPU to a GpuMsg_CreateGpuMemoryBuffer message.
364 IPC_MESSAGE_CONTROL1(GpuHostMsg_GpuMemoryBufferCreated,
365                      gfx::GpuMemoryBufferHandle /* handle */)
366
367 // Response from GPU to a GpuMsg_CollectGraphicsInfo.
368 IPC_MESSAGE_CONTROL1(GpuHostMsg_GraphicsInfoCollected,
369                      gpu::GPUInfo /* GPU logging stats */)
370
371 // Response from GPU to a GpuMsg_GetVideoMemory.
372 IPC_MESSAGE_CONTROL1(GpuHostMsg_VideoMemoryUsageStats,
373                      content::GPUVideoMemoryUsageStats /* GPU memory stats */)
374
375 // Message from GPU to add a GPU log message to the about:gpu page.
376 IPC_MESSAGE_CONTROL3(GpuHostMsg_OnLogMessage,
377                      int /*severity*/,
378                      std::string /* header */,
379                      std::string /* message */)
380
381 // Tells the browser that a new accelerated surface was initialized.
382 IPC_MESSAGE_CONTROL2(GpuHostMsg_AcceleratedSurfaceInitialized,
383                      int32 /* surface_id */,
384                      int32 /* route_id */)
385
386 // Tells the browser that a frame with the specific latency info was drawn to
387 // the screen
388 IPC_MESSAGE_CONTROL1(GpuHostMsg_FrameDrawn,
389                      std::vector<ui::LatencyInfo> /* latency_info */)
390
391 // Same as above with a rect of the part of the surface that changed.
392 IPC_MESSAGE_CONTROL1(GpuHostMsg_AcceleratedSurfaceBuffersSwapped,
393                      GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params)
394
395 // This message notifies the browser process that the renderer
396 // swapped a portion of the buffers associated with the given "window", which
397 // should cause the browser to redraw the compositor's contents.
398 IPC_MESSAGE_CONTROL1(GpuHostMsg_AcceleratedSurfacePostSubBuffer,
399                      GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params)
400
401 // Tells the browser to release whatever resources are associated with
402 // the given surface. The browser must send an ACK once this operation
403 // is complete.
404 IPC_MESSAGE_CONTROL1(GpuHostMsg_AcceleratedSurfaceRelease,
405                      GpuHostMsg_AcceleratedSurfaceRelease_Params)
406
407 // Tells the browser to release resources for the given surface until the next
408 // time swap buffers or post sub buffer is sent.
409 IPC_MESSAGE_CONTROL1(GpuHostMsg_AcceleratedSurfaceSuspend,
410                      int32 /* surface_id */)
411
412 // Tells the browser about updated parameters for vsync alignment.
413 IPC_MESSAGE_CONTROL3(GpuHostMsg_UpdateVSyncParameters,
414                      int32 /* surface_id */,
415                      base::TimeTicks /* timebase */,
416                      base::TimeDelta /* interval */)
417
418 IPC_MESSAGE_CONTROL1(GpuHostMsg_DidCreateOffscreenContext,
419                      GURL /* url */)
420
421 IPC_MESSAGE_CONTROL3(GpuHostMsg_DidLoseContext,
422                      bool /* offscreen */,
423                      gpu::error::ContextLostReason /* reason */,
424                      GURL /* url */)
425
426 IPC_MESSAGE_CONTROL1(GpuHostMsg_DidDestroyOffscreenContext,
427                      GURL /* url */)
428
429 // Tells the browser about GPU memory usage statistics for UMA logging.
430 IPC_MESSAGE_CONTROL1(GpuHostMsg_GpuMemoryUmaStats,
431                      content::GPUMemoryUmaStats /* GPU memory UMA stats */)
432
433 //------------------------------------------------------------------------------
434 // GPU Channel Messages
435 // These are messages from a renderer process to the GPU process.
436
437 // Tells the GPU process to create a new command buffer that renders to an
438 // offscreen frame buffer.
439 IPC_SYNC_MESSAGE_CONTROL3_1(GpuChannelMsg_CreateOffscreenCommandBuffer,
440                             gfx::Size, /* size */
441                             GPUCreateCommandBufferConfig, /* init_params */
442                             int32, /* route_id */
443                             bool /* succeeded */)
444
445 // The CommandBufferProxy sends this to the GpuCommandBufferStub in its
446 // destructor, so that the stub deletes the actual CommandBufferService
447 // object that it's hosting.
448 IPC_SYNC_MESSAGE_CONTROL1_0(GpuChannelMsg_DestroyCommandBuffer,
449                             int32 /* instance_id */)
450
451 // Sent by DevTools agent in the inspected renderer process to initiate GPU
452 // instrumentation events recording.
453 IPC_SYNC_MESSAGE_CONTROL1_1(GpuChannelMsg_DevToolsStartEventsRecording,
454                             int32, /* route_id */
455                             bool /* succeeded */)
456
457 // The message is sent when DevTools want to stop events recording.
458 IPC_MESSAGE_CONTROL0(GpuChannelMsg_DevToolsStopEventsRecording)
459
460 #if defined(OS_ANDROID)
461 //------------------------------------------------------------------------------
462 // Stream Texture Messages
463 // Tells the GPU process create and send the java surface texture object to
464 // the renderer process through the binder thread.
465 IPC_MESSAGE_ROUTED2(GpuStreamTextureMsg_EstablishPeer,
466                     int32, /* primary_id */
467                     int32  /* secondary_id */)
468
469 // Tells the GPU process to set the size of StreamTexture from the given
470 // stream Id.
471 IPC_MESSAGE_ROUTED1(GpuStreamTextureMsg_SetSize,
472                     gfx::Size /* size */)
473
474 // Tells the service-side instance to start sending frame available
475 // notifications.
476 IPC_MESSAGE_ROUTED0(GpuStreamTextureMsg_StartListening)
477
478 // Inform the renderer that a new frame is available.
479 IPC_MESSAGE_ROUTED0(GpuStreamTextureMsg_FrameAvailable)
480
481 // Inform the renderer process that the transform matrix has changed.
482 IPC_MESSAGE_ROUTED1(GpuStreamTextureMsg_MatrixChanged,
483                     GpuStreamTextureMsg_MatrixChanged_Params /* params */)
484 #endif
485
486 //------------------------------------------------------------------------------
487 // GPU Command Buffer Messages
488 // These are messages between a renderer process to the GPU process relating to
489 // a single OpenGL context.
490 // Initialize a command buffer with the given number of command entries.
491 // Returns the shared memory handle for the command buffer mapped to the
492 // calling process.
493 IPC_SYNC_MESSAGE_ROUTED1_2(GpuCommandBufferMsg_Initialize,
494                            base::SharedMemoryHandle /* shared_state */,
495                            bool /* result */,
496                            gpu::Capabilities /* capabilities */)
497
498 // Sets the shared memory buffer used for commands.
499 IPC_SYNC_MESSAGE_ROUTED1_0(GpuCommandBufferMsg_SetGetBuffer,
500                            int32 /* shm_id */)
501
502 // Produces the front buffer into a mailbox. This allows another context to draw
503 // the output of this context.
504 IPC_MESSAGE_ROUTED1(GpuCommandBufferMsg_ProduceFrontBuffer,
505                     gpu::Mailbox /* mailbox */)
506
507 // Wait until the token is in a specific range, inclusive.
508 IPC_SYNC_MESSAGE_ROUTED2_1(GpuCommandBufferMsg_WaitForTokenInRange,
509                            int32 /* start */,
510                            int32 /* end */,
511                            gpu::CommandBuffer::State /* state */)
512
513 // Wait until the get offset is in a specific range, inclusive.
514 IPC_SYNC_MESSAGE_ROUTED2_1(GpuCommandBufferMsg_WaitForGetOffsetInRange,
515                            int32 /* start */,
516                            int32 /* end */,
517                            gpu::CommandBuffer::State /* state */)
518
519 // Asynchronously synchronize the put and get offsets of both processes.
520 // Caller passes its current put offset. Current state (including get offset)
521 // is returned in shared memory.
522 IPC_MESSAGE_ROUTED2(GpuCommandBufferMsg_AsyncFlush,
523                     int32 /* put_offset */,
524                     uint32 /* flush_count */)
525
526 // Sends information about the latency of the current frame to the GPU
527 // process.
528 IPC_MESSAGE_ROUTED1(GpuCommandBufferMsg_SetLatencyInfo,
529                     std::vector<ui::LatencyInfo> /* latency_info */)
530
531 // Asynchronously process any commands known to the GPU process. This is only
532 // used in the event that a channel is unscheduled and needs to be flushed
533 // again to process any commands issued subsequent to unscheduling. The GPU
534 // process actually sends it (deferred) to itself.
535 IPC_MESSAGE_ROUTED0(GpuCommandBufferMsg_Rescheduled)
536
537 // Sent by the GPU process to display messages in the console.
538 IPC_MESSAGE_ROUTED1(GpuCommandBufferMsg_ConsoleMsg,
539                     GPUCommandBufferConsoleMessage /* msg */)
540
541 // Register an existing shared memory transfer buffer. The id that can be
542 // used to identify the transfer buffer from a command buffer.
543 IPC_MESSAGE_ROUTED3(GpuCommandBufferMsg_RegisterTransferBuffer,
544                     int32 /* id */,
545                     base::SharedMemoryHandle /* transfer_buffer */,
546                     uint32 /* size */)
547
548 // Destroy a previously created transfer buffer.
549 IPC_MESSAGE_ROUTED1(GpuCommandBufferMsg_DestroyTransferBuffer,
550                     int32 /* id */)
551
552 // Create and initialize a hardware video decoder using the specified route_id.
553 // Created decoders should be freed with AcceleratedVideoDecoderMsg_Destroy when
554 // no longer needed.
555 IPC_SYNC_MESSAGE_ROUTED2_1(GpuCommandBufferMsg_CreateVideoDecoder,
556                            media::VideoCodecProfile /* profile */,
557                            int32, /* route_id */
558                            bool /* succeeded */)
559
560 // Create and initialize a hardware video encoder using the specified route_id.
561 // Created encoders should be freed with AcceleratedVideoEncoderMsg_Destroy when
562 // no longer needed.
563 IPC_SYNC_MESSAGE_ROUTED5_1(GpuCommandBufferMsg_CreateVideoEncoder,
564                            media::VideoFrame::Format /* input_format */,
565                            gfx::Size /* input_visible_size */,
566                            media::VideoCodecProfile /* output_profile */,
567                            uint32 /* initial_bitrate */,
568                            int32, /* route_id */
569                            bool /* succeeded */)
570
571 // Tells the proxy that there was an error and the command buffer had to be
572 // destroyed for some reason.
573 IPC_MESSAGE_ROUTED1(GpuCommandBufferMsg_Destroyed,
574                     gpu::error::ContextLostReason /* reason */)
575
576 // Request that the GPU process reply with the given message. Reply may be
577 // delayed.
578 IPC_MESSAGE_ROUTED1(GpuCommandBufferMsg_Echo,
579                     IPC::Message /* reply */)
580
581 // Response to a GpuChannelMsg_Echo message.
582 IPC_MESSAGE_ROUTED0(GpuCommandBufferMsg_EchoAck)
583
584 // Send to stub on surface visibility change.
585 IPC_MESSAGE_ROUTED1(GpuCommandBufferMsg_SetSurfaceVisible, bool /* visible */)
586
587 // Sent to proxy when the gpu memory manager changes its memory allocation.
588 IPC_MESSAGE_ROUTED1(GpuCommandBufferMsg_SetMemoryAllocation,
589                     gpu::MemoryAllocation /* allocation */)
590
591 // Sent to stub when proxy is assigned a memory allocation changed callback.
592 IPC_MESSAGE_ROUTED1(
593     GpuCommandBufferMsg_SetClientHasMemoryAllocationChangedCallback,
594     bool /* has_callback */)
595
596 // Inserts a sync point into the channel. This is handled on the IO thread, so
597 // can be expected to be reasonably fast, but the sync point is actually
598 // retired in order with respect to the other calls. The sync point is shared
599 // across channels.
600 IPC_SYNC_MESSAGE_ROUTED1_1(GpuCommandBufferMsg_InsertSyncPoint,
601                            bool /* retire */,
602                            uint32 /* sync_point */)
603
604 // Retires the sync point. Note: this message is not sent explicitly by the
605 // renderer, but is synthesized by the GPU process.
606 IPC_MESSAGE_ROUTED1(GpuCommandBufferMsg_RetireSyncPoint,
607                     uint32 /* sync_point */)
608
609 // Makes this command buffer signal when a sync point is reached, by sending
610 // back a GpuCommandBufferMsg_SignalSyncPointAck message with the same
611 // signal_id.
612 IPC_MESSAGE_ROUTED2(GpuCommandBufferMsg_SignalSyncPoint,
613                     uint32 /* sync_point */,
614                     uint32 /* signal_id */)
615
616 // Response to GpuCommandBufferMsg_SignalSyncPoint.
617 IPC_MESSAGE_ROUTED1(GpuCommandBufferMsg_SignalSyncPointAck,
618                     uint32 /* signal_id */)
619
620 // Makes this command buffer signal when a query is reached, by sending
621 // back a GpuCommandBufferMsg_SignalSyncPointAck message with the same
622 // signal_id.
623 IPC_MESSAGE_ROUTED2(GpuCommandBufferMsg_SignalQuery,
624                     uint32 /* query */,
625                     uint32 /* signal_id */)
626
627 // Register an existing gpu memory buffer. The id that can be
628 // used to identify the gpu memory buffer from a command buffer.
629 IPC_MESSAGE_ROUTED5(GpuCommandBufferMsg_RegisterGpuMemoryBuffer,
630                     int32 /* id */,
631                     gfx::GpuMemoryBufferHandle /* gpu_memory_buffer */,
632                     uint32 /* width */,
633                     uint32 /* height */,
634                     uint32 /* internalformat */)
635
636 // Unregister a previously registered gpu memory buffer.
637 IPC_MESSAGE_ROUTED1(GpuCommandBufferMsg_UnregisterGpuMemoryBuffer,
638                     int32 /* id */)
639
640 // Attaches an external image stream to the client texture.
641 IPC_SYNC_MESSAGE_ROUTED2_1(GpuCommandBufferMsg_CreateStreamTexture,
642                            uint32, /* client_texture_id */
643                            int32, /* stream_id */
644                            bool /* succeeded */)
645
646 //------------------------------------------------------------------------------
647 // Accelerated Video Decoder Messages
648 // These messages are sent from Renderer process to GPU process.
649
650 // Send input buffer for decoding.
651 IPC_MESSAGE_ROUTED3(AcceleratedVideoDecoderMsg_Decode,
652                     base::SharedMemoryHandle, /* input_buffer_handle */
653                     int32, /* bitstream_buffer_id */
654                     uint32) /* size */
655
656 // Sent from Renderer process to the GPU process to give the texture IDs for
657 // the textures the decoder will use for output.
658 IPC_MESSAGE_ROUTED2(AcceleratedVideoDecoderMsg_AssignPictureBuffers,
659                     std::vector<int32>,  /* Picture buffer ID */
660                     std::vector<uint32>) /* Texture ID */
661
662 // Send from Renderer process to the GPU process to recycle the given picture
663 // buffer for further decoding.
664 IPC_MESSAGE_ROUTED1(AcceleratedVideoDecoderMsg_ReusePictureBuffer,
665                     int32) /* Picture buffer ID */
666
667 // Send flush request to the decoder.
668 IPC_MESSAGE_ROUTED0(AcceleratedVideoDecoderMsg_Flush)
669
670 // Send reset request to the decoder.
671 IPC_MESSAGE_ROUTED0(AcceleratedVideoDecoderMsg_Reset)
672
673 // Send destroy request to the decoder.
674 IPC_MESSAGE_ROUTED0(AcceleratedVideoDecoderMsg_Destroy)
675
676 //------------------------------------------------------------------------------
677 // Accelerated Video Decoder Host Messages
678 // These messages are sent from GPU process to Renderer process.
679 // Inform AcceleratedVideoDecoderHost that AcceleratedVideoDecoder has been
680 // created.
681
682 // Accelerated video decoder has consumed input buffer from transfer buffer.
683 IPC_MESSAGE_ROUTED1(AcceleratedVideoDecoderHostMsg_BitstreamBufferProcessed,
684                     int32) /* Processed buffer ID */
685
686 // Allocate video frames for output of the hardware video decoder.
687 IPC_MESSAGE_ROUTED3(
688     AcceleratedVideoDecoderHostMsg_ProvidePictureBuffers,
689     int32, /* Number of video frames to generate */
690     gfx::Size, /* Requested size of buffer */
691     uint32 ) /* Texture target */
692
693 // Decoder reports that a picture is ready and buffer does not need to be passed
694 // back to the decoder.
695 IPC_MESSAGE_ROUTED1(AcceleratedVideoDecoderHostMsg_DismissPictureBuffer,
696                     int32) /* Picture buffer ID */
697
698 // Decoder reports that a picture is ready.
699 IPC_MESSAGE_ROUTED2(AcceleratedVideoDecoderHostMsg_PictureReady,
700                     int32,  /* Picture buffer ID */
701                     int32)  /* Bitstream buffer ID */
702
703 // Confirm decoder has been flushed.
704 IPC_MESSAGE_ROUTED0(AcceleratedVideoDecoderHostMsg_FlushDone)
705
706 // Confirm decoder has been reset.
707 IPC_MESSAGE_ROUTED0(AcceleratedVideoDecoderHostMsg_ResetDone)
708
709 // Video decoder has encountered an error.
710 IPC_MESSAGE_ROUTED1(AcceleratedVideoDecoderHostMsg_ErrorNotification,
711                     uint32) /* Error ID */
712
713 //------------------------------------------------------------------------------
714 // Accelerated Video Encoder Messages
715 // These messages are sent from the Renderer process to GPU process.
716
717 // Queue a input buffer to the encoder to encode. |frame_id| will be returned by
718 // AcceleratedVideoEncoderHostMsg_NotifyEncodeDone.
719 IPC_MESSAGE_ROUTED4(AcceleratedVideoEncoderMsg_Encode,
720                     int32 /* frame_id */,
721                     base::SharedMemoryHandle /* buffer_handle */,
722                     uint32 /* buffer_size */,
723                     bool /* force_keyframe */)
724
725 // Queue a buffer to the encoder for use in returning output.  |buffer_id| will
726 // be returned by AcceleratedVideoEncoderHostMsg_BitstreamBufferReady.
727 IPC_MESSAGE_ROUTED3(AcceleratedVideoEncoderMsg_UseOutputBitstreamBuffer,
728                     int32 /* buffer_id */,
729                     base::SharedMemoryHandle /* buffer_handle */,
730                     uint32 /* buffer_size */)
731
732 // Request a runtime encoding parameter change.
733 IPC_MESSAGE_ROUTED2(AcceleratedVideoEncoderMsg_RequestEncodingParametersChange,
734                     uint32 /* bitrate */,
735                     uint32 /* framerate */)
736
737 //------------------------------------------------------------------------------
738 // Accelerated Video Encoder Host Messages
739 // These messages are sent from GPU process to Renderer process.
740
741 // Notify renderer of the input/output buffer requirements of the encoder.
742 IPC_MESSAGE_ROUTED3(AcceleratedVideoEncoderHostMsg_RequireBitstreamBuffers,
743                     uint32 /* input_count */,
744                     gfx::Size /* input_coded_size */,
745                     uint32 /* output_buffer_size */)
746
747 // Notify the renderer that the encoder has finished using an input buffer.
748 // There is no congruent entry point in the media::VideoEncodeAccelerator
749 // interface, in VEA this same done condition is indicated by dropping the
750 // reference to the media::VideoFrame passed to VEA::Encode().
751 IPC_MESSAGE_ROUTED1(AcceleratedVideoEncoderHostMsg_NotifyInputDone,
752                     int32 /* frame_id */)
753
754 // Notify the renderer that an output buffer has been filled with encoded data.
755 IPC_MESSAGE_ROUTED3(AcceleratedVideoEncoderHostMsg_BitstreamBufferReady,
756                     int32 /* bitstream_buffer_id */,
757                     uint32 /* payload_size */,
758                     bool /* key_frame */)
759
760 // Report error condition.
761 IPC_MESSAGE_ROUTED1(AcceleratedVideoEncoderHostMsg_NotifyError,
762                     media::VideoEncodeAccelerator::Error /* error */)
763
764 // Send destroy request to the encoder.
765 IPC_MESSAGE_ROUTED0(AcceleratedVideoEncoderMsg_Destroy)