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

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

Issue 7529015: Allow the renderer process to map textures from one context into another. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 4 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) 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"
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 "base/memory/weak_ptr.h"
13 #include "gpu/command_buffer/service/gl_utils.h" 14 #include "gpu/command_buffer/service/gl_utils.h"
14 15
15 namespace gpu { 16 namespace gpu {
16 namespace gles2 { 17 namespace gles2 {
17 18
18 class FeatureInfo; 19 class FeatureInfo;
19 20
20 // This class keeps track of the textures and their sizes so we can do NPOT and 21 // This class keeps track of the textures and their sizes so we can do NPOT and
21 // texture complete checking. 22 // texture complete checking.
22 // 23 //
23 // NOTE: To support shared resources an instance of this class will need to be 24 // NOTE: To support shared resources an instance of this class will need to be
24 // shared by multiple GLES2Decoders. 25 // shared by multiple GLES2Decoders.
25 class TextureManager { 26 class TextureManager : public base::SupportsWeakPtr<TextureManager> {
26 public: 27 public:
27 // Info about Textures currently in the system. 28 // Info about Textures currently in the system.
28 class TextureInfo : public base::RefCounted<TextureInfo> { 29 class TextureInfo : public base::RefCounted<TextureInfo> {
29 public: 30 public:
30 typedef scoped_refptr<TextureInfo> Ref; 31 typedef scoped_refptr<TextureInfo> Ref;
31 32
32 explicit TextureInfo(GLuint service_id) 33 explicit TextureInfo(GLuint service_id)
33 : service_id_(service_id), 34 : service_id_(service_id),
34 deleted_(false), 35 deleted_(false),
35 target_(0), 36 target_(0),
36 min_filter_(GL_NEAREST_MIPMAP_LINEAR), 37 min_filter_(GL_NEAREST_MIPMAP_LINEAR),
37 mag_filter_(GL_LINEAR), 38 mag_filter_(GL_LINEAR),
38 wrap_s_(GL_REPEAT), 39 wrap_s_(GL_REPEAT),
39 wrap_t_(GL_REPEAT), 40 wrap_t_(GL_REPEAT),
40 max_level_set_(-1), 41 max_level_set_(-1),
41 texture_complete_(false), 42 texture_complete_(false),
42 cube_complete_(false), 43 cube_complete_(false),
43 npot_(false), 44 npot_(false),
44 has_been_bound_(false), 45 has_been_bound_(false),
45 framebuffer_attachment_count_(0), 46 framebuffer_attachment_count_(0) {
46 owned_(true) {
47 } 47 }
48 48
49 GLenum min_filter() const { 49 GLenum min_filter() const {
50 return min_filter_; 50 return min_filter_;
51 } 51 }
52 52
53 GLenum mag_filter() const { 53 GLenum mag_filter() const {
54 return mag_filter_; 54 return mag_filter_;
55 } 55 }
56 56
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 // same format, all the same dimensions and all width = height. 89 // same format, all the same dimensions and all width = height.
90 bool cube_complete() const { 90 bool cube_complete() const {
91 return cube_complete_; 91 return cube_complete_;
92 } 92 }
93 93
94 // Whether or not this texture is a non-power-of-two texture. 94 // Whether or not this texture is a non-power-of-two texture.
95 bool npot() const { 95 bool npot() const {
96 return npot_; 96 return npot_;
97 } 97 }
98 98
99 TextureManager* owner() const {
100 return owner_.get();
101 }
102
99 // Returns true if mipmaps can be generated by GL. 103 // Returns true if mipmaps can be generated by GL.
100 bool CanGenerateMipmaps(const FeatureInfo* feature_info) const; 104 bool CanGenerateMipmaps(const FeatureInfo* feature_info) const;
101 105
102 // Get the width and height for a particular level. Returns false if level 106 // Get the width and height for a particular level. Returns false if level
103 // does not exist. 107 // does not exist.
104 bool GetLevelSize( 108 bool GetLevelSize(
105 GLint face, GLint level, GLsizei* width, GLsizei* height) const; 109 GLint face, GLint level, GLsizei* width, GLsizei* height) const;
106 110
107 // Get the type of a level. Returns false if level does not exist. 111 // Get the type of a level. Returns false if level does not exist.
108 bool GetLevelType( 112 bool GetLevelType(
(...skipping 12 matching lines...) Expand all
121 GLint yoffset, 125 GLint yoffset,
122 GLsizei width, 126 GLsizei width,
123 GLsizei height, 127 GLsizei height,
124 GLenum format, 128 GLenum format,
125 GLenum type) const; 129 GLenum type) const;
126 130
127 bool IsValid() const { 131 bool IsValid() const {
128 return target() && !IsDeleted(); 132 return target() && !IsDeleted();
129 } 133 }
130 134
131 void SetNotOwned() {
132 owned_ = false;
133 }
134
135 bool IsAttachedToFramebuffer() const { 135 bool IsAttachedToFramebuffer() const {
136 return framebuffer_attachment_count_ != 0; 136 return framebuffer_attachment_count_ != 0;
137 } 137 }
138 138
139 void AttachToFramebuffer() { 139 void AttachToFramebuffer() {
140 ++framebuffer_attachment_count_; 140 ++framebuffer_attachment_count_;
141 } 141 }
142 142
143 void DetachFromFramebuffer() { 143 void DetachFromFramebuffer() {
144 DCHECK(framebuffer_attachment_count_ > 0); 144 DCHECK(framebuffer_attachment_count_ > 0);
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 243
244 // Whether or not this texture is non-power-of-two 244 // Whether or not this texture is non-power-of-two
245 bool npot_; 245 bool npot_;
246 246
247 // Whether this texture has ever been bound. 247 // Whether this texture has ever been bound.
248 bool has_been_bound_; 248 bool has_been_bound_;
249 249
250 // The number of framebuffers this texture is attached to. 250 // The number of framebuffers this texture is attached to.
251 int framebuffer_attachment_count_; 251 int framebuffer_attachment_count_;
252 252
253 // Whether the associated context group owns this texture and should delete 253 // The framebuffer manager that controls the lifetime of this framebuffer
254 // it. 254 // or NULL if it has been deleted.
255 bool owned_; 255 base::WeakPtr<TextureManager> owner_;
256 256
257 DISALLOW_COPY_AND_ASSIGN(TextureInfo); 257 DISALLOW_COPY_AND_ASSIGN(TextureInfo);
258 }; 258 };
259 259
260 TextureManager(GLsizei max_texture_size, 260 TextureManager(GLsizei max_texture_size,
261 GLsizei max_cube_map_texture_size); 261 GLsizei max_cube_map_texture_size);
262 ~TextureManager(); 262 ~TextureManager();
263 263
264 // Init the texture manager. 264 // Init the texture manager.
265 bool Initialize(const FeatureInfo* feature_info); 265 bool Initialize(const FeatureInfo* feature_info);
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 const FeatureInfo* feature_info, 331 const FeatureInfo* feature_info,
332 TextureManager::TextureInfo* info); 332 TextureManager::TextureInfo* info);
333 333
334 // Creates a new texture info. 334 // Creates a new texture info.
335 TextureInfo* CreateTextureInfo( 335 TextureInfo* CreateTextureInfo(
336 const FeatureInfo* feature_info, GLuint client_id, GLuint service_id); 336 const FeatureInfo* feature_info, GLuint client_id, GLuint service_id);
337 337
338 // Gets the texture info for the given texture. 338 // Gets the texture info for the given texture.
339 TextureInfo* GetTextureInfo(GLuint client_id); 339 TextureInfo* GetTextureInfo(GLuint client_id);
340 340
341 // Adds a texture info for a texture owned by another texture
342 // manager.
343 void AddTextureInfo(const FeatureInfo* feature_info,
344 GLuint client_id,
345 TextureInfo* info);
346
341 // Removes a texture info. 347 // Removes a texture info.
342 void RemoveTextureInfo(const FeatureInfo* feature_info, GLuint client_id); 348 void RemoveTextureInfo(const FeatureInfo* feature_info, GLuint client_id);
343 349
344 // Gets a client id for a given service id. 350 // Gets a client id for a given service id.
345 bool GetClientId(GLuint service_id, GLuint* client_id) const; 351 bool GetClientId(GLuint service_id, GLuint* client_id) const;
346 352
347 TextureInfo* GetDefaultTextureInfo(GLenum target) { 353 TextureInfo* GetDefaultTextureInfo(GLenum target) {
348 switch (target) { 354 switch (target) {
349 case GL_TEXTURE_2D: 355 case GL_TEXTURE_2D:
350 return default_texture_2d_; 356 return default_texture_2d_;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 TextureInfo::Ref default_texture_cube_map_; 406 TextureInfo::Ref default_texture_cube_map_;
401 TextureInfo::Ref default_texture_external_oes_; 407 TextureInfo::Ref default_texture_external_oes_;
402 408
403 DISALLOW_COPY_AND_ASSIGN(TextureManager); 409 DISALLOW_COPY_AND_ASSIGN(TextureManager);
404 }; 410 };
405 411
406 } // namespace gles2 412 } // namespace gles2
407 } // namespace gpu 413 } // namespace gpu
408 414
409 #endif // GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_ 415 #endif // GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698