OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "webkit/plugins/ppapi/ppb_context_3d_impl.h" | 5 #include "webkit/plugins/ppapi/ppb_context_3d_impl.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/shared_memory.h" | 8 #include "base/shared_memory.h" |
9 #include "gpu/command_buffer/client/gles2_cmd_helper.h" | 9 #include "gpu/command_buffer/client/gles2_cmd_helper.h" |
10 #include "gpu/command_buffer/client/gles2_implementation.h" | 10 #include "gpu/command_buffer/client/gles2_implementation.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 *shm_size = size; | 39 *shm_size = size; |
40 return true; | 40 return true; |
41 } | 41 } |
42 | 42 |
43 PP_Context3DTrustedState PPStateFromGPUState(gpu::CommandBuffer::State s) { | 43 PP_Context3DTrustedState PPStateFromGPUState(gpu::CommandBuffer::State s) { |
44 PP_Context3DTrustedState state = { | 44 PP_Context3DTrustedState state = { |
45 s.num_entries, | 45 s.num_entries, |
46 s.get_offset, | 46 s.get_offset, |
47 s.put_offset, | 47 s.put_offset, |
48 s.token, | 48 s.token, |
49 static_cast<PPB_Context3DTrustedError>(s.error) | 49 static_cast<PPB_Context3DTrustedError>(s.error), |
| 50 s.generation |
50 }; | 51 }; |
51 return state; | 52 return state; |
52 } | 53 } |
53 | 54 |
54 PP_Resource Create(PP_Instance instance_id, | 55 PP_Resource Create(PP_Instance instance_id, |
55 PP_Config3D_Dev config, | 56 PP_Config3D_Dev config, |
56 PP_Resource share_context, | 57 PP_Resource share_context, |
57 const int32_t* attrib_list) { | 58 const int32_t* attrib_list) { |
58 // TODO(alokp): Support shared context. | 59 // TODO(alokp): Support shared context. |
59 DCHECK_EQ(0, share_context); | 60 DCHECK_EQ(0, share_context); |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 } | 185 } |
185 | 186 |
186 PP_Context3DTrustedState FlushSync(PP_Resource context_id, int32_t put_offset) { | 187 PP_Context3DTrustedState FlushSync(PP_Resource context_id, int32_t put_offset) { |
187 scoped_refptr<PPB_Context3D_Impl> context( | 188 scoped_refptr<PPB_Context3D_Impl> context( |
188 Resource::GetAs<PPB_Context3D_Impl>(context_id)); | 189 Resource::GetAs<PPB_Context3D_Impl>(context_id)); |
189 if (!context.get() || !context->command_buffer()) { | 190 if (!context.get() || !context->command_buffer()) { |
190 PP_Context3DTrustedState error_state = { 0 }; | 191 PP_Context3DTrustedState error_state = { 0 }; |
191 return error_state; | 192 return error_state; |
192 } | 193 } |
193 | 194 |
194 return PPStateFromGPUState(context->command_buffer()->FlushSync(put_offset)); | 195 gpu::CommandBuffer::State state = context->command_buffer()->GetState(); |
| 196 return PPStateFromGPUState( |
| 197 context->command_buffer()->FlushSync(put_offset, state.get_offset)); |
195 } | 198 } |
196 | 199 |
197 int32_t CreateTransferBuffer(PP_Resource context_id, uint32_t size) { | 200 int32_t CreateTransferBuffer(PP_Resource context_id, uint32_t size) { |
198 scoped_refptr<PPB_Context3D_Impl> context( | 201 scoped_refptr<PPB_Context3D_Impl> context( |
199 Resource::GetAs<PPB_Context3D_Impl>(context_id)); | 202 Resource::GetAs<PPB_Context3D_Impl>(context_id)); |
200 if (!context.get() || !context->command_buffer()) | 203 if (!context.get() || !context->command_buffer()) |
201 return 0; | 204 return 0; |
202 return context->command_buffer()->CreateTransferBuffer(size, -1); | 205 return context->command_buffer()->CreateTransferBuffer(size, -1); |
203 } | 206 } |
204 | 207 |
(...skipping 13 matching lines...) Expand all Loading... |
218 scoped_refptr<PPB_Context3D_Impl> context( | 221 scoped_refptr<PPB_Context3D_Impl> context( |
219 Resource::GetAs<PPB_Context3D_Impl>(context_id)); | 222 Resource::GetAs<PPB_Context3D_Impl>(context_id)); |
220 if (!context.get() || !context->command_buffer()) | 223 if (!context.get() || !context->command_buffer()) |
221 return PP_FALSE; | 224 return PP_FALSE; |
222 gpu::Buffer buffer = context->command_buffer()->GetTransferBuffer(id); | 225 gpu::Buffer buffer = context->command_buffer()->GetTransferBuffer(id); |
223 | 226 |
224 return ShmToHandle(buffer.shared_memory, buffer.size, shm_handle, shm_size) | 227 return ShmToHandle(buffer.shared_memory, buffer.size, shm_handle, shm_size) |
225 ? PP_TRUE : PP_FALSE; | 228 ? PP_TRUE : PP_FALSE; |
226 } | 229 } |
227 | 230 |
| 231 PP_Context3DTrustedState FlushSyncFast( |
| 232 PP_Resource context_id, int32_t put_offset, int32 last_known_get) { |
| 233 scoped_refptr<PPB_Context3D_Impl> context( |
| 234 Resource::GetAs<PPB_Context3D_Impl>(context_id)); |
| 235 if (!context.get() || !context->command_buffer()) { |
| 236 PP_Context3DTrustedState error_state = { 0 }; |
| 237 return error_state; |
| 238 } |
| 239 |
| 240 return PPStateFromGPUState( |
| 241 context->command_buffer()->FlushSync(put_offset, last_known_get)); |
| 242 } |
228 } // namespace | 243 } // namespace |
229 | 244 |
230 PPB_Context3D_Impl::PPB_Context3D_Impl(PluginInstance* instance) | 245 PPB_Context3D_Impl::PPB_Context3D_Impl(PluginInstance* instance) |
231 : Resource(instance), | 246 : Resource(instance), |
232 instance_(instance), | 247 instance_(instance), |
233 transfer_buffer_id_(0), | 248 transfer_buffer_id_(0), |
234 draw_surface_(NULL), | 249 draw_surface_(NULL), |
235 read_surface_(NULL), | 250 read_surface_(NULL), |
236 callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { | 251 callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { |
237 } | 252 } |
238 | 253 |
239 PPB_Context3D_Impl::~PPB_Context3D_Impl() { | 254 PPB_Context3D_Impl::~PPB_Context3D_Impl() { |
240 Destroy(); | 255 Destroy(); |
241 } | 256 } |
242 | 257 |
243 const PPB_Context3D_Dev* PPB_Context3D_Impl::GetInterface() { | 258 const PPB_Context3D_Dev* PPB_Context3D_Impl::GetInterface() { |
244 return &ppb_context3d; | 259 return &ppb_context3d; |
245 } | 260 } |
246 | 261 |
247 const PPB_Context3DTrusted_Dev* PPB_Context3D_Impl::GetTrustedInterface() { | 262 const PPB_Context3DTrusted_Dev* PPB_Context3D_Impl::GetTrustedInterface() { |
248 static const PPB_Context3DTrusted_Dev iface = { | 263 static const PPB_Context3DTrusted_Dev iface = { |
249 &CreateRaw, | 264 &CreateRaw, |
250 &Initialize, | 265 &Initialize, |
251 &GetRingBuffer, | 266 &GetRingBuffer, |
252 &GetState, | 267 &GetState, |
253 &Flush, | 268 &Flush, |
254 &FlushSync, | 269 &FlushSync, |
255 &CreateTransferBuffer, | 270 &CreateTransferBuffer, |
256 &DestroyTransferBuffer, | 271 &DestroyTransferBuffer, |
257 &GetTransferBuffer | 272 &GetTransferBuffer, |
| 273 &FlushSyncFast, |
258 }; | 274 }; |
259 return &iface; | 275 return &iface; |
260 } | 276 } |
261 | 277 |
262 PPB_Context3D_Impl* PPB_Context3D_Impl::AsPPB_Context3D_Impl() { | 278 PPB_Context3D_Impl* PPB_Context3D_Impl::AsPPB_Context3D_Impl() { |
263 return this; | 279 return this; |
264 } | 280 } |
265 | 281 |
266 bool PPB_Context3D_Impl::InitRaw(PP_Config3D_Dev config, | 282 bool PPB_Context3D_Impl::InitRaw(PP_Config3D_Dev config, |
267 PP_Resource share_context, | 283 PP_Resource share_context, |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 read_surface_->OnContextLost(); | 392 read_surface_->OnContextLost(); |
377 } | 393 } |
378 | 394 |
379 gpu::CommandBuffer *PPB_Context3D_Impl::command_buffer() { | 395 gpu::CommandBuffer *PPB_Context3D_Impl::command_buffer() { |
380 return platform_context_.get() ? platform_context_->GetCommandBuffer() : NULL; | 396 return platform_context_.get() ? platform_context_->GetCommandBuffer() : NULL; |
381 } | 397 } |
382 | 398 |
383 } // namespace ppapi | 399 } // namespace ppapi |
384 } // namespace webkit | 400 } // namespace webkit |
385 | 401 |
OLD | NEW |