OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/bind_helpers.h" | 6 #include "base/bind_helpers.h" |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/hash.h" | 8 #include "base/hash.h" |
9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
10 #include "base/memory/shared_memory.h" | 10 #include "base/memory/shared_memory.h" |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 // messages directed at the command buffer. This ensures that the message | 254 // messages directed at the command buffer. This ensures that the message |
255 // handler can assume that the context is current (not necessary for | 255 // handler can assume that the context is current (not necessary for |
256 // RetireSyncPoint or WaitSyncPoint). | 256 // RetireSyncPoint or WaitSyncPoint). |
257 if (decoder_.get() && | 257 if (decoder_.get() && |
258 message.type() != GpuCommandBufferMsg_SetGetBuffer::ID && | 258 message.type() != GpuCommandBufferMsg_SetGetBuffer::ID && |
259 message.type() != GpuCommandBufferMsg_WaitForTokenInRange::ID && | 259 message.type() != GpuCommandBufferMsg_WaitForTokenInRange::ID && |
260 message.type() != GpuCommandBufferMsg_WaitForGetOffsetInRange::ID && | 260 message.type() != GpuCommandBufferMsg_WaitForGetOffsetInRange::ID && |
261 message.type() != GpuCommandBufferMsg_RegisterTransferBuffer::ID && | 261 message.type() != GpuCommandBufferMsg_RegisterTransferBuffer::ID && |
262 message.type() != GpuCommandBufferMsg_DestroyTransferBuffer::ID && | 262 message.type() != GpuCommandBufferMsg_DestroyTransferBuffer::ID && |
263 message.type() != GpuCommandBufferMsg_RetireSyncPoint::ID && | 263 message.type() != GpuCommandBufferMsg_RetireSyncPoint::ID && |
264 message.type() != GpuCommandBufferMsg_SignalSyncPoint::ID && | 264 message.type() != GpuCommandBufferMsg_SignalSyncPoint::ID) { |
265 message.type() != | |
266 GpuCommandBufferMsg_SetClientHasMemoryAllocationChangedCallback::ID) { | |
267 if (!MakeCurrent()) | 265 if (!MakeCurrent()) |
268 return false; | 266 return false; |
269 have_context = true; | 267 have_context = true; |
270 } | 268 } |
271 | 269 |
272 // Always use IPC_MESSAGE_HANDLER_DELAY_REPLY for synchronous message handlers | 270 // Always use IPC_MESSAGE_HANDLER_DELAY_REPLY for synchronous message handlers |
273 // here. This is so the reply can be delayed if the scheduler is unscheduled. | 271 // here. This is so the reply can be delayed if the scheduler is unscheduled. |
274 bool handled = true; | 272 bool handled = true; |
275 IPC_BEGIN_MESSAGE_MAP(GpuCommandBufferStub, message) | 273 IPC_BEGIN_MESSAGE_MAP(GpuCommandBufferStub, message) |
276 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_Initialize, | 274 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_Initialize, |
(...skipping 17 matching lines...) Expand all Loading... |
294 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_CreateVideoEncoder, | 292 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_CreateVideoEncoder, |
295 OnCreateVideoEncoder) | 293 OnCreateVideoEncoder) |
296 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_SetSurfaceVisible, | 294 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_SetSurfaceVisible, |
297 OnSetSurfaceVisible) | 295 OnSetSurfaceVisible) |
298 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_RetireSyncPoint, | 296 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_RetireSyncPoint, |
299 OnRetireSyncPoint) | 297 OnRetireSyncPoint) |
300 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_SignalSyncPoint, | 298 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_SignalSyncPoint, |
301 OnSignalSyncPoint) | 299 OnSignalSyncPoint) |
302 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_SignalQuery, | 300 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_SignalQuery, |
303 OnSignalQuery) | 301 OnSignalQuery) |
304 IPC_MESSAGE_HANDLER( | |
305 GpuCommandBufferMsg_SetClientHasMemoryAllocationChangedCallback, | |
306 OnSetClientHasMemoryAllocationChangedCallback) | |
307 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_CreateImage, OnCreateImage); | 302 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_CreateImage, OnCreateImage); |
308 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_DestroyImage, OnDestroyImage); | 303 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_DestroyImage, OnDestroyImage); |
309 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_CreateStreamTexture, | 304 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_CreateStreamTexture, |
310 OnCreateStreamTexture) | 305 OnCreateStreamTexture) |
311 IPC_MESSAGE_UNHANDLED(handled = false) | 306 IPC_MESSAGE_UNHANDLED(handled = false) |
312 IPC_END_MESSAGE_MAP() | 307 IPC_END_MESSAGE_MAP() |
313 | 308 |
314 CheckCompleteWaits(); | 309 CheckCompleteWaits(); |
315 | 310 |
316 if (have_context) { | 311 if (have_context) { |
(...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
970 this->AsWeakPtr(), | 965 this->AsWeakPtr(), |
971 id)); | 966 id)); |
972 return; | 967 return; |
973 } | 968 } |
974 } | 969 } |
975 } | 970 } |
976 // Something went wrong, run callback immediately. | 971 // Something went wrong, run callback immediately. |
977 OnSignalSyncPointAck(id); | 972 OnSignalSyncPointAck(id); |
978 } | 973 } |
979 | 974 |
980 | |
981 void GpuCommandBufferStub::OnSetClientHasMemoryAllocationChangedCallback( | |
982 bool has_callback) { | |
983 TRACE_EVENT0( | |
984 "gpu", | |
985 "GpuCommandBufferStub::OnSetClientHasMemoryAllocationChangedCallback"); | |
986 if (has_callback) { | |
987 if (!memory_manager_client_state_) { | |
988 memory_manager_client_state_.reset(GetMemoryManager()->CreateClientState( | |
989 this, surface_id_ != 0, true)); | |
990 } | |
991 } else { | |
992 memory_manager_client_state_.reset(); | |
993 } | |
994 } | |
995 | |
996 void GpuCommandBufferStub::OnCreateImage(int32 id, | 975 void GpuCommandBufferStub::OnCreateImage(int32 id, |
997 gfx::GpuMemoryBufferHandle handle, | 976 gfx::GpuMemoryBufferHandle handle, |
998 gfx::Size size, | 977 gfx::Size size, |
999 gfx::BufferFormat format, | 978 gfx::BufferFormat format, |
1000 uint32 internalformat) { | 979 uint32 internalformat) { |
1001 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnCreateImage"); | 980 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnCreateImage"); |
1002 | 981 |
1003 if (!decoder_) | 982 if (!decoder_) |
1004 return; | 983 return; |
1005 | 984 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1098 } | 1077 } |
1099 | 1078 |
1100 const gpu::gles2::FeatureInfo* GpuCommandBufferStub::GetFeatureInfo() const { | 1079 const gpu::gles2::FeatureInfo* GpuCommandBufferStub::GetFeatureInfo() const { |
1101 return context_group_->feature_info(); | 1080 return context_group_->feature_info(); |
1102 } | 1081 } |
1103 | 1082 |
1104 gpu::gles2::MemoryTracker* GpuCommandBufferStub::GetMemoryTracker() const { | 1083 gpu::gles2::MemoryTracker* GpuCommandBufferStub::GetMemoryTracker() const { |
1105 return context_group_->memory_tracker(); | 1084 return context_group_->memory_tracker(); |
1106 } | 1085 } |
1107 | 1086 |
1108 void GpuCommandBufferStub::SetMemoryAllocation( | |
1109 const gpu::MemoryAllocation& allocation) { | |
1110 if (!last_memory_allocation_valid_ || | |
1111 !allocation.Equals(last_memory_allocation_)) { | |
1112 Send(new GpuCommandBufferMsg_SetMemoryAllocation( | |
1113 route_id_, allocation)); | |
1114 } | |
1115 | |
1116 last_memory_allocation_valid_ = true; | |
1117 last_memory_allocation_ = allocation; | |
1118 } | |
1119 | |
1120 void GpuCommandBufferStub::SuggestHaveFrontBuffer( | 1087 void GpuCommandBufferStub::SuggestHaveFrontBuffer( |
1121 bool suggest_have_frontbuffer) { | 1088 bool suggest_have_frontbuffer) { |
1122 // This can be called outside of OnMessageReceived, so the context needs | 1089 // This can be called outside of OnMessageReceived, so the context needs |
1123 // to be made current before calling methods on the surface. | 1090 // to be made current before calling methods on the surface. |
1124 if (surface_.get() && MakeCurrent()) | 1091 if (surface_.get() && MakeCurrent()) |
1125 surface_->SetFrontbufferAllocation(suggest_have_frontbuffer); | 1092 surface_->SetFrontbufferAllocation(suggest_have_frontbuffer); |
1126 } | 1093 } |
1127 | 1094 |
1128 bool GpuCommandBufferStub::CheckContextLost() { | 1095 bool GpuCommandBufferStub::CheckContextLost() { |
1129 DCHECK(command_buffer_); | 1096 DCHECK(command_buffer_); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1180 result)); | 1147 result)); |
1181 } | 1148 } |
1182 | 1149 |
1183 void GpuCommandBufferStub::SendUpdateVSyncParameters(base::TimeTicks timebase, | 1150 void GpuCommandBufferStub::SendUpdateVSyncParameters(base::TimeTicks timebase, |
1184 base::TimeDelta interval) { | 1151 base::TimeDelta interval) { |
1185 Send(new GpuCommandBufferMsg_UpdateVSyncParameters(route_id_, timebase, | 1152 Send(new GpuCommandBufferMsg_UpdateVSyncParameters(route_id_, timebase, |
1186 interval)); | 1153 interval)); |
1187 } | 1154 } |
1188 | 1155 |
1189 } // namespace content | 1156 } // namespace content |
OLD | NEW |