1 /* 2 * Copyright 2014 Google Inc. 3 * 4 * Use of this source code is governed by a BSD-style license that can be 5 * found in the LICENSE file. 6 */ 7 8 #ifndef GrTexturePriv_DEFINED 9 #define GrTexturePriv_DEFINED 10 11 #include "include/gpu/GrTexture.h" 12 #include "src/gpu/GrSamplerState.h" 13 14 /** Class that adds methods to GrTexture that are only intended for use internal to Skia. 15 This class is purely a privileged window into GrTexture. It should never have additional data 16 members or virtual methods. 17 Non-static methods that are not trivial inlines should be spring-boarded (e.g. declared and 18 implemented privately in GrTexture with a inline public method here). */ 19 class GrTexturePriv { 20 public: markMipMapsDirty()21 void markMipMapsDirty() { 22 fTexture->markMipMapsDirty(); 23 } 24 markMipMapsClean()25 void markMipMapsClean() { 26 fTexture->markMipMapsClean(); 27 } 28 mipMapsStatus()29 GrMipMapsStatus mipMapsStatus() const { return fTexture->fMipMapsStatus; } 30 mipMapsAreDirty()31 bool mipMapsAreDirty() const { 32 return GrMipMapsStatus::kValid != this->mipMapsStatus(); 33 } 34 mipMapped()35 GrMipMapped mipMapped() const { 36 if (GrMipMapsStatus::kNotAllocated != this->mipMapsStatus()) { 37 return GrMipMapped::kYes; 38 } 39 return GrMipMapped::kNo; 40 } 41 maxMipMapLevel()42 int maxMipMapLevel() const { 43 return fTexture->fMaxMipMapLevel; 44 } 45 textureType()46 GrTextureType textureType() const { return fTexture->fTextureType; } hasRestrictedSampling()47 bool hasRestrictedSampling() const { 48 return GrTextureTypeHasRestrictedSampling(this->textureType()); 49 } 50 /** Filtering is clamped to this value. */ highestFilterMode()51 GrSamplerState::Filter highestFilterMode() const { 52 return this->hasRestrictedSampling() ? GrSamplerState::Filter::kBilerp 53 : GrSamplerState::Filter::kMipMap; 54 } 55 56 static void ComputeScratchKey(const GrSurfaceDesc&, GrRenderable, int sampleCnt, GrScratchKey*); 57 static void ComputeScratchKey(GrPixelConfig config, int width, int height, GrRenderable, 58 int sampleCnt, GrMipMapped, GrScratchKey* key); 59 60 private: GrTexturePriv(GrTexture * texture)61 GrTexturePriv(GrTexture* texture) : fTexture(texture) { } GrTexturePriv(const GrTexturePriv & that)62 GrTexturePriv(const GrTexturePriv& that) : fTexture(that.fTexture) { } 63 GrTexturePriv& operator=(const GrTexturePriv&); // unimpl 64 65 // No taking addresses of this type. 66 const GrTexturePriv* operator&() const; 67 GrTexturePriv* operator&(); 68 69 GrTexture* fTexture; 70 71 friend class GrTexture; // to construct/copy this type. 72 }; 73 texturePriv()74inline GrTexturePriv GrTexture::texturePriv() { return GrTexturePriv(this); } 75 texturePriv()76inline const GrTexturePriv GrTexture::texturePriv () const { 77 return GrTexturePriv(const_cast<GrTexture*>(this)); 78 } 79 80 #endif 81