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