Home | History | Annotate | Download | only in gpu
      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_allocation.h"
     14 #include "content/common/gpu/gpu_memory_uma_stats.h"
     15 #include "content/common/gpu/gpu_process_launch_causes.h"
     16 #include "content/common/gpu/gpu_rendering_stats.h"
     17 #include "content/public/common/common_param_traits.h"
     18 #include "content/public/common/gpu_memory_stats.h"
     19 #include "gpu/command_buffer/common/command_buffer.h"
     20 #include "gpu/command_buffer/common/constants.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/video/video_decode_accelerator.h"
     27 #include "ui/base/latency_info.h"
     28 #include "ui/gfx/native_widget_types.h"
     29 #include "ui/gfx/size.h"
     30 #include "ui/gl/gpu_preference.h"
     31 
     32 #if defined(OS_ANDROID)
     33 #include "content/common/android/surface_texture_peer.h"
     34 #endif
     35 
     36 #define IPC_MESSAGE_START GpuMsgStart
     37 
     38 IPC_STRUCT_BEGIN(GPUCreateCommandBufferConfig)
     39   IPC_STRUCT_MEMBER(int32, share_group_id)
     40   IPC_STRUCT_MEMBER(std::string, allowed_extensions)
     41   IPC_STRUCT_MEMBER(std::vector<int>, attribs)
     42   IPC_STRUCT_MEMBER(GURL, active_url)
     43   IPC_STRUCT_MEMBER(gfx::GpuPreference, gpu_preference)
     44 IPC_STRUCT_END()
     45 
     46 #undef IPC_MESSAGE_EXPORT
     47 #define IPC_MESSAGE_EXPORT CONTENT_EXPORT
     48 IPC_STRUCT_BEGIN(GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params)
     49   IPC_STRUCT_MEMBER(int32, surface_id)
     50   IPC_STRUCT_MEMBER(uint64, surface_handle)
     51   IPC_STRUCT_MEMBER(int32, route_id)
     52   IPC_STRUCT_MEMBER(std::string, mailbox_name)
     53   IPC_STRUCT_MEMBER(gfx::Size, size)
     54   IPC_STRUCT_MEMBER(float, scale_factor)
     55   IPC_STRUCT_MEMBER(ui::LatencyInfo, latency_info)
     56 IPC_STRUCT_END()
     57 #undef IPC_MESSAGE_EXPORT
     58 #define IPC_MESSAGE_EXPORT
     59 
     60 IPC_STRUCT_BEGIN(GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params)
     61   IPC_STRUCT_MEMBER(int32, surface_id)
     62   IPC_STRUCT_MEMBER(uint64, surface_handle)
     63   IPC_STRUCT_MEMBER(int32, route_id)
     64   IPC_STRUCT_MEMBER(int, x)
     65   IPC_STRUCT_MEMBER(int, y)
     66   IPC_STRUCT_MEMBER(int, width)
     67   IPC_STRUCT_MEMBER(int, height)
     68   IPC_STRUCT_MEMBER(std::string, mailbox_name)
     69   IPC_STRUCT_MEMBER(gfx::Size, surface_size)
     70   IPC_STRUCT_MEMBER(float, surface_scale_factor)
     71   IPC_STRUCT_MEMBER(ui::LatencyInfo, latency_info)
     72 IPC_STRUCT_END()
     73 
     74 IPC_STRUCT_BEGIN(GpuHostMsg_AcceleratedSurfaceRelease_Params)
     75   IPC_STRUCT_MEMBER(int32, surface_id)
     76   IPC_STRUCT_MEMBER(int32, route_id)
     77 IPC_STRUCT_END()
     78 
     79 IPC_STRUCT_BEGIN(AcceleratedSurfaceMsg_BufferPresented_Params)
     80   IPC_STRUCT_MEMBER(std::string, mailbox_name)
     81   IPC_STRUCT_MEMBER(uint32, sync_point)
     82 #if defined(OS_MACOSX)
     83   IPC_STRUCT_MEMBER(int32, renderer_id)
     84 #endif
     85 IPC_STRUCT_END()
     86 
     87 IPC_STRUCT_BEGIN(GPUCommandBufferConsoleMessage)
     88   IPC_STRUCT_MEMBER(int32, id)
     89   IPC_STRUCT_MEMBER(std::string, message)
     90 IPC_STRUCT_END()
     91 
     92 #if defined(OS_ANDROID)
     93 IPC_STRUCT_BEGIN(GpuStreamTextureMsg_MatrixChanged_Params)
     94   IPC_STRUCT_MEMBER(float, m00)
     95   IPC_STRUCT_MEMBER(float, m01)
     96   IPC_STRUCT_MEMBER(float, m02)
     97   IPC_STRUCT_MEMBER(float, m03)
     98   IPC_STRUCT_MEMBER(float, m10)
     99   IPC_STRUCT_MEMBER(float, m11)
    100   IPC_STRUCT_MEMBER(float, m12)
    101   IPC_STRUCT_MEMBER(float, m13)
    102   IPC_STRUCT_MEMBER(float, m20)
    103   IPC_STRUCT_MEMBER(float, m21)
    104   IPC_STRUCT_MEMBER(float, m22)
    105   IPC_STRUCT_MEMBER(float, m23)
    106   IPC_STRUCT_MEMBER(float, m30)
    107   IPC_STRUCT_MEMBER(float, m31)
    108   IPC_STRUCT_MEMBER(float, m32)
    109   IPC_STRUCT_MEMBER(float, m33)
    110 IPC_STRUCT_END()
    111 #endif
    112 
    113   IPC_STRUCT_TRAITS_BEGIN(gpu::DxDiagNode)
    114   IPC_STRUCT_TRAITS_MEMBER(values)
    115   IPC_STRUCT_TRAITS_MEMBER(children)
    116 IPC_STRUCT_TRAITS_END()
    117 
    118 IPC_STRUCT_TRAITS_BEGIN(gpu::GpuPerformanceStats)
    119   IPC_STRUCT_TRAITS_MEMBER(graphics)
    120   IPC_STRUCT_TRAITS_MEMBER(gaming)
    121   IPC_STRUCT_TRAITS_MEMBER(overall)
    122 IPC_STRUCT_TRAITS_END()
    123 
    124 IPC_STRUCT_TRAITS_BEGIN(gpu::GPUInfo::GPUDevice)
    125   IPC_STRUCT_TRAITS_MEMBER(vendor_id)
    126   IPC_STRUCT_TRAITS_MEMBER(device_id)
    127   IPC_STRUCT_TRAITS_MEMBER(vendor_string)
    128   IPC_STRUCT_TRAITS_MEMBER(device_string)
    129 IPC_STRUCT_TRAITS_END()
    130 
    131 IPC_STRUCT_TRAITS_BEGIN(gpu::GPUInfo)
    132   IPC_STRUCT_TRAITS_MEMBER(finalized)
    133   IPC_STRUCT_TRAITS_MEMBER(initialization_time)
    134   IPC_STRUCT_TRAITS_MEMBER(optimus)
    135   IPC_STRUCT_TRAITS_MEMBER(amd_switchable)
    136   IPC_STRUCT_TRAITS_MEMBER(lenovo_dcute)
    137   IPC_STRUCT_TRAITS_MEMBER(gpu)
    138   IPC_STRUCT_TRAITS_MEMBER(secondary_gpus)
    139   IPC_STRUCT_TRAITS_MEMBER(adapter_luid)
    140   IPC_STRUCT_TRAITS_MEMBER(driver_vendor)
    141   IPC_STRUCT_TRAITS_MEMBER(driver_version)
    142   IPC_STRUCT_TRAITS_MEMBER(driver_date)
    143   IPC_STRUCT_TRAITS_MEMBER(pixel_shader_version)
    144   IPC_STRUCT_TRAITS_MEMBER(vertex_shader_version)
    145   IPC_STRUCT_TRAITS_MEMBER(machine_model)
    146   IPC_STRUCT_TRAITS_MEMBER(gl_version)
    147   IPC_STRUCT_TRAITS_MEMBER(gl_version_string)
    148   IPC_STRUCT_TRAITS_MEMBER(gl_vendor)
    149   IPC_STRUCT_TRAITS_MEMBER(gl_renderer)
    150   IPC_STRUCT_TRAITS_MEMBER(gl_extensions)
    151   IPC_STRUCT_TRAITS_MEMBER(gl_ws_vendor)
    152   IPC_STRUCT_TRAITS_MEMBER(gl_ws_version)
    153   IPC_STRUCT_TRAITS_MEMBER(gl_ws_extensions)
    154   IPC_STRUCT_TRAITS_MEMBER(gl_reset_notification_strategy)
    155   IPC_STRUCT_TRAITS_MEMBER(can_lose_context)
    156   IPC_STRUCT_TRAITS_MEMBER(performance_stats)
    157   IPC_STRUCT_TRAITS_MEMBER(software_rendering)
    158   IPC_STRUCT_TRAITS_MEMBER(sandboxed)
    159 #if defined(OS_WIN)
    160   IPC_STRUCT_TRAITS_MEMBER(dx_diagnostics)
    161 #endif
    162 IPC_STRUCT_TRAITS_END()
    163 
    164 IPC_STRUCT_TRAITS_BEGIN(content::GPUVideoMemoryUsageStats::ProcessStats)
    165   IPC_STRUCT_TRAITS_MEMBER(video_memory)
    166   IPC_STRUCT_TRAITS_MEMBER(has_duplicates)
    167 IPC_STRUCT_TRAITS_END()
    168 
    169 IPC_STRUCT_TRAITS_BEGIN(content::GPUVideoMemoryUsageStats)
    170   IPC_STRUCT_TRAITS_MEMBER(process_map)
    171   IPC_STRUCT_TRAITS_MEMBER(bytes_allocated)
    172   IPC_STRUCT_TRAITS_MEMBER(bytes_allocated_historical_max)
    173 IPC_STRUCT_TRAITS_END()
    174 
    175 IPC_STRUCT_TRAITS_BEGIN(content::GPUMemoryUmaStats)
    176   IPC_STRUCT_TRAITS_MEMBER(bytes_allocated_current)
    177   IPC_STRUCT_TRAITS_MEMBER(bytes_allocated_max)
    178   IPC_STRUCT_TRAITS_MEMBER(bytes_limit)
    179 IPC_STRUCT_TRAITS_END()
    180 
    181 IPC_STRUCT_TRAITS_BEGIN(content::GpuMemoryAllocationForRenderer)
    182   IPC_STRUCT_TRAITS_MEMBER(bytes_limit_when_visible)
    183   IPC_STRUCT_TRAITS_MEMBER(priority_cutoff_when_visible)
    184   IPC_STRUCT_TRAITS_MEMBER(bytes_limit_when_not_visible)
    185   IPC_STRUCT_TRAITS_MEMBER(priority_cutoff_when_not_visible)
    186   IPC_STRUCT_TRAITS_MEMBER(have_backbuffer_when_not_visible)
    187 IPC_STRUCT_TRAITS_END()
    188 IPC_ENUM_TRAITS(content::GpuMemoryAllocationForRenderer::PriorityCutoff)
    189 
    190 IPC_STRUCT_TRAITS_BEGIN(content::GpuManagedMemoryStats)
    191   IPC_STRUCT_TRAITS_MEMBER(bytes_required)
    192   IPC_STRUCT_TRAITS_MEMBER(bytes_nice_to_have)
    193   IPC_STRUCT_TRAITS_MEMBER(bytes_allocated)
    194   IPC_STRUCT_TRAITS_MEMBER(backbuffer_requested)
    195 IPC_STRUCT_TRAITS_END()
    196 
    197 IPC_ENUM_TRAITS(gfx::SurfaceType)
    198 IPC_STRUCT_TRAITS_BEGIN(gfx::GLSurfaceHandle)
    199   IPC_STRUCT_TRAITS_MEMBER(handle)
    200   IPC_STRUCT_TRAITS_MEMBER(transport_type)
    201   IPC_STRUCT_TRAITS_MEMBER(parent_gpu_process_id)
    202   IPC_STRUCT_TRAITS_MEMBER(parent_client_id)
    203 IPC_STRUCT_TRAITS_END()
    204 
    205 IPC_ENUM_TRAITS(content::CauseForGpuLaunch)
    206 IPC_ENUM_TRAITS(gfx::GpuPreference)
    207 IPC_ENUM_TRAITS(gpu::error::ContextLostReason)
    208 
    209 IPC_ENUM_TRAITS(media::VideoCodecProfile)
    210 
    211 IPC_STRUCT_TRAITS_BEGIN(content::GpuRenderingStats)
    212   IPC_STRUCT_TRAITS_MEMBER(global_texture_upload_count)
    213   IPC_STRUCT_TRAITS_MEMBER(global_total_texture_upload_time)
    214   IPC_STRUCT_TRAITS_MEMBER(texture_upload_count)
    215   IPC_STRUCT_TRAITS_MEMBER(total_texture_upload_time)
    216   IPC_STRUCT_TRAITS_MEMBER(global_total_processing_commands_time)
    217   IPC_STRUCT_TRAITS_MEMBER(total_processing_commands_time)
    218 IPC_STRUCT_TRAITS_END()
    219 
    220 //------------------------------------------------------------------------------
    221 // GPU Messages
    222 // These are messages from the browser to the GPU process.
    223 
    224 // Tells the GPU process to initialize itself. The browser explicitly
    225 // requests this be done so that we are guaranteed that the channel is set
    226 // up between the browser and GPU process before doing any work that might
    227 // potentially crash the GPU process. Detection of the child process
    228 // exiting abruptly is predicated on having the IPC channel set up.
    229 IPC_MESSAGE_CONTROL0(GpuMsg_Initialize)
    230 
    231 // Tells the GPU process to create a new channel for communication with a
    232 // given client.  The channel name is returned in a
    233 // GpuHostMsg_ChannelEstablished message.  The client ID is passed so that
    234 // the GPU process reuses an existing channel to that process if it exists.
    235 // This ID is a unique opaque identifier generated by the browser process.
    236 IPC_MESSAGE_CONTROL2(GpuMsg_EstablishChannel,
    237                      int /* client_id */,
    238                      bool /* share_context */)
    239 
    240 // Tells the GPU process to close the channel identified by IPC channel
    241 // handle.  If no channel can be identified, do nothing.
    242 IPC_MESSAGE_CONTROL1(GpuMsg_CloseChannel,
    243                      IPC::ChannelHandle /* channel_handle */)
    244 
    245 // Tells the GPU process to create a new command buffer that renders directly
    246 // to a native view. A corresponding GpuCommandBufferStub is created.
    247 IPC_MESSAGE_CONTROL4(GpuMsg_CreateViewCommandBuffer,
    248                      gfx::GLSurfaceHandle, /* compositing_surface */
    249                      int32, /* surface_id */
    250                      int32, /* client_id */
    251                      GPUCreateCommandBufferConfig /* init_params */)
    252 
    253 // Tells the GPU process to create a new image from a window. Images
    254 // can be bound to textures using CHROMIUM_texture_from_image.
    255 IPC_MESSAGE_CONTROL3(GpuMsg_CreateImage,
    256                      gfx::PluginWindowHandle, /* window */
    257                      int32, /* client_id */
    258                      int32 /* image_id */)
    259 
    260 // Tells the GPU process to delete image.
    261 IPC_MESSAGE_CONTROL3(GpuMsg_DeleteImage,
    262                      int32, /* client_id */
    263                      int32, /* image_id */
    264                      int32 /* sync_point */)
    265 
    266 // Tells the GPU process to create a context for collecting graphics card
    267 // information.
    268 IPC_MESSAGE_CONTROL0(GpuMsg_CollectGraphicsInfo)
    269 
    270 // Tells the GPU process to report video_memory information for the task manager
    271 IPC_MESSAGE_CONTROL0(GpuMsg_GetVideoMemoryUsageStats)
    272 
    273 // Tells the GPU process that the browser process has finished resizing the
    274 // view.
    275 IPC_MESSAGE_ROUTED0(AcceleratedSurfaceMsg_ResizeViewACK)
    276 
    277 // Tells the GPU process that the browser process has handled the swap
    278 // buffers or post sub-buffer request. A non-zero sync point means
    279 // that we should wait for the sync point. The surface_handle identifies
    280 // that buffer that has finished presented, i.e. the buffer being returned.
    281 IPC_MESSAGE_ROUTED1(AcceleratedSurfaceMsg_BufferPresented,
    282                     AcceleratedSurfaceMsg_BufferPresented_Params)
    283 
    284 // Tells the GPU process to remove all contexts.
    285 IPC_MESSAGE_CONTROL0(GpuMsg_Clean)
    286 
    287 // Tells the GPU process to crash.
    288 IPC_MESSAGE_CONTROL0(GpuMsg_Crash)
    289 
    290 // Tells the GPU process to hang.
    291 IPC_MESSAGE_CONTROL0(GpuMsg_Hang)
    292 
    293 // Tells the GPU process to disable the watchdog thread.
    294 IPC_MESSAGE_CONTROL0(GpuMsg_DisableWatchdog)
    295 
    296 //------------------------------------------------------------------------------
    297 // GPU Host Messages
    298 // These are messages to the browser.
    299 
    300 // A renderer sends this when it wants to create a connection to the GPU
    301 // process. The browser will create the GPU process if necessary, and will
    302 // return a handle to the channel via a GpuChannelEstablished message.
    303 IPC_SYNC_MESSAGE_CONTROL1_3(GpuHostMsg_EstablishGpuChannel,
    304                             content::CauseForGpuLaunch,
    305                             int /* client id */,
    306                             IPC::ChannelHandle /* handle to channel */,
    307                             gpu::GPUInfo /* stats about GPU process*/)
    308 
    309 // A renderer sends this to the browser process when it wants to
    310 // create a GL context associated with the given view_id.
    311 IPC_SYNC_MESSAGE_CONTROL2_1(GpuHostMsg_CreateViewCommandBuffer,
    312                             int32, /* surface_id */
    313                             GPUCreateCommandBufferConfig, /* init_params */
    314                             int32 /* route_id */)
    315 
    316 // Response from GPU to a GputMsg_Initialize message.
    317 IPC_MESSAGE_CONTROL2(GpuHostMsg_Initialized,
    318                      bool /* result */,
    319                      ::gpu::GPUInfo /* gpu_info */)
    320 
    321 // Response from GPU to a GpuHostMsg_EstablishChannel message.
    322 IPC_MESSAGE_CONTROL1(GpuHostMsg_ChannelEstablished,
    323                      IPC::ChannelHandle /* channel_handle */)
    324 
    325 // Message from GPU to notify to destroy the channel.
    326 IPC_MESSAGE_CONTROL1(GpuHostMsg_DestroyChannel,
    327                      int32 /* client_id */)
    328 
    329 // Message to cache the given shader information.
    330 IPC_MESSAGE_CONTROL3(GpuHostMsg_CacheShader,
    331                      int32 /* client_id */,
    332                      std::string /* key */,
    333                      std::string /* shader */)
    334 
    335 // Message to the GPU that a shader was loaded from disk.
    336 IPC_MESSAGE_CONTROL1(GpuMsg_LoadedShader,
    337                      std::string /* encoded shader */)
    338 
    339 // Respond from GPU to a GpuMsg_CreateViewCommandBuffer message.
    340 IPC_MESSAGE_CONTROL1(GpuHostMsg_CommandBufferCreated,
    341                      int32 /* route_id */)
    342 
    343 // Request from GPU to free the browser resources associated with the
    344 // command buffer.
    345 IPC_MESSAGE_CONTROL1(GpuHostMsg_DestroyCommandBuffer,
    346                      int32 /* surface_id */)
    347 
    348 // Response from GPU to a GpuMsg_CreateImage message.
    349 IPC_MESSAGE_CONTROL1(GpuHostMsg_ImageCreated,
    350                      gfx::Size /* size */)
    351 
    352 // Response from GPU to a GpuMsg_CollectGraphicsInfo.
    353 IPC_MESSAGE_CONTROL1(GpuHostMsg_GraphicsInfoCollected,
    354                      gpu::GPUInfo /* GPU logging stats */)
    355 
    356 // Response from GPU to a GpuMsg_GetVideoMemory.
    357 IPC_MESSAGE_CONTROL1(GpuHostMsg_VideoMemoryUsageStats,
    358                      content::GPUVideoMemoryUsageStats /* GPU memory stats */)
    359 
    360 // Message from GPU to add a GPU log message to the about:gpu page.
    361 IPC_MESSAGE_CONTROL3(GpuHostMsg_OnLogMessage,
    362                      int /*severity*/,
    363                      std::string /* header */,
    364                      std::string /* message */)
    365 
    366 // Resize the window that is being drawn into. It's important that this
    367 // resize be synchronized with the swapping of the front and back buffers.
    368 IPC_MESSAGE_CONTROL3(GpuHostMsg_ResizeView,
    369                      int32 /* surface_id */,
    370                      int32 /* route_id */,
    371                      gfx::Size /* size */)
    372 
    373 // Tells the browser that a frame with the specific latency info was drawn to
    374 // the screen
    375 IPC_MESSAGE_CONTROL1(GpuHostMsg_FrameDrawn,
    376                      ui::LatencyInfo /* latency_info */)
    377 
    378 // Same as above with a rect of the part of the surface that changed.
    379 IPC_MESSAGE_CONTROL1(GpuHostMsg_AcceleratedSurfaceBuffersSwapped,
    380                      GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params)
    381 
    382 // This message notifies the browser process that the renderer
    383 // swapped a portion of the buffers associated with the given "window", which
    384 // should cause the browser to redraw the compositor's contents.
    385 IPC_MESSAGE_CONTROL1(GpuHostMsg_AcceleratedSurfacePostSubBuffer,
    386                      GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params)
    387 
    388 // Tells the browser to release whatever resources are associated with
    389 // the given surface. The browser must send an ACK once this operation
    390 // is complete.
    391 IPC_MESSAGE_CONTROL1(GpuHostMsg_AcceleratedSurfaceRelease,
    392                      GpuHostMsg_AcceleratedSurfaceRelease_Params)
    393 
    394 // Tells the browser to release resources for the given surface until the next
    395 // time swap buffers or post sub buffer is sent.
    396 IPC_MESSAGE_CONTROL1(GpuHostMsg_AcceleratedSurfaceSuspend,
    397                      int32 /* surface_id */)
    398 
    399 // Tells the browser about updated parameters for vsync alignment.
    400 IPC_MESSAGE_CONTROL3(GpuHostMsg_UpdateVSyncParameters,
    401                      int32 /* surface_id */,
    402                      base::TimeTicks /* timebase */,
    403                      base::TimeDelta /* interval */)
    404 
    405 IPC_MESSAGE_CONTROL1(GpuHostMsg_DidCreateOffscreenContext,
    406                      GURL /* url */)
    407 
    408 IPC_MESSAGE_CONTROL3(GpuHostMsg_DidLoseContext,
    409                      bool /* offscreen */,
    410                      gpu::error::ContextLostReason /* reason */,
    411                      GURL /* url */)
    412 
    413 IPC_MESSAGE_CONTROL1(GpuHostMsg_DidDestroyOffscreenContext,
    414                      GURL /* url */)
    415 
    416 // Tells the browser about GPU memory usage statistics for UMA logging.
    417 IPC_MESSAGE_CONTROL1(GpuHostMsg_GpuMemoryUmaStats,
    418                      content::GPUMemoryUmaStats /* GPU memory UMA stats */)
    419 
    420 //------------------------------------------------------------------------------
    421 // GPU Channel Messages
    422 // These are messages from a renderer process to the GPU process.
    423 
    424 // Tells the GPU process to create a new command buffer that renders to an
    425 // offscreen frame buffer.
    426 IPC_SYNC_MESSAGE_CONTROL2_1(GpuChannelMsg_CreateOffscreenCommandBuffer,
    427                             gfx::Size, /* size */
    428                             GPUCreateCommandBufferConfig, /* init_params */
    429                             int32 /* route_id */)
    430 
    431 // The CommandBufferProxy sends this to the GpuCommandBufferStub in its
    432 // destructor, so that the stub deletes the actual CommandBufferService
    433 // object that it's hosting.
    434 IPC_SYNC_MESSAGE_CONTROL1_0(GpuChannelMsg_DestroyCommandBuffer,
    435                             int32 /* instance_id */)
    436 
    437 // Generates n new unique mailbox names synchronously.
    438 IPC_SYNC_MESSAGE_CONTROL1_1(GpuChannelMsg_GenerateMailboxNames,
    439                             unsigned, /* num */
    440                             std::vector<gpu::Mailbox> /* mailbox_names */)
    441 
    442 // Generates n new unique mailbox names asynchronously.
    443 IPC_MESSAGE_CONTROL1(GpuChannelMsg_GenerateMailboxNamesAsync,
    444                      unsigned /* num */)
    445 
    446 // Reply to GpuChannelMsg_GenerateMailboxNamesAsync.
    447 IPC_MESSAGE_CONTROL1(GpuChannelMsg_GenerateMailboxNamesReply,
    448                      std::vector<gpu::Mailbox> /* mailbox_names */)
    449 
    450 #if defined(OS_ANDROID)
    451 // Register the StreamTextureProxy class with the GPU process, so that
    452 // the renderer process will get notified whenever a frame becomes available.
    453 IPC_SYNC_MESSAGE_CONTROL1_1(GpuChannelMsg_RegisterStreamTextureProxy,
    454                             int32, /* stream_id */
    455                             int /* route_id */)
    456 
    457 // Tells the GPU process create and send the java surface texture object to
    458 // the renderer process through the binder thread.
    459 IPC_MESSAGE_CONTROL3(GpuChannelMsg_EstablishStreamTexture,
    460                      int32, /* stream_id */
    461                      int32, /* primary_id */
    462                      int32 /* secondary_id */)
    463 
    464 // Tells the GPU process to set the size of StreamTexture from the given
    465 // stream Id.
    466 IPC_MESSAGE_CONTROL2(GpuChannelMsg_SetStreamTextureSize,
    467                      int32, /* stream_id */
    468                      gfx::Size /* size */)
    469 #endif
    470 
    471 // Tells the GPU process to collect rendering stats.
    472 IPC_SYNC_MESSAGE_CONTROL1_1(GpuChannelMsg_CollectRenderingStatsForSurface,
    473                             int32 /* surface_id */,
    474                             content::GpuRenderingStats /* stats */)
    475 
    476 #if defined(OS_ANDROID)
    477 //------------------------------------------------------------------------------
    478 // Stream Texture Messages
    479 // Inform the renderer that a new frame is available.
    480 IPC_MESSAGE_ROUTED0(GpuStreamTextureMsg_FrameAvailable)
    481 
    482 // Inform the renderer process that the transform matrix has changed.
    483 IPC_MESSAGE_ROUTED1(GpuStreamTextureMsg_MatrixChanged,
    484                     GpuStreamTextureMsg_MatrixChanged_Params /* params */)
    485 #endif
    486 
    487 //------------------------------------------------------------------------------
    488 // GPU Command Buffer Messages
    489 // These are messages between a renderer process to the GPU process relating to
    490 // a single OpenGL context.
    491 // Initialize a command buffer with the given number of command entries.
    492 // Returns the shared memory handle for the command buffer mapped to the
    493 // calling process.
    494 IPC_SYNC_MESSAGE_ROUTED1_1(GpuCommandBufferMsg_Initialize,
    495                            base::SharedMemoryHandle /* shared_state */,
    496                            bool /* result */)
    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 // Get the current state of the command buffer.
    508 IPC_SYNC_MESSAGE_ROUTED0_1(GpuCommandBufferMsg_GetState,
    509                            gpu::CommandBuffer::State /* state */)
    510 
    511 // Get the current state of the command buffer, as fast as possible.
    512 IPC_SYNC_MESSAGE_ROUTED0_1(GpuCommandBufferMsg_GetStateFast,
    513                            gpu::CommandBuffer::State /* state */)
    514 
    515 // Asynchronously synchronize the put and get offsets of both processes.
    516 // Caller passes its current put offset. Current state (including get offset)
    517 // is returned in shared memory.
    518 IPC_MESSAGE_ROUTED2(GpuCommandBufferMsg_AsyncFlush,
    519                     int32 /* put_offset */,
    520                     uint32 /* flush_count */)
    521 
    522 // Sends information about the latency of the current frame to the GPU
    523 // process.
    524 IPC_MESSAGE_ROUTED1(GpuCommandBufferMsg_SetLatencyInfo,
    525                     ui::LatencyInfo /* latency_info */)
    526 
    527 // Asynchronously process any commands known to the GPU process. This is only
    528 // used in the event that a channel is unscheduled and needs to be flushed
    529 // again to process any commands issued subsequent to unscheduling. The GPU
    530 // process actually sends it (deferred) to itself.
    531 IPC_MESSAGE_ROUTED0(GpuCommandBufferMsg_Rescheduled)
    532 
    533 // Sent by the GPU process to display messages in the console.
    534 IPC_MESSAGE_ROUTED1(GpuCommandBufferMsg_ConsoleMsg,
    535                     GPUCommandBufferConsoleMessage /* msg */)
    536 
    537 // Register an existing shared memory transfer buffer. Returns an id that can be
    538 // used to identify the transfer buffer from a command buffer.
    539 IPC_MESSAGE_ROUTED3(GpuCommandBufferMsg_RegisterTransferBuffer,
    540                     int32 /* id */,
    541                     base::SharedMemoryHandle /* transfer_buffer */,
    542                     uint32 /* size */)
    543 
    544 // Destroy a previously created transfer buffer.
    545 IPC_MESSAGE_ROUTED1(GpuCommandBufferMsg_DestroyTransferBuffer,
    546                     int32 /* id */)
    547 
    548 // Get the shared memory handle for a transfer buffer mapped to the callers
    549 // process.
    550 IPC_SYNC_MESSAGE_ROUTED1_2(GpuCommandBufferMsg_GetTransferBuffer,
    551                            int32 /* id */,
    552                            base::SharedMemoryHandle /* transfer_buffer */,
    553                            uint32 /* size */)
    554 
    555 // Create and initialize a hardware video decoder, returning its new route_id.
    556 // Created decoders should be freed with AcceleratedVideoDecoderMsg_Destroy when
    557 // no longer needed.
    558 IPC_SYNC_MESSAGE_ROUTED1_1(GpuCommandBufferMsg_CreateVideoDecoder,
    559                            media::VideoCodecProfile /* profile */,
    560                            int /* route_id */)
    561 
    562 // Tells the proxy that there was an error and the command buffer had to be
    563 // destroyed for some reason.
    564 IPC_MESSAGE_ROUTED1(GpuCommandBufferMsg_Destroyed,
    565                     gpu::error::ContextLostReason /* reason */)
    566 
    567 // Request that the GPU process reply with the given message. Reply may be
    568 // delayed.
    569 IPC_MESSAGE_ROUTED1(GpuCommandBufferMsg_Echo,
    570                     IPC::Message /* reply */)
    571 
    572 // Response to a GpuChannelMsg_Echo message.
    573 IPC_MESSAGE_ROUTED0(GpuCommandBufferMsg_EchoAck)
    574 
    575 // Send to stub on surface visibility change.
    576 IPC_MESSAGE_ROUTED1(GpuCommandBufferMsg_SetSurfaceVisible, bool /* visible */)
    577 
    578 IPC_MESSAGE_ROUTED0(GpuCommandBufferMsg_DiscardBackbuffer)
    579 IPC_MESSAGE_ROUTED0(GpuCommandBufferMsg_EnsureBackbuffer)
    580 
    581 // Sent to proxy when the gpu memory manager changes its memory allocation.
    582 IPC_MESSAGE_ROUTED1(GpuCommandBufferMsg_SetMemoryAllocation,
    583                     content::GpuMemoryAllocationForRenderer /* allocation */)
    584 
    585 // Sent to stub from the proxy with statistics on managed memory usage and
    586 // requirements.
    587 IPC_MESSAGE_ROUTED1(
    588     GpuCommandBufferMsg_SendClientManagedMemoryStats,
    589     content::GpuManagedMemoryStats /* stats */)
    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_ROUTED0_1(GpuCommandBufferMsg_InsertSyncPoint,
    601                            uint32 /* sync_point */)
    602 
    603 // Retires the sync point. Note: this message is not sent explicitly by the
    604 // renderer, but is synthesized by the GPU process.
    605 IPC_MESSAGE_ROUTED1(GpuCommandBufferMsg_RetireSyncPoint,
    606                     uint32 /* sync_point */)
    607 
    608 // Makes this command buffer signal when a sync point is reached, by sending
    609 // back a GpuCommandBufferMsg_SignalSyncPointAck message with the same
    610 // signal_id.
    611 IPC_MESSAGE_ROUTED2(GpuCommandBufferMsg_SignalSyncPoint,
    612                     uint32 /* sync_point */,
    613                     uint32 /* signal_id */)
    614 
    615 // Response to GpuCommandBufferMsg_SignalSyncPoint.
    616 IPC_MESSAGE_ROUTED1(GpuCommandBufferMsg_SignalSyncPointAck,
    617                     uint32 /* signal_id */)
    618 
    619 // Makes this command buffer signal when a query is reached, by sending
    620 // back a GpuCommandBufferMsg_SignalSyncPointAck message with the same
    621 // signal_id.
    622 IPC_MESSAGE_ROUTED2(GpuCommandBufferMsg_SignalQuery,
    623                     uint32 /* query */,
    624                     uint32 /* signal_id */)
    625 
    626 //------------------------------------------------------------------------------
    627 // Accelerated Video Decoder Messages
    628 // These messages are sent from Renderer process to GPU process.
    629 
    630 // Send input buffer for decoding.
    631 IPC_MESSAGE_ROUTED3(AcceleratedVideoDecoderMsg_Decode,
    632                     base::SharedMemoryHandle, /* input_buffer_handle */
    633                     int32, /* bitstream_buffer_id */
    634                     uint32) /* size */
    635 
    636 // Sent from Renderer process to the GPU process to give the texture IDs for
    637 // the textures the decoder will use for output.
    638 IPC_MESSAGE_ROUTED3(AcceleratedVideoDecoderMsg_AssignPictureBuffers,
    639                     std::vector<int32>, /* Picture buffer ID */
    640                     std::vector<uint32>, /* Texture ID */
    641                     std::vector<gfx::Size>) /* Size */
    642 
    643 // Send from Renderer process to the GPU process to recycle the given picture
    644 // buffer for further decoding.
    645 IPC_MESSAGE_ROUTED1(AcceleratedVideoDecoderMsg_ReusePictureBuffer,
    646                     int32) /* Picture buffer ID */
    647 
    648 // Send flush request to the decoder.
    649 IPC_MESSAGE_ROUTED0(AcceleratedVideoDecoderMsg_Flush)
    650 
    651 // Send reset request to the decoder.
    652 IPC_MESSAGE_ROUTED0(AcceleratedVideoDecoderMsg_Reset)
    653 
    654 // Send destroy request to the decoder.
    655 IPC_MESSAGE_ROUTED0(AcceleratedVideoDecoderMsg_Destroy)
    656 
    657 //------------------------------------------------------------------------------
    658 // Accelerated Video Decoder Host Messages
    659 // These messages are sent from GPU process to Renderer process.
    660 // Inform AcceleratedVideoDecoderHost that AcceleratedVideoDecoder has been
    661 // created.
    662 
    663 // Accelerated video decoder has consumed input buffer from transfer buffer.
    664 IPC_MESSAGE_ROUTED1(AcceleratedVideoDecoderHostMsg_BitstreamBufferProcessed,
    665                     int32) /* Processed buffer ID */
    666 
    667 // Allocate video frames for output of the hardware video decoder.
    668 IPC_MESSAGE_ROUTED3(
    669     AcceleratedVideoDecoderHostMsg_ProvidePictureBuffers,
    670     int32, /* Number of video frames to generate */
    671     gfx::Size, /* Requested size of buffer */
    672     uint32 ) /* Texture target */
    673 
    674 // Decoder reports that a picture is ready and buffer does not need to be passed
    675 // back to the decoder.
    676 IPC_MESSAGE_ROUTED1(AcceleratedVideoDecoderHostMsg_DismissPictureBuffer,
    677                     int32) /* Picture buffer ID */
    678 
    679 // Decoder reports that a picture is ready.
    680 IPC_MESSAGE_ROUTED2(AcceleratedVideoDecoderHostMsg_PictureReady,
    681                     int32,  /* Picture buffer ID */
    682                     int32)  /* Bitstream buffer ID */
    683 
    684 // Confirm decoder has been flushed.
    685 IPC_MESSAGE_ROUTED0(AcceleratedVideoDecoderHostMsg_FlushDone)
    686 
    687 // Confirm decoder has been reset.
    688 IPC_MESSAGE_ROUTED0(AcceleratedVideoDecoderHostMsg_ResetDone)
    689 
    690 // Video decoder has encountered an error.
    691 IPC_MESSAGE_ROUTED1(AcceleratedVideoDecoderHostMsg_ErrorNotification,
    692                     uint32) /* Error ID */
    693