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/async_pixel_transfer_delegate.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(bool texsubimage_faster_than_teximage
)
540 : tex_image_failed(false),
541 texture_upload_count(0),
542 texsubimage_faster_than_teximage(texsubimage_faster_than_teximage
) {}
544 // This indicates all the following texSubImage*D calls that are part of the
545 // failed texImage*D call should be ignored. The client calls have a lock
546 // around them, so it will affect only a single texImage*D + texSubImage*D
548 bool tex_image_failed
;
550 // Command buffer stats.
551 int texture_upload_count
;
552 base::TimeDelta total_texture_upload_time
;
554 bool texsubimage_faster_than_teximage
;
557 // This class keeps track of the textures and their sizes so we can do NPOT and
558 // texture complete checking.
560 // NOTE: To support shared resources an instance of this class will need to be
561 // shared by multiple GLES2Decoders.
562 class GPU_EXPORT TextureManager
: public base::trace_event::MemoryDumpProvider
{
564 class GPU_EXPORT DestructionObserver
{
566 DestructionObserver();
567 virtual ~DestructionObserver();
569 // Called in ~TextureManager.
570 virtual void OnTextureManagerDestroying(TextureManager
* manager
) = 0;
572 // Called via ~TextureRef.
573 virtual void OnTextureRefDestroying(TextureRef
* texture
) = 0;
576 DISALLOW_COPY_AND_ASSIGN(DestructionObserver
);
579 enum DefaultAndBlackTextures
{
587 TextureManager(MemoryTracker
* memory_tracker
,
588 FeatureInfo
* feature_info
,
589 GLsizei max_texture_size
,
590 GLsizei max_cube_map_texture_size
,
591 GLsizei max_rectangle_texture_size
,
592 GLsizei max_3d_texture_size
,
593 bool use_default_textures
);
594 ~TextureManager() override
;
596 void set_framebuffer_manager(FramebufferManager
* manager
) {
597 framebuffer_manager_
= manager
;
600 // Init the texture manager.
603 // Must call before destruction.
604 void Destroy(bool have_context
);
606 // Returns the maximum number of levels.
607 GLint
MaxLevelsForTarget(GLenum target
) const {
611 case GL_TEXTURE_RECTANGLE_ARB
:
612 case GL_TEXTURE_EXTERNAL_OES
:
615 case GL_TEXTURE_2D_ARRAY
:
616 return max_3d_levels_
;
618 return max_cube_map_levels_
;
622 // Returns the maximum size.
623 GLsizei
MaxSizeForTarget(GLenum target
) const {
626 case GL_TEXTURE_EXTERNAL_OES
:
627 return max_texture_size_
;
628 case GL_TEXTURE_RECTANGLE
:
629 return max_rectangle_texture_size_
;
631 case GL_TEXTURE_2D_ARRAY
:
632 return max_3d_texture_size_
;
634 return max_cube_map_texture_size_
;
638 // Returns the maxium number of levels a texture of the given size can have.
639 static GLsizei
ComputeMipMapCount(GLenum target
,
644 // Checks if a dimensions are valid for a given target.
646 GLenum target
, GLint level
,
647 GLsizei width
, GLsizei height
, GLsizei depth
);
649 // True if this texture meets all the GLES2 criteria for rendering.
650 // See section 3.8.2 of the GLES2 spec.
651 bool CanRender(const TextureRef
* ref
) const {
652 return ref
->texture()->CanRender(feature_info_
.get());
655 // Returns true if mipmaps can be generated by GL.
656 bool CanGenerateMipmaps(const TextureRef
* ref
) const {
657 return ref
->texture()->CanGenerateMipmaps(feature_info_
.get());
660 // Sets the Texture's target
662 // target: GL_TEXTURE_2D or GL_TEXTURE_CUBE_MAP
663 // GL_TEXTURE_2D_ARRAY or GL_TEXTURE_3D (for GLES3)
664 // max_levels: The maximum levels this type of target can have.
669 // Set the info for a particular level in a TexureInfo.
670 void SetLevelInfo(TextureRef
* ref
,
673 GLenum internal_format
,
680 const gfx::Rect
& cleared_rect
);
682 // Adapter to call above function.
683 void SetLevelInfoFromParams(TextureRef
* ref
,
684 const gpu::AsyncTexImage2DParams
& params
) {
685 SetLevelInfo(ref
, params
.target
, params
.level
, params
.internal_format
,
686 params
.width
, params
.height
, 1 /* depth */, params
.border
,
687 params
.format
, params
.type
,
688 gfx::Rect(params
.width
, params
.height
) /* cleared_rect */);
691 Texture
* Produce(TextureRef
* ref
);
693 // Maps an existing texture into the texture manager, at a given client ID.
694 TextureRef
* Consume(GLuint client_id
, Texture
* texture
);
696 // Sets |rect| of mip as cleared.
697 void SetLevelClearedRect(TextureRef
* ref
,
700 const gfx::Rect
& cleared_rect
);
702 // Sets a mip as cleared.
703 void SetLevelCleared(TextureRef
* ref
, GLenum target
,
704 GLint level
, bool cleared
);
706 // Sets a texture parameter of a Texture
707 // Returns GL_NO_ERROR on success. Otherwise the error to generate.
708 // TODO(gman): Expand to SetParameteriv,fv
710 const char* function_name
, ErrorState
* error_state
,
711 TextureRef
* ref
, GLenum pname
, GLint param
);
713 const char* function_name
, ErrorState
* error_state
,
714 TextureRef
* ref
, GLenum pname
, GLfloat param
);
716 // Makes each of the mip levels as though they were generated.
717 // Returns false if that's not allowed for the given texture.
718 bool MarkMipmapsGenerated(TextureRef
* ref
);
720 // Clears any uncleared renderable levels.
721 bool ClearRenderableLevels(GLES2Decoder
* decoder
, TextureRef
* ref
);
723 // Clear a specific level.
724 bool ClearTextureLevel(
725 GLES2Decoder
* decoder
, TextureRef
* ref
, GLenum target
, GLint level
);
727 // Creates a new texture info.
728 TextureRef
* CreateTexture(GLuint client_id
, GLuint service_id
);
730 // Gets the texture info for the given texture.
731 TextureRef
* GetTexture(GLuint client_id
) const;
733 // Removes a texture info.
734 void RemoveTexture(GLuint client_id
);
736 // Gets a Texture for a given service id (note: it assumes the texture object
737 // is still mapped in this TextureManager).
738 Texture
* GetTextureForServiceId(GLuint service_id
) const;
740 TextureRef
* GetDefaultTextureInfo(GLenum target
) {
743 return default_textures_
[kTexture2D
].get();
744 case GL_TEXTURE_CUBE_MAP
:
745 return default_textures_
[kCubeMap
].get();
746 case GL_TEXTURE_EXTERNAL_OES
:
747 return default_textures_
[kExternalOES
].get();
748 case GL_TEXTURE_RECTANGLE_ARB
:
749 return default_textures_
[kRectangleARB
].get();
756 bool HaveUnrenderableTextures() const {
757 return num_unrenderable_textures_
> 0;
760 bool HaveUnsafeTextures() const {
761 return num_unsafe_textures_
> 0;
764 bool HaveUnclearedMips() const {
765 return num_uncleared_mips_
> 0;
768 bool HaveImages() const {
769 return num_images_
> 0;
772 GLuint
black_texture_id(GLenum target
) const {
775 return black_texture_ids_
[kTexture2D
];
776 case GL_SAMPLER_CUBE
:
777 return black_texture_ids_
[kCubeMap
];
778 case GL_SAMPLER_EXTERNAL_OES
:
779 return black_texture_ids_
[kExternalOES
];
780 case GL_SAMPLER_2D_RECT_ARB
:
781 return black_texture_ids_
[kRectangleARB
];
788 size_t mem_represented() const {
790 memory_tracker_managed_
->GetMemRepresented() +
791 memory_tracker_unmanaged_
->GetMemRepresented();
798 gfx::GLImage
* image
);
800 size_t GetSignatureSize() const;
806 std::string
* signature
) const;
808 void AddObserver(DestructionObserver
* observer
) {
809 destruction_observers_
.push_back(observer
);
812 void RemoveObserver(DestructionObserver
* observer
) {
813 for (unsigned int i
= 0; i
< destruction_observers_
.size(); i
++) {
814 if (destruction_observers_
[i
] == observer
) {
815 std::swap(destruction_observers_
[i
], destruction_observers_
.back());
816 destruction_observers_
.pop_back();
823 struct DoTexImageArguments
{
824 enum TexImageCommandType
{
831 GLenum internal_format
;
840 TexImageCommandType command_type
;
843 bool ValidateTexImage(
845 const char* function_name
,
846 const DoTexImageArguments
& args
,
847 // Pointer to TextureRef filled in if validation successful.
848 // Presumes the pointer is valid.
849 TextureRef
** texture_ref
);
851 void ValidateAndDoTexImage(
852 DecoderTextureState
* texture_state
,
854 DecoderFramebufferState
* framebuffer_state
,
855 const char* function_name
,
856 const DoTexImageArguments
& args
);
858 // TODO(kloveless): Make GetTexture* private once this is no longer called
859 // from gles2_cmd_decoder.
860 TextureRef
* GetTextureInfoForTarget(ContextState
* state
, GLenum target
);
861 TextureRef
* GetTextureInfoForTargetUnlessDefault(
862 ContextState
* state
, GLenum target
);
864 bool ValidateFormatAndTypeCombination(
865 ErrorState
* error_state
, const char* function_name
,
866 GLenum format
, GLenum type
);
868 // Note that internal_format is only checked in relation to the format
869 // parameter, so that this function may be used to validate texSubImage2D.
870 bool ValidateTextureParameters(
871 ErrorState
* error_state
, const char* function_name
,
872 GLenum format
, GLenum type
, GLenum internal_format
, GLint level
);
874 // base::trace_event::MemoryDumpProvider implementation.
875 bool OnMemoryDump(const base::trace_event::MemoryDumpArgs
& args
,
876 base::trace_event::ProcessMemoryDump
* pmd
) override
;
879 friend class Texture
;
880 friend class TextureRef
;
882 // Helper for Initialize().
883 scoped_refptr
<TextureRef
> CreateDefaultAndBlackTextures(
885 GLuint
* black_texture
);
888 DecoderTextureState
* texture_state
,
889 ErrorState
* error_state
,
890 DecoderFramebufferState
* framebuffer_state
,
891 const char* function_name
,
892 TextureRef
* texture_ref
,
893 const DoTexImageArguments
& args
);
895 void StartTracking(TextureRef
* texture
);
896 void StopTracking(TextureRef
* texture
);
898 void UpdateSafeToRenderFrom(int delta
);
899 void UpdateUnclearedMips(int delta
);
900 void UpdateCanRenderCondition(Texture::CanRenderCondition old_condition
,
901 Texture::CanRenderCondition new_condition
);
902 void UpdateNumImages(int delta
);
903 void IncFramebufferStateChangeCount();
905 GLenum
AdjustTexFormat(GLenum format
) const;
907 // Helper function called by OnMemoryDump.
908 void DumpTextureRef(base::trace_event::ProcessMemoryDump
* pmd
,
911 MemoryTypeTracker
* GetMemTracker(GLenum texture_pool
);
912 scoped_ptr
<MemoryTypeTracker
> memory_tracker_managed_
;
913 scoped_ptr
<MemoryTypeTracker
> memory_tracker_unmanaged_
;
914 MemoryTracker
* memory_tracker_
;
916 scoped_refptr
<FeatureInfo
> feature_info_
;
918 FramebufferManager
* framebuffer_manager_
;
920 // Info for each texture in the system.
921 typedef base::hash_map
<GLuint
, scoped_refptr
<TextureRef
> > TextureMap
;
922 TextureMap textures_
;
924 GLsizei max_texture_size_
;
925 GLsizei max_cube_map_texture_size_
;
926 GLsizei max_rectangle_texture_size_
;
927 GLsizei max_3d_texture_size_
;
929 GLint max_cube_map_levels_
;
930 GLint max_3d_levels_
;
932 const bool use_default_textures_
;
934 int num_unrenderable_textures_
;
935 int num_unsafe_textures_
;
936 int num_uncleared_mips_
;
939 // Counts the number of Textures allocated with 'this' as its manager.
940 // Allows to check no Texture will outlive this.
941 unsigned int texture_count_
;
945 // Black (0,0,0,1) textures for when non-renderable textures are used.
946 // NOTE: There is no corresponding Texture for these textures.
947 // TextureInfos are only for textures the client side can access.
948 GLuint black_texture_ids_
[kNumDefaultTextures
];
950 // The default textures for each target (texture name = 0)
951 scoped_refptr
<TextureRef
> default_textures_
[kNumDefaultTextures
];
953 std::vector
<DestructionObserver
*> destruction_observers_
;
955 DISALLOW_COPY_AND_ASSIGN(TextureManager
);
958 // This class records texture upload time when in scope.
959 class ScopedTextureUploadTimer
{
961 explicit ScopedTextureUploadTimer(DecoderTextureState
* texture_state
);
962 ~ScopedTextureUploadTimer();
965 DecoderTextureState
* texture_state_
;
966 base::TimeTicks begin_time_
;
967 DISALLOW_COPY_AND_ASSIGN(ScopedTextureUploadTimer
);
973 #endif // GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_