Chromium Code Reviews| 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 #ifndef UI_GL_SCOPED_BINDERS_H_ | 5 #ifndef UI_GL_SCOPED_BINDERS_H_ |
| 6 #define UI_GL_SCOPED_BINDERS_H_ | 6 #define UI_GL_SCOPED_BINDERS_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "ui/gl/gl_export.h" | 9 #include "ui/gl/gl_export.h" |
| 10 | 10 |
| 11 namespace gfx { | 11 namespace gfx { |
| 12 class GLStateRestorer; | 12 class GLStateRestorer; |
| 13 | 13 |
| 14 class GL_EXPORT ScopedFrameBufferBinder { | 14 class GL_EXPORT ScopedFrameBufferBinder { |
| 15 public: | 15 public: |
| 16 explicit ScopedFrameBufferBinder(unsigned int fbo); | 16 explicit ScopedFrameBufferBinder(unsigned int fbo); |
| 17 ~ScopedFrameBufferBinder(); | 17 ~ScopedFrameBufferBinder(); |
| 18 | 18 |
| 19 private: | 19 private: |
| 20 // Whenever possible we prefer to use the current GLContext's | 20 // Whenever possible we prefer to use the current GLContext's |
| 21 // GLStateRestorer to maximize driver compabitility. | 21 // GLStateRestorer to maximize driver compabitility. |
| 22 GLStateRestorer* state_restorer_; | 22 GLStateRestorer* state_restorer_; |
| 23 | 23 |
| 24 // Failing that we use GL calls to save and restore state. | 24 // Failing that we use GL calls to save and restore state. |
| 25 int old_fbo_; | 25 int old_fbo_; |
| 26 | 26 |
| 27 DISALLOW_COPY_AND_ASSIGN(ScopedFrameBufferBinder); | 27 DISALLOW_COPY_AND_ASSIGN(ScopedFrameBufferBinder); |
| 28 }; | 28 }; |
| 29 | 29 |
| 30 class GL_EXPORT ScopedActiveTexture { | |
| 31 public: | |
| 32 ScopedActiveTexture(unsigned int texture); | |
| 33 ~ScopedActiveTexture(); | |
| 34 | |
| 35 private: | |
| 36 // TODO(dcastagna): Use GLStateRestorer. | |
| 37 int old_texture_; | |
|
reveman
2015/11/01 14:19:05
nit: blankline before DISALLOW_COP..
Daniele Castagna
2015/11/01 21:55:31
Done.
| |
| 38 DISALLOW_COPY_AND_ASSIGN(ScopedActiveTexture); | |
| 39 }; | |
| 30 | 40 |
| 31 class GL_EXPORT ScopedTextureBinder { | 41 class GL_EXPORT ScopedTextureBinder { |
| 32 public: | 42 public: |
| 33 ScopedTextureBinder(unsigned int target, unsigned int id); | 43 ScopedTextureBinder(unsigned int target, unsigned int id); |
| 34 ~ScopedTextureBinder(); | 44 ~ScopedTextureBinder(); |
| 35 | 45 |
| 36 private: | 46 private: |
| 37 // Whenever possible we prefer to use the current GLContext's | 47 // Whenever possible we prefer to use the current GLContext's |
| 38 // GLStateRestorer to maximize driver compabitility. | 48 // GLStateRestorer to maximize driver compabitility. |
| 39 GLStateRestorer* state_restorer_; | 49 GLStateRestorer* state_restorer_; |
| 40 | 50 |
| 41 // Failing that we use GL calls to save and restore state. | 51 // Failing that we use GL calls to save and restore state. |
| 42 int target_; | 52 int target_; |
| 43 int old_id_; | 53 int old_id_; |
| 44 | 54 |
| 45 DISALLOW_COPY_AND_ASSIGN(ScopedTextureBinder); | 55 DISALLOW_COPY_AND_ASSIGN(ScopedTextureBinder); |
| 46 }; | 56 }; |
| 47 | 57 |
| 58 class GL_EXPORT ScopedUseProgram { | |
| 59 public: | |
| 60 ScopedUseProgram(unsigned int program); | |
| 61 ~ScopedUseProgram(); | |
| 62 | |
| 63 private: | |
| 64 // TODO(dcastagna): Use GLStateRestorer. | |
| 65 int old_program_; | |
| 66 | |
| 67 DISALLOW_COPY_AND_ASSIGN(ScopedUseProgram); | |
| 68 }; | |
| 69 | |
| 70 class GL_EXPORT ScopedEnableVertexAttribArray { | |
| 71 public: | |
| 72 ScopedEnableVertexAttribArray(unsigned int index); | |
| 73 ~ScopedEnableVertexAttribArray(); | |
| 74 | |
| 75 private: | |
| 76 // TODO(dcastagna): Use GLStateRestorer. | |
| 77 int enabled_; | |
| 78 int index_; | |
| 79 | |
| 80 DISALLOW_COPY_AND_ASSIGN(ScopedEnableVertexAttribArray); | |
| 81 }; | |
| 82 | |
| 83 class GL_EXPORT ScopedBufferBinder { | |
| 84 public: | |
| 85 ScopedBufferBinder(unsigned int target, unsigned int index); | |
| 86 ~ScopedBufferBinder(); | |
| 87 | |
| 88 private: | |
| 89 // TODO(dcastagna): Use GLStateRestorer. | |
| 90 int target_; | |
| 91 int old_id_; | |
| 92 | |
| 93 DISALLOW_COPY_AND_ASSIGN(ScopedBufferBinder); | |
| 94 }; | |
| 95 | |
| 96 class GL_EXPORT ScopedViewport { | |
| 97 public: | |
| 98 ScopedViewport(int x, int y, int width, int height); | |
| 99 ~ScopedViewport(); | |
| 100 | |
| 101 private: | |
| 102 int data_[4] = {}; | |
| 103 DISALLOW_COPY_AND_ASSIGN(ScopedViewport); | |
|
reveman
2015/11/01 14:19:05
nit: blankline before DISALLOW_COP..
Daniele Castagna
2015/11/01 21:55:31
Done.
| |
| 104 }; | |
| 105 | |
| 48 } // namespace gfx | 106 } // namespace gfx |
| 49 | 107 |
| 50 #endif // UI_GL_SCOPED_BINDERS_H_ | 108 #endif // UI_GL_SCOPED_BINDERS_H_ |
| OLD | NEW |