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 3108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3716 state_.UnbindSampler(sampler); | 3715 state_.UnbindSampler(sampler); |
3717 | 3716 |
3718 RemoveSampler(client_ids[ii]); | 3717 RemoveSampler(client_ids[ii]); |
3719 } | 3718 } |
3720 } | 3719 } |
3721 } | 3720 } |
3722 | 3721 |
3723 // } // anonymous namespace | 3722 // } // anonymous namespace |
3724 | 3723 |
3725 bool GLES2DecoderImpl::MakeCurrent() { | 3724 bool GLES2DecoderImpl::MakeCurrent() { |
3726 DCHECK(surface_); | |
3727 if (!context_.get()) | 3725 if (!context_.get()) |
3728 return false; | 3726 return false; |
3729 | 3727 |
3730 if (WasContextLost()) { | 3728 if (WasContextLost()) { |
3731 LOG(ERROR) << " GLES2DecoderImpl: Trying to make lost context current."; | 3729 LOG(ERROR) << " GLES2DecoderImpl: Trying to make lost context current."; |
3732 return false; | 3730 return false; |
3733 } | 3731 } |
3734 | 3732 |
3735 if (!context_->MakeCurrent(surface_.get())) { | 3733 if (!context_->MakeCurrent(surface_.get())) { |
3736 LOG(ERROR) << " GLES2DecoderImpl: Context lost during MakeCurrent."; | 3734 LOG(ERROR) << " GLES2DecoderImpl: Context lost during MakeCurrent."; |
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4274 it != texture_to_io_surface_map_.end(); ++it) { | 4272 it != texture_to_io_surface_map_.end(); ++it) { |
4275 CFRelease(it->second); | 4273 CFRelease(it->second); |
4276 } | 4274 } |
4277 texture_to_io_surface_map_.clear(); | 4275 texture_to_io_surface_map_.clear(); |
4278 #endif | 4276 #endif |
4279 } | 4277 } |
4280 | 4278 |
4281 void GLES2DecoderImpl::SetSurface( | 4279 void GLES2DecoderImpl::SetSurface( |
4282 const scoped_refptr<gfx::GLSurface>& surface) { | 4280 const scoped_refptr<gfx::GLSurface>& surface) { |
4283 DCHECK(context_->IsCurrent(NULL)); | 4281 DCHECK(context_->IsCurrent(NULL)); |
4284 DCHECK(surface); | 4282 DCHECK(surface_.get()); |
4285 surface_ = surface; | 4283 surface_ = surface; |
4286 RestoreCurrentFramebufferBindings(); | 4284 RestoreCurrentFramebufferBindings(); |
4287 } | 4285 } |
4288 | 4286 |
4289 void GLES2DecoderImpl::ReleaseSurface() { | |
4290 if (!context_.get()) | |
4291 return; | |
4292 if (WasContextLost()) { | |
4293 DLOG(ERROR) << " GLES2DecoderImpl: Trying to release lost context."; | |
4294 return; | |
4295 } | |
4296 context_->ReleaseCurrent(surface_.get()); | |
4297 surface_ = nullptr; | |
4298 } | |
4299 | |
4300 void GLES2DecoderImpl::ProduceFrontBuffer(const Mailbox& mailbox) { | 4287 void GLES2DecoderImpl::ProduceFrontBuffer(const Mailbox& mailbox) { |
4301 if (!offscreen_saved_color_texture_.get()) { | 4288 if (!offscreen_saved_color_texture_.get()) { |
4302 LOG(ERROR) << "Called ProduceFrontBuffer on a non-offscreen context"; | 4289 LOG(ERROR) << "Called ProduceFrontBuffer on a non-offscreen context"; |
4303 return; | 4290 return; |
4304 } | 4291 } |
4305 if (!offscreen_saved_color_texture_info_.get()) { | 4292 if (!offscreen_saved_color_texture_info_.get()) { |
4306 GLuint service_id = offscreen_saved_color_texture_->id(); | 4293 GLuint service_id = offscreen_saved_color_texture_->id(); |
4307 offscreen_saved_color_texture_info_ = TextureRef::Create( | 4294 offscreen_saved_color_texture_info_ = TextureRef::Create( |
4308 texture_manager(), 0, service_id); | 4295 texture_manager(), 0, service_id); |
4309 texture_manager()->SetTarget(offscreen_saved_color_texture_info_.get(), | 4296 texture_manager()->SetTarget(offscreen_saved_color_texture_info_.get(), |
(...skipping 12255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16565 } | 16552 } |
16566 | 16553 |
16567 // Include the auto-generated part of this file. We split this because it means | 16554 // Include the auto-generated part of this file. We split this because it means |
16568 // we can easily edit the non-auto generated parts right here in this file | 16555 // we can easily edit the non-auto generated parts right here in this file |
16569 // instead of having to edit some template or the code generator. | 16556 // instead of having to edit some template or the code generator. |
16570 #include "base/macros.h" | 16557 #include "base/macros.h" |
16571 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 16558 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
16572 | 16559 |
16573 } // namespace gles2 | 16560 } // namespace gles2 |
16574 } // namespace gpu | 16561 } // namespace gpu |
OLD | NEW |