| 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 // This file contains the ContextState class. | 5 // This file contains the ContextState class. |
| 6 | 6 |
| 7 #ifndef GPU_COMMAND_BUFFER_SERVICE_CONTEXT_STATE_H_ | 7 #ifndef GPU_COMMAND_BUFFER_SERVICE_CONTEXT_STATE_H_ |
| 8 #define GPU_COMMAND_BUFFER_SERVICE_CONTEXT_STATE_H_ | 8 #define GPU_COMMAND_BUFFER_SERVICE_CONTEXT_STATE_H_ |
| 9 | 9 |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 | 29 |
| 30 // State associated with each texture unit. | 30 // State associated with each texture unit. |
| 31 struct GPU_EXPORT TextureUnit { | 31 struct GPU_EXPORT TextureUnit { |
| 32 TextureUnit(); | 32 TextureUnit(); |
| 33 ~TextureUnit(); | 33 ~TextureUnit(); |
| 34 | 34 |
| 35 // The last target that was bound to this texture unit. | 35 // The last target that was bound to this texture unit. |
| 36 GLenum bind_target; | 36 GLenum bind_target; |
| 37 | 37 |
| 38 // texture currently bound to this unit's GL_TEXTURE_2D with glBindTexture | 38 // texture currently bound to this unit's GL_TEXTURE_2D with glBindTexture |
| 39 scoped_refptr<Texture> bound_texture_2d; | 39 scoped_refptr<TextureRef> bound_texture_2d; |
| 40 | 40 |
| 41 // texture currently bound to this unit's GL_TEXTURE_CUBE_MAP with | 41 // texture currently bound to this unit's GL_TEXTURE_CUBE_MAP with |
| 42 // glBindTexture | 42 // glBindTexture |
| 43 scoped_refptr<Texture> bound_texture_cube_map; | 43 scoped_refptr<TextureRef> bound_texture_cube_map; |
| 44 | 44 |
| 45 // texture currently bound to this unit's GL_TEXTURE_EXTERNAL_OES with | 45 // texture currently bound to this unit's GL_TEXTURE_EXTERNAL_OES with |
| 46 // glBindTexture | 46 // glBindTexture |
| 47 scoped_refptr<Texture> bound_texture_external_oes; | 47 scoped_refptr<TextureRef> bound_texture_external_oes; |
| 48 | 48 |
| 49 // texture currently bound to this unit's GL_TEXTURE_RECTANGLE_ARB with | 49 // texture currently bound to this unit's GL_TEXTURE_RECTANGLE_ARB with |
| 50 // glBindTexture | 50 // glBindTexture |
| 51 scoped_refptr<Texture> bound_texture_rectangle_arb; | 51 scoped_refptr<TextureRef> bound_texture_rectangle_arb; |
| 52 | 52 |
| 53 scoped_refptr<Texture> GetInfoForSamplerType( | 53 scoped_refptr<TextureRef> GetInfoForSamplerType( |
| 54 GLenum type) { | 54 GLenum type) { |
| 55 DCHECK(type == GL_SAMPLER_2D || type == GL_SAMPLER_CUBE || | 55 DCHECK(type == GL_SAMPLER_2D || type == GL_SAMPLER_CUBE || |
| 56 type == GL_SAMPLER_EXTERNAL_OES || type == GL_SAMPLER_2D_RECT_ARB); | 56 type == GL_SAMPLER_EXTERNAL_OES || type == GL_SAMPLER_2D_RECT_ARB); |
| 57 switch (type) { | 57 switch (type) { |
| 58 case GL_SAMPLER_2D: | 58 case GL_SAMPLER_2D: |
| 59 return bound_texture_2d; | 59 return bound_texture_2d; |
| 60 case GL_SAMPLER_CUBE: | 60 case GL_SAMPLER_CUBE: |
| 61 return bound_texture_cube_map; | 61 return bound_texture_cube_map; |
| 62 case GL_SAMPLER_EXTERNAL_OES: | 62 case GL_SAMPLER_EXTERNAL_OES: |
| 63 return bound_texture_external_oes; | 63 return bound_texture_external_oes; |
| 64 case GL_SAMPLER_2D_RECT_ARB: | 64 case GL_SAMPLER_2D_RECT_ARB: |
| 65 return bound_texture_rectangle_arb; | 65 return bound_texture_rectangle_arb; |
| 66 } | 66 } |
| 67 | 67 |
| 68 NOTREACHED(); | 68 NOTREACHED(); |
| 69 return NULL; | 69 return NULL; |
| 70 } | 70 } |
| 71 | 71 |
| 72 void Unbind(Texture* texture) { | 72 void Unbind(TextureRef* texture) { |
| 73 if (bound_texture_2d == texture) { | 73 if (bound_texture_2d == texture) { |
| 74 bound_texture_2d = NULL; | 74 bound_texture_2d = NULL; |
| 75 } | 75 } |
| 76 if (bound_texture_cube_map == texture) { | 76 if (bound_texture_cube_map == texture) { |
| 77 bound_texture_cube_map = NULL; | 77 bound_texture_cube_map = NULL; |
| 78 } | 78 } |
| 79 if (bound_texture_external_oes == texture) { | 79 if (bound_texture_external_oes == texture) { |
| 80 bound_texture_external_oes = NULL; | 80 bound_texture_external_oes = NULL; |
| 81 } | 81 } |
| 82 } | 82 } |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 | 170 |
| 171 private: | 171 private: |
| 172 scoped_ptr<ErrorState> error_state_; | 172 scoped_ptr<ErrorState> error_state_; |
| 173 }; | 173 }; |
| 174 | 174 |
| 175 } // namespace gles2 | 175 } // namespace gles2 |
| 176 } // namespace gpu | 176 } // namespace gpu |
| 177 | 177 |
| 178 #endif // GPU_COMMAND_BUFFER_SERVICE_CONTEXT_STATE_H_ | 178 #endif // GPU_COMMAND_BUFFER_SERVICE_CONTEXT_STATE_H_ |
| 179 | 179 |
| OLD | NEW |