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