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/macros.h" | 8 #include "base/macros.h" |
9 #include "ui/gl/gl_export.h" | 9 #include "ui/gl/gl_export.h" |
10 | 10 |
(...skipping 15 matching lines...) Expand all Loading... |
26 | 26 |
27 DISALLOW_COPY_AND_ASSIGN(ScopedFramebufferBinder); | 27 DISALLOW_COPY_AND_ASSIGN(ScopedFramebufferBinder); |
28 }; | 28 }; |
29 | 29 |
30 class GL_EXPORT ScopedActiveTexture { | 30 class GL_EXPORT ScopedActiveTexture { |
31 public: | 31 public: |
32 ScopedActiveTexture(unsigned int texture); | 32 ScopedActiveTexture(unsigned int texture); |
33 ~ScopedActiveTexture(); | 33 ~ScopedActiveTexture(); |
34 | 34 |
35 private: | 35 private: |
36 // TODO(dcastagna): Use GLStateRestorer. | 36 // Whenever possible we prefer to use the current GLContext's |
| 37 // GLStateRestorer to maximize driver compabitility. |
| 38 GLStateRestorer* state_restorer_; |
| 39 |
| 40 // Failing that we use GL calls to save and restore state. |
37 int old_texture_; | 41 int old_texture_; |
38 | 42 |
39 DISALLOW_COPY_AND_ASSIGN(ScopedActiveTexture); | 43 DISALLOW_COPY_AND_ASSIGN(ScopedActiveTexture); |
40 }; | 44 }; |
41 | 45 |
42 class GL_EXPORT ScopedTextureBinder { | 46 class GL_EXPORT ScopedTextureBinder { |
43 public: | 47 public: |
44 ScopedTextureBinder(unsigned int target, unsigned int id); | 48 ScopedTextureBinder(unsigned int target, unsigned int id); |
45 ~ScopedTextureBinder(); | 49 ~ScopedTextureBinder(); |
46 | 50 |
47 private: | 51 private: |
48 // Whenever possible we prefer to use the current GLContext's | 52 // Whenever possible we prefer to use the current GLContext's |
49 // GLStateRestorer to maximize driver compabitility. | 53 // GLStateRestorer to maximize driver compabitility. |
50 GLStateRestorer* state_restorer_; | 54 GLStateRestorer* state_restorer_; |
51 | 55 |
52 // Failing that we use GL calls to save and restore state. | 56 // Failing that we use GL calls to save and restore state. |
53 int target_; | 57 int target_; |
54 int old_id_; | 58 int old_id_; |
55 | 59 |
56 DISALLOW_COPY_AND_ASSIGN(ScopedTextureBinder); | 60 DISALLOW_COPY_AND_ASSIGN(ScopedTextureBinder); |
57 }; | 61 }; |
58 | 62 |
59 class GL_EXPORT ScopedUseProgram { | 63 class GL_EXPORT ScopedUseProgram { |
60 public: | 64 public: |
61 ScopedUseProgram(unsigned int program); | 65 ScopedUseProgram(unsigned int program); |
62 ~ScopedUseProgram(); | 66 ~ScopedUseProgram(); |
63 | 67 |
64 private: | 68 private: |
65 // TODO(dcastagna): Use GLStateRestorer. | 69 // Whenever possible we prefer to use the current GLContext's |
| 70 // GLStateRestorer to maximize driver compabitility. |
| 71 GLStateRestorer* state_restorer_; |
| 72 |
| 73 // Failing that we use GL calls to save and restore state. |
66 int old_program_; | 74 int old_program_; |
67 | 75 |
68 DISALLOW_COPY_AND_ASSIGN(ScopedUseProgram); | 76 DISALLOW_COPY_AND_ASSIGN(ScopedUseProgram); |
69 }; | 77 }; |
70 | 78 |
71 class GL_EXPORT ScopedVertexAttribArray { | 79 class GL_EXPORT ScopedVertexAttribArray { |
72 public: | 80 public: |
73 ScopedVertexAttribArray(unsigned int index, | 81 ScopedVertexAttribArray(unsigned int index, |
74 int size, | 82 int size, |
75 unsigned int type, | 83 unsigned int type, |
76 char normalized, | 84 char normalized, |
77 int stride, | 85 int stride, |
78 const void* pointer); | 86 const void* pointer); |
79 ~ScopedVertexAttribArray(); | 87 ~ScopedVertexAttribArray(); |
80 | 88 |
81 private: | 89 private: |
82 // TODO(dcastagna): Use GLStateRestorer. | 90 // Whenever possible we prefer to use the current GLContext's |
| 91 // GLStateRestorer to maximize driver compabitility. |
| 92 GLStateRestorer* state_restorer_; |
| 93 |
| 94 // Failing that we use GL calls to save and restore state. |
83 int buffer_; | 95 int buffer_; |
84 int enabled_; | 96 int enabled_; |
85 int index_; | 97 int index_; |
86 int size_; | 98 int size_; |
87 int type_; | 99 int type_; |
88 int normalized_; | 100 int normalized_; |
89 int stride_; | 101 int stride_; |
90 void* pointer_; | 102 void* pointer_; |
91 | 103 |
92 DISALLOW_COPY_AND_ASSIGN(ScopedVertexAttribArray); | 104 DISALLOW_COPY_AND_ASSIGN(ScopedVertexAttribArray); |
93 }; | 105 }; |
94 | 106 |
95 class GL_EXPORT ScopedBufferBinder { | 107 class GL_EXPORT ScopedBufferBinder { |
96 public: | 108 public: |
97 ScopedBufferBinder(unsigned int target, unsigned int index); | 109 ScopedBufferBinder(unsigned int target, unsigned int index); |
98 ~ScopedBufferBinder(); | 110 ~ScopedBufferBinder(); |
99 | 111 |
100 private: | 112 private: |
101 // TODO(dcastagna): Use GLStateRestorer. | 113 // Whenever possible we prefer to use the current GLContext's |
| 114 // GLStateRestorer to maximize driver compabitility. |
| 115 GLStateRestorer* state_restorer_; |
| 116 |
| 117 // Failing that we use GL calls to save and restore state. |
102 int target_; | 118 int target_; |
103 int old_id_; | 119 int old_id_; |
104 | 120 |
105 DISALLOW_COPY_AND_ASSIGN(ScopedBufferBinder); | 121 DISALLOW_COPY_AND_ASSIGN(ScopedBufferBinder); |
106 }; | 122 }; |
107 | 123 |
108 class GL_EXPORT ScopedViewport { | 124 class GL_EXPORT ScopedViewport { |
109 public: | 125 public: |
110 ScopedViewport(int x, int y, int width, int height); | 126 ScopedViewport(int x, int y, int width, int height); |
111 ~ScopedViewport(); | 127 ~ScopedViewport(); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 private: | 165 private: |
150 unsigned capability_; | 166 unsigned capability_; |
151 unsigned char enabled_; | 167 unsigned char enabled_; |
152 | 168 |
153 DISALLOW_COPY_AND_ASSIGN(ScopedCapability); | 169 DISALLOW_COPY_AND_ASSIGN(ScopedCapability); |
154 }; | 170 }; |
155 | 171 |
156 } // namespace gl | 172 } // namespace gl |
157 | 173 |
158 #endif // UI_GL_SCOPED_BINDERS_H_ | 174 #endif // UI_GL_SCOPED_BINDERS_H_ |
OLD | NEW |