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
149 // level and if the type matches the level.
150 bool ValidForTexture(
161 bool IsValid() const {
165 bool IsAttachedToFramebuffer() const {
166 return framebuffer_attachment_count_
!= 0;
169 void AttachToFramebuffer() {
170 ++framebuffer_attachment_count_
;
173 void DetachFromFramebuffer() {
174 DCHECK_GT(framebuffer_attachment_count_
, 0);
175 --framebuffer_attachment_count_
;
178 void SetImmutable(bool immutable
) {
179 immutable_
= immutable
;
182 bool IsImmutable() const {
186 // Get the cleared rectangle for a particular level. Returns an empty
187 // rectangle if level does not exist.
188 gfx::Rect
GetLevelClearedRect(GLenum target
, GLint level
) const;
190 // Whether a particular level/face is cleared.
191 bool IsLevelCleared(GLenum target
, GLint level
) const;
193 // Whether the texture has been defined
194 bool IsDefined() const {
195 return estimated_size() > 0;
198 // Initialize TEXTURE_MAX_ANISOTROPY to 1 if we haven't done so yet.
199 void InitTextureMaxAnisotropyIfNeeded(GLenum target
);
201 void OnWillModifyPixels();
202 void OnDidModifyPixels();
204 void DumpLevelMemory(base::trace_event::ProcessMemoryDump
* pmd
,
205 uint64_t client_tracing_id
,
206 const std::string
& dump_name
) const;
209 friend class MailboxManagerImpl
;
210 friend class MailboxManagerSync
;
211 friend class MailboxManagerTest
;
212 friend class TextureDefinition
;
213 friend class TextureManager
;
214 friend class TextureRef
;
215 friend class TextureTestHelper
;
218 void AddTextureRef(TextureRef
* ref
);
219 void RemoveTextureRef(TextureRef
* ref
, bool have_context
);
220 MemoryTypeTracker
* GetMemTracker();
222 // Condition on which this texture is renderable. Can be ONLY_IF_NPOT if it
223 // depends on context support for non-power-of-two textures (i.e. will be
224 // renderable if NPOT support is in the context, otherwise not, e.g. texture
225 // with a NPOT level). ALWAYS means it doesn't depend on context features
226 // (e.g. complete POT), NEVER means it's not renderable regardless (e.g.
228 enum CanRenderCondition
{
231 CAN_RENDER_ONLY_IF_NPOT
236 LevelInfo(const LevelInfo
& rhs
);
239 gfx::Rect cleared_rect
;
242 GLenum internal_format
;
249 scoped_refptr
<gfx::GLImage
> image
;
250 uint32 estimated_size
;
257 GLsizei num_mip_levels
;
258 std::vector
<LevelInfo
> level_infos
;
261 // Set the info for a particular level.
262 void SetLevelInfo(const FeatureInfo
* feature_info
,
265 GLenum internal_format
,
272 const gfx::Rect
& cleared_rect
);
274 // In GLES2 "texture complete" means it has all required mips for filtering
275 // down to a 1x1 pixel texture, they are in the correct order, they are all
277 bool texture_complete() const {
278 return texture_complete_
;
281 // In GLES2 "cube complete" means all 6 faces level 0 are defined, all the
282 // same format, all the same dimensions and all width = height.
283 bool cube_complete() const {
284 return cube_complete_
;
287 // Whether or not this texture is a non-power-of-two texture.
292 // Marks a |rect| of a particular level as cleared.
293 void SetLevelClearedRect(GLenum target
,
295 const gfx::Rect
& cleared_rect
);
297 // Marks a particular level as cleared or uncleared.
298 void SetLevelCleared(GLenum target
, GLint level
, bool cleared
);
300 // Updates the cleared flag for this texture by inspecting all the mips.
301 void UpdateCleared();
303 // Clears any renderable uncleared levels.
304 // Returns false if a GL error was generated.
305 bool ClearRenderableLevels(GLES2Decoder
* decoder
);
308 // Returns false if a GL error was generated.
309 bool ClearLevel(GLES2Decoder
* decoder
, GLenum target
, GLint level
);
311 // Sets a texture parameter.
312 // TODO(gman): Expand to SetParameteriv,fv
313 // Returns GL_NO_ERROR on success. Otherwise the error to generate.
314 GLenum
SetParameteri(
315 const FeatureInfo
* feature_info
, GLenum pname
, GLint param
);
316 GLenum
SetParameterf(
317 const FeatureInfo
* feature_info
, GLenum pname
, GLfloat param
);
319 // Makes each of the mip levels as though they were generated.
320 bool MarkMipmapsGenerated(const FeatureInfo
* feature_info
);
322 bool NeedsMips() const {
323 return min_filter_
!= GL_NEAREST
&& min_filter_
!= GL_LINEAR
;
326 // True if this texture meets all the GLES2 criteria for rendering.
327 // See section 3.8.2 of the GLES2 spec.
328 bool CanRender(const FeatureInfo
* feature_info
) const;
330 // Returns true if mipmaps can be generated by GL.
331 bool CanGenerateMipmaps(const FeatureInfo
* feature_info
) const;
333 // Returns true if any of the texture dimensions are not a power of two.
334 static bool TextureIsNPOT(GLsizei width
, GLsizei height
, GLsizei depth
);
336 // Returns true if texture face is complete relative to the first face.
337 static bool TextureFaceComplete(const Texture::LevelInfo
& first_face
,
340 GLenum internal_format
,
347 // Returns true if texture mip level is complete relative to first level.
348 static bool TextureMipComplete(const Texture::LevelInfo
& level0_face
,
351 GLenum internal_format
,
358 // Sets the Texture's target
360 // target: GL_TEXTURE_2D or GL_TEXTURE_CUBE_MAP or
361 // GL_TEXTURE_EXTERNAL_OES or GL_TEXTURE_RECTANGLE_ARB
362 // GL_TEXTURE_2D_ARRAY or GL_TEXTURE_3D (for GLES3)
363 // max_levels: The maximum levels this type of target can have.
365 const FeatureInfo
* feature_info
, GLenum target
, GLint max_levels
);
367 // Update info about this texture.
368 void Update(const FeatureInfo
* feature_info
);
370 // Set the image for a particular level.
372 const FeatureInfo
* feature_info
,
375 gfx::GLImage
* image
);
377 // Appends a signature for the given level.
379 const FeatureInfo
* feature_info
,
380 GLenum target
, GLint level
, std::string
* signature
) const;
382 void SetMailboxManager(MailboxManager
* mailbox_manager
);
384 // Updates the unsafe textures count in all the managers referencing this
386 void UpdateSafeToRenderFrom(bool cleared
);
388 // Updates the uncleared mip count in all the managers referencing this
390 void UpdateMipCleared(LevelInfo
* info
,
393 const gfx::Rect
& cleared_rect
);
395 // Computes the CanRenderCondition flag.
396 CanRenderCondition
GetCanRenderCondition() const;
398 // Updates the unrenderable texture count in all the managers referencing this
400 void UpdateCanRenderCondition();
402 // Updates the images count in all the managers referencing this
404 void UpdateHasImages();
406 // Increment the framebuffer state change count in all the managers
407 // referencing this texture.
408 void IncAllFramebufferStateChangeCount();
410 MailboxManager
* mailbox_manager_
;
412 // Info about each face and level of texture.
413 std::vector
<FaceInfo
> face_infos_
;
415 // The texture refs that point to this Texture.
416 typedef std::set
<TextureRef
*> RefSet
;
419 // The single TextureRef that accounts for memory for this texture. Must be
421 TextureRef
* memory_tracking_ref_
;
423 // The id of the texure
426 // Whether all renderable mips of this texture have been cleared.
429 int num_uncleared_mips_
;
432 // The target. 0 if unset, otherwise GL_TEXTURE_2D or GL_TEXTURE_CUBE_MAP.
433 // Or GL_TEXTURE_2D_ARRAY or GL_TEXTURE_3D (for GLES3).
436 // Texture parameters.
444 GLenum compare_func_
;
445 GLenum compare_mode_
;
451 // The maximum level that has been set.
452 GLint max_level_set_
;
454 // Whether or not this texture is "texture complete"
455 bool texture_complete_
;
457 // Whether mip levels have changed and should be reverified.
458 bool texture_mips_dirty_
;
459 bool texture_mips_complete_
;
461 // Whether or not this texture is "cube complete"
464 // Whether any level 0 faces have changed and should be reverified.
465 bool texture_level0_dirty_
;
466 bool texture_level0_complete_
;
468 // Whether or not this texture is non-power-of-two
471 // Whether this texture has ever been bound.
472 bool has_been_bound_
;
474 // The number of framebuffers this texture is attached to.
475 int framebuffer_attachment_count_
;
477 // Whether the texture is immutable and no further changes to the format
478 // or dimensions of the texture object can be made.
481 // Whether or not this texture has images.
484 // Size in bytes this texture is assumed to take in memory.
485 uint32 estimated_size_
;
487 // Cache of the computed CanRenderCondition flag.
488 CanRenderCondition can_render_condition_
;
490 // Whether we have initialized TEXTURE_MAX_ANISOTROPY to 1.
491 bool texture_max_anisotropy_initialized_
;
493 DISALLOW_COPY_AND_ASSIGN(Texture
);
496 // This class represents a texture in a client context group. It's mostly 1:1
497 // with a client id, though it can outlive the client id if it's still bound to
498 // a FBO or another context when destroyed.
499 // Multiple TextureRef can point to the same texture with cross-context sharing.
500 class GPU_EXPORT TextureRef
: public base::RefCounted
<TextureRef
> {
502 TextureRef(TextureManager
* manager
, GLuint client_id
, Texture
* texture
);
503 static scoped_refptr
<TextureRef
> Create(TextureManager
* manager
,
507 void AddObserver() { num_observers_
++; }
508 void RemoveObserver() { num_observers_
--; }
510 const Texture
* texture() const { return texture_
; }
511 Texture
* texture() { return texture_
; }
512 GLuint
client_id() const { return client_id_
; }
513 GLuint
service_id() const { return texture_
->service_id(); }
514 GLint
num_observers() const { return num_observers_
; }
517 friend class base::RefCounted
<TextureRef
>;
518 friend class Texture
;
519 friend class TextureManager
;
522 const TextureManager
* manager() const { return manager_
; }
523 TextureManager
* manager() { return manager_
; }
524 void reset_client_id() { client_id_
= 0; }
526 TextureManager
* manager_
;
529 GLint num_observers_
;
531 DISALLOW_COPY_AND_ASSIGN(TextureRef
);
534 // Holds data that is per gles2_cmd_decoder, but is related to to the
536 struct DecoderTextureState
{
537 // total_texture_upload_time automatically initialized to 0 in default
539 explicit DecoderTextureState(const FeatureInfo::Workarounds
& workarounds
)
540 : tex_image_failed(false),
541 texture_upload_count(0),
542 texsubimage_faster_than_teximage(
543 workarounds
.texsubimage_faster_than_teximage
),
544 force_cube_map_positive_x_allocation(
545 workarounds
.force_cube_map_positive_x_allocation
),
546 force_cube_complete(workarounds
.force_cube_complete
) {}
548 // This indicates all the following texSubImage*D calls that are part of the
549 // failed texImage*D call should be ignored. The client calls have a lock
550 // around them, so it will affect only a single texImage*D + texSubImage*D
552 bool tex_image_failed
;
554 // Command buffer stats.
555 int texture_upload_count
;
556 base::TimeDelta total_texture_upload_time
;
558 bool texsubimage_faster_than_teximage
;
559 bool force_cube_map_positive_x_allocation
;
560 bool force_cube_complete
;
563 // This class keeps track of the textures and their sizes so we can do NPOT and
564 // texture complete checking.
566 // NOTE: To support shared resources an instance of this class will need to be
567 // shared by multiple GLES2Decoders.
568 class GPU_EXPORT TextureManager
: public base::trace_event::MemoryDumpProvider
{
570 class GPU_EXPORT DestructionObserver
{
572 DestructionObserver();
573 virtual ~DestructionObserver();
575 // Called in ~TextureManager.
576 virtual void OnTextureManagerDestroying(TextureManager
* manager
) = 0;
578 // Called via ~TextureRef.
579 virtual void OnTextureRefDestroying(TextureRef
* texture
) = 0;
582 DISALLOW_COPY_AND_ASSIGN(DestructionObserver
);
585 enum DefaultAndBlackTextures
{
593 TextureManager(MemoryTracker
* memory_tracker
,
594 FeatureInfo
* feature_info
,
595 GLsizei max_texture_size
,
596 GLsizei max_cube_map_texture_size
,
597 GLsizei max_rectangle_texture_size
,
598 GLsizei max_3d_texture_size
,
599 bool use_default_textures
);
600 ~TextureManager() override
;
602 void set_framebuffer_manager(FramebufferManager
* manager
) {
603 framebuffer_manager_
= manager
;
606 // Init the texture manager.
609 // Must call before destruction.
610 void Destroy(bool have_context
);
612 // Returns the maximum number of levels.
613 GLint
MaxLevelsForTarget(GLenum target
) const {
617 case GL_TEXTURE_RECTANGLE_ARB
:
618 case GL_TEXTURE_EXTERNAL_OES
:
621 case GL_TEXTURE_2D_ARRAY
:
622 return max_3d_levels_
;
624 return max_cube_map_levels_
;
628 // Returns the maximum size.
629 GLsizei
MaxSizeForTarget(GLenum target
) const {
632 case GL_TEXTURE_EXTERNAL_OES
:
633 return max_texture_size_
;
634 case GL_TEXTURE_RECTANGLE
:
635 return max_rectangle_texture_size_
;
637 case GL_TEXTURE_2D_ARRAY
:
638 return max_3d_texture_size_
;
640 return max_cube_map_texture_size_
;
644 // Returns the maxium number of levels a texture of the given size can have.
645 static GLsizei
ComputeMipMapCount(GLenum target
,
650 // Checks if a dimensions are valid for a given target.
652 GLenum target
, GLint level
,
653 GLsizei width
, GLsizei height
, GLsizei depth
);
655 // True if this texture meets all the GLES2 criteria for rendering.
656 // See section 3.8.2 of the GLES2 spec.
657 bool CanRender(const TextureRef
* ref
) const {
658 return ref
->texture()->CanRender(feature_info_
.get());
661 // Returns true if mipmaps can be generated by GL.
662 bool CanGenerateMipmaps(const TextureRef
* ref
) const {
663 return ref
->texture()->CanGenerateMipmaps(feature_info_
.get());
666 // Sets the Texture's target
668 // target: GL_TEXTURE_2D or GL_TEXTURE_CUBE_MAP
669 // GL_TEXTURE_2D_ARRAY or GL_TEXTURE_3D (for GLES3)
670 // max_levels: The maximum levels this type of target can have.
675 // Set the info for a particular level in a TexureInfo.
676 void SetLevelInfo(TextureRef
* ref
,
679 GLenum internal_format
,
686 const gfx::Rect
& cleared_rect
);
688 Texture
* Produce(TextureRef
* ref
);
690 // Maps an existing texture into the texture manager, at a given client ID.
691 TextureRef
* Consume(GLuint client_id
, Texture
* texture
);
693 // Sets |rect| of mip as cleared.
694 void SetLevelClearedRect(TextureRef
* ref
,
697 const gfx::Rect
& cleared_rect
);
699 // Sets a mip as cleared.
700 void SetLevelCleared(TextureRef
* ref
, GLenum target
,
701 GLint level
, bool cleared
);
703 // Sets a texture parameter of a Texture
704 // Returns GL_NO_ERROR on success. Otherwise the error to generate.
705 // TODO(gman): Expand to SetParameteriv,fv
707 const char* function_name
, ErrorState
* error_state
,
708 TextureRef
* ref
, GLenum pname
, GLint param
);
710 const char* function_name
, ErrorState
* error_state
,
711 TextureRef
* ref
, GLenum pname
, GLfloat param
);
713 // Makes each of the mip levels as though they were generated.
714 // Returns false if that's not allowed for the given texture.
715 bool MarkMipmapsGenerated(TextureRef
* ref
);
717 // Clears any uncleared renderable levels.
718 bool ClearRenderableLevels(GLES2Decoder
* decoder
, TextureRef
* ref
);
720 // Clear a specific level.
721 bool ClearTextureLevel(
722 GLES2Decoder
* decoder
, TextureRef
* ref
, GLenum target
, GLint level
);
724 // Creates a new texture info.
725 TextureRef
* CreateTexture(GLuint client_id
, GLuint service_id
);
727 // Gets the texture info for the given texture.
728 TextureRef
* GetTexture(GLuint client_id
) const;
730 // Removes a texture info.
731 void RemoveTexture(GLuint client_id
);
733 // Gets a Texture for a given service id (note: it assumes the texture object
734 // is still mapped in this TextureManager).
735 Texture
* GetTextureForServiceId(GLuint service_id
) const;
737 TextureRef
* GetDefaultTextureInfo(GLenum target
) {
740 return default_textures_
[kTexture2D
].get();
741 case GL_TEXTURE_CUBE_MAP
:
742 return default_textures_
[kCubeMap
].get();
743 case GL_TEXTURE_EXTERNAL_OES
:
744 return default_textures_
[kExternalOES
].get();
745 case GL_TEXTURE_RECTANGLE_ARB
:
746 return default_textures_
[kRectangleARB
].get();
753 bool HaveUnrenderableTextures() const {
754 return num_unrenderable_textures_
> 0;
757 bool HaveUnsafeTextures() const {
758 return num_unsafe_textures_
> 0;
761 bool HaveUnclearedMips() const {
762 return num_uncleared_mips_
> 0;
765 bool HaveImages() const {
766 return num_images_
> 0;
769 GLuint
black_texture_id(GLenum target
) const {
772 return black_texture_ids_
[kTexture2D
];
773 case GL_SAMPLER_CUBE
:
774 return black_texture_ids_
[kCubeMap
];
775 case GL_SAMPLER_EXTERNAL_OES
:
776 return black_texture_ids_
[kExternalOES
];
777 case GL_SAMPLER_2D_RECT_ARB
:
778 return black_texture_ids_
[kRectangleARB
];
785 size_t mem_represented() const {
787 memory_tracker_managed_
->GetMemRepresented() +
788 memory_tracker_unmanaged_
->GetMemRepresented();
795 gfx::GLImage
* image
);
797 size_t GetSignatureSize() const;
803 std::string
* signature
) const;
805 void AddObserver(DestructionObserver
* observer
) {
806 destruction_observers_
.push_back(observer
);
809 void RemoveObserver(DestructionObserver
* observer
) {
810 for (unsigned int i
= 0; i
< destruction_observers_
.size(); i
++) {
811 if (destruction_observers_
[i
] == observer
) {
812 std::swap(destruction_observers_
[i
], destruction_observers_
.back());
813 destruction_observers_
.pop_back();
820 struct DoTexImageArguments
{
821 enum TexImageCommandType
{
828 GLenum internal_format
;
837 TexImageCommandType command_type
;
840 bool ValidateTexImage(
842 const char* function_name
,
843 const DoTexImageArguments
& args
,
844 // Pointer to TextureRef filled in if validation successful.
845 // Presumes the pointer is valid.
846 TextureRef
** texture_ref
);
848 void ValidateAndDoTexImage(
849 DecoderTextureState
* texture_state
,
851 DecoderFramebufferState
* framebuffer_state
,
852 const char* function_name
,
853 const DoTexImageArguments
& args
);
855 // TODO(kloveless): Make GetTexture* private once this is no longer called
856 // from gles2_cmd_decoder.
857 TextureRef
* GetTextureInfoForTarget(ContextState
* state
, GLenum target
);
858 TextureRef
* GetTextureInfoForTargetUnlessDefault(
859 ContextState
* state
, GLenum target
);
861 bool ValidateFormatAndTypeCombination(
862 ErrorState
* error_state
, const char* function_name
,
863 GLenum format
, GLenum type
);
865 // Note that internal_format is only checked in relation to the format
866 // parameter, so that this function may be used to validate texSubImage2D.
867 bool ValidateTextureParameters(
868 ErrorState
* error_state
, const char* function_name
,
869 GLenum format
, GLenum type
, GLenum internal_format
, GLint level
);
871 // base::trace_event::MemoryDumpProvider implementation.
872 bool OnMemoryDump(const base::trace_event::MemoryDumpArgs
& args
,
873 base::trace_event::ProcessMemoryDump
* pmd
) override
;
876 friend class Texture
;
877 friend class TextureRef
;
879 // Helper for Initialize().
880 scoped_refptr
<TextureRef
> CreateDefaultAndBlackTextures(
882 GLuint
* black_texture
);
885 DecoderTextureState
* texture_state
,
886 ErrorState
* error_state
,
887 DecoderFramebufferState
* framebuffer_state
,
888 const char* function_name
,
889 TextureRef
* texture_ref
,
890 const DoTexImageArguments
& args
);
892 void StartTracking(TextureRef
* texture
);
893 void StopTracking(TextureRef
* texture
);
895 void UpdateSafeToRenderFrom(int delta
);
896 void UpdateUnclearedMips(int delta
);
897 void UpdateCanRenderCondition(Texture::CanRenderCondition old_condition
,
898 Texture::CanRenderCondition new_condition
);
899 void UpdateNumImages(int delta
);
900 void IncFramebufferStateChangeCount();
902 GLenum
AdjustTexFormat(GLenum format
) const;
904 // Helper function called by OnMemoryDump.
905 void DumpTextureRef(base::trace_event::ProcessMemoryDump
* pmd
,
908 MemoryTypeTracker
* GetMemTracker(GLenum texture_pool
);
909 scoped_ptr
<MemoryTypeTracker
> memory_tracker_managed_
;
910 scoped_ptr
<MemoryTypeTracker
> memory_tracker_unmanaged_
;
911 MemoryTracker
* memory_tracker_
;
913 scoped_refptr
<FeatureInfo
> feature_info_
;
915 FramebufferManager
* framebuffer_manager_
;
917 // Info for each texture in the system.
918 typedef base::hash_map
<GLuint
, scoped_refptr
<TextureRef
> > TextureMap
;
919 TextureMap textures_
;
921 GLsizei max_texture_size_
;
922 GLsizei max_cube_map_texture_size_
;
923 GLsizei max_rectangle_texture_size_
;
924 GLsizei max_3d_texture_size_
;
926 GLint max_cube_map_levels_
;
927 GLint max_3d_levels_
;
929 const bool use_default_textures_
;
931 int num_unrenderable_textures_
;
932 int num_unsafe_textures_
;
933 int num_uncleared_mips_
;
936 // Counts the number of Textures allocated with 'this' as its manager.
937 // Allows to check no Texture will outlive this.
938 unsigned int texture_count_
;
942 // Black (0,0,0,1) textures for when non-renderable textures are used.
943 // NOTE: There is no corresponding Texture for these textures.
944 // TextureInfos are only for textures the client side can access.
945 GLuint black_texture_ids_
[kNumDefaultTextures
];
947 // The default textures for each target (texture name = 0)
948 scoped_refptr
<TextureRef
> default_textures_
[kNumDefaultTextures
];
950 std::vector
<DestructionObserver
*> destruction_observers_
;
952 DISALLOW_COPY_AND_ASSIGN(TextureManager
);
955 // This class records texture upload time when in scope.
956 class ScopedTextureUploadTimer
{
958 explicit ScopedTextureUploadTimer(DecoderTextureState
* texture_state
);
959 ~ScopedTextureUploadTimer();
962 DecoderTextureState
* texture_state_
;
963 base::TimeTicks begin_time_
;
964 DISALLOW_COPY_AND_ASSIGN(ScopedTextureUploadTimer
);
970 #endif // GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_