| 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 "ui/gl/scoped_binders.h" | 5 #include "ui/gl/scoped_binders.h" |
| 6 #include "ui/gl/gl_bindings.h" | 6 #include "ui/gl/gl_bindings.h" |
| 7 #include "ui/gl/gl_context.h" | 7 #include "ui/gl/gl_context.h" |
| 8 #include "ui/gl/gl_state_restorer.h" | 8 #include "ui/gl/gl_state_restorer.h" |
| 9 | 9 |
| 10 namespace gl { | 10 namespace gl { |
| 11 | 11 |
| 12 ScopedFrameBufferBinder::ScopedFrameBufferBinder(unsigned int fbo) | 12 ScopedFramebufferBinder::ScopedFramebufferBinder(unsigned int fbo) |
| 13 : state_restorer_(!GLContext::GetCurrent() | 13 : state_restorer_(!GLContext::GetCurrent() |
| 14 ? NULL | 14 ? NULL |
| 15 : GLContext::GetCurrent()->GetGLStateRestorer()), | 15 : GLContext::GetCurrent()->GetGLStateRestorer()), |
| 16 old_fbo_(-1) { | 16 old_fbo_(-1) { |
| 17 if (!state_restorer_) | 17 if (!state_restorer_) |
| 18 glGetIntegerv(GL_FRAMEBUFFER_BINDING, &old_fbo_); | 18 glGetIntegerv(GL_FRAMEBUFFER_BINDING, &old_fbo_); |
| 19 glBindFramebufferEXT(GL_FRAMEBUFFER, fbo); | 19 glBindFramebufferEXT(GL_FRAMEBUFFER, fbo); |
| 20 } | 20 } |
| 21 | 21 |
| 22 ScopedFrameBufferBinder::~ScopedFrameBufferBinder() { | 22 ScopedFramebufferBinder::~ScopedFramebufferBinder() { |
| 23 if (state_restorer_) { | 23 if (state_restorer_) { |
| 24 DCHECK(!!GLContext::GetCurrent()); | 24 DCHECK(!!GLContext::GetCurrent()); |
| 25 DCHECK_EQ(state_restorer_, GLContext::GetCurrent()->GetGLStateRestorer()); | 25 DCHECK_EQ(state_restorer_, GLContext::GetCurrent()->GetGLStateRestorer()); |
| 26 state_restorer_->RestoreFramebufferBindings(); | 26 state_restorer_->RestoreFramebufferBindings(); |
| 27 } else { | 27 } else { |
| 28 glBindFramebufferEXT(GL_FRAMEBUFFER, old_fbo_); | 28 glBindFramebufferEXT(GL_FRAMEBUFFER, old_fbo_); |
| 29 } | 29 } |
| 30 } | 30 } |
| 31 | 31 |
| 32 ScopedActiveTexture::ScopedActiveTexture(unsigned int texture) | 32 ScopedActiveTexture::ScopedActiveTexture(unsigned int texture) |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 | 170 |
| 171 ScopedCapability::~ScopedCapability() { | 171 ScopedCapability::~ScopedCapability() { |
| 172 if (enabled_ == GL_TRUE) { | 172 if (enabled_ == GL_TRUE) { |
| 173 glEnable(capability_); | 173 glEnable(capability_); |
| 174 } else { | 174 } else { |
| 175 glDisable(capability_); | 175 glDisable(capability_); |
| 176 } | 176 } |
| 177 } | 177 } |
| 178 | 178 |
| 179 } // namespace gl | 179 } // namespace gl |
| OLD | NEW |