Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(355)

Side by Side Diff: gpu/command_buffer/service/texture_manager.h

Issue 10106015: Allow textures to be moved from one GL context group to another. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 156
180 void DetachFromFramebuffer() { 157 void DetachFromFramebuffer() {
181 DCHECK_GT(framebuffer_attachment_count_, 0); 158 DCHECK_GT(framebuffer_attachment_count_, 0);
182 --framebuffer_attachment_count_; 159 --framebuffer_attachment_count_;
183 } 160 }
184 161
185 void SetStreamTexture(bool stream_texture) { 162 void SetStreamTexture(bool stream_texture) {
186 stream_texture_ = stream_texture; 163 stream_texture_ = stream_texture;
187 } 164 }
188 165
166 bool IsValidForSwap();
167 bool Swap(TextureInfo* other);
168
189 int IsStreamTexture() { 169 int IsStreamTexture() {
190 return stream_texture_; 170 return stream_texture_;
191 } 171 }
192 172
193 void SetImmutable(bool immutable) { 173 void SetImmutable(bool immutable) {
194 DCHECK(!immutable_); 174 DCHECK(!immutable_);
195 immutable_ = immutable; 175 immutable_ = immutable;
196 } 176 }
197 177
198 bool IsImmutable() { 178 bool IsImmutable() {
(...skipping 17 matching lines...) Expand all
216 internal_format(0), 196 internal_format(0),
217 width(0), 197 width(0),
218 height(0), 198 height(0),
219 depth(0), 199 depth(0),
220 border(0), 200 border(0),
221 format(0), 201 format(0),
222 type(0), 202 type(0),
223 estimated_size(0) { 203 estimated_size(0) {
224 } 204 }
225 205
206 LevelInfo(const LevelInfo& rhs)
207 : cleared(rhs.cleared),
208 target(rhs.target),
209 level(rhs.level),
210 internal_format(rhs.internal_format),
211 width(rhs.width),
212 height(rhs.height),
213 depth(rhs.depth),
214 border(rhs.border),
215 format(rhs.format),
216 type(rhs.type),
217 estimated_size(rhs.estimated_size) {
218 }
219
226 bool cleared; 220 bool cleared;
227 GLenum target; 221 GLenum target;
228 GLint level; 222 GLint level;
229 GLenum internal_format; 223 GLenum internal_format;
230 GLsizei width; 224 GLsizei width;
231 GLsizei height; 225 GLsizei height;
232 GLsizei depth; 226 GLsizei depth;
233 GLint border; 227 GLint border;
234 GLenum format; 228 GLenum format;
235 GLenum type; 229 GLenum type;
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 GLint level, 423 GLint level,
430 GLenum internal_format, 424 GLenum internal_format,
431 GLsizei width, 425 GLsizei width,
432 GLsizei height, 426 GLsizei height,
433 GLsizei depth, 427 GLsizei depth,
434 GLint border, 428 GLint border,
435 GLenum format, 429 GLenum format,
436 GLenum type, 430 GLenum type,
437 bool cleared); 431 bool cleared);
438 432
433 // Save the texture definition and leave it undefined.
434 TextureDefinition* Save(TextureInfo* info);
435
436 // Redefine all the levels from the texture definition.
437 bool Restore(TextureInfo* info,
438 TextureDefinition* definition);
439
439 // Sets a mip as cleared. 440 // Sets a mip as cleared.
440 void SetLevelCleared(TextureInfo* info, GLenum target, GLint level); 441 void SetLevelCleared(TextureInfo* info, GLenum target, GLint level);
441 442
442 // Sets a texture parameter of a TextureInfo 443 // Sets a texture parameter of a TextureInfo
443 // TODO(gman): Expand to SetParameteri,f,iv,fv 444 // TODO(gman): Expand to SetParameteri,f,iv,fv
444 bool SetParameter( 445 bool SetParameter(
445 TextureInfo* info, GLenum pname, GLint param); 446 TextureInfo* info, GLenum pname, GLint param);
446 447
447 // Makes each of the mip levels as though they were generated. 448 // Makes each of the mip levels as though they were generated.
448 // Returns false if that's not allowed for the given texture. 449 // Returns false if that's not allowed for the given texture.
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 // The default textures for each target (texture name = 0) 555 // The default textures for each target (texture name = 0)
555 TextureInfo::Ref default_textures_[kNumDefaultTextures]; 556 TextureInfo::Ref default_textures_[kNumDefaultTextures];
556 557
557 DISALLOW_COPY_AND_ASSIGN(TextureManager); 558 DISALLOW_COPY_AND_ASSIGN(TextureManager);
558 }; 559 };
559 560
560 } // namespace gles2 561 } // namespace gles2
561 } // namespace gpu 562 } // namespace gpu
562 563
563 #endif // GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_ 564 #endif // GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698