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
3 // found in the LICENSE file.
5 #ifndef GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_
6 #define GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_
13 #include "base/basictypes.h"
14 #include "base/containers/hash_tables.h"
15 #include "base/memory/ref_counted.h"
16 #include "gpu/command_buffer/service/feature_info.h"
17 #include "gpu/command_buffer/service/gl_utils.h"
18 #include "gpu/command_buffer/service/memory_tracking.h"
19 #include "gpu/gpu_export.h"
20 #include "ui/gfx/geometry/rect.h"
21 #include "ui/gl/gl_image.h"
28 struct DecoderFramebufferState
;
32 class FramebufferManager
;
37 // Info about Textures currently in the system.
38 // This class wraps a real GL texture, keeping track of its meta-data. It is
39 // jointly owned by possibly multiple TextureRef.
40 class GPU_EXPORT Texture
{
42 explicit Texture(GLuint service_id
);
44 GLenum
min_filter() const {
48 GLenum
mag_filter() const {
52 GLenum
wrap_r() const {
56 GLenum
wrap_s() const {
60 GLenum
wrap_t() const {
64 GLenum
usage() const {
72 GLenum
compare_func() const {
76 GLenum
compare_mode() const {
80 GLfloat
max_lod() const {
84 GLfloat
min_lod() const {
88 GLint
base_level() const {
92 GLint
max_level() const {
96 int num_uncleared_mips() const {
97 return num_uncleared_mips_
;
100 uint32
estimated_size() const {
101 return estimated_size_
;
104 bool CanRenderTo() const {
105 return target_
!= GL_TEXTURE_EXTERNAL_OES
;
108 // The service side OpenGL id of the texture.
109 GLuint
service_id() const {
113 void SetServiceId(GLuint service_id
) {
115 service_id_
= service_id
;
118 // Returns the target this texure was first bound to or 0 if it has not
119 // been bound. Once a texture is bound to a specific target it can never be
120 // bound to a different target.
121 GLenum
target() const {
125 bool SafeToRenderFrom() const {
129 // Get the width/height/depth for a particular level. Returns false if level
131 // |depth| is optional and can be nullptr.
133 GLint target
, GLint level
,
134 GLsizei
* width
, GLsizei
* height
, GLsizei
* depth
) const;
136 // Get the type of a level. Returns false if level does not exist.
138 GLint target
, GLint level
, GLenum
* type
, GLenum
* internal_format
) const;
140 // Get the image bound to a particular level. Returns NULL if level
142 gfx::GLImage
* GetLevelImage(GLint target
, GLint level
) const;
144 bool HasImages() const {
148 // Returns true of the given dimensions are inside the dimensions of the
150 bool ValidForTexture(
158 GLsizei depth
) const;
160 bool IsValid() const {
164 bool IsAttachedToFramebuffer() const {
165 return framebuffer_attachment_count_
!= 0;
168 void AttachToFramebuffer() {
169 ++framebuffer_attachment_count_
;
172 void DetachFromFramebuffer() {
173 DCHECK_GT(framebuffer_attachment_count_
, 0);
174 --framebuffer_attachment_count_
;
177 void SetImmutable(bool immutable
) {
178 immutable_
= immutable
;
181 bool IsImmutable() const {
185 // Get the cleared rectangle for a particular level. Returns an empty
186 // rectangle if level does not exist.
187 gfx::Rect
GetLevelClearedRect(GLenum target
, GLint level
) const;
189 // Whether a particular level/face is cleared.
190 bool IsLevelCleared(GLenum target
, GLint level
) const;
192 // Whether the texture has been defined
193 bool IsDefined() const {
194 return estimated_size() > 0;
197 // Initialize TEXTURE_MAX_ANISOTROPY to 1 if we haven't done so yet.
198 void InitTextureMaxAnisotropyIfNeeded(GLenum target
);
200 void OnWillModifyPixels();
201 void OnDidModifyPixels();
203 void DumpLevelMemory(base::trace_event::ProcessMemoryDump
* pmd
,
204 uint64_t client_tracing_id
,
205 const std::string
& dump_name
) const;
208 friend class MailboxManagerImpl
;
209 friend class MailboxManagerSync
;
210 friend class MailboxManagerTest
;
211 friend class TextureDefinition
;
212 friend class TextureManager
;
213 friend class TextureRef
;
214 friend class TextureTestHelper
;
217 void AddTextureRef(TextureRef
* ref
);
218 void RemoveTextureRef(TextureRef
* ref
, bool have_context
);
219 MemoryTypeTracker
* GetMemTracker();
221 // Condition on which this texture is renderable. Can be ONLY_IF_NPOT if it
222 // depends on context support for non-power-of-two textures (i.e. will be
223 // renderable if NPOT support is in the context, otherwise not, e.g. texture
224 // with a NPOT level). ALWAYS means it doesn't depend on context features
225 // (e.g. complete POT), NEVER means it's not renderable regardless (e.g.
227 enum CanRenderCondition
{
230 CAN_RENDER_ONLY_IF_NPOT
235 LevelInfo(const LevelInfo
& rhs
);
238 gfx::Rect cleared_rect
;
241 GLenum internal_format
;
248 scoped_refptr
<gfx::GLImage
> image
;
249 uint32 estimated_size
;
256 GLsizei num_mip_levels
;
257 std::vector
<LevelInfo
> level_infos
;
260 // Set the info for a particular level.
261 void SetLevelInfo(const FeatureInfo
* feature_info
,
264 GLenum internal_format
,
271 const gfx::Rect
& cleared_rect
);
273 // In GLES2 "texture complete" means it has all required mips for filtering
274 // down to a 1x1 pixel texture, they are in the correct order, they are all
276 bool texture_complete() const {
277 return texture_complete_
;
280 // In GLES2 "cube complete" means all 6 faces level 0 are defined, all the
281 // same format, all the same dimensions and all width = height.
282 bool cube_complete() const {
283 return cube_complete_
;
286 // Whether or not this texture is a non-power-of-two texture.
291 // Marks a |rect| of a particular level as cleared.
292 void SetLevelClearedRect(GLenum target
,
294 const gfx::Rect
& cleared_rect
);
296 // Marks a particular level as cleared or uncleared.
297 void SetLevelCleared(GLenum target
, GLint level
, bool cleared
);
299 // Updates the cleared flag for this texture by inspecting all the mips.
300 void UpdateCleared();
302 // Clears any renderable uncleared levels.
303 // Returns false if a GL error was generated.
304 bool ClearRenderableLevels(GLES2Decoder
* decoder
);
307 // Returns false if a GL error was generated.
308 bool ClearLevel(GLES2Decoder
* decoder
, GLenum target
, GLint level
);
310 // Sets a texture parameter.
311 // TODO(gman): Expand to SetParameteriv,fv
312 // Returns GL_NO_ERROR on success. Otherwise the error to generate.
313 GLenum
SetParameteri(
314 const FeatureInfo
* feature_info
, GLenum pname
, GLint param
);
315 GLenum
SetParameterf(
316 const FeatureInfo
* feature_info
, GLenum pname
, GLfloat param
);
318 // Makes each of the mip levels as though they were generated.
319 bool MarkMipmapsGenerated(const FeatureInfo
* feature_info
);
321 bool NeedsMips() const {
322 return min_filter_
!= GL_NEAREST
&& min_filter_
!= GL_LINEAR
;
325 // True if this texture meets all the GLES2 criteria for rendering.
326 // See section 3.8.2 of the GLES2 spec.
327 bool CanRender(const FeatureInfo
* feature_info
) const;
329 // Returns true if mipmaps can be generated by GL.
330 bool CanGenerateMipmaps(const FeatureInfo
* feature_info
) const;
332 // Returns true if any of the texture dimensions are not a power of two.
333 static bool TextureIsNPOT(GLsizei width
, GLsizei height
, GLsizei depth
);
335 // Returns true if texture face is complete relative to the first face.
336 static bool TextureFaceComplete(const Texture::LevelInfo
& first_face
,
339 GLenum internal_format
,
346 // Returns true if texture mip level is complete relative to first level.
347 static bool TextureMipComplete(const Texture::LevelInfo
& level0_face
,
350 GLenum internal_format
,
357 // Sets the Texture's target
359 // target: GL_TEXTURE_2D or GL_TEXTURE_CUBE_MAP or
360 // GL_TEXTURE_EXTERNAL_OES or GL_TEXTURE_RECTANGLE_ARB
361 // GL_TEXTURE_2D_ARRAY or GL_TEXTURE_3D (for GLES3)
362 // max_levels: The maximum levels this type of target can have.
364 const FeatureInfo
* feature_info
, GLenum target
, GLint max_levels
);
366 // Update info about this texture.
367 void Update(const FeatureInfo
* feature_info
);
369 // Set the image for a particular level.
371 const FeatureInfo
* feature_info
,
374 gfx::GLImage
* image
);
376 // Appends a signature for the given level.
378 const FeatureInfo
* feature_info
,
379 GLenum target
, GLint level
, std::string
* signature
) const;
381 void SetMailboxManager(MailboxManager
* mailbox_manager
);
383 // Updates the unsafe textures count in all the managers referencing this
385 void UpdateSafeToRenderFrom(bool cleared
);
387 // Updates the uncleared mip count in all the managers referencing this
389 void UpdateMipCleared(LevelInfo
* info
,
392 const gfx::Rect
& cleared_rect
);
394 // Computes the CanRenderCondition flag.
395 CanRenderCondition
GetCanRenderCondition() const;
397 // Updates the unrenderable texture count in all the managers referencing this
399 void UpdateCanRenderCondition();
401 // Updates the images count in all the managers referencing this
403 void UpdateHasImages();
405 // Increment the framebuffer state change count in all the managers
406 // referencing this texture.
407 void IncAllFramebufferStateChangeCount();
409 MailboxManager
* mailbox_manager_
;
411 // Info about each face and level of texture.
412 std::vector
<FaceInfo
> face_infos_
;
414 // The texture refs that point to this Texture.
415 typedef std::set
<TextureRef
*> RefSet
;
418 // The single TextureRef that accounts for memory for this texture. Must be
420 TextureRef
* memory_tracking_ref_
;
422 // The id of the texure
425 // Whether all renderable mips of this texture have been cleared.
428 int num_uncleared_mips_
;
431 // The target. 0 if unset, otherwise GL_TEXTURE_2D or GL_TEXTURE_CUBE_MAP.
432 // Or GL_TEXTURE_2D_ARRAY or GL_TEXTURE_3D (for GLES3).
435 // Texture parameters.
443 GLenum compare_func_
;
444 GLenum compare_mode_
;
450 // The maximum level that has been set.
451 GLint max_level_set_
;
453 // Whether or not this texture is "texture complete"
454 bool texture_complete_
;
456 // Whether mip levels have changed and should be reverified.
457 bool texture_mips_dirty_
;
458 bool texture_mips_complete_
;
460 // Whether or not this texture is "cube complete"
463 // Whether any level 0 faces have changed and should be reverified.
464 bool texture_level0_dirty_
;
465 bool texture_level0_complete_
;
467 // Whether or not this texture is non-power-of-two
470 // Whether this texture has ever been bound.
471 bool has_been_bound_
;
473 // The number of framebuffers this texture is attached to.
474 int framebuffer_attachment_count_
;
476 // Whether the texture is immutable and no further changes to the format
477 // or dimensions of the texture object can be made.
480 // Whether or not this texture has images.
483 // Size in bytes this texture is assumed to take in memory.
484 uint32 estimated_size_
;
486 // Cache of the computed CanRenderCondition flag.
487 CanRenderCondition can_render_condition_
;
489 // Whether we have initialized TEXTURE_MAX_ANISOTROPY to 1.
490 bool texture_max_anisotropy_initialized_
;
492 DISALLOW_COPY_AND_ASSIGN(Texture
);
495 // This class represents a texture in a client context group. It's mostly 1:1
496 // with a client id, though it can outlive the client id if it's still bound to
497 // a FBO or another context when destroyed.
498 // Multiple TextureRef can point to the same texture with cross-context sharing.
499 class GPU_EXPORT TextureRef
: public base::RefCounted
<TextureRef
> {
501 TextureRef(TextureManager
* manager
, GLuint client_id
, Texture
* texture
);
502 static scoped_refptr
<TextureRef
> Create(TextureManager
* manager
,
506 void AddObserver() { num_observers_
++; }
507 void RemoveObserver() { num_observers_
--; }
509 const Texture
* texture() const { return texture_
; }
510 Texture
* texture() { return texture_
; }
511 GLuint
client_id() const { return client_id_
; }
512 GLuint
service_id() const { return texture_
->service_id(); }
513 GLint
num_observers() const { return num_observers_
; }
516 friend class base::RefCounted
<TextureRef
>;
517 friend class Texture
;
518 friend class TextureManager
;
521 const TextureManager
* manager() const { return manager_
; }
522 TextureManager
* manager() { return manager_
; }
523 void reset_client_id() { client_id_
= 0; }
525 TextureManager
* manager_
;
528 GLint num_observers_
;
530 DISALLOW_COPY_AND_ASSIGN(TextureRef
);
533 // Holds data that is per gles2_cmd_decoder, but is related to to the
535 struct DecoderTextureState
{
536 // total_texture_upload_time automatically initialized to 0 in default
538 explicit DecoderTextureState(const FeatureInfo::Workarounds
& workarounds
)
539 : tex_image_failed(false),
540 texture_upload_count(0),
541 texsubimage_faster_than_teximage(
542 workarounds
.texsubimage_faster_than_teximage
),
543 force_cube_map_positive_x_allocation(
544 workarounds
.force_cube_map_positive_x_allocation
),
545 force_cube_complete(workarounds
.force_cube_complete
) {}
547 // This indicates all the following texSubImage*D calls that are part of the
548 // failed texImage*D call should be ignored. The client calls have a lock
549 // around them, so it will affect only a single texImage*D + texSubImage*D
551 bool tex_image_failed
;
553 // Command buffer stats.
554 int texture_upload_count
;
555 base::TimeDelta total_texture_upload_time
;
557 bool texsubimage_faster_than_teximage
;
558 bool force_cube_map_positive_x_allocation
;
559 bool force_cube_complete
;
562 // This class keeps track of the textures and their sizes so we can do NPOT and
563 // texture complete checking.
565 // NOTE: To support shared resources an instance of this class will need to be
566 // shared by multiple GLES2Decoders.
567 class GPU_EXPORT TextureManager
: public base::trace_event::MemoryDumpProvider
{
569 class GPU_EXPORT DestructionObserver
{
571 DestructionObserver();
572 virtual ~DestructionObserver();
574 // Called in ~TextureManager.
575 virtual void OnTextureManagerDestroying(TextureManager
* manager
) = 0;
577 // Called via ~TextureRef.
578 virtual void OnTextureRefDestroying(TextureRef
* texture
) = 0;
581 DISALLOW_COPY_AND_ASSIGN(DestructionObserver
);
584 enum DefaultAndBlackTextures
{
594 TextureManager(MemoryTracker
* memory_tracker
,
595 FeatureInfo
* feature_info
,
596 GLsizei max_texture_size
,
597 GLsizei max_cube_map_texture_size
,
598 GLsizei max_rectangle_texture_size
,
599 GLsizei max_3d_texture_size
,
600 bool use_default_textures
);
601 ~TextureManager() override
;
603 void set_framebuffer_manager(FramebufferManager
* manager
) {
604 framebuffer_manager_
= manager
;
607 // Init the texture manager.
610 // Must call before destruction.
611 void Destroy(bool have_context
);
613 // Returns the maximum number of levels.
614 GLint
MaxLevelsForTarget(GLenum target
) const {
618 case GL_TEXTURE_RECTANGLE_ARB
:
619 case GL_TEXTURE_EXTERNAL_OES
:
622 case GL_TEXTURE_2D_ARRAY
:
623 return max_3d_levels_
;
625 return max_cube_map_levels_
;
629 // Returns the maximum size.
630 GLsizei
MaxSizeForTarget(GLenum target
) const {
633 case GL_TEXTURE_EXTERNAL_OES
:
634 return max_texture_size_
;
635 case GL_TEXTURE_RECTANGLE
:
636 return max_rectangle_texture_size_
;
638 case GL_TEXTURE_2D_ARRAY
:
639 return max_3d_texture_size_
;
641 return max_cube_map_texture_size_
;
645 // Returns the maxium number of levels a texture of the given size can have.
646 static GLsizei
ComputeMipMapCount(GLenum target
,
651 // Checks if a dimensions are valid for a given target.
653 GLenum target
, GLint level
,
654 GLsizei width
, GLsizei height
, GLsizei depth
);
656 // True if this texture meets all the GLES2 criteria for rendering.
657 // See section 3.8.2 of the GLES2 spec.
658 bool CanRender(const TextureRef
* ref
) const {
659 return ref
->texture()->CanRender(feature_info_
.get());
662 // Returns true if mipmaps can be generated by GL.
663 bool CanGenerateMipmaps(const TextureRef
* ref
) const {
664 return ref
->texture()->CanGenerateMipmaps(feature_info_
.get());
667 // Sets the Texture's target
669 // target: GL_TEXTURE_2D or GL_TEXTURE_CUBE_MAP
670 // GL_TEXTURE_2D_ARRAY or GL_TEXTURE_3D (for GLES3)
671 // max_levels: The maximum levels this type of target can have.
676 // Set the info for a particular level in a TexureInfo.
677 void SetLevelInfo(TextureRef
* ref
,
680 GLenum internal_format
,
687 const gfx::Rect
& cleared_rect
);
689 Texture
* Produce(TextureRef
* ref
);
691 // Maps an existing texture into the texture manager, at a given client ID.
692 TextureRef
* Consume(GLuint client_id
, Texture
* texture
);
694 // Sets |rect| of mip as cleared.
695 void SetLevelClearedRect(TextureRef
* ref
,
698 const gfx::Rect
& cleared_rect
);
700 // Sets a mip as cleared.
701 void SetLevelCleared(TextureRef
* ref
, GLenum target
,
702 GLint level
, bool cleared
);
704 // Sets a texture parameter of a Texture
705 // Returns GL_NO_ERROR on success. Otherwise the error to generate.
706 // TODO(gman): Expand to SetParameteriv,fv
708 const char* function_name
, ErrorState
* error_state
,
709 TextureRef
* ref
, GLenum pname
, GLint param
);
711 const char* function_name
, ErrorState
* error_state
,
712 TextureRef
* ref
, GLenum pname
, GLfloat param
);
714 // Makes each of the mip levels as though they were generated.
715 // Returns false if that's not allowed for the given texture.
716 bool MarkMipmapsGenerated(TextureRef
* ref
);
718 // Clears any uncleared renderable levels.
719 bool ClearRenderableLevels(GLES2Decoder
* decoder
, TextureRef
* ref
);
721 // Clear a specific level.
722 bool ClearTextureLevel(
723 GLES2Decoder
* decoder
, TextureRef
* ref
, GLenum target
, GLint level
);
725 // Creates a new texture info.
726 TextureRef
* CreateTexture(GLuint client_id
, GLuint service_id
);
728 // Gets the texture info for the given texture.
729 TextureRef
* GetTexture(GLuint client_id
) const;
731 // Removes a texture info.
732 void RemoveTexture(GLuint client_id
);
734 // Gets a Texture for a given service id (note: it assumes the texture object
735 // is still mapped in this TextureManager).
736 Texture
* GetTextureForServiceId(GLuint service_id
) const;
738 TextureRef
* GetDefaultTextureInfo(GLenum target
) {
741 return default_textures_
[kTexture2D
].get();
743 return default_textures_
[kTexture3D
].get();
744 case GL_TEXTURE_2D_ARRAY
:
745 return default_textures_
[kTexture2DArray
].get();
746 case GL_TEXTURE_CUBE_MAP
:
747 return default_textures_
[kCubeMap
].get();
748 case GL_TEXTURE_EXTERNAL_OES
:
749 return default_textures_
[kExternalOES
].get();
750 case GL_TEXTURE_RECTANGLE_ARB
:
751 return default_textures_
[kRectangleARB
].get();
758 bool HaveUnrenderableTextures() const {
759 return num_unrenderable_textures_
> 0;
762 bool HaveUnsafeTextures() const {
763 return num_unsafe_textures_
> 0;
766 bool HaveUnclearedMips() const {
767 return num_uncleared_mips_
> 0;
770 bool HaveImages() const {
771 return num_images_
> 0;
774 GLuint
black_texture_id(GLenum target
) const {
777 return black_texture_ids_
[kTexture2D
];
779 return black_texture_ids_
[kTexture3D
];
780 case GL_SAMPLER_2D_ARRAY
:
781 return black_texture_ids_
[kTexture2DArray
];
782 case GL_SAMPLER_CUBE
:
783 return black_texture_ids_
[kCubeMap
];
784 case GL_SAMPLER_EXTERNAL_OES
:
785 return black_texture_ids_
[kExternalOES
];
786 case GL_SAMPLER_2D_RECT_ARB
:
787 return black_texture_ids_
[kRectangleARB
];
794 size_t mem_represented() const {
796 memory_tracker_managed_
->GetMemRepresented() +
797 memory_tracker_unmanaged_
->GetMemRepresented();
804 gfx::GLImage
* image
);
806 size_t GetSignatureSize() const;
812 std::string
* signature
) const;
814 void AddObserver(DestructionObserver
* observer
) {
815 destruction_observers_
.push_back(observer
);
818 void RemoveObserver(DestructionObserver
* observer
) {
819 for (unsigned int i
= 0; i
< destruction_observers_
.size(); i
++) {
820 if (destruction_observers_
[i
] == observer
) {
821 std::swap(destruction_observers_
[i
], destruction_observers_
.back());
822 destruction_observers_
.pop_back();
829 struct DoTexImageArguments
{
830 enum TexImageCommandType
{
837 GLenum internal_format
;
846 TexImageCommandType command_type
;
849 bool ValidateTexImage(
851 const char* function_name
,
852 const DoTexImageArguments
& args
,
853 // Pointer to TextureRef filled in if validation successful.
854 // Presumes the pointer is valid.
855 TextureRef
** texture_ref
);
857 void ValidateAndDoTexImage(
858 DecoderTextureState
* texture_state
,
860 DecoderFramebufferState
* framebuffer_state
,
861 const char* function_name
,
862 const DoTexImageArguments
& args
);
864 // TODO(kloveless): Make GetTexture* private once this is no longer called
865 // from gles2_cmd_decoder.
866 TextureRef
* GetTextureInfoForTarget(ContextState
* state
, GLenum target
);
867 TextureRef
* GetTextureInfoForTargetUnlessDefault(
868 ContextState
* state
, GLenum target
);
870 bool ValidateFormatAndTypeCombination(
871 ErrorState
* error_state
, const char* function_name
,
872 GLenum format
, GLenum type
);
874 // Note that internal_format is only checked in relation to the format
875 // parameter, so that this function may be used to validate texSubImage2D.
876 bool ValidateTextureParameters(
877 ErrorState
* error_state
, const char* function_name
,
878 GLenum format
, GLenum type
, GLenum internal_format
, GLint level
);
880 // base::trace_event::MemoryDumpProvider implementation.
881 bool OnMemoryDump(const base::trace_event::MemoryDumpArgs
& args
,
882 base::trace_event::ProcessMemoryDump
* pmd
) override
;
885 friend class Texture
;
886 friend class TextureRef
;
888 // Helper for Initialize().
889 scoped_refptr
<TextureRef
> CreateDefaultAndBlackTextures(
891 GLuint
* black_texture
);
894 DecoderTextureState
* texture_state
,
895 ErrorState
* error_state
,
896 DecoderFramebufferState
* framebuffer_state
,
897 const char* function_name
,
898 TextureRef
* texture_ref
,
899 const DoTexImageArguments
& args
);
901 void StartTracking(TextureRef
* texture
);
902 void StopTracking(TextureRef
* texture
);
904 void UpdateSafeToRenderFrom(int delta
);
905 void UpdateUnclearedMips(int delta
);
906 void UpdateCanRenderCondition(Texture::CanRenderCondition old_condition
,
907 Texture::CanRenderCondition new_condition
);
908 void UpdateNumImages(int delta
);
909 void IncFramebufferStateChangeCount();
911 GLenum
AdjustTexFormat(GLenum format
) const;
913 // Helper function called by OnMemoryDump.
914 void DumpTextureRef(base::trace_event::ProcessMemoryDump
* pmd
,
917 MemoryTypeTracker
* GetMemTracker(GLenum texture_pool
);
918 scoped_ptr
<MemoryTypeTracker
> memory_tracker_managed_
;
919 scoped_ptr
<MemoryTypeTracker
> memory_tracker_unmanaged_
;
920 MemoryTracker
* memory_tracker_
;
922 scoped_refptr
<FeatureInfo
> feature_info_
;
924 FramebufferManager
* framebuffer_manager_
;
926 // Info for each texture in the system.
927 typedef base::hash_map
<GLuint
, scoped_refptr
<TextureRef
> > TextureMap
;
928 TextureMap textures_
;
930 GLsizei max_texture_size_
;
931 GLsizei max_cube_map_texture_size_
;
932 GLsizei max_rectangle_texture_size_
;
933 GLsizei max_3d_texture_size_
;
935 GLint max_cube_map_levels_
;
936 GLint max_3d_levels_
;
938 const bool use_default_textures_
;
940 int num_unrenderable_textures_
;
941 int num_unsafe_textures_
;
942 int num_uncleared_mips_
;
945 // Counts the number of Textures allocated with 'this' as its manager.
946 // Allows to check no Texture will outlive this.
947 unsigned int texture_count_
;
951 // Black (0,0,0,1) textures for when non-renderable textures are used.
952 // NOTE: There is no corresponding Texture for these textures.
953 // TextureInfos are only for textures the client side can access.
954 GLuint black_texture_ids_
[kNumDefaultTextures
];
956 // The default textures for each target (texture name = 0)
957 scoped_refptr
<TextureRef
> default_textures_
[kNumDefaultTextures
];
959 std::vector
<DestructionObserver
*> destruction_observers_
;
961 DISALLOW_COPY_AND_ASSIGN(TextureManager
);
964 // This class records texture upload time when in scope.
965 class ScopedTextureUploadTimer
{
967 explicit ScopedTextureUploadTimer(DecoderTextureState
* texture_state
);
968 ~ScopedTextureUploadTimer();
971 DecoderTextureState
* texture_state_
;
972 base::TimeTicks begin_time_
;
973 DISALLOW_COPY_AND_ASSIGN(ScopedTextureUploadTimer
);
979 #endif // GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_