| 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 770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1262 GLuint copy_texture_to_parent_texture_fb_; | 1261 GLuint copy_texture_to_parent_texture_fb_; |
| 1263 | 1262 |
| 1264 // The copy that is saved when SwapBuffers is called. It is also | 1263 // The copy that is saved when SwapBuffers is called. It is also |
| 1265 // used as the destination for multi-sample resolves. | 1264 // used as the destination for multi-sample resolves. |
| 1266 scoped_ptr<FrameBuffer> offscreen_saved_frame_buffer_; | 1265 scoped_ptr<FrameBuffer> offscreen_saved_frame_buffer_; |
| 1267 scoped_ptr<Texture> offscreen_saved_color_texture_; | 1266 scoped_ptr<Texture> offscreen_saved_color_texture_; |
| 1268 GLenum offscreen_saved_color_format_; | 1267 GLenum offscreen_saved_color_format_; |
| 1269 | 1268 |
| 1270 scoped_ptr<Callback1<gfx::Size>::Type> resize_callback_; | 1269 scoped_ptr<Callback1<gfx::Size>::Type> resize_callback_; |
| 1271 scoped_ptr<Callback0::Type> swap_buffers_callback_; | 1270 scoped_ptr<Callback0::Type> swap_buffers_callback_; |
| 1272 base::Callback<void(bool)> latch_callback_; | |
| 1273 | 1271 |
| 1274 // The format of the back buffer_ | 1272 // The format of the back buffer_ |
| 1275 GLenum back_buffer_color_format_; | 1273 GLenum back_buffer_color_format_; |
| 1276 bool back_buffer_has_depth_; | 1274 bool back_buffer_has_depth_; |
| 1277 bool back_buffer_has_stencil_; | 1275 bool back_buffer_has_stencil_; |
| 1278 | 1276 |
| 1279 bool teximage2d_faster_than_texsubimage2d_; | 1277 bool teximage2d_faster_than_texsubimage2d_; |
| 1280 bool bufferdata_faster_than_buffersubdata_; | 1278 bool bufferdata_faster_than_buffersubdata_; |
| 1281 | 1279 |
| 1282 // The last error message set. | 1280 // The last error message set. |
| (...skipping 1051 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2334 } | 2332 } |
| 2335 | 2333 |
| 2336 void GLES2DecoderImpl::SetResizeCallback(Callback1<gfx::Size>::Type* callback) { | 2334 void GLES2DecoderImpl::SetResizeCallback(Callback1<gfx::Size>::Type* callback) { |
| 2337 resize_callback_.reset(callback); | 2335 resize_callback_.reset(callback); |
| 2338 } | 2336 } |
| 2339 | 2337 |
| 2340 void GLES2DecoderImpl::SetSwapBuffersCallback(Callback0::Type* callback) { | 2338 void GLES2DecoderImpl::SetSwapBuffersCallback(Callback0::Type* callback) { |
| 2341 swap_buffers_callback_.reset(callback); | 2339 swap_buffers_callback_.reset(callback); |
| 2342 } | 2340 } |
| 2343 | 2341 |
| 2344 void GLES2DecoderImpl::SetLatchCallback( | |
| 2345 const base::Callback<void(bool)>& callback) { | |
| 2346 latch_callback_ = callback; | |
| 2347 } | |
| 2348 | |
| 2349 bool GLES2DecoderImpl::GetServiceTextureId(uint32 client_texture_id, | 2342 bool GLES2DecoderImpl::GetServiceTextureId(uint32 client_texture_id, |
| 2350 uint32* service_texture_id) { | 2343 uint32* service_texture_id) { |
| 2351 TextureManager::TextureInfo* texture = | 2344 TextureManager::TextureInfo* texture = |
| 2352 texture_manager()->GetTextureInfo(client_texture_id); | 2345 texture_manager()->GetTextureInfo(client_texture_id); |
| 2353 if (texture) { | 2346 if (texture) { |
| 2354 *service_texture_id = texture->service_id(); | 2347 *service_texture_id = texture->service_id(); |
| 2355 return true; | 2348 return true; |
| 2356 } | 2349 } |
| 2357 return false; | 2350 return false; |
| 2358 } | 2351 } |
| (...skipping 4119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6478 } | 6471 } |
| 6479 } | 6472 } |
| 6480 | 6473 |
| 6481 if (swap_buffers_callback_.get()) { | 6474 if (swap_buffers_callback_.get()) { |
| 6482 swap_buffers_callback_->Run(); | 6475 swap_buffers_callback_->Run(); |
| 6483 } | 6476 } |
| 6484 | 6477 |
| 6485 return error::kNoError; | 6478 return error::kNoError; |
| 6486 } | 6479 } |
| 6487 | 6480 |
| 6488 error::Error GLES2DecoderImpl::HandleSetLatchCHROMIUM( | |
| 6489 uint32 immediate_data_size, const gles2::SetLatchCHROMIUM& c) { | |
| 6490 TRACE_EVENT1("gpu", "SetLatch", "latch_id", c.latch_id); | |
| 6491 // Ensure the side effects of previous commands are visible to other contexts. | |
| 6492 // There is no need to do this for ANGLE because it uses a | |
| 6493 // single D3D device for all contexts. | |
| 6494 if (!IsAngle()) | |
| 6495 glFlush(); | |
| 6496 | |
| 6497 int32 shm_id = gpu::kLatchSharedMemoryId; | |
| 6498 uint32 latch_id = c.latch_id; | |
| 6499 uint32 shm_offset = 0; | |
| 6500 base::subtle::Atomic32* latch; | |
| 6501 if (!SafeMultiplyUint32(latch_id, sizeof(*latch), &shm_offset)) { | |
| 6502 return error::kOutOfBounds; | |
| 6503 } | |
| 6504 latch = GetSharedMemoryAs<base::subtle::Atomic32*>( | |
| 6505 shm_id, shm_offset, sizeof(*latch)); | |
| 6506 if (!latch) { | |
| 6507 return error::kOutOfBounds; | |
| 6508 } | |
| 6509 base::subtle::Atomic32 old = | |
| 6510 base::subtle::NoBarrier_CompareAndSwap(latch, 0, 1); | |
| 6511 DCHECK(old == 0); | |
| 6512 if (!latch_callback_.is_null()) | |
| 6513 latch_callback_.Run(true); | |
| 6514 return error::kNoError; | |
| 6515 } | |
| 6516 | |
| 6517 error::Error GLES2DecoderImpl::HandleWaitLatchCHROMIUM( | |
| 6518 uint32 immediate_data_size, const gles2::WaitLatchCHROMIUM& c) { | |
| 6519 TRACE_EVENT1("gpu", "WaitLatch", "latch_id", c.latch_id); | |
| 6520 int32 shm_id = gpu::kLatchSharedMemoryId; | |
| 6521 uint32 latch_id = c.latch_id; | |
| 6522 uint32 shm_offset = 0; | |
| 6523 base::subtle::Atomic32* latch; | |
| 6524 if (!SafeMultiplyUint32(latch_id, sizeof(*latch), &shm_offset)) { | |
| 6525 return error::kOutOfBounds; | |
| 6526 } | |
| 6527 latch = GetSharedMemoryAs<base::subtle::Atomic32*>( | |
| 6528 shm_id, shm_offset, sizeof(*latch)); | |
| 6529 if (!latch) { | |
| 6530 return error::kOutOfBounds; | |
| 6531 } | |
| 6532 | |
| 6533 base::subtle::Atomic32 old = | |
| 6534 base::subtle::NoBarrier_CompareAndSwap(latch, 1, 0); | |
| 6535 if (old == 0) { | |
| 6536 if (!latch_callback_.is_null()) | |
| 6537 latch_callback_.Run(false); | |
| 6538 return error::kWaiting; | |
| 6539 } else { | |
| 6540 return error::kNoError; | |
| 6541 } | |
| 6542 } | |
| 6543 | |
| 6544 error::Error GLES2DecoderImpl::HandleCommandBufferEnableCHROMIUM( | 6481 error::Error GLES2DecoderImpl::HandleCommandBufferEnableCHROMIUM( |
| 6545 uint32 immediate_data_size, const gles2::CommandBufferEnableCHROMIUM& c) { | 6482 uint32 immediate_data_size, const gles2::CommandBufferEnableCHROMIUM& c) { |
| 6546 Bucket* bucket = GetBucket(c.bucket_id); | 6483 Bucket* bucket = GetBucket(c.bucket_id); |
| 6547 typedef gles2::CommandBufferEnableCHROMIUM::Result Result; | 6484 typedef gles2::CommandBufferEnableCHROMIUM::Result Result; |
| 6548 Result* result = GetSharedMemoryAs<Result*>( | 6485 Result* result = GetSharedMemoryAs<Result*>( |
| 6549 c.result_shm_id, c.result_shm_offset, sizeof(*result)); | 6486 c.result_shm_id, c.result_shm_offset, sizeof(*result)); |
| 6550 if (!result) { | 6487 if (!result) { |
| 6551 return error::kOutOfBounds; | 6488 return error::kOutOfBounds; |
| 6552 } | 6489 } |
| 6553 // Check that the client initialized the result. | 6490 // Check that the client initialized the result. |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6700 return error::kNoError; | 6637 return error::kNoError; |
| 6701 } | 6638 } |
| 6702 | 6639 |
| 6703 // Include the auto-generated part of this file. We split this because it means | 6640 // Include the auto-generated part of this file. We split this because it means |
| 6704 // we can easily edit the non-auto generated parts right here in this file | 6641 // we can easily edit the non-auto generated parts right here in this file |
| 6705 // instead of having to edit some template or the code generator. | 6642 // instead of having to edit some template or the code generator. |
| 6706 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 6643 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 6707 | 6644 |
| 6708 } // namespace gles2 | 6645 } // namespace gles2 |
| 6709 } // namespace gpu | 6646 } // namespace gpu |
| OLD | NEW |