Home | History | Annotate | Download | only in service
      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.
      4 
      5 #ifndef GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_
      6 #define GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_
      7 
      8 #include <list>
      9 #include <set>
     10 #include <string>
     11 #include <vector>
     12 #include "base/basictypes.h"
     13 #include "base/containers/hash_tables.h"
     14 #include "base/logging.h"
     15 #include "base/memory/ref_counted.h"
     16 #include "base/observer_list.h"
     17 #include "gpu/command_buffer/service/async_pixel_transfer_delegate.h"
     18 #include "gpu/command_buffer/service/gl_utils.h"
     19 #include "gpu/command_buffer/service/memory_tracking.h"
     20 #include "gpu/gpu_export.h"
     21 #include "ui/gl/gl_image.h"
     22 
     23 namespace gpu {
     24 
     25 class StreamTextureManager;
     26 
     27 namespace gles2 {
     28 
     29 class GLES2Decoder;
     30 class Display;
     31 class ErrorState;
     32 class FeatureInfo;
     33 class FramebufferManager;
     34 class MailboxManager;
     35 class TextureManager;
     36 class TextureRef;
     37 
     38 // Info about Textures currently in the system.
     39 // This class wraps a real GL texture, keeping track of its meta-data. It is
     40 // jointly owned by possibly multiple TextureRef.
     41 class GPU_EXPORT Texture {
     42  public:
     43   explicit Texture(GLuint service_id);
     44 
     45   GLenum min_filter() const {
     46     return min_filter_;
     47   }
     48 
     49   GLenum mag_filter() const {
     50     return mag_filter_;
     51   }
     52 
     53   GLenum wrap_s() const {
     54     return wrap_s_;
     55   }
     56 
     57   GLenum wrap_t() const {
     58     return wrap_t_;
     59   }
     60 
     61   GLenum usage() const {
     62     return usage_;
     63   }
     64 
     65   GLenum pool() const {
     66     return pool_;
     67   }
     68 
     69   int num_uncleared_mips() const {
     70     return num_uncleared_mips_;
     71   }
     72 
     73   uint32 estimated_size() const {
     74     return estimated_size_;
     75   }
     76 
     77   bool CanRenderTo() const {
     78     return !stream_texture_ && target_ != GL_TEXTURE_EXTERNAL_OES;
     79   }
     80 
     81   // The service side OpenGL id of the texture.
     82   GLuint service_id() const {
     83     return service_id_;
     84   }
     85 
     86   void SetServiceId(GLuint service_id) {
     87     DCHECK(service_id);
     88     service_id_ = service_id;
     89   }
     90 
     91   // Returns the target this texure was first bound to or 0 if it has not
     92   // been bound. Once a texture is bound to a specific target it can never be
     93   // bound to a different target.
     94   GLenum target() const {
     95     return target_;
     96   }
     97 
     98   bool SafeToRenderFrom() const {
     99     return cleared_;
    100   }
    101 
    102   // Get the width and height for a particular level. Returns false if level
    103   // does not exist.
    104   bool GetLevelSize(
    105       GLint target, GLint level, GLsizei* width, GLsizei* height) const;
    106 
    107   // Get the type of a level. Returns false if level does not exist.
    108   bool GetLevelType(
    109       GLint target, GLint level, GLenum* type, GLenum* internal_format) const;
    110 
    111   // Get the image bound to a particular level. Returns NULL if level
    112   // does not exist.
    113   gfx::GLImage* GetLevelImage(GLint target, GLint level) const;
    114 
    115   // Returns true of the given dimensions are inside the dimensions of the
    116   // level and if the format and type match the level.
    117   bool ValidForTexture(
    118       GLint target,
    119       GLint level,
    120       GLint xoffset,
    121       GLint yoffset,
    122       GLsizei width,
    123       GLsizei height,
    124       GLenum format,
    125       GLenum type) const;
    126 
    127   bool IsValid() const {
    128     return !!target();
    129   }
    130 
    131   bool IsAttachedToFramebuffer() const {
    132     return framebuffer_attachment_count_ != 0;
    133   }
    134 
    135   void AttachToFramebuffer() {
    136     ++framebuffer_attachment_count_;
    137   }
    138 
    139   void DetachFromFramebuffer() {
    140     DCHECK_GT(framebuffer_attachment_count_, 0);
    141     --framebuffer_attachment_count_;
    142   }
    143 
    144   bool IsStreamTexture() const {
    145     return stream_texture_;
    146   }
    147 
    148   void SetImmutable(bool immutable) {
    149     immutable_ = immutable;
    150   }
    151 
    152   bool IsImmutable() const {
    153     return immutable_;
    154   }
    155 
    156   // Whether a particular level/face is cleared.
    157   bool IsLevelCleared(GLenum target, GLint level) const;
    158 
    159   // Whether the texture has been defined
    160   bool IsDefined() const {
    161     return estimated_size() > 0;
    162   }
    163 
    164  private:
    165   friend class MailboxManager;
    166   friend class MailboxManagerTest;
    167   friend class TextureManager;
    168   friend class TextureRef;
    169   friend class TextureTestHelper;
    170 
    171   ~Texture();
    172   void AddTextureRef(TextureRef* ref);
    173   void RemoveTextureRef(TextureRef* ref, bool have_context);
    174   MemoryTypeTracker* GetMemTracker();
    175 
    176   // Condition on which this texture is renderable. Can be ONLY_IF_NPOT if it
    177   // depends on context support for non-power-of-two textures (i.e. will be
    178   // renderable if NPOT support is in the context, otherwise not, e.g. texture
    179   // with a NPOT level). ALWAYS means it doesn't depend on context features
    180   // (e.g. complete POT), NEVER means it's not renderable regardless (e.g.
    181   // incomplete).
    182   enum CanRenderCondition {
    183     CAN_RENDER_ALWAYS,
    184     CAN_RENDER_NEVER,
    185     CAN_RENDER_ONLY_IF_NPOT
    186   };
    187 
    188   struct LevelInfo {
    189     LevelInfo();
    190     LevelInfo(const LevelInfo& rhs);
    191     ~LevelInfo();
    192 
    193     bool cleared;
    194     GLenum target;
    195     GLint level;
    196     GLenum internal_format;
    197     GLsizei width;
    198     GLsizei height;
    199     GLsizei depth;
    200     GLint border;
    201     GLenum format;
    202     GLenum type;
    203     scoped_refptr<gfx::GLImage> image;
    204     uint32 estimated_size;
    205   };
    206 
    207   // Set the info for a particular level.
    208   void SetLevelInfo(
    209       const FeatureInfo* feature_info,
    210       GLenum target,
    211       GLint level,
    212       GLenum internal_format,
    213       GLsizei width,
    214       GLsizei height,
    215       GLsizei depth,
    216       GLint border,
    217       GLenum format,
    218       GLenum type,
    219       bool cleared);
    220 
    221   // In GLES2 "texture complete" means it has all required mips for filtering
    222   // down to a 1x1 pixel texture, they are in the correct order, they are all
    223   // the same format.
    224   bool texture_complete() const {
    225     return texture_complete_;
    226   }
    227 
    228   // In GLES2 "cube complete" means all 6 faces level 0 are defined, all the
    229   // same format, all the same dimensions and all width = height.
    230   bool cube_complete() const {
    231     return cube_complete_;
    232   }
    233 
    234   // Whether or not this texture is a non-power-of-two texture.
    235   bool npot() const {
    236     return npot_;
    237   }
    238 
    239   void SetStreamTexture(bool stream_texture) {
    240     stream_texture_ = stream_texture;
    241     UpdateCanRenderCondition();
    242   }
    243 
    244   // Marks a particular level as cleared or uncleared.
    245   void SetLevelCleared(GLenum target, GLint level, bool cleared);
    246 
    247   // Updates the cleared flag for this texture by inspecting all the mips.
    248   void UpdateCleared();
    249 
    250   // Clears any renderable uncleared levels.
    251   // Returns false if a GL error was generated.
    252   bool ClearRenderableLevels(GLES2Decoder* decoder);
    253 
    254   // Clears the level.
    255   // Returns false if a GL error was generated.
    256   bool ClearLevel(GLES2Decoder* decoder, GLenum target, GLint level);
    257 
    258   // Sets a texture parameter.
    259   // TODO(gman): Expand to SetParameteri,f,iv,fv
    260   // Returns GL_NO_ERROR on success. Otherwise the error to generate.
    261   GLenum SetParameter(
    262       const FeatureInfo* feature_info, GLenum pname, GLint param);
    263 
    264   // Makes each of the mip levels as though they were generated.
    265   bool MarkMipmapsGenerated(const FeatureInfo* feature_info);
    266 
    267   bool NeedsMips() const {
    268     return min_filter_ != GL_NEAREST && min_filter_ != GL_LINEAR;
    269   }
    270 
    271   // True if this texture meets all the GLES2 criteria for rendering.
    272   // See section 3.8.2 of the GLES2 spec.
    273   bool CanRender(const FeatureInfo* feature_info) const;
    274 
    275   // Returns true if mipmaps can be generated by GL.
    276   bool CanGenerateMipmaps(const FeatureInfo* feature_info) const;
    277 
    278   // Sets the Texture's target
    279   // Parameters:
    280   //   target: GL_TEXTURE_2D or GL_TEXTURE_CUBE_MAP or
    281   //           GL_TEXTURE_EXTERNAL_OES or GL_TEXTURE_RECTANGLE_ARB
    282   //   max_levels: The maximum levels this type of target can have.
    283   void SetTarget(
    284       const FeatureInfo* feature_info, GLenum target, GLint max_levels);
    285 
    286   // Update info about this texture.
    287   void Update(const FeatureInfo* feature_info);
    288 
    289   // Set the image for a particular level.
    290   void SetLevelImage(
    291       const FeatureInfo* feature_info,
    292       GLenum target,
    293       GLint level,
    294       gfx::GLImage* image);
    295 
    296   // Appends a signature for the given level.
    297   void AddToSignature(
    298       const FeatureInfo* feature_info,
    299       GLenum target, GLint level, std::string* signature) const;
    300 
    301   void SetMailboxManager(MailboxManager* mailbox_manager);
    302 
    303   // Updates the unsafe textures count in all the managers referencing this
    304   // texture.
    305   void UpdateSafeToRenderFrom(bool cleared);
    306 
    307   // Updates the uncleared mip count in all the managers referencing this
    308   // texture.
    309   void UpdateMipCleared(LevelInfo* info, bool cleared);
    310 
    311   // Computes the CanRenderCondition flag.
    312   CanRenderCondition GetCanRenderCondition() const;
    313 
    314   // Updates the unrenderable texture count in all the managers referencing this
    315   // texture.
    316   void UpdateCanRenderCondition();
    317 
    318   // Increment the framebuffer state change count in all the managers
    319   // referencing this texture.
    320   void IncAllFramebufferStateChangeCount();
    321 
    322   MailboxManager* mailbox_manager_;
    323 
    324   // Info about each face and level of texture.
    325   std::vector<std::vector<LevelInfo> > level_infos_;
    326 
    327   // The texture refs that point to this Texture.
    328   typedef std::set<TextureRef*> RefSet;
    329   RefSet refs_;
    330 
    331   // The single TextureRef that accounts for memory for this texture. Must be
    332   // one of refs_.
    333   TextureRef* memory_tracking_ref_;
    334 
    335   // The id of the texure
    336   GLuint service_id_;
    337 
    338   // Whether all renderable mips of this texture have been cleared.
    339   bool cleared_;
    340 
    341   int num_uncleared_mips_;
    342 
    343   // The target. 0 if unset, otherwise GL_TEXTURE_2D or GL_TEXTURE_CUBE_MAP.
    344   GLenum target_;
    345 
    346   // Texture parameters.
    347   GLenum min_filter_;
    348   GLenum mag_filter_;
    349   GLenum wrap_s_;
    350   GLenum wrap_t_;
    351   GLenum usage_;
    352   GLenum pool_;
    353 
    354   // The maximum level that has been set.
    355   GLint max_level_set_;
    356 
    357   // Whether or not this texture is "texture complete"
    358   bool texture_complete_;
    359 
    360   // Whether or not this texture is "cube complete"
    361   bool cube_complete_;
    362 
    363   // Whether or not this texture is non-power-of-two
    364   bool npot_;
    365 
    366   // Whether this texture has ever been bound.
    367   bool has_been_bound_;
    368 
    369   // The number of framebuffers this texture is attached to.
    370   int framebuffer_attachment_count_;
    371 
    372   // Whether this is a special streaming texture.
    373   bool stream_texture_;
    374 
    375   // Whether the texture is immutable and no further changes to the format
    376   // or dimensions of the texture object can be made.
    377   bool immutable_;
    378 
    379   // Size in bytes this texture is assumed to take in memory.
    380   uint32 estimated_size_;
    381 
    382   // Cache of the computed CanRenderCondition flag.
    383   CanRenderCondition can_render_condition_;
    384 
    385   DISALLOW_COPY_AND_ASSIGN(Texture);
    386 };
    387 
    388 // This class represents a texture in a client context group. It's mostly 1:1
    389 // with a client id, though it can outlive the client id if it's still bound to
    390 // a FBO or another context when destroyed.
    391 // Multiple TextureRef can point to the same texture with cross-context sharing.
    392 //
    393 // Note: for stream textures, the TextureRef that created the stream texture is
    394 // set as the "owner" of the stream texture, i.e. it will call
    395 // DestroyStreamTexture on destruction. This is because the StreamTextureManager
    396 // isn't generally shared between ContextGroups, so ownership can't be at the
    397 // Texture level. We also can't have multiple StreamTexture on the same service
    398 // id, so there can be only one owner.
    399 class GPU_EXPORT TextureRef : public base::RefCounted<TextureRef> {
    400  public:
    401   TextureRef(TextureManager* manager, GLuint client_id, Texture* texture);
    402   static scoped_refptr<TextureRef> Create(TextureManager* manager,
    403                                           GLuint client_id,
    404                                           GLuint service_id);
    405   const Texture* texture() const { return texture_; }
    406   Texture* texture() { return texture_; }
    407   GLuint client_id() const { return client_id_; }
    408   GLuint service_id() const { return texture_->service_id(); }
    409 
    410  private:
    411   friend class base::RefCounted<TextureRef>;
    412   friend class Texture;
    413   friend class TextureManager;
    414 
    415   ~TextureRef();
    416   const TextureManager* manager() const { return manager_; }
    417   TextureManager* manager() { return manager_; }
    418   void reset_client_id() { client_id_ = 0; }
    419   void set_is_stream_texture_owner(bool owner) {
    420     is_stream_texture_owner_ = owner;
    421   }
    422   bool is_stream_texture_owner() const { return is_stream_texture_owner_; }
    423 
    424   TextureManager* manager_;
    425   Texture* texture_;
    426   GLuint client_id_;
    427   bool is_stream_texture_owner_;
    428 
    429   DISALLOW_COPY_AND_ASSIGN(TextureRef);
    430 };
    431 
    432 // This class keeps track of the textures and their sizes so we can do NPOT and
    433 // texture complete checking.
    434 //
    435 // NOTE: To support shared resources an instance of this class will need to be
    436 // shared by multiple GLES2Decoders.
    437 class GPU_EXPORT TextureManager {
    438  public:
    439   class GPU_EXPORT DestructionObserver {
    440    public:
    441     DestructionObserver();
    442     virtual ~DestructionObserver();
    443 
    444     // Called in ~TextureManager.
    445     virtual void OnTextureManagerDestroying(TextureManager* manager) = 0;
    446 
    447     // Called via ~TextureRef.
    448     virtual void OnTextureRefDestroying(TextureRef* texture) = 0;
    449 
    450    private:
    451     DISALLOW_COPY_AND_ASSIGN(DestructionObserver);
    452   };
    453 
    454   enum DefaultAndBlackTextures {
    455     kTexture2D,
    456     kCubeMap,
    457     kExternalOES,
    458     kRectangleARB,
    459     kNumDefaultTextures
    460   };
    461 
    462   TextureManager(MemoryTracker* memory_tracker,
    463                  FeatureInfo* feature_info,
    464                  GLsizei max_texture_size,
    465                  GLsizei max_cube_map_texture_size);
    466   ~TextureManager();
    467 
    468   void set_framebuffer_manager(FramebufferManager* manager) {
    469     framebuffer_manager_ = manager;
    470   }
    471 
    472   void set_stream_texture_manager(StreamTextureManager* manager) {
    473     stream_texture_manager_ = manager;
    474   }
    475 
    476   // Init the texture manager.
    477   bool Initialize();
    478 
    479   // Must call before destruction.
    480   void Destroy(bool have_context);
    481 
    482   // Returns the maximum number of levels.
    483   GLint MaxLevelsForTarget(GLenum target) const {
    484     switch (target) {
    485       case GL_TEXTURE_2D:
    486         return  max_levels_;
    487       case GL_TEXTURE_EXTERNAL_OES:
    488         return 1;
    489       default:
    490         return max_cube_map_levels_;
    491     }
    492   }
    493 
    494   // Returns the maximum size.
    495   GLsizei MaxSizeForTarget(GLenum target) const {
    496     switch (target) {
    497       case GL_TEXTURE_2D:
    498       case GL_TEXTURE_EXTERNAL_OES:
    499         return max_texture_size_;
    500       default:
    501         return max_cube_map_texture_size_;
    502     }
    503   }
    504 
    505   // Returns the maxium number of levels a texture of the given size can have.
    506   static GLsizei ComputeMipMapCount(
    507     GLsizei width, GLsizei height, GLsizei depth);
    508 
    509   // Checks if a dimensions are valid for a given target.
    510   bool ValidForTarget(
    511       GLenum target, GLint level,
    512       GLsizei width, GLsizei height, GLsizei depth);
    513 
    514   // True if this texture meets all the GLES2 criteria for rendering.
    515   // See section 3.8.2 of the GLES2 spec.
    516   bool CanRender(const TextureRef* ref) const {
    517     return ref->texture()->CanRender(feature_info_.get());
    518   }
    519 
    520   // Returns true if mipmaps can be generated by GL.
    521   bool CanGenerateMipmaps(const TextureRef* ref) const {
    522     return ref->texture()->CanGenerateMipmaps(feature_info_.get());
    523   }
    524 
    525   // Sets the Texture's target
    526   // Parameters:
    527   //   target: GL_TEXTURE_2D or GL_TEXTURE_CUBE_MAP
    528   //   max_levels: The maximum levels this type of target can have.
    529   void SetTarget(
    530       TextureRef* ref,
    531       GLenum target);
    532 
    533   // Marks a texture as a stream texture, and the ref as the stream texture
    534   // owner.
    535   void SetStreamTexture(TextureRef* ref, bool stream_texture);
    536 
    537   // Whether the TextureRef is the stream texture owner.
    538   bool IsStreamTextureOwner(TextureRef* ref);
    539 
    540   // Set the info for a particular level in a TexureInfo.
    541   void SetLevelInfo(
    542       TextureRef* ref,
    543       GLenum target,
    544       GLint level,
    545       GLenum internal_format,
    546       GLsizei width,
    547       GLsizei height,
    548       GLsizei depth,
    549       GLint border,
    550       GLenum format,
    551       GLenum type,
    552       bool cleared);
    553 
    554   // Adapter to call above function.
    555   void SetLevelInfoFromParams(TextureRef* ref,
    556                               const gpu::AsyncTexImage2DParams& params) {
    557     SetLevelInfo(
    558         ref, params.target, params.level, params.internal_format,
    559         params.width, params.height, 1 /* depth */,
    560         params.border, params.format,
    561         params.type, true /* cleared */ );
    562   }
    563 
    564   Texture* Produce(TextureRef* ref);
    565 
    566   // Maps an existing texture into the texture manager, at a given client ID.
    567   TextureRef* Consume(GLuint client_id, Texture* texture);
    568 
    569   // Sets a mip as cleared.
    570   void SetLevelCleared(TextureRef* ref, GLenum target,
    571                        GLint level, bool cleared);
    572 
    573   // Sets a texture parameter of a Texture
    574   // Returns GL_NO_ERROR on success. Otherwise the error to generate.
    575   // TODO(gman): Expand to SetParameteri,f,iv,fv
    576   void SetParameter(
    577       const char* function_name, ErrorState* error_state,
    578       TextureRef* ref, GLenum pname, GLint param);
    579 
    580   // Makes each of the mip levels as though they were generated.
    581   // Returns false if that's not allowed for the given texture.
    582   bool MarkMipmapsGenerated(TextureRef* ref);
    583 
    584   // Clears any uncleared renderable levels.
    585   bool ClearRenderableLevels(GLES2Decoder* decoder, TextureRef* ref);
    586 
    587   // Clear a specific level.
    588   bool ClearTextureLevel(
    589       GLES2Decoder* decoder, TextureRef* ref, GLenum target, GLint level);
    590 
    591   // Creates a new texture info.
    592   TextureRef* CreateTexture(GLuint client_id, GLuint service_id);
    593 
    594   // Gets the texture info for the given texture.
    595   TextureRef* GetTexture(GLuint client_id) const;
    596 
    597   // Removes a texture info.
    598   void RemoveTexture(GLuint client_id);
    599 
    600   // Gets a Texture for a given service id (note: it assumes the texture object
    601   // is still mapped in this TextureManager).
    602   Texture* GetTextureForServiceId(GLuint service_id) const;
    603 
    604   TextureRef* GetDefaultTextureInfo(GLenum target) {
    605     switch (target) {
    606       case GL_TEXTURE_2D:
    607         return default_textures_[kTexture2D].get();
    608       case GL_TEXTURE_CUBE_MAP:
    609         return default_textures_[kCubeMap].get();
    610       case GL_TEXTURE_EXTERNAL_OES:
    611         return default_textures_[kExternalOES].get();
    612       case GL_TEXTURE_RECTANGLE_ARB:
    613         return default_textures_[kRectangleARB].get();
    614       default:
    615         NOTREACHED();
    616         return NULL;
    617     }
    618   }
    619 
    620   bool HaveUnrenderableTextures() const {
    621     return num_unrenderable_textures_ > 0;
    622   }
    623 
    624   bool HaveUnsafeTextures() const {
    625     return num_unsafe_textures_ > 0;
    626   }
    627 
    628   bool HaveUnclearedMips() const {
    629     return num_uncleared_mips_ > 0;
    630   }
    631 
    632   GLuint black_texture_id(GLenum target) const {
    633     switch (target) {
    634       case GL_SAMPLER_2D:
    635         return black_texture_ids_[kTexture2D];
    636       case GL_SAMPLER_CUBE:
    637         return black_texture_ids_[kCubeMap];
    638       case GL_SAMPLER_EXTERNAL_OES:
    639         return black_texture_ids_[kExternalOES];
    640       case GL_SAMPLER_2D_RECT_ARB:
    641         return black_texture_ids_[kRectangleARB];
    642       default:
    643         NOTREACHED();
    644         return 0;
    645     }
    646   }
    647 
    648   size_t mem_represented() const {
    649     return
    650         memory_tracker_managed_->GetMemRepresented() +
    651         memory_tracker_unmanaged_->GetMemRepresented();
    652   }
    653 
    654   void SetLevelImage(
    655       TextureRef* ref,
    656       GLenum target,
    657       GLint level,
    658       gfx::GLImage* image);
    659 
    660   void AddToSignature(
    661       TextureRef* ref,
    662       GLenum target,
    663       GLint level,
    664       std::string* signature) const;
    665 
    666   void AddObserver(DestructionObserver* observer) {
    667     destruction_observers_.AddObserver(observer);
    668   }
    669 
    670   void RemoveObserver(DestructionObserver* observer) {
    671     destruction_observers_.RemoveObserver(observer);
    672   }
    673 
    674  private:
    675   friend class Texture;
    676   friend class TextureRef;
    677 
    678   // Helper for Initialize().
    679   scoped_refptr<TextureRef> CreateDefaultAndBlackTextures(
    680       GLenum target,
    681       GLuint* black_texture);
    682 
    683   void StartTracking(TextureRef* texture);
    684   void StopTracking(TextureRef* texture);
    685 
    686   void UpdateSafeToRenderFrom(int delta);
    687   void UpdateUnclearedMips(int delta);
    688   void UpdateCanRenderCondition(Texture::CanRenderCondition old_condition,
    689                                 Texture::CanRenderCondition new_condition);
    690   void IncFramebufferStateChangeCount();
    691 
    692   MemoryTypeTracker* GetMemTracker(GLenum texture_pool);
    693   scoped_ptr<MemoryTypeTracker> memory_tracker_managed_;
    694   scoped_ptr<MemoryTypeTracker> memory_tracker_unmanaged_;
    695 
    696   scoped_refptr<FeatureInfo> feature_info_;
    697 
    698   FramebufferManager* framebuffer_manager_;
    699   StreamTextureManager* stream_texture_manager_;
    700 
    701   // Info for each texture in the system.
    702   typedef base::hash_map<GLuint, scoped_refptr<TextureRef> > TextureMap;
    703   TextureMap textures_;
    704 
    705   GLsizei max_texture_size_;
    706   GLsizei max_cube_map_texture_size_;
    707   GLint max_levels_;
    708   GLint max_cube_map_levels_;
    709 
    710   int num_unrenderable_textures_;
    711   int num_unsafe_textures_;
    712   int num_uncleared_mips_;
    713 
    714   // Counts the number of Textures allocated with 'this' as its manager.
    715   // Allows to check no Texture will outlive this.
    716   unsigned int texture_count_;
    717 
    718   bool have_context_;
    719 
    720   // Black (0,0,0,1) textures for when non-renderable textures are used.
    721   // NOTE: There is no corresponding Texture for these textures.
    722   // TextureInfos are only for textures the client side can access.
    723   GLuint black_texture_ids_[kNumDefaultTextures];
    724 
    725   // The default textures for each target (texture name = 0)
    726   scoped_refptr<TextureRef> default_textures_[kNumDefaultTextures];
    727 
    728   ObserverList<DestructionObserver> destruction_observers_;
    729 
    730   DISALLOW_COPY_AND_ASSIGN(TextureManager);
    731 };
    732 
    733 }  // namespace gles2
    734 }  // namespace gpu
    735 
    736 #endif  // GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_
    737