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