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