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; | |
598 void ProduceFrontBuffer(const Mailbox& mailbox) override; | 597 void ProduceFrontBuffer(const Mailbox& mailbox) override; |
599 bool ResizeOffscreenFrameBuffer(const gfx::Size& size) override; | 598 bool ResizeOffscreenFrameBuffer(const gfx::Size& size) override; |
600 void UpdateParentTextureInfo(); | 599 void UpdateParentTextureInfo(); |
601 bool MakeCurrent() override; | 600 bool MakeCurrent() override; |
602 GLES2Util* GetGLES2Util() override { return &util_; } | 601 GLES2Util* GetGLES2Util() override { return &util_; } |
603 gfx::GLContext* GetGLContext() override { return context_.get(); } | 602 gfx::GLContext* GetGLContext() override { return context_.get(); } |
604 ContextGroup* GetContextGroup() override { return group_.get(); } | 603 ContextGroup* GetContextGroup() override { return group_.get(); } |
605 Capabilities GetCapabilities() override; | 604 Capabilities GetCapabilities() override; |
606 void RestoreState(const ContextState* prev_state) override; | 605 void RestoreState(const ContextState* prev_state) override; |
607 | 606 |
(...skipping 3092 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3700 state_.UnbindSampler(sampler); | 3699 state_.UnbindSampler(sampler); |
3701 | 3700 |
3702 RemoveSampler(client_ids[ii]); | 3701 RemoveSampler(client_ids[ii]); |
3703 } | 3702 } |
3704 } | 3703 } |
3705 } | 3704 } |
3706 | 3705 |
3707 // } // anonymous namespace | 3706 // } // anonymous namespace |
3708 | 3707 |
3709 bool GLES2DecoderImpl::MakeCurrent() { | 3708 bool GLES2DecoderImpl::MakeCurrent() { |
3710 DCHECK(surface_); | |
3711 if (!context_.get()) | 3709 if (!context_.get()) |
3712 return false; | 3710 return false; |
3713 | 3711 |
3714 if (WasContextLost()) { | 3712 if (WasContextLost()) { |
3715 LOG(ERROR) << " GLES2DecoderImpl: Trying to make lost context current."; | 3713 LOG(ERROR) << " GLES2DecoderImpl: Trying to make lost context current."; |
3716 return false; | 3714 return false; |
3717 } | 3715 } |
3718 | 3716 |
3719 if (!context_->MakeCurrent(surface_.get())) { | 3717 if (!context_->MakeCurrent(surface_.get())) { |
3720 LOG(ERROR) << " GLES2DecoderImpl: Context lost during MakeCurrent."; | 3718 LOG(ERROR) << " GLES2DecoderImpl: Context lost during MakeCurrent."; |
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4258 it != texture_to_io_surface_map_.end(); ++it) { | 4256 it != texture_to_io_surface_map_.end(); ++it) { |
4259 CFRelease(it->second); | 4257 CFRelease(it->second); |
4260 } | 4258 } |
4261 texture_to_io_surface_map_.clear(); | 4259 texture_to_io_surface_map_.clear(); |
4262 #endif | 4260 #endif |
4263 } | 4261 } |
4264 | 4262 |
4265 void GLES2DecoderImpl::SetSurface( | 4263 void GLES2DecoderImpl::SetSurface( |
4266 const scoped_refptr<gfx::GLSurface>& surface) { | 4264 const scoped_refptr<gfx::GLSurface>& surface) { |
4267 DCHECK(context_->IsCurrent(NULL)); | 4265 DCHECK(context_->IsCurrent(NULL)); |
4268 DCHECK(surface); | 4266 DCHECK(surface_.get()); |
4269 surface_ = surface; | 4267 surface_ = surface; |
4270 RestoreCurrentFramebufferBindings(); | 4268 RestoreCurrentFramebufferBindings(); |
4271 } | 4269 } |
4272 | 4270 |
4273 void GLES2DecoderImpl::ReleaseSurface() { | |
4274 if (!context_.get()) | |
4275 return; | |
4276 if (WasContextLost()) { | |
4277 DLOG(ERROR) << " GLES2DecoderImpl: Trying to release lost context."; | |
4278 return; | |
4279 } | |
4280 context_->ReleaseCurrent(surface_.get()); | |
4281 surface_ = nullptr; | |
4282 } | |
4283 | |
4284 void GLES2DecoderImpl::ProduceFrontBuffer(const Mailbox& mailbox) { | 4271 void GLES2DecoderImpl::ProduceFrontBuffer(const Mailbox& mailbox) { |
4285 if (!offscreen_saved_color_texture_.get()) { | 4272 if (!offscreen_saved_color_texture_.get()) { |
4286 LOG(ERROR) << "Called ProduceFrontBuffer on a non-offscreen context"; | 4273 LOG(ERROR) << "Called ProduceFrontBuffer on a non-offscreen context"; |
4287 return; | 4274 return; |
4288 } | 4275 } |
4289 if (!offscreen_saved_color_texture_info_.get()) { | 4276 if (!offscreen_saved_color_texture_info_.get()) { |
4290 GLuint service_id = offscreen_saved_color_texture_->id(); | 4277 GLuint service_id = offscreen_saved_color_texture_->id(); |
4291 offscreen_saved_color_texture_info_ = TextureRef::Create( | 4278 offscreen_saved_color_texture_info_ = TextureRef::Create( |
4292 texture_manager(), 0, service_id); | 4279 texture_manager(), 0, service_id); |
4293 texture_manager()->SetTarget(offscreen_saved_color_texture_info_.get(), | 4280 texture_manager()->SetTarget(offscreen_saved_color_texture_info_.get(), |
(...skipping 12211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16505 } | 16492 } |
16506 | 16493 |
16507 // Include the auto-generated part of this file. We split this because it means | 16494 // Include the auto-generated part of this file. We split this because it means |
16508 // we can easily edit the non-auto generated parts right here in this file | 16495 // we can easily edit the non-auto generated parts right here in this file |
16509 // instead of having to edit some template or the code generator. | 16496 // instead of having to edit some template or the code generator. |
16510 #include "base/macros.h" | 16497 #include "base/macros.h" |
16511 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 16498 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
16512 | 16499 |
16513 } // namespace gles2 | 16500 } // namespace gles2 |
16514 } // namespace gpu | 16501 } // namespace gpu |
OLD | NEW |