1 /* 2 * Copyright 2016 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 GrTextureProxy_DEFINED 9 #define GrTextureProxy_DEFINED 10 11 #include "GrSamplerParams.h" 12 #include "GrSurfaceProxy.h" 13 14 class GrCaps; 15 class GrResourceProvider; 16 class GrTextureOpList; 17 18 // This class delays the acquisition of textures until they are actually required 19 class GrTextureProxy : virtual public GrSurfaceProxy { 20 public: asTextureProxy()21 GrTextureProxy* asTextureProxy() override { return this; } asTextureProxy()22 const GrTextureProxy* asTextureProxy() const override { return this; } 23 24 // Actually instantiate the backing texture, if necessary 25 bool instantiate(GrResourceProvider*) override; 26 27 void setMipColorMode(SkDestinationSurfaceColorMode colorMode); 28 29 GrSamplerParams::FilterMode highestFilterMode() const; 30 imageStorageType()31 GrSLType imageStorageType() const { 32 if (GrPixelConfigIsSint(this->config())) { 33 return kIImageStorage2D_GrSLType; 34 } else { 35 return kImageStorage2D_GrSLType; 36 } 37 } 38 isMipMapped()39 bool isMipMapped() const { return fIsMipMapped; } 40 41 protected: 42 friend class GrSurfaceProxy; // for ctors 43 44 // Deferred version 45 GrTextureProxy(const GrSurfaceDesc& srcDesc, SkBackingFit, SkBudgeted, 46 const void* srcData, size_t srcRowBytes, uint32_t flags); 47 // Wrapped version 48 GrTextureProxy(sk_sp<GrSurface>); 49 mipColorMode()50 SkDestinationSurfaceColorMode mipColorMode() const { return fMipColorMode; } 51 52 sk_sp<GrSurface> createSurface(GrResourceProvider*) const override; 53 54 private: 55 bool fIsMipMapped; 56 SkDestinationSurfaceColorMode fMipColorMode; 57 58 size_t onUninstantiatedGpuMemorySize() const override; 59 60 // For wrapped proxies the GrTexture pointer is stored in GrIORefProxy. 61 // For deferred proxies that pointer will be filled in when we need to instantiate 62 // the deferred resource 63 64 typedef GrSurfaceProxy INHERITED; 65 }; 66 67 #endif 68