Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / gpu / command_buffer / service / gl_state_restorer_impl.cc
blobc132ef8ac7a8502ec04edfc42173feecb43d25fa
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.
5 #include "gpu/command_buffer/service/gl_state_restorer_impl.h"
7 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
8 #include "gpu/command_buffer/service/query_manager.h"
10 namespace gpu {
12 GLStateRestorerImpl::GLStateRestorerImpl(
13 base::WeakPtr<gles2::GLES2Decoder> decoder)
14 : decoder_(decoder) {
17 GLStateRestorerImpl::~GLStateRestorerImpl() {
20 bool GLStateRestorerImpl::IsInitialized() {
21 DCHECK(decoder_.get());
22 return decoder_->initialized();
25 void GLStateRestorerImpl::RestoreState(const gfx::GLStateRestorer* prev_state) {
26 DCHECK(decoder_.get());
27 const GLStateRestorerImpl* restorer_impl =
28 static_cast<const GLStateRestorerImpl*>(prev_state);
30 decoder_->RestoreState(
31 restorer_impl ? restorer_impl->GetContextState() : NULL);
34 void GLStateRestorerImpl::RestoreAllTextureUnitBindings() {
35 DCHECK(decoder_.get());
36 decoder_->RestoreAllTextureUnitBindings(NULL);
39 void GLStateRestorerImpl::RestoreActiveTextureUnitBinding(unsigned int target) {
40 DCHECK(decoder_.get());
41 decoder_->RestoreActiveTextureUnitBinding(target);
44 void GLStateRestorerImpl::RestoreFramebufferBindings() {
45 DCHECK(decoder_.get());
46 decoder_->RestoreFramebufferBindings();
49 void GLStateRestorerImpl::PauseQueries() {
50 DCHECK(decoder_.get());
51 decoder_->GetQueryManager()->PauseQueries();
54 void GLStateRestorerImpl::ResumeQueries() {
55 DCHECK(decoder_.get());
56 decoder_->GetQueryManager()->ResumeQueries();
59 const gles2::ContextState* GLStateRestorerImpl::GetContextState() const {
60 DCHECK(decoder_.get());
61 return decoder_->GetContextState();
64 } // namespace gpu