| OLD | NEW |
| (Empty) |
| 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 <stdint.h> | |
| 9 | |
| 10 #include <string> | |
| 11 #include <vector> | |
| 12 | |
| 13 #include "base/memory/shared_memory.h" | |
| 14 #include "build/build_config.h" | |
| 15 #include "content/common/content_export.h" | |
| 16 #include "content/common/gpu/gpu_memory_uma_stats.h" | |
| 17 #include "content/common/gpu/gpu_param_traits.h" | |
| 18 #include "content/common/gpu/gpu_process_launch_causes.h" | |
| 19 #include "gpu/command_buffer/common/capabilities.h" | |
| 20 #include "gpu/command_buffer/common/command_buffer.h" | |
| 21 #include "gpu/command_buffer/common/constants.h" | |
| 22 #include "gpu/command_buffer/common/gpu_memory_allocation.h" | |
| 23 #include "gpu/command_buffer/common/mailbox.h" | |
| 24 #include "gpu/command_buffer/common/sync_token.h" | |
| 25 #include "gpu/command_buffer/common/value_state.h" | |
| 26 #include "gpu/config/gpu_info.h" | |
| 27 #include "gpu/ipc/common/gpu_command_buffer_traits.h" | |
| 28 #include "gpu/ipc/common/surface_handle.h" | |
| 29 #include "ipc/ipc_channel_handle.h" | |
| 30 #include "ipc/ipc_message_macros.h" | |
| 31 #include "ui/events/ipc/latency_info_param_traits.h" | |
| 32 #include "ui/events/latency_info.h" | |
| 33 #include "ui/gfx/geometry/size.h" | |
| 34 #include "ui/gfx/gpu_memory_buffer.h" | |
| 35 #include "ui/gfx/ipc/gfx_param_traits.h" | |
| 36 #include "ui/gfx/native_widget_types.h" | |
| 37 #include "ui/gfx/swap_result.h" | |
| 38 #include "url/ipc/url_param_traits.h" | |
| 39 | |
| 40 #if defined(OS_ANDROID) | |
| 41 #include "gpu/ipc/common/android/surface_texture_peer.h" | |
| 42 #elif defined(OS_MACOSX) | |
| 43 #include "ui/base/cocoa/remote_layer_api.h" | |
| 44 #include "ui/gfx/mac/io_surface.h" | |
| 45 #endif | |
| 46 | |
| 47 #undef IPC_MESSAGE_EXPORT | |
| 48 #define IPC_MESSAGE_EXPORT CONTENT_EXPORT | |
| 49 | |
| 50 #define IPC_MESSAGE_START GpuChannelMsgStart | |
| 51 | |
| 52 IPC_STRUCT_BEGIN(GPUCommandBufferConsoleMessage) | |
| 53 IPC_STRUCT_MEMBER(int32_t, id) | |
| 54 IPC_STRUCT_MEMBER(std::string, message) | |
| 55 IPC_STRUCT_END() | |
| 56 | |
| 57 IPC_STRUCT_BEGIN(GPUCreateCommandBufferConfig) | |
| 58 IPC_STRUCT_MEMBER(int32_t, share_group_id) | |
| 59 IPC_STRUCT_MEMBER(int32_t, stream_id) | |
| 60 IPC_STRUCT_MEMBER(content::GpuStreamPriority, stream_priority) | |
| 61 IPC_STRUCT_MEMBER(std::vector<int>, attribs) | |
| 62 IPC_STRUCT_MEMBER(GURL, active_url) | |
| 63 IPC_STRUCT_MEMBER(gfx::GpuPreference, gpu_preference) | |
| 64 IPC_STRUCT_END() | |
| 65 | |
| 66 IPC_STRUCT_BEGIN(GpuCommandBufferMsg_CreateImage_Params) | |
| 67 IPC_STRUCT_MEMBER(int32_t, id) | |
| 68 IPC_STRUCT_MEMBER(gfx::GpuMemoryBufferHandle, gpu_memory_buffer) | |
| 69 IPC_STRUCT_MEMBER(gfx::Size, size) | |
| 70 IPC_STRUCT_MEMBER(gfx::BufferFormat, format) | |
| 71 IPC_STRUCT_MEMBER(uint32_t, internal_format) | |
| 72 IPC_STRUCT_MEMBER(uint64_t, image_release_count) | |
| 73 IPC_STRUCT_END() | |
| 74 | |
| 75 #if defined(OS_ANDROID) | |
| 76 IPC_STRUCT_BEGIN(GpuStreamTextureMsg_MatrixChanged_Params) | |
| 77 IPC_STRUCT_MEMBER(float, m00) | |
| 78 IPC_STRUCT_MEMBER(float, m01) | |
| 79 IPC_STRUCT_MEMBER(float, m02) | |
| 80 IPC_STRUCT_MEMBER(float, m03) | |
| 81 IPC_STRUCT_MEMBER(float, m10) | |
| 82 IPC_STRUCT_MEMBER(float, m11) | |
| 83 IPC_STRUCT_MEMBER(float, m12) | |
| 84 IPC_STRUCT_MEMBER(float, m13) | |
| 85 IPC_STRUCT_MEMBER(float, m20) | |
| 86 IPC_STRUCT_MEMBER(float, m21) | |
| 87 IPC_STRUCT_MEMBER(float, m22) | |
| 88 IPC_STRUCT_MEMBER(float, m23) | |
| 89 IPC_STRUCT_MEMBER(float, m30) | |
| 90 IPC_STRUCT_MEMBER(float, m31) | |
| 91 IPC_STRUCT_MEMBER(float, m32) | |
| 92 IPC_STRUCT_MEMBER(float, m33) | |
| 93 IPC_STRUCT_END() | |
| 94 #endif | |
| 95 | |
| 96 //------------------------------------------------------------------------------ | |
| 97 // GPU Channel Messages | |
| 98 // These are messages from a renderer process to the GPU process. | |
| 99 | |
| 100 // Tells the GPU process to create a new command buffer. A corresponding | |
| 101 // GpuCommandBufferStub is created. if |surface_handle| is non-null, |size| is | |
| 102 // ignored, and it will render directly to the native surface (only the browser | |
| 103 // process is allowed to create those). Otherwise it will create an offscreen | |
| 104 // backbuffer of dimensions |size|. | |
| 105 IPC_SYNC_MESSAGE_CONTROL4_1(GpuChannelMsg_CreateCommandBuffer, | |
| 106 gpu::SurfaceHandle /* surface_handle */, | |
| 107 gfx::Size /* size */, | |
| 108 GPUCreateCommandBufferConfig /* init_params */, | |
| 109 int32_t /* route_id */, | |
| 110 bool /* succeeded */) | |
| 111 | |
| 112 // The CommandBufferProxy sends this to the GpuCommandBufferStub in its | |
| 113 // destructor, so that the stub deletes the actual CommandBufferService | |
| 114 // object that it's hosting. | |
| 115 IPC_SYNC_MESSAGE_CONTROL1_0(GpuChannelMsg_DestroyCommandBuffer, | |
| 116 int32_t /* instance_id */) | |
| 117 | |
| 118 // Simple NOP message which can be used as fence to ensure all previous sent | |
| 119 // messages have been received. | |
| 120 IPC_SYNC_MESSAGE_CONTROL0_0(GpuChannelMsg_Nop) | |
| 121 | |
| 122 #if defined(OS_ANDROID) | |
| 123 //------------------------------------------------------------------------------ | |
| 124 // Stream Texture Messages | |
| 125 // Tells the GPU process create and send the java surface texture object to | |
| 126 // the renderer process through the binder thread. | |
| 127 IPC_MESSAGE_ROUTED2(GpuStreamTextureMsg_EstablishPeer, | |
| 128 int32_t, /* primary_id */ | |
| 129 int32_t /* secondary_id */) | |
| 130 | |
| 131 // Tells the GPU process to set the size of StreamTexture from the given | |
| 132 // stream Id. | |
| 133 IPC_MESSAGE_ROUTED1(GpuStreamTextureMsg_SetSize, | |
| 134 gfx::Size /* size */) | |
| 135 | |
| 136 // Tells the service-side instance to start sending frame available | |
| 137 // notifications. | |
| 138 IPC_MESSAGE_ROUTED0(GpuStreamTextureMsg_StartListening) | |
| 139 | |
| 140 // Inform the renderer that a new frame is available. | |
| 141 IPC_MESSAGE_ROUTED0(GpuStreamTextureMsg_FrameAvailable) | |
| 142 | |
| 143 // Inform the renderer process that the transform matrix has changed. | |
| 144 IPC_MESSAGE_ROUTED1(GpuStreamTextureMsg_MatrixChanged, | |
| 145 GpuStreamTextureMsg_MatrixChanged_Params /* params */) | |
| 146 #endif | |
| 147 | |
| 148 //------------------------------------------------------------------------------ | |
| 149 // GPU Command Buffer Messages | |
| 150 // These are messages between a renderer process to the GPU process relating to | |
| 151 // a single OpenGL context. | |
| 152 // Initialize a command buffer with the given number of command entries. | |
| 153 // Returns the shared memory handle for the command buffer mapped to the | |
| 154 // calling process. | |
| 155 IPC_SYNC_MESSAGE_ROUTED1_2(GpuCommandBufferMsg_Initialize, | |
| 156 base::SharedMemoryHandle /* shared_state */, | |
| 157 bool /* result */, | |
| 158 gpu::Capabilities /* capabilities */) | |
| 159 | |
| 160 // Sets the shared memory buffer used for commands. | |
| 161 IPC_SYNC_MESSAGE_ROUTED1_0(GpuCommandBufferMsg_SetGetBuffer, | |
| 162 int32_t /* shm_id */) | |
| 163 | |
| 164 // Produces the front buffer into a mailbox. This allows another context to draw | |
| 165 // the output of this context. | |
| 166 IPC_MESSAGE_ROUTED1(GpuCommandBufferMsg_ProduceFrontBuffer, | |
| 167 gpu::Mailbox /* mailbox */) | |
| 168 | |
| 169 // Wait until the token is in a specific range, inclusive. | |
| 170 IPC_SYNC_MESSAGE_ROUTED2_1(GpuCommandBufferMsg_WaitForTokenInRange, | |
| 171 int32_t /* start */, | |
| 172 int32_t /* end */, | |
| 173 gpu::CommandBuffer::State /* state */) | |
| 174 | |
| 175 // Wait until the get offset is in a specific range, inclusive. | |
| 176 IPC_SYNC_MESSAGE_ROUTED2_1(GpuCommandBufferMsg_WaitForGetOffsetInRange, | |
| 177 int32_t /* start */, | |
| 178 int32_t /* end */, | |
| 179 gpu::CommandBuffer::State /* state */) | |
| 180 | |
| 181 // Asynchronously synchronize the put and get offsets of both processes. | |
| 182 // Caller passes its current put offset. Current state (including get offset) | |
| 183 // is returned in shared memory. The input latency info for the current | |
| 184 // frame is also sent to the GPU process. | |
| 185 IPC_MESSAGE_ROUTED3(GpuCommandBufferMsg_AsyncFlush, | |
| 186 int32_t /* put_offset */, | |
| 187 uint32_t /* flush_count */, | |
| 188 std::vector<ui::LatencyInfo> /* latency_info */) | |
| 189 | |
| 190 // Sent by the GPU process to display messages in the console. | |
| 191 IPC_MESSAGE_ROUTED1(GpuCommandBufferMsg_ConsoleMsg, | |
| 192 GPUCommandBufferConsoleMessage /* msg */) | |
| 193 | |
| 194 // Register an existing shared memory transfer buffer. The id that can be | |
| 195 // used to identify the transfer buffer from a command buffer. | |
| 196 IPC_MESSAGE_ROUTED3(GpuCommandBufferMsg_RegisterTransferBuffer, | |
| 197 int32_t /* id */, | |
| 198 base::SharedMemoryHandle /* transfer_buffer */, | |
| 199 uint32_t /* size */) | |
| 200 | |
| 201 // Destroy a previously created transfer buffer. | |
| 202 IPC_MESSAGE_ROUTED1(GpuCommandBufferMsg_DestroyTransferBuffer, int32_t /* id */) | |
| 203 | |
| 204 // Tells the proxy that there was an error and the command buffer had to be | |
| 205 // destroyed for some reason. | |
| 206 IPC_MESSAGE_ROUTED2(GpuCommandBufferMsg_Destroyed, | |
| 207 gpu::error::ContextLostReason, /* reason */ | |
| 208 gpu::error::Error /* error */) | |
| 209 | |
| 210 // Tells the browser that SwapBuffers returned and passes latency info | |
| 211 IPC_MESSAGE_ROUTED2(GpuCommandBufferMsg_SwapBuffersCompleted, | |
| 212 std::vector<ui::LatencyInfo> /* latency_info */, | |
| 213 gfx::SwapResult /* result */) | |
| 214 | |
| 215 // Tells the browser about updated parameters for vsync alignment. | |
| 216 IPC_MESSAGE_ROUTED2(GpuCommandBufferMsg_UpdateVSyncParameters, | |
| 217 base::TimeTicks /* timebase */, | |
| 218 base::TimeDelta /* interval */) | |
| 219 | |
| 220 IPC_MESSAGE_ROUTED2(GpuCommandBufferMsg_SignalSyncToken, | |
| 221 gpu::SyncToken /* sync_token */, | |
| 222 uint32_t /* signal_id */) | |
| 223 | |
| 224 // Makes this command buffer signal when a query is reached, by sending | |
| 225 // back a GpuCommandBufferMsg_SignalSyncPointAck message with the same | |
| 226 // signal_id. | |
| 227 IPC_MESSAGE_ROUTED2(GpuCommandBufferMsg_SignalQuery, | |
| 228 uint32_t /* query */, | |
| 229 uint32_t /* signal_id */) | |
| 230 | |
| 231 // Response to SignalSyncPoint, SignalSyncToken, and SignalQuery. | |
| 232 IPC_MESSAGE_ROUTED1(GpuCommandBufferMsg_SignalAck, uint32_t /* signal_id */) | |
| 233 | |
| 234 // Create an image from an existing gpu memory buffer. The id that can be | |
| 235 // used to identify the image from a command buffer. | |
| 236 IPC_MESSAGE_ROUTED1(GpuCommandBufferMsg_CreateImage, | |
| 237 GpuCommandBufferMsg_CreateImage_Params /* params */) | |
| 238 | |
| 239 // Destroy a previously created image. | |
| 240 IPC_MESSAGE_ROUTED1(GpuCommandBufferMsg_DestroyImage, int32_t /* id */) | |
| 241 | |
| 242 // Attaches an external image stream to the client texture. | |
| 243 IPC_SYNC_MESSAGE_ROUTED2_1(GpuCommandBufferMsg_CreateStreamTexture, | |
| 244 uint32_t, /* client_texture_id */ | |
| 245 int32_t, /* stream_id */ | |
| 246 bool /* succeeded */) | |
| OLD | NEW |