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 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
588 | 588 |
589 // Overridden from GLES2Decoder. | 589 // Overridden from GLES2Decoder. |
590 bool Initialize(const scoped_refptr<gfx::GLSurface>& surface, | 590 bool Initialize(const scoped_refptr<gfx::GLSurface>& surface, |
591 const scoped_refptr<gfx::GLContext>& context, | 591 const scoped_refptr<gfx::GLContext>& context, |
592 bool offscreen, | 592 bool offscreen, |
593 const gfx::Size& offscreen_size, | 593 const gfx::Size& offscreen_size, |
594 const DisallowedFeatures& disallowed_features, | 594 const DisallowedFeatures& disallowed_features, |
595 const std::vector<int32_t>& attribs) override; | 595 const std::vector<int32_t>& attribs) override; |
596 void Destroy(bool have_context) override; | 596 void Destroy(bool have_context) override; |
597 void SetSurface(const scoped_refptr<gfx::GLSurface>& surface) override; | 597 void SetSurface(const scoped_refptr<gfx::GLSurface>& surface) override; |
| 598 void ReleaseSurface() override; |
598 void ProduceFrontBuffer(const Mailbox& mailbox) override; | 599 void ProduceFrontBuffer(const Mailbox& mailbox) override; |
599 bool ResizeOffscreenFrameBuffer(const gfx::Size& size) override; | 600 bool ResizeOffscreenFrameBuffer(const gfx::Size& size) override; |
600 void UpdateParentTextureInfo(); | 601 void UpdateParentTextureInfo(); |
601 bool MakeCurrent() override; | 602 bool MakeCurrent() override; |
602 GLES2Util* GetGLES2Util() override { return &util_; } | 603 GLES2Util* GetGLES2Util() override { return &util_; } |
603 gfx::GLContext* GetGLContext() override { return context_.get(); } | 604 gfx::GLContext* GetGLContext() override { return context_.get(); } |
604 ContextGroup* GetContextGroup() override { return group_.get(); } | 605 ContextGroup* GetContextGroup() override { return group_.get(); } |
605 Capabilities GetCapabilities() override; | 606 Capabilities GetCapabilities() override; |
606 void RestoreState(const ContextState* prev_state) override; | 607 void RestoreState(const ContextState* prev_state) override; |
607 | 608 |
(...skipping 3156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3764 GL_TRANSFORM_FEEDBACK); | 3765 GL_TRANSFORM_FEEDBACK); |
3765 state_.bound_transform_feedback = | 3766 state_.bound_transform_feedback = |
3766 state_.default_transform_feedback.get(); | 3767 state_.default_transform_feedback.get(); |
3767 } | 3768 } |
3768 RemoveTransformFeedback(client_ids[ii]); | 3769 RemoveTransformFeedback(client_ids[ii]); |
3769 } | 3770 } |
3770 } | 3771 } |
3771 } | 3772 } |
3772 | 3773 |
3773 bool GLES2DecoderImpl::MakeCurrent() { | 3774 bool GLES2DecoderImpl::MakeCurrent() { |
| 3775 DCHECK(surface_); |
3774 if (!context_.get()) | 3776 if (!context_.get()) |
3775 return false; | 3777 return false; |
3776 | 3778 |
3777 if (WasContextLost()) { | 3779 if (WasContextLost()) { |
3778 LOG(ERROR) << " GLES2DecoderImpl: Trying to make lost context current."; | 3780 LOG(ERROR) << " GLES2DecoderImpl: Trying to make lost context current."; |
3779 return false; | 3781 return false; |
3780 } | 3782 } |
3781 | 3783 |
3782 if (!context_->MakeCurrent(surface_.get())) { | 3784 if (!context_->MakeCurrent(surface_.get())) { |
3783 LOG(ERROR) << " GLES2DecoderImpl: Context lost during MakeCurrent."; | 3785 LOG(ERROR) << " GLES2DecoderImpl: Context lost during MakeCurrent."; |
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4332 it != texture_to_io_surface_map_.end(); ++it) { | 4334 it != texture_to_io_surface_map_.end(); ++it) { |
4333 CFRelease(it->second); | 4335 CFRelease(it->second); |
4334 } | 4336 } |
4335 texture_to_io_surface_map_.clear(); | 4337 texture_to_io_surface_map_.clear(); |
4336 #endif | 4338 #endif |
4337 } | 4339 } |
4338 | 4340 |
4339 void GLES2DecoderImpl::SetSurface( | 4341 void GLES2DecoderImpl::SetSurface( |
4340 const scoped_refptr<gfx::GLSurface>& surface) { | 4342 const scoped_refptr<gfx::GLSurface>& surface) { |
4341 DCHECK(context_->IsCurrent(NULL)); | 4343 DCHECK(context_->IsCurrent(NULL)); |
4342 DCHECK(surface_.get()); | 4344 DCHECK(surface); |
4343 surface_ = surface; | 4345 surface_ = surface; |
4344 RestoreCurrentFramebufferBindings(); | 4346 RestoreCurrentFramebufferBindings(); |
4345 } | 4347 } |
4346 | 4348 |
| 4349 void GLES2DecoderImpl::ReleaseSurface() { |
| 4350 if (!context_.get()) |
| 4351 return; |
| 4352 if (WasContextLost()) { |
| 4353 DLOG(ERROR) << " GLES2DecoderImpl: Trying to release lost context."; |
| 4354 return; |
| 4355 } |
| 4356 context_->ReleaseCurrent(surface_.get()); |
| 4357 surface_ = nullptr; |
| 4358 } |
| 4359 |
4347 void GLES2DecoderImpl::ProduceFrontBuffer(const Mailbox& mailbox) { | 4360 void GLES2DecoderImpl::ProduceFrontBuffer(const Mailbox& mailbox) { |
4348 if (!offscreen_saved_color_texture_.get()) { | 4361 if (!offscreen_saved_color_texture_.get()) { |
4349 LOG(ERROR) << "Called ProduceFrontBuffer on a non-offscreen context"; | 4362 LOG(ERROR) << "Called ProduceFrontBuffer on a non-offscreen context"; |
4350 return; | 4363 return; |
4351 } | 4364 } |
4352 if (!offscreen_saved_color_texture_info_.get()) { | 4365 if (!offscreen_saved_color_texture_info_.get()) { |
4353 GLuint service_id = offscreen_saved_color_texture_->id(); | 4366 GLuint service_id = offscreen_saved_color_texture_->id(); |
4354 offscreen_saved_color_texture_info_ = TextureRef::Create( | 4367 offscreen_saved_color_texture_info_ = TextureRef::Create( |
4355 texture_manager(), 0, service_id); | 4368 texture_manager(), 0, service_id); |
4356 texture_manager()->SetTarget(offscreen_saved_color_texture_info_.get(), | 4369 texture_manager()->SetTarget(offscreen_saved_color_texture_info_.get(), |
(...skipping 12317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16674 } | 16687 } |
16675 | 16688 |
16676 // Include the auto-generated part of this file. We split this because it means | 16689 // Include the auto-generated part of this file. We split this because it means |
16677 // we can easily edit the non-auto generated parts right here in this file | 16690 // we can easily edit the non-auto generated parts right here in this file |
16678 // instead of having to edit some template or the code generator. | 16691 // instead of having to edit some template or the code generator. |
16679 #include "base/macros.h" | 16692 #include "base/macros.h" |
16680 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 16693 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
16681 | 16694 |
16682 } // namespace gles2 | 16695 } // namespace gles2 |
16683 } // namespace gpu | 16696 } // namespace gpu |
OLD | NEW |