1 /* 2 * Copyright 2021 Google LLC 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 skgpu_TextureProxy_DEFINED 9 #define skgpu_TextureProxy_DEFINED 10 11 #include "experimental/graphite/include/TextureInfo.h" 12 #include "include/core/SkRefCnt.h" 13 #include "include/core/SkSize.h" 14 15 namespace skgpu { 16 17 class ResourceProvider; 18 class Texture; 19 20 class TextureProxy : public SkRefCnt { 21 public: 22 TextureProxy(SkISize dimensions, const TextureInfo& info); 23 24 ~TextureProxy() override; 25 numSamples()26 int numSamples() const { return fInfo.numSamples(); } mipmapped()27 Mipmapped mipmapped() const { return Mipmapped(fInfo.numMipLevels() > 1); } 28 dimensions()29 SkISize dimensions() const { return fDimensions; } textureInfo()30 const TextureInfo& textureInfo() const { return fInfo; } 31 32 bool instantiate(ResourceProvider*); 33 sk_sp<Texture> refTexture() const; 34 const Texture* texture() const; 35 36 private: 37 #ifdef SK_DEBUG 38 void validateTexture(const Texture*); 39 #endif 40 41 SkISize fDimensions; 42 TextureInfo fInfo; 43 44 sk_sp<Texture> fTexture; 45 }; 46 47 } // namepsace skgpu 48 49 #endif // skgpu_TextureProxy_DEFINED 50