OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <limits.h> | 7 #include <limits.h> |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 #include <stdio.h> | 10 #include <stdio.h> |
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
556 bool offscreen, | 556 bool offscreen, |
557 const gfx::Size& offscreen_size, | 557 const gfx::Size& offscreen_size, |
558 const DisallowedFeatures& disallowed_features, | 558 const DisallowedFeatures& disallowed_features, |
559 const std::vector<int32_t>& attribs) override; | 559 const std::vector<int32_t>& attribs) override; |
560 void Destroy(bool have_context) override; | 560 void Destroy(bool have_context) override; |
561 void SetSurface(const scoped_refptr<gfx::GLSurface>& surface) override; | 561 void SetSurface(const scoped_refptr<gfx::GLSurface>& surface) override; |
562 void ProduceFrontBuffer(const Mailbox& mailbox) override; | 562 void ProduceFrontBuffer(const Mailbox& mailbox) override; |
563 bool ResizeOffscreenFrameBuffer(const gfx::Size& size) override; | 563 bool ResizeOffscreenFrameBuffer(const gfx::Size& size) override; |
564 void UpdateParentTextureInfo(); | 564 void UpdateParentTextureInfo(); |
565 bool MakeCurrent() override; | 565 bool MakeCurrent() override; |
| 566 void ReleaseCurrent() override; |
566 GLES2Util* GetGLES2Util() override { return &util_; } | 567 GLES2Util* GetGLES2Util() override { return &util_; } |
567 gfx::GLContext* GetGLContext() override { return context_.get(); } | 568 gfx::GLContext* GetGLContext() override { return context_.get(); } |
568 ContextGroup* GetContextGroup() override { return group_.get(); } | 569 ContextGroup* GetContextGroup() override { return group_.get(); } |
569 Capabilities GetCapabilities() override; | 570 Capabilities GetCapabilities() override; |
570 void RestoreState(const ContextState* prev_state) override; | 571 void RestoreState(const ContextState* prev_state) override; |
571 | 572 |
572 void RestoreActiveTexture() const override { state_.RestoreActiveTexture(); } | 573 void RestoreActiveTexture() const override { state_.RestoreActiveTexture(); } |
573 void RestoreAllTextureUnitBindings( | 574 void RestoreAllTextureUnitBindings( |
574 const ContextState* prev_state) const override { | 575 const ContextState* prev_state) const override { |
575 state_.RestoreAllTextureUnitBindings(prev_state); | 576 state_.RestoreAllTextureUnitBindings(prev_state); |
(...skipping 3029 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3605 RestoreFramebufferBindings(); | 3606 RestoreFramebufferBindings(); |
3606 | 3607 |
3607 framebuffer_state_.clear_state_dirty = true; | 3608 framebuffer_state_.clear_state_dirty = true; |
3608 | 3609 |
3609 // Rebind textures if the service ids may have changed. | 3610 // Rebind textures if the service ids may have changed. |
3610 RestoreAllExternalTextureBindingsIfNeeded(); | 3611 RestoreAllExternalTextureBindingsIfNeeded(); |
3611 | 3612 |
3612 return true; | 3613 return true; |
3613 } | 3614 } |
3614 | 3615 |
| 3616 void GLES2DecoderImpl::ReleaseCurrent() { |
| 3617 if (!context_.get()) |
| 3618 return; |
| 3619 |
| 3620 if (WasContextLost()) { |
| 3621 LOG(ERROR) << " GLES2DecoderImpl: Trying to release lost context."; |
| 3622 return; |
| 3623 } |
| 3624 |
| 3625 context_->ReleaseCurrent(surface_.get()); |
| 3626 } |
| 3627 |
3615 void GLES2DecoderImpl::ProcessFinishedAsyncTransfers() { | 3628 void GLES2DecoderImpl::ProcessFinishedAsyncTransfers() { |
3616 ProcessPendingReadPixels(false); | 3629 ProcessPendingReadPixels(false); |
3617 if (engine() && query_manager_.get()) | 3630 if (engine() && query_manager_.get()) |
3618 query_manager_->ProcessPendingTransferQueries(); | 3631 query_manager_->ProcessPendingTransferQueries(); |
3619 } | 3632 } |
3620 | 3633 |
3621 static void RebindCurrentFramebuffer( | 3634 static void RebindCurrentFramebuffer( |
3622 GLenum target, | 3635 GLenum target, |
3623 Framebuffer* framebuffer, | 3636 Framebuffer* framebuffer, |
3624 GLuint back_buffer_service_id) { | 3637 GLuint back_buffer_service_id) { |
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4126 it != texture_to_io_surface_map_.end(); ++it) { | 4139 it != texture_to_io_surface_map_.end(); ++it) { |
4127 CFRelease(it->second); | 4140 CFRelease(it->second); |
4128 } | 4141 } |
4129 texture_to_io_surface_map_.clear(); | 4142 texture_to_io_surface_map_.clear(); |
4130 #endif | 4143 #endif |
4131 } | 4144 } |
4132 | 4145 |
4133 void GLES2DecoderImpl::SetSurface( | 4146 void GLES2DecoderImpl::SetSurface( |
4134 const scoped_refptr<gfx::GLSurface>& surface) { | 4147 const scoped_refptr<gfx::GLSurface>& surface) { |
4135 DCHECK(context_->IsCurrent(NULL)); | 4148 DCHECK(context_->IsCurrent(NULL)); |
4136 DCHECK(surface_.get()); | 4149 // Surface can be null, but then the client should not use the decoder. |
4137 surface_ = surface; | 4150 surface_ = surface; |
4138 RestoreCurrentFramebufferBindings(); | 4151 RestoreCurrentFramebufferBindings(); |
4139 } | 4152 } |
4140 | 4153 |
4141 void GLES2DecoderImpl::ProduceFrontBuffer(const Mailbox& mailbox) { | 4154 void GLES2DecoderImpl::ProduceFrontBuffer(const Mailbox& mailbox) { |
4142 if (!offscreen_saved_color_texture_.get()) { | 4155 if (!offscreen_saved_color_texture_.get()) { |
4143 LOG(ERROR) << "Called ProduceFrontBuffer on a non-offscreen context"; | 4156 LOG(ERROR) << "Called ProduceFrontBuffer on a non-offscreen context"; |
4144 return; | 4157 return; |
4145 } | 4158 } |
4146 if (!offscreen_saved_color_texture_info_.get()) { | 4159 if (!offscreen_saved_color_texture_info_.get()) { |
(...skipping 11507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15654 } | 15667 } |
15655 | 15668 |
15656 // Include the auto-generated part of this file. We split this because it means | 15669 // Include the auto-generated part of this file. We split this because it means |
15657 // we can easily edit the non-auto generated parts right here in this file | 15670 // we can easily edit the non-auto generated parts right here in this file |
15658 // instead of having to edit some template or the code generator. | 15671 // instead of having to edit some template or the code generator. |
15659 #include "base/macros.h" | 15672 #include "base/macros.h" |
15660 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 15673 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
15661 | 15674 |
15662 } // namespace gles2 | 15675 } // namespace gles2 |
15663 } // namespace gpu | 15676 } // namespace gpu |
OLD | NEW |