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 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" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "gpu/command_buffer/service/feature_info.h" | 13 #include "gpu/command_buffer/service/feature_info.h" |
14 #include "gpu/command_buffer/service/gl_utils.h" | 14 #include "gpu/command_buffer/service/gl_utils.h" |
15 #include "gpu/gpu_export.h" | 15 #include "gpu/gpu_export.h" |
16 | 16 |
17 namespace gpu { | 17 namespace gpu { |
18 namespace gles2 { | 18 namespace gles2 { |
19 | 19 |
20 class GLES2Decoder; | 20 class GLES2Decoder; |
| 21 class Display; |
| 22 class TextureDefinition; |
21 | 23 |
22 // This class keeps track of the textures and their sizes so we can do NPOT and | 24 // This class keeps track of the textures and their sizes so we can do NPOT and |
23 // texture complete checking. | 25 // texture complete checking. |
24 // | 26 // |
25 // NOTE: To support shared resources an instance of this class will need to be | 27 // NOTE: To support shared resources an instance of this class will need to be |
26 // shared by multiple GLES2Decoders. | 28 // shared by multiple GLES2Decoders. |
27 class GPU_EXPORT TextureManager { | 29 class GPU_EXPORT TextureManager { |
28 public: | 30 public: |
29 enum DefaultAndBlackTextures { | 31 enum DefaultAndBlackTextures { |
30 kTexture2D, | 32 kTexture2D, |
31 kCubeMap, | 33 kCubeMap, |
32 kExternalOES, | 34 kExternalOES, |
33 kRectangleARB, | 35 kRectangleARB, |
34 kNumDefaultTextures | 36 kNumDefaultTextures |
35 }; | 37 }; |
36 | 38 |
37 // Info about Textures currently in the system. | 39 // Info about Textures currently in the system. |
38 class GPU_EXPORT TextureInfo : public base::RefCounted<TextureInfo> { | 40 class GPU_EXPORT TextureInfo : public base::RefCounted<TextureInfo> { |
39 public: | 41 public: |
40 typedef scoped_refptr<TextureInfo> Ref; | 42 typedef scoped_refptr<TextureInfo> Ref; |
41 | 43 |
42 TextureInfo(TextureManager* manager, GLuint service_id) | 44 TextureInfo(TextureManager* manager, GLuint service_id); |
43 : manager_(manager), | |
44 service_id_(service_id), | |
45 deleted_(false), | |
46 cleared_(true), | |
47 num_uncleared_mips_(0), | |
48 target_(0), | |
49 min_filter_(GL_NEAREST_MIPMAP_LINEAR), | |
50 mag_filter_(GL_LINEAR), | |
51 wrap_s_(GL_REPEAT), | |
52 wrap_t_(GL_REPEAT), | |
53 usage_(GL_NONE), | |
54 max_level_set_(-1), | |
55 texture_complete_(false), | |
56 cube_complete_(false), | |
57 npot_(false), | |
58 has_been_bound_(false), | |
59 framebuffer_attachment_count_(0), | |
60 owned_(true), | |
61 stream_texture_(false), | |
62 immutable_(false), | |
63 estimated_size_(0) { | |
64 if (manager_) { | |
65 manager_->StartTracking(this); | |
66 } | |
67 } | |
68 | 45 |
69 GLenum min_filter() const { | 46 GLenum min_filter() const { |
70 return min_filter_; | 47 return min_filter_; |
71 } | 48 } |
72 | 49 |
73 GLenum mag_filter() const { | 50 GLenum mag_filter() const { |
74 return mag_filter_; | 51 return mag_filter_; |
75 } | 52 } |
76 | 53 |
77 GLenum wrap_s() const { | 54 GLenum wrap_s() const { |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 internal_format(0), | 193 internal_format(0), |
217 width(0), | 194 width(0), |
218 height(0), | 195 height(0), |
219 depth(0), | 196 depth(0), |
220 border(0), | 197 border(0), |
221 format(0), | 198 format(0), |
222 type(0), | 199 type(0), |
223 estimated_size(0) { | 200 estimated_size(0) { |
224 } | 201 } |
225 | 202 |
| 203 LevelInfo(const LevelInfo& rhs) |
| 204 : cleared(rhs.cleared), |
| 205 target(rhs.target), |
| 206 level(rhs.level), |
| 207 internal_format(rhs.internal_format), |
| 208 width(rhs.width), |
| 209 height(rhs.height), |
| 210 depth(rhs.depth), |
| 211 border(rhs.border), |
| 212 format(rhs.format), |
| 213 type(rhs.type), |
| 214 estimated_size(rhs.estimated_size) { |
| 215 } |
| 216 |
226 bool cleared; | 217 bool cleared; |
227 GLenum target; | 218 GLenum target; |
228 GLint level; | 219 GLint level; |
229 GLenum internal_format; | 220 GLenum internal_format; |
230 GLsizei width; | 221 GLsizei width; |
231 GLsizei height; | 222 GLsizei height; |
232 GLsizei depth; | 223 GLsizei depth; |
233 GLint border; | 224 GLint border; |
234 GLenum format; | 225 GLenum format; |
235 GLenum type; | 226 GLenum type; |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 GLint level, | 420 GLint level, |
430 GLenum internal_format, | 421 GLenum internal_format, |
431 GLsizei width, | 422 GLsizei width, |
432 GLsizei height, | 423 GLsizei height, |
433 GLsizei depth, | 424 GLsizei depth, |
434 GLint border, | 425 GLint border, |
435 GLenum format, | 426 GLenum format, |
436 GLenum type, | 427 GLenum type, |
437 bool cleared); | 428 bool cleared); |
438 | 429 |
| 430 // Save the texture definition and leave it undefined. |
| 431 TextureDefinition* Save(TextureInfo* info); |
| 432 |
| 433 // Redefine all the levels from the texture definition. |
| 434 bool Restore(TextureInfo* info, |
| 435 TextureDefinition* definition); |
| 436 |
439 // Sets a mip as cleared. | 437 // Sets a mip as cleared. |
440 void SetLevelCleared(TextureInfo* info, GLenum target, GLint level); | 438 void SetLevelCleared(TextureInfo* info, GLenum target, GLint level); |
441 | 439 |
442 // Sets a texture parameter of a TextureInfo | 440 // Sets a texture parameter of a TextureInfo |
443 // TODO(gman): Expand to SetParameteri,f,iv,fv | 441 // TODO(gman): Expand to SetParameteri,f,iv,fv |
444 bool SetParameter( | 442 bool SetParameter( |
445 TextureInfo* info, GLenum pname, GLint param); | 443 TextureInfo* info, GLenum pname, GLint param); |
446 | 444 |
447 // Makes each of the mip levels as though they were generated. | 445 // Makes each of the mip levels as though they were generated. |
448 // Returns false if that's not allowed for the given texture. | 446 // Returns false if that's not allowed for the given texture. |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
554 // The default textures for each target (texture name = 0) | 552 // The default textures for each target (texture name = 0) |
555 TextureInfo::Ref default_textures_[kNumDefaultTextures]; | 553 TextureInfo::Ref default_textures_[kNumDefaultTextures]; |
556 | 554 |
557 DISALLOW_COPY_AND_ASSIGN(TextureManager); | 555 DISALLOW_COPY_AND_ASSIGN(TextureManager); |
558 }; | 556 }; |
559 | 557 |
560 } // namespace gles2 | 558 } // namespace gles2 |
561 } // namespace gpu | 559 } // namespace gpu |
562 | 560 |
563 #endif // GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_ | 561 #endif // GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_ |
OLD | NEW |