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 TextureProxy(sk_sp<Texture>); 24 25 ~TextureProxy() override; 26 numSamples()27 int numSamples() const { return fInfo.numSamples(); } mipmapped()28 Mipmapped mipmapped() const { return Mipmapped(fInfo.numMipLevels() > 1); } 29 dimensions()30 SkISize dimensions() const { return fDimensions; } textureInfo()31 const TextureInfo& textureInfo() const { return fInfo; } 32 33 bool instantiate(ResourceProvider*); 34 sk_sp<Texture> refTexture() const; 35 const Texture* texture() const; 36 37 private: 38 #ifdef SK_DEBUG 39 void validateTexture(const Texture*); 40 #endif 41 42 SkISize fDimensions; 43 TextureInfo fInfo; 44 45 sk_sp<Texture> fTexture; 46 }; 47 48 } // namepsace skgpu 49 50 #endif // skgpu_TextureProxy_DEFINED 51