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 3 // found in the LICENSE file. 4 5 #include "gpu/command_buffer/service/gl_state_restorer_impl.h" 6 7 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" 8 9 namespace gpu { 10 GLStateRestorerImpl(base::WeakPtr<gles2::GLES2Decoder> decoder)11GLStateRestorerImpl::GLStateRestorerImpl( 12 base::WeakPtr<gles2::GLES2Decoder> decoder) 13 : decoder_(decoder) { 14 } 15 ~GLStateRestorerImpl()16GLStateRestorerImpl::~GLStateRestorerImpl() { 17 } 18 IsInitialized()19bool GLStateRestorerImpl::IsInitialized() { 20 DCHECK(decoder_.get()); 21 return decoder_->initialized(); 22 } 23 RestoreState(const gfx::GLStateRestorer * prev_state)24void GLStateRestorerImpl::RestoreState(const gfx::GLStateRestorer* prev_state) { 25 DCHECK(decoder_.get()); 26 const GLStateRestorerImpl* restorer_impl = 27 static_cast<const GLStateRestorerImpl*>(prev_state); 28 decoder_->RestoreState( 29 restorer_impl ? restorer_impl->GetContextState() : NULL); 30 } 31 RestoreAllTextureUnitBindings()32void GLStateRestorerImpl::RestoreAllTextureUnitBindings() { 33 DCHECK(decoder_.get()); 34 decoder_->RestoreAllTextureUnitBindings(NULL); 35 } 36 RestoreActiveTextureUnitBinding(unsigned int target)37void GLStateRestorerImpl::RestoreActiveTextureUnitBinding(unsigned int target) { 38 DCHECK(decoder_.get()); 39 decoder_->RestoreActiveTextureUnitBinding(target); 40 } 41 RestoreFramebufferBindings()42void GLStateRestorerImpl::RestoreFramebufferBindings() { 43 DCHECK(decoder_.get()); 44 decoder_->RestoreFramebufferBindings(); 45 } 46 GetContextState() const47const gles2::ContextState* GLStateRestorerImpl::GetContextState() const { 48 DCHECK(decoder_.get()); 49 return decoder_->GetContextState(); 50 } 51 52 } // namespace gpu 53