OLD | NEW |
1 // Copyright (c) 2011 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 <vector> | 8 #include <vector> |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/hash_tables.h" | 10 #include "base/hash_tables.h" |
(...skipping 24 matching lines...) Expand all Loading... |
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 has_been_bound_(false), | 44 has_been_bound_(false), |
| 45 framebuffer_attachment_count_(0), |
45 owned_(true) { | 46 owned_(true) { |
46 } | 47 } |
47 | 48 |
48 GLenum min_filter() const { | 49 GLenum min_filter() const { |
49 return min_filter_; | 50 return min_filter_; |
50 } | 51 } |
51 | 52 |
52 GLenum mag_filter() const { | 53 GLenum mag_filter() const { |
53 return mag_filter_; | 54 return mag_filter_; |
54 } | 55 } |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 GLenum type) const; | 125 GLenum type) const; |
125 | 126 |
126 bool IsValid() const { | 127 bool IsValid() const { |
127 return target() && !IsDeleted(); | 128 return target() && !IsDeleted(); |
128 } | 129 } |
129 | 130 |
130 void SetNotOwned() { | 131 void SetNotOwned() { |
131 owned_ = false; | 132 owned_ = false; |
132 } | 133 } |
133 | 134 |
| 135 bool IsAttachedToFramebuffer() const { |
| 136 return framebuffer_attachment_count_ != 0; |
| 137 } |
| 138 |
| 139 void AttachToFramebuffer() { |
| 140 ++framebuffer_attachment_count_; |
| 141 } |
| 142 |
| 143 void DetachFromFramebuffer() { |
| 144 DCHECK(framebuffer_attachment_count_ > 0); |
| 145 --framebuffer_attachment_count_; |
| 146 } |
| 147 |
134 private: | 148 private: |
135 friend class TextureManager; | 149 friend class TextureManager; |
136 friend class base::RefCounted<TextureInfo>; | 150 friend class base::RefCounted<TextureInfo>; |
137 | 151 |
138 ~TextureInfo() { } | 152 ~TextureInfo() { } |
139 | 153 |
140 struct LevelInfo { | 154 struct LevelInfo { |
141 LevelInfo() | 155 LevelInfo() |
142 : valid(false), | 156 : valid(false), |
143 internal_format(0), | 157 internal_format(0), |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 | 247 |
234 // Whether or not this texture is "cube complete" | 248 // Whether or not this texture is "cube complete" |
235 bool cube_complete_; | 249 bool cube_complete_; |
236 | 250 |
237 // Whether or not this texture is non-power-of-two | 251 // Whether or not this texture is non-power-of-two |
238 bool npot_; | 252 bool npot_; |
239 | 253 |
240 // Whether this texture has ever been bound. | 254 // Whether this texture has ever been bound. |
241 bool has_been_bound_; | 255 bool has_been_bound_; |
242 | 256 |
| 257 // The number of framebuffers this texture is attached to. |
| 258 int framebuffer_attachment_count_; |
| 259 |
243 // Whether the associated context group owns this texture and should delete | 260 // Whether the associated context group owns this texture and should delete |
244 // it. | 261 // it. |
245 bool owned_; | 262 bool owned_; |
246 | 263 |
247 DISALLOW_COPY_AND_ASSIGN(TextureInfo); | 264 DISALLOW_COPY_AND_ASSIGN(TextureInfo); |
248 }; | 265 }; |
249 | 266 |
250 TextureManager(GLsizei max_texture_size, | 267 TextureManager(GLsizei max_texture_size, |
251 GLsizei max_cube_map_texture_size); | 268 GLsizei max_cube_map_texture_size); |
252 ~TextureManager(); | 269 ~TextureManager(); |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 TextureInfo::Ref default_texture_2d_; | 375 TextureInfo::Ref default_texture_2d_; |
359 TextureInfo::Ref default_texture_cube_map_; | 376 TextureInfo::Ref default_texture_cube_map_; |
360 | 377 |
361 DISALLOW_COPY_AND_ASSIGN(TextureManager); | 378 DISALLOW_COPY_AND_ASSIGN(TextureManager); |
362 }; | 379 }; |
363 | 380 |
364 } // namespace gles2 | 381 } // namespace gles2 |
365 } // namespace gpu | 382 } // namespace gpu |
366 | 383 |
367 #endif // GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_ | 384 #endif // GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_ |
OLD | NEW |