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 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
587 | 587 |
588 // Overridden from GLES2Decoder. | 588 // Overridden from GLES2Decoder. |
589 bool Initialize(const scoped_refptr<gfx::GLSurface>& surface, | 589 bool Initialize(const scoped_refptr<gfx::GLSurface>& surface, |
590 const scoped_refptr<gfx::GLContext>& context, | 590 const scoped_refptr<gfx::GLContext>& context, |
591 bool offscreen, | 591 bool offscreen, |
592 const gfx::Size& offscreen_size, | 592 const gfx::Size& offscreen_size, |
593 const DisallowedFeatures& disallowed_features, | 593 const DisallowedFeatures& disallowed_features, |
594 const std::vector<int32_t>& attribs) override; | 594 const std::vector<int32_t>& attribs) override; |
595 void Destroy(bool have_context) override; | 595 void Destroy(bool have_context) override; |
596 void SetSurface(const scoped_refptr<gfx::GLSurface>& surface) override; | 596 void SetSurface(const scoped_refptr<gfx::GLSurface>& surface) override; |
| 597 void ReleaseSurface() override; |
597 void ProduceFrontBuffer(const Mailbox& mailbox) override; | 598 void ProduceFrontBuffer(const Mailbox& mailbox) override; |
598 bool ResizeOffscreenFrameBuffer(const gfx::Size& size) override; | 599 bool ResizeOffscreenFrameBuffer(const gfx::Size& size) override; |
599 void UpdateParentTextureInfo(); | 600 void UpdateParentTextureInfo(); |
600 bool MakeCurrent() override; | 601 bool MakeCurrent() override; |
601 GLES2Util* GetGLES2Util() override { return &util_; } | 602 GLES2Util* GetGLES2Util() override { return &util_; } |
602 gfx::GLContext* GetGLContext() override { return context_.get(); } | 603 gfx::GLContext* GetGLContext() override { return context_.get(); } |
603 ContextGroup* GetContextGroup() override { return group_.get(); } | 604 ContextGroup* GetContextGroup() override { return group_.get(); } |
604 Capabilities GetCapabilities() override; | 605 Capabilities GetCapabilities() override; |
605 void RestoreState(const ContextState* prev_state) override; | 606 void RestoreState(const ContextState* prev_state) override; |
606 | 607 |
(...skipping 3069 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3676 state_.UnbindSampler(sampler); | 3677 state_.UnbindSampler(sampler); |
3677 | 3678 |
3678 RemoveSampler(client_ids[ii]); | 3679 RemoveSampler(client_ids[ii]); |
3679 } | 3680 } |
3680 } | 3681 } |
3681 } | 3682 } |
3682 | 3683 |
3683 // } // anonymous namespace | 3684 // } // anonymous namespace |
3684 | 3685 |
3685 bool GLES2DecoderImpl::MakeCurrent() { | 3686 bool GLES2DecoderImpl::MakeCurrent() { |
| 3687 DCHECK(surface_); |
3686 if (!context_.get()) | 3688 if (!context_.get()) |
3687 return false; | 3689 return false; |
3688 | 3690 |
3689 if (WasContextLost()) { | 3691 if (WasContextLost()) { |
3690 LOG(ERROR) << " GLES2DecoderImpl: Trying to make lost context current."; | 3692 LOG(ERROR) << " GLES2DecoderImpl: Trying to make lost context current."; |
3691 return false; | 3693 return false; |
3692 } | 3694 } |
3693 | 3695 |
3694 if (!context_->MakeCurrent(surface_.get())) { | 3696 if (!context_->MakeCurrent(surface_.get())) { |
3695 LOG(ERROR) << " GLES2DecoderImpl: Context lost during MakeCurrent."; | 3697 LOG(ERROR) << " GLES2DecoderImpl: Context lost during MakeCurrent."; |
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4233 it != texture_to_io_surface_map_.end(); ++it) { | 4235 it != texture_to_io_surface_map_.end(); ++it) { |
4234 CFRelease(it->second); | 4236 CFRelease(it->second); |
4235 } | 4237 } |
4236 texture_to_io_surface_map_.clear(); | 4238 texture_to_io_surface_map_.clear(); |
4237 #endif | 4239 #endif |
4238 } | 4240 } |
4239 | 4241 |
4240 void GLES2DecoderImpl::SetSurface( | 4242 void GLES2DecoderImpl::SetSurface( |
4241 const scoped_refptr<gfx::GLSurface>& surface) { | 4243 const scoped_refptr<gfx::GLSurface>& surface) { |
4242 DCHECK(context_->IsCurrent(NULL)); | 4244 DCHECK(context_->IsCurrent(NULL)); |
4243 DCHECK(surface_.get()); | 4245 DCHECK(surface); |
4244 surface_ = surface; | 4246 surface_ = surface; |
4245 RestoreCurrentFramebufferBindings(); | 4247 RestoreCurrentFramebufferBindings(); |
4246 } | 4248 } |
4247 | 4249 |
| 4250 void GLES2DecoderImpl::ReleaseSurface() { |
| 4251 if (!context_.get()) |
| 4252 return; |
| 4253 if (WasContextLost()) { |
| 4254 DLOG(ERROR) << " GLES2DecoderImpl: Trying to release lost context."; |
| 4255 return; |
| 4256 } |
| 4257 context_->ReleaseCurrent(surface_.get()); |
| 4258 surface_ = nullptr; |
| 4259 } |
| 4260 |
4248 void GLES2DecoderImpl::ProduceFrontBuffer(const Mailbox& mailbox) { | 4261 void GLES2DecoderImpl::ProduceFrontBuffer(const Mailbox& mailbox) { |
4249 if (!offscreen_saved_color_texture_.get()) { | 4262 if (!offscreen_saved_color_texture_.get()) { |
4250 LOG(ERROR) << "Called ProduceFrontBuffer on a non-offscreen context"; | 4263 LOG(ERROR) << "Called ProduceFrontBuffer on a non-offscreen context"; |
4251 return; | 4264 return; |
4252 } | 4265 } |
4253 if (!offscreen_saved_color_texture_info_.get()) { | 4266 if (!offscreen_saved_color_texture_info_.get()) { |
4254 GLuint service_id = offscreen_saved_color_texture_->id(); | 4267 GLuint service_id = offscreen_saved_color_texture_->id(); |
4255 offscreen_saved_color_texture_info_ = TextureRef::Create( | 4268 offscreen_saved_color_texture_info_ = TextureRef::Create( |
4256 texture_manager(), 0, service_id); | 4269 texture_manager(), 0, service_id); |
4257 texture_manager()->SetTarget(offscreen_saved_color_texture_info_.get(), | 4270 texture_manager()->SetTarget(offscreen_saved_color_texture_info_.get(), |
(...skipping 12119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16377 } | 16390 } |
16378 | 16391 |
16379 // Include the auto-generated part of this file. We split this because it means | 16392 // Include the auto-generated part of this file. We split this because it means |
16380 // we can easily edit the non-auto generated parts right here in this file | 16393 // we can easily edit the non-auto generated parts right here in this file |
16381 // instead of having to edit some template or the code generator. | 16394 // instead of having to edit some template or the code generator. |
16382 #include "base/macros.h" | 16395 #include "base/macros.h" |
16383 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 16396 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
16384 | 16397 |
16385 } // namespace gles2 | 16398 } // namespace gles2 |
16386 } // namespace gpu | 16399 } // namespace gpu |
OLD | NEW |