OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_ | 5 #ifndef GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_ |
6 #define GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_ | 6 #define GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <vector> | 9 #include <vector> |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
(...skipping 21 matching lines...) Expand all Loading... |
33 : service_id_(service_id), | 33 : service_id_(service_id), |
34 deleted_(false), | 34 deleted_(false), |
35 target_(0), | 35 target_(0), |
36 min_filter_(GL_NEAREST_MIPMAP_LINEAR), | 36 min_filter_(GL_NEAREST_MIPMAP_LINEAR), |
37 mag_filter_(GL_LINEAR), | 37 mag_filter_(GL_LINEAR), |
38 wrap_s_(GL_REPEAT), | 38 wrap_s_(GL_REPEAT), |
39 wrap_t_(GL_REPEAT), | 39 wrap_t_(GL_REPEAT), |
40 max_level_set_(-1), | 40 max_level_set_(-1), |
41 texture_complete_(false), | 41 texture_complete_(false), |
42 cube_complete_(false), | 42 cube_complete_(false), |
43 npot_(false) { | 43 npot_(false), |
| 44 owned_(true) { |
44 } | 45 } |
45 | 46 |
46 // True if this texture meets all the GLES2 criteria for rendering. | 47 // True if this texture meets all the GLES2 criteria for rendering. |
47 // See section 3.8.2 of the GLES2 spec. | 48 // See section 3.8.2 of the GLES2 spec. |
48 bool CanRender(const FeatureInfo* feature_info) const; | 49 bool CanRender(const FeatureInfo* feature_info) const; |
49 | 50 |
50 // The service side OpenGL id of the texture. | 51 // The service side OpenGL id of the texture. |
51 GLuint service_id() const { | 52 GLuint service_id() const { |
52 return service_id_; | 53 return service_id_; |
53 } | 54 } |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 GLint yoffset, | 103 GLint yoffset, |
103 GLsizei width, | 104 GLsizei width, |
104 GLsizei height, | 105 GLsizei height, |
105 GLenum format, | 106 GLenum format, |
106 GLenum type) const; | 107 GLenum type) const; |
107 | 108 |
108 bool IsValid() const { | 109 bool IsValid() const { |
109 return target() && !IsDeleted(); | 110 return target() && !IsDeleted(); |
110 } | 111 } |
111 | 112 |
| 113 void SetNotOwned() { |
| 114 owned_ = false; |
| 115 } |
| 116 |
112 private: | 117 private: |
113 friend class TextureManager; | 118 friend class TextureManager; |
114 friend class base::RefCounted<TextureInfo>; | 119 friend class base::RefCounted<TextureInfo>; |
115 | 120 |
116 ~TextureInfo() { } | 121 ~TextureInfo() { } |
117 | 122 |
118 struct LevelInfo { | 123 struct LevelInfo { |
119 LevelInfo() | 124 LevelInfo() |
120 : valid(false), | 125 : valid(false), |
121 internal_format(0), | 126 internal_format(0), |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 | 215 |
211 // Whether or not this texture is "cube complete" | 216 // Whether or not this texture is "cube complete" |
212 bool cube_complete_; | 217 bool cube_complete_; |
213 | 218 |
214 // Whether or not this texture is non-power-of-two | 219 // Whether or not this texture is non-power-of-two |
215 bool npot_; | 220 bool npot_; |
216 | 221 |
217 // Whether this texture has ever been bound. | 222 // Whether this texture has ever been bound. |
218 bool has_been_bound_; | 223 bool has_been_bound_; |
219 | 224 |
| 225 // Whether the associated context group owns this texture and should delete |
| 226 // it. |
| 227 bool owned_; |
| 228 |
220 DISALLOW_COPY_AND_ASSIGN(TextureInfo); | 229 DISALLOW_COPY_AND_ASSIGN(TextureInfo); |
221 }; | 230 }; |
222 | 231 |
223 TextureManager(GLsizei max_texture_size, | 232 TextureManager(GLsizei max_texture_size, |
224 GLsizei max_cube_map_texture_size); | 233 GLsizei max_cube_map_texture_size); |
225 ~TextureManager(); | 234 ~TextureManager(); |
226 | 235 |
227 // Init the texture manager. | 236 // Init the texture manager. |
228 bool Initialize(); | 237 bool Initialize(); |
229 | 238 |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 TextureInfo::Ref default_texture_2d_; | 341 TextureInfo::Ref default_texture_2d_; |
333 TextureInfo::Ref default_texture_cube_map_; | 342 TextureInfo::Ref default_texture_cube_map_; |
334 | 343 |
335 DISALLOW_COPY_AND_ASSIGN(TextureManager); | 344 DISALLOW_COPY_AND_ASSIGN(TextureManager); |
336 }; | 345 }; |
337 | 346 |
338 } // namespace gles2 | 347 } // namespace gles2 |
339 } // namespace gpu | 348 } // namespace gpu |
340 | 349 |
341 #endif // GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_ | 350 #endif // GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_ |
OLD | NEW |