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