| 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 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 uint32 parent_texture_id); | 470 uint32 parent_texture_id); |
| 471 virtual bool ResizeOffscreenFrameBuffer(const gfx::Size& size); | 471 virtual bool ResizeOffscreenFrameBuffer(const gfx::Size& size); |
| 472 void UpdateParentTextureInfo(); | 472 void UpdateParentTextureInfo(); |
| 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 |
| 481 #if defined(OS_MACOSX) |
| 480 virtual void SetSwapBuffersCallback(Callback0::Type* callback); | 482 virtual void SetSwapBuffersCallback(Callback0::Type* callback); |
| 483 #endif |
| 484 |
| 481 virtual bool GetServiceTextureId(uint32 client_texture_id, | 485 virtual bool GetServiceTextureId(uint32 client_texture_id, |
| 482 uint32* service_texture_id); | 486 uint32* service_texture_id); |
| 483 | 487 |
| 484 // Restores the current state to the user's settings. | 488 // Restores the current state to the user's settings. |
| 485 void RestoreCurrentFramebufferBindings(); | 489 void RestoreCurrentFramebufferBindings(); |
| 486 void RestoreCurrentRenderbufferBindings(); | 490 void RestoreCurrentRenderbufferBindings(); |
| 487 void RestoreCurrentTexture2DBindings(); | 491 void RestoreCurrentTexture2DBindings(); |
| 488 | 492 |
| 489 // Sets DEPTH_TEST, STENCIL_TEST and color mask for the current framebuffer. | 493 // Sets DEPTH_TEST, STENCIL_TEST and color mask for the current framebuffer. |
| 490 void ApplyDirtyState(); | 494 void ApplyDirtyState(); |
| (...skipping 786 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1277 // The copy that is saved when SwapBuffers is called. | 1281 // The copy that is saved when SwapBuffers is called. |
| 1278 scoped_ptr<FrameBuffer> offscreen_saved_frame_buffer_; | 1282 scoped_ptr<FrameBuffer> offscreen_saved_frame_buffer_; |
| 1279 scoped_ptr<Texture> offscreen_saved_color_texture_; | 1283 scoped_ptr<Texture> offscreen_saved_color_texture_; |
| 1280 | 1284 |
| 1281 // The copy that is used as the destination for multi-sample resolves. | 1285 // The copy that is used as the destination for multi-sample resolves. |
| 1282 scoped_ptr<FrameBuffer> offscreen_resolved_frame_buffer_; | 1286 scoped_ptr<FrameBuffer> offscreen_resolved_frame_buffer_; |
| 1283 scoped_ptr<Texture> offscreen_resolved_color_texture_; | 1287 scoped_ptr<Texture> offscreen_resolved_color_texture_; |
| 1284 GLenum offscreen_saved_color_format_; | 1288 GLenum offscreen_saved_color_format_; |
| 1285 | 1289 |
| 1286 scoped_ptr<Callback1<gfx::Size>::Type> resize_callback_; | 1290 scoped_ptr<Callback1<gfx::Size>::Type> resize_callback_; |
| 1291 |
| 1292 #if defined(OS_MACOSX) |
| 1287 scoped_ptr<Callback0::Type> swap_buffers_callback_; | 1293 scoped_ptr<Callback0::Type> swap_buffers_callback_; |
| 1294 #endif |
| 1288 | 1295 |
| 1289 // The format of the back buffer_ | 1296 // The format of the back buffer_ |
| 1290 GLenum back_buffer_color_format_; | 1297 GLenum back_buffer_color_format_; |
| 1291 bool back_buffer_has_depth_; | 1298 bool back_buffer_has_depth_; |
| 1292 bool back_buffer_has_stencil_; | 1299 bool back_buffer_has_stencil_; |
| 1293 | 1300 |
| 1294 bool teximage2d_faster_than_texsubimage2d_; | 1301 bool teximage2d_faster_than_texsubimage2d_; |
| 1295 bool bufferdata_faster_than_buffersubdata_; | 1302 bool bufferdata_faster_than_buffersubdata_; |
| 1296 | 1303 |
| 1297 // The last error message set. | 1304 // The last error message set. |
| (...skipping 975 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2273 GL_TEXTURE_WRAP_T, | 2280 GL_TEXTURE_WRAP_T, |
| 2274 GL_CLAMP_TO_EDGE); | 2281 GL_CLAMP_TO_EDGE); |
| 2275 } | 2282 } |
| 2276 } | 2283 } |
| 2277 | 2284 |
| 2278 void GLES2DecoderImpl::SetResizeCallback( | 2285 void GLES2DecoderImpl::SetResizeCallback( |
| 2279 Callback1<gfx::Size>::Type* callback) { | 2286 Callback1<gfx::Size>::Type* callback) { |
| 2280 resize_callback_.reset(callback); | 2287 resize_callback_.reset(callback); |
| 2281 } | 2288 } |
| 2282 | 2289 |
| 2290 #if defined(OS_MACOSX) |
| 2283 void GLES2DecoderImpl::SetSwapBuffersCallback(Callback0::Type* callback) { | 2291 void GLES2DecoderImpl::SetSwapBuffersCallback(Callback0::Type* callback) { |
| 2284 swap_buffers_callback_.reset(callback); | 2292 swap_buffers_callback_.reset(callback); |
| 2285 } | 2293 } |
| 2294 #endif |
| 2286 | 2295 |
| 2287 bool GLES2DecoderImpl::GetServiceTextureId(uint32 client_texture_id, | 2296 bool GLES2DecoderImpl::GetServiceTextureId(uint32 client_texture_id, |
| 2288 uint32* service_texture_id) { | 2297 uint32* service_texture_id) { |
| 2289 TextureManager::TextureInfo* texture = | 2298 TextureManager::TextureInfo* texture = |
| 2290 texture_manager()->GetTextureInfo(client_texture_id); | 2299 texture_manager()->GetTextureInfo(client_texture_id); |
| 2291 if (texture) { | 2300 if (texture) { |
| 2292 *service_texture_id = texture->service_id(); | 2301 *service_texture_id = texture->service_id(); |
| 2293 return true; | 2302 return true; |
| 2294 } | 2303 } |
| 2295 return false; | 2304 return false; |
| (...skipping 4277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6573 "frame", this_frame_number); | 6582 "frame", this_frame_number); |
| 6574 // If offscreen then don't actually SwapBuffers to the display. Just copy | 6583 // If offscreen then don't actually SwapBuffers to the display. Just copy |
| 6575 // the rendered frame to another frame buffer. | 6584 // the rendered frame to another frame buffer. |
| 6576 if (is_offscreen) { | 6585 if (is_offscreen) { |
| 6577 ScopedGLErrorSuppressor suppressor(this); | 6586 ScopedGLErrorSuppressor suppressor(this); |
| 6578 | 6587 |
| 6579 if (IsOffscreenBufferMultisampled()) { | 6588 if (IsOffscreenBufferMultisampled()) { |
| 6580 // For multisampled buffers, bind the resolved frame buffer so that | 6589 // For multisampled buffers, bind the resolved frame buffer so that |
| 6581 // callbacks can call ReadPixels or CopyTexImage2D. | 6590 // callbacks can call ReadPixels or CopyTexImage2D. |
| 6582 ScopedResolvedFrameBufferBinder binder(this, true, false); | 6591 ScopedResolvedFrameBufferBinder binder(this, true, false); |
| 6592 #if defined(OS_MACOSX) |
| 6583 if (swap_buffers_callback_.get()) { | 6593 if (swap_buffers_callback_.get()) { |
| 6584 swap_buffers_callback_->Run(); | 6594 swap_buffers_callback_->Run(); |
| 6585 } | 6595 } |
| 6596 #endif |
| 6586 return error::kNoError; | 6597 return error::kNoError; |
| 6587 } else { | 6598 } else { |
| 6588 ScopedFrameBufferBinder binder(this, | 6599 ScopedFrameBufferBinder binder(this, |
| 6589 offscreen_target_frame_buffer_->id()); | 6600 offscreen_target_frame_buffer_->id()); |
| 6590 | 6601 |
| 6591 if (surface_->IsOffscreen()) { | 6602 if (surface_->IsOffscreen()) { |
| 6592 // Copy the target frame buffer to the saved offscreen texture. | 6603 // Copy the target frame buffer to the saved offscreen texture. |
| 6593 offscreen_saved_color_texture_->Copy( | 6604 offscreen_saved_color_texture_->Copy( |
| 6594 offscreen_saved_color_texture_->size(), | 6605 offscreen_saved_color_texture_->size(), |
| 6595 offscreen_saved_color_format_); | 6606 offscreen_saved_color_format_); |
| 6596 | 6607 |
| 6597 // Ensure the side effects of the copy are visible to the parent | 6608 // Ensure the side effects of the copy are visible to the parent |
| 6598 // context. There is no need to do this for ANGLE because it uses a | 6609 // context. There is no need to do this for ANGLE because it uses a |
| 6599 // single D3D device for all contexts. | 6610 // single D3D device for all contexts. |
| 6600 if (!IsAngle()) | 6611 if (!IsAngle()) |
| 6601 glFlush(); | 6612 glFlush(); |
| 6602 } | 6613 } |
| 6603 | 6614 |
| 6604 // Run the callback with |binder| in scope, so that the callback can call | 6615 // Run the callback with |binder| in scope, so that the callback can call |
| 6605 // ReadPixels or CopyTexImage2D. | 6616 // ReadPixels or CopyTexImage2D. |
| 6617 #if defined(OS_MACOSX) |
| 6606 if (swap_buffers_callback_.get()) { | 6618 if (swap_buffers_callback_.get()) { |
| 6607 swap_buffers_callback_->Run(); | 6619 swap_buffers_callback_->Run(); |
| 6608 } | 6620 } |
| 6621 #endif |
| 6609 return error::kNoError; | 6622 return error::kNoError; |
| 6610 } | 6623 } |
| 6611 } else { | 6624 } else { |
| 6612 TRACE_EVENT1("gpu", "GLContext::SwapBuffers", "frame", this_frame_number); | 6625 TRACE_EVENT1("gpu", "GLContext::SwapBuffers", "frame", this_frame_number); |
| 6613 if (!surface_->SwapBuffers()) { | 6626 if (!surface_->SwapBuffers()) { |
| 6614 LOG(ERROR) << "Context lost because SwapBuffers failed."; | 6627 LOG(ERROR) << "Context lost because SwapBuffers failed."; |
| 6615 return error::kLostContext; | 6628 return error::kLostContext; |
| 6616 } | 6629 } |
| 6617 } | 6630 } |
| 6618 | 6631 |
| 6632 #if defined(OS_MACOSX) |
| 6619 if (swap_buffers_callback_.get()) { | 6633 if (swap_buffers_callback_.get()) { |
| 6620 swap_buffers_callback_->Run(); | 6634 swap_buffers_callback_->Run(); |
| 6621 } | 6635 } |
| 6636 #endif |
| 6622 | 6637 |
| 6623 return error::kNoError; | 6638 return error::kNoError; |
| 6624 } | 6639 } |
| 6625 | 6640 |
| 6626 error::Error GLES2DecoderImpl::HandleEnableFeatureCHROMIUM( | 6641 error::Error GLES2DecoderImpl::HandleEnableFeatureCHROMIUM( |
| 6627 uint32 immediate_data_size, const gles2::EnableFeatureCHROMIUM& c) { | 6642 uint32 immediate_data_size, const gles2::EnableFeatureCHROMIUM& c) { |
| 6628 Bucket* bucket = GetBucket(c.bucket_id); | 6643 Bucket* bucket = GetBucket(c.bucket_id); |
| 6629 typedef gles2::EnableFeatureCHROMIUM::Result Result; | 6644 typedef gles2::EnableFeatureCHROMIUM::Result Result; |
| 6630 Result* result = GetSharedMemoryAs<Result*>( | 6645 Result* result = GetSharedMemoryAs<Result*>( |
| 6631 c.result_shm_id, c.result_shm_offset, sizeof(*result)); | 6646 c.result_shm_id, c.result_shm_offset, sizeof(*result)); |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6828 return false; | 6843 return false; |
| 6829 } | 6844 } |
| 6830 | 6845 |
| 6831 // Include the auto-generated part of this file. We split this because it means | 6846 // Include the auto-generated part of this file. We split this because it means |
| 6832 // we can easily edit the non-auto generated parts right here in this file | 6847 // we can easily edit the non-auto generated parts right here in this file |
| 6833 // instead of having to edit some template or the code generator. | 6848 // instead of having to edit some template or the code generator. |
| 6834 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 6849 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 6835 | 6850 |
| 6836 } // namespace gles2 | 6851 } // namespace gles2 |
| 6837 } // namespace gpu | 6852 } // namespace gpu |
| OLD | NEW |