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 "gpu/command_buffer/service/gles2_cmd_decoder.h" | 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
6 | 6 |
7 #include <stdio.h> | 7 #include <stdio.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <list> | 10 #include <list> |
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
472 virtual bool UpdateOffscreenFrameBufferSize(); | 472 virtual bool UpdateOffscreenFrameBufferSize(); |
473 void UpdateParentTextureInfo(); | 473 void UpdateParentTextureInfo(); |
474 virtual bool MakeCurrent(); | 474 virtual bool MakeCurrent(); |
475 virtual GLES2Util* GetGLES2Util() { return &util_; } | 475 virtual GLES2Util* GetGLES2Util() { return &util_; } |
476 virtual gfx::GLContext* GetGLContext() { return context_.get(); } | 476 virtual gfx::GLContext* GetGLContext() { return context_.get(); } |
477 virtual gfx::GLSurface* GetGLSurface() { return surface_.get(); } | 477 virtual gfx::GLSurface* GetGLSurface() { return surface_.get(); } |
478 virtual ContextGroup* GetContextGroup() { return group_.get(); } | 478 virtual ContextGroup* GetContextGroup() { return group_.get(); } |
479 | 479 |
480 virtual void SetResizeCallback(Callback1<gfx::Size>::Type* callback); | 480 virtual void SetResizeCallback(Callback1<gfx::Size>::Type* callback); |
481 virtual void SetSwapBuffersCallback(Callback0::Type* callback); | 481 virtual void SetSwapBuffersCallback(Callback0::Type* callback); |
| 482 virtual void SetLatchCallback(const base::Callback<void(bool)>& callback);; |
482 virtual bool GetServiceTextureId(uint32 client_texture_id, | 483 virtual bool GetServiceTextureId(uint32 client_texture_id, |
483 uint32* service_texture_id); | 484 uint32* service_texture_id); |
484 | 485 |
485 // Restores the current state to the user's settings. | 486 // Restores the current state to the user's settings. |
486 void RestoreCurrentFramebufferBindings(); | 487 void RestoreCurrentFramebufferBindings(); |
487 void RestoreCurrentRenderbufferBindings(); | 488 void RestoreCurrentRenderbufferBindings(); |
488 void RestoreCurrentTexture2DBindings(); | 489 void RestoreCurrentTexture2DBindings(); |
489 | 490 |
490 // Sets DEPTH_TEST, STENCIL_TEST and color mask for the current framebuffer. | 491 // Sets DEPTH_TEST, STENCIL_TEST and color mask for the current framebuffer. |
491 void ApplyDirtyState(); | 492 void ApplyDirtyState(); |
(...skipping 772 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1264 GLuint copy_texture_to_parent_texture_fb_; | 1265 GLuint copy_texture_to_parent_texture_fb_; |
1265 | 1266 |
1266 // The copy that is saved when SwapBuffers is called. It is also | 1267 // The copy that is saved when SwapBuffers is called. It is also |
1267 // used as the destination for multi-sample resolves. | 1268 // used as the destination for multi-sample resolves. |
1268 scoped_ptr<FrameBuffer> offscreen_saved_frame_buffer_; | 1269 scoped_ptr<FrameBuffer> offscreen_saved_frame_buffer_; |
1269 scoped_ptr<Texture> offscreen_saved_color_texture_; | 1270 scoped_ptr<Texture> offscreen_saved_color_texture_; |
1270 GLenum offscreen_saved_color_format_; | 1271 GLenum offscreen_saved_color_format_; |
1271 | 1272 |
1272 scoped_ptr<Callback1<gfx::Size>::Type> resize_callback_; | 1273 scoped_ptr<Callback1<gfx::Size>::Type> resize_callback_; |
1273 scoped_ptr<Callback0::Type> swap_buffers_callback_; | 1274 scoped_ptr<Callback0::Type> swap_buffers_callback_; |
| 1275 base::Callback<void(bool)> latch_callback_; |
1274 | 1276 |
1275 // The format of the back buffer_ | 1277 // The format of the back buffer_ |
1276 GLenum back_buffer_color_format_; | 1278 GLenum back_buffer_color_format_; |
1277 bool back_buffer_has_depth_; | 1279 bool back_buffer_has_depth_; |
1278 bool back_buffer_has_stencil_; | 1280 bool back_buffer_has_stencil_; |
1279 | 1281 |
1280 bool teximage2d_faster_than_texsubimage2d_; | 1282 bool teximage2d_faster_than_texsubimage2d_; |
1281 bool bufferdata_faster_than_buffersubdata_; | 1283 bool bufferdata_faster_than_buffersubdata_; |
1282 | 1284 |
1283 // The last error message set. | 1285 // The last error message set. |
(...skipping 1067 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2351 } | 2353 } |
2352 | 2354 |
2353 void GLES2DecoderImpl::SetResizeCallback(Callback1<gfx::Size>::Type* callback) { | 2355 void GLES2DecoderImpl::SetResizeCallback(Callback1<gfx::Size>::Type* callback) { |
2354 resize_callback_.reset(callback); | 2356 resize_callback_.reset(callback); |
2355 } | 2357 } |
2356 | 2358 |
2357 void GLES2DecoderImpl::SetSwapBuffersCallback(Callback0::Type* callback) { | 2359 void GLES2DecoderImpl::SetSwapBuffersCallback(Callback0::Type* callback) { |
2358 swap_buffers_callback_.reset(callback); | 2360 swap_buffers_callback_.reset(callback); |
2359 } | 2361 } |
2360 | 2362 |
| 2363 void GLES2DecoderImpl::SetLatchCallback( |
| 2364 const base::Callback<void(bool)>& callback) { |
| 2365 latch_callback_ = callback; |
| 2366 } |
| 2367 |
2361 bool GLES2DecoderImpl::GetServiceTextureId(uint32 client_texture_id, | 2368 bool GLES2DecoderImpl::GetServiceTextureId(uint32 client_texture_id, |
2362 uint32* service_texture_id) { | 2369 uint32* service_texture_id) { |
2363 TextureManager::TextureInfo* texture = | 2370 TextureManager::TextureInfo* texture = |
2364 texture_manager()->GetTextureInfo(client_texture_id); | 2371 texture_manager()->GetTextureInfo(client_texture_id); |
2365 if (texture) { | 2372 if (texture) { |
2366 *service_texture_id = texture->service_id(); | 2373 *service_texture_id = texture->service_id(); |
2367 return true; | 2374 return true; |
2368 } | 2375 } |
2369 return false; | 2376 return false; |
2370 } | 2377 } |
(...skipping 4151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6522 } | 6529 } |
6523 } | 6530 } |
6524 | 6531 |
6525 if (swap_buffers_callback_.get()) { | 6532 if (swap_buffers_callback_.get()) { |
6526 swap_buffers_callback_->Run(); | 6533 swap_buffers_callback_->Run(); |
6527 } | 6534 } |
6528 | 6535 |
6529 return error::kNoError; | 6536 return error::kNoError; |
6530 } | 6537 } |
6531 | 6538 |
| 6539 error::Error GLES2DecoderImpl::HandleSetLatchCHROMIUM( |
| 6540 uint32 immediate_data_size, const gles2::SetLatchCHROMIUM& c) { |
| 6541 TRACE_EVENT1("gpu", "SetLatch", "latch_id", c.latch_id); |
| 6542 // Ensure the side effects of previous commands are visible to other contexts. |
| 6543 // There is no need to do this for ANGLE because it uses a |
| 6544 // single D3D device for all contexts. |
| 6545 if (!IsAngle()) |
| 6546 glFlush(); |
| 6547 |
| 6548 int32 shm_id = gpu::kLatchSharedMemoryId; |
| 6549 uint32 latch_id = c.latch_id; |
| 6550 uint32 shm_offset = 0; |
| 6551 base::subtle::Atomic32* latch; |
| 6552 if (!SafeMultiplyUint32(latch_id, sizeof(*latch), &shm_offset)) { |
| 6553 return error::kOutOfBounds; |
| 6554 } |
| 6555 latch = GetSharedMemoryAs<base::subtle::Atomic32*>( |
| 6556 shm_id, shm_offset, sizeof(*latch)); |
| 6557 if (!latch) { |
| 6558 return error::kOutOfBounds; |
| 6559 } |
| 6560 base::subtle::Atomic32 old = |
| 6561 base::subtle::NoBarrier_CompareAndSwap(latch, 0, 1); |
| 6562 DCHECK(old == 0); |
| 6563 if (!latch_callback_.is_null()) |
| 6564 latch_callback_.Run(true); |
| 6565 return error::kNoError; |
| 6566 } |
| 6567 |
| 6568 error::Error GLES2DecoderImpl::HandleWaitLatchCHROMIUM( |
| 6569 uint32 immediate_data_size, const gles2::WaitLatchCHROMIUM& c) { |
| 6570 TRACE_EVENT1("gpu", "WaitLatch", "latch_id", c.latch_id); |
| 6571 int32 shm_id = gpu::kLatchSharedMemoryId; |
| 6572 uint32 latch_id = c.latch_id; |
| 6573 uint32 shm_offset = 0; |
| 6574 base::subtle::Atomic32* latch; |
| 6575 if (!SafeMultiplyUint32(latch_id, sizeof(*latch), &shm_offset)) { |
| 6576 return error::kOutOfBounds; |
| 6577 } |
| 6578 latch = GetSharedMemoryAs<base::subtle::Atomic32*>( |
| 6579 shm_id, shm_offset, sizeof(*latch)); |
| 6580 if (!latch) { |
| 6581 return error::kOutOfBounds; |
| 6582 } |
| 6583 |
| 6584 base::subtle::Atomic32 old = |
| 6585 base::subtle::NoBarrier_CompareAndSwap(latch, 1, 0); |
| 6586 if (old == 0) { |
| 6587 if (!latch_callback_.is_null()) |
| 6588 latch_callback_.Run(false); |
| 6589 return error::kWaiting; |
| 6590 } else { |
| 6591 return error::kNoError; |
| 6592 } |
| 6593 } |
| 6594 |
6532 error::Error GLES2DecoderImpl::HandleCommandBufferEnableCHROMIUM( | 6595 error::Error GLES2DecoderImpl::HandleCommandBufferEnableCHROMIUM( |
6533 uint32 immediate_data_size, const gles2::CommandBufferEnableCHROMIUM& c) { | 6596 uint32 immediate_data_size, const gles2::CommandBufferEnableCHROMIUM& c) { |
6534 Bucket* bucket = GetBucket(c.bucket_id); | 6597 Bucket* bucket = GetBucket(c.bucket_id); |
6535 typedef gles2::CommandBufferEnableCHROMIUM::Result Result; | 6598 typedef gles2::CommandBufferEnableCHROMIUM::Result Result; |
6536 Result* result = GetSharedMemoryAs<Result*>( | 6599 Result* result = GetSharedMemoryAs<Result*>( |
6537 c.result_shm_id, c.result_shm_offset, sizeof(*result)); | 6600 c.result_shm_id, c.result_shm_offset, sizeof(*result)); |
6538 if (!result) { | 6601 if (!result) { |
6539 return error::kOutOfBounds; | 6602 return error::kOutOfBounds; |
6540 } | 6603 } |
6541 // Check that the client initialized the result. | 6604 // Check that the client initialized the result. |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6744 return false; | 6807 return false; |
6745 } | 6808 } |
6746 | 6809 |
6747 // Include the auto-generated part of this file. We split this because it means | 6810 // Include the auto-generated part of this file. We split this because it means |
6748 // we can easily edit the non-auto generated parts right here in this file | 6811 // we can easily edit the non-auto generated parts right here in this file |
6749 // instead of having to edit some template or the code generator. | 6812 // instead of having to edit some template or the code generator. |
6750 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 6813 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
6751 | 6814 |
6752 } // namespace gles2 | 6815 } // namespace gles2 |
6753 } // namespace gpu | 6816 } // namespace gpu |
OLD | NEW |