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 3097 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3705 state_.UnbindSampler(sampler); | 3704 state_.UnbindSampler(sampler); |
3706 | 3705 |
3707 RemoveSampler(client_ids[ii]); | 3706 RemoveSampler(client_ids[ii]); |
3708 } | 3707 } |
3709 } | 3708 } |
3710 } | 3709 } |
3711 | 3710 |
3712 // } // anonymous namespace | 3711 // } // anonymous namespace |
3713 | 3712 |
3714 bool GLES2DecoderImpl::MakeCurrent() { | 3713 bool GLES2DecoderImpl::MakeCurrent() { |
3715 DCHECK(surface_); | |
3716 if (!context_.get()) | 3714 if (!context_.get()) |
3717 return false; | 3715 return false; |
3718 | 3716 |
3719 if (WasContextLost()) { | 3717 if (WasContextLost()) { |
3720 LOG(ERROR) << " GLES2DecoderImpl: Trying to make lost context current."; | 3718 LOG(ERROR) << " GLES2DecoderImpl: Trying to make lost context current."; |
3721 return false; | 3719 return false; |
3722 } | 3720 } |
3723 | 3721 |
3724 if (!context_->MakeCurrent(surface_.get())) { | 3722 if (!context_->MakeCurrent(surface_.get())) { |
3725 LOG(ERROR) << " GLES2DecoderImpl: Context lost during MakeCurrent."; | 3723 LOG(ERROR) << " GLES2DecoderImpl: Context lost during MakeCurrent."; |
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4263 it != texture_to_io_surface_map_.end(); ++it) { | 4261 it != texture_to_io_surface_map_.end(); ++it) { |
4264 CFRelease(it->second); | 4262 CFRelease(it->second); |
4265 } | 4263 } |
4266 texture_to_io_surface_map_.clear(); | 4264 texture_to_io_surface_map_.clear(); |
4267 #endif | 4265 #endif |
4268 } | 4266 } |
4269 | 4267 |
4270 void GLES2DecoderImpl::SetSurface( | 4268 void GLES2DecoderImpl::SetSurface( |
4271 const scoped_refptr<gfx::GLSurface>& surface) { | 4269 const scoped_refptr<gfx::GLSurface>& surface) { |
4272 DCHECK(context_->IsCurrent(NULL)); | 4270 DCHECK(context_->IsCurrent(NULL)); |
4273 DCHECK(surface); | 4271 DCHECK(surface_.get()); |
4274 surface_ = surface; | 4272 surface_ = surface; |
4275 RestoreCurrentFramebufferBindings(); | 4273 RestoreCurrentFramebufferBindings(); |
4276 } | 4274 } |
4277 | 4275 |
4278 void GLES2DecoderImpl::ReleaseSurface() { | |
4279 if (!context_.get()) | |
4280 return; | |
4281 if (WasContextLost()) { | |
4282 DLOG(ERROR) << " GLES2DecoderImpl: Trying to release lost context."; | |
4283 return; | |
4284 } | |
4285 context_->ReleaseCurrent(surface_.get()); | |
4286 surface_ = nullptr; | |
4287 } | |
4288 | |
4289 void GLES2DecoderImpl::ProduceFrontBuffer(const Mailbox& mailbox) { | 4276 void GLES2DecoderImpl::ProduceFrontBuffer(const Mailbox& mailbox) { |
4290 if (!offscreen_saved_color_texture_.get()) { | 4277 if (!offscreen_saved_color_texture_.get()) { |
4291 LOG(ERROR) << "Called ProduceFrontBuffer on a non-offscreen context"; | 4278 LOG(ERROR) << "Called ProduceFrontBuffer on a non-offscreen context"; |
4292 return; | 4279 return; |
4293 } | 4280 } |
4294 if (!offscreen_saved_color_texture_info_.get()) { | 4281 if (!offscreen_saved_color_texture_info_.get()) { |
4295 GLuint service_id = offscreen_saved_color_texture_->id(); | 4282 GLuint service_id = offscreen_saved_color_texture_->id(); |
4296 offscreen_saved_color_texture_info_ = TextureRef::Create( | 4283 offscreen_saved_color_texture_info_ = TextureRef::Create( |
4297 texture_manager(), 0, service_id); | 4284 texture_manager(), 0, service_id); |
4298 texture_manager()->SetTarget(offscreen_saved_color_texture_info_.get(), | 4285 texture_manager()->SetTarget(offscreen_saved_color_texture_info_.get(), |
(...skipping 12234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16533 } | 16520 } |
16534 | 16521 |
16535 // Include the auto-generated part of this file. We split this because it means | 16522 // Include the auto-generated part of this file. We split this because it means |
16536 // we can easily edit the non-auto generated parts right here in this file | 16523 // we can easily edit the non-auto generated parts right here in this file |
16537 // instead of having to edit some template or the code generator. | 16524 // instead of having to edit some template or the code generator. |
16538 #include "base/macros.h" | 16525 #include "base/macros.h" |
16539 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 16526 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
16540 | 16527 |
16541 } // namespace gles2 | 16528 } // namespace gles2 |
16542 } // namespace gpu | 16529 } // namespace gpu |
OLD | NEW |