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_graphite_Texture_DEFINED 9 #define skgpu_graphite_Texture_DEFINED 10 11 #include "include/core/SkSize.h" 12 #include "include/gpu/graphite/TextureInfo.h" 13 #include "src/gpu/graphite/Resource.h" 14 #include "src/gpu/graphite/ResourceTypes.h" 15 16 namespace skgpu { 17 class MutableTextureState; 18 class RefCntedCallback; 19 enum class Budgeted : bool; 20 }; 21 22 namespace skgpu::graphite { 23 24 class Texture : public Resource { 25 public: 26 ~Texture() override; 27 numSamples()28 int numSamples() const { return fInfo.numSamples(); } mipmapped()29 Mipmapped mipmapped() const { return fInfo.mipmapped(); } 30 dimensions()31 SkISize dimensions() const { return fDimensions; } textureInfo()32 const TextureInfo& textureInfo() const { return fInfo; } 33 34 void setReleaseCallback(sk_sp<RefCntedCallback>); 35 getResourceType()36 const char* getResourceType() const override { return "Texture"; } 37 38 #if defined(GRAPHITE_TEST_UTILS) asTexture()39 const Texture* asTexture() const override { return this; } 40 #endif 41 42 protected: 43 Texture(const SharedContext*, 44 SkISize dimensions, 45 const TextureInfo& info, 46 sk_sp<MutableTextureState> mutableState, 47 Ownership, 48 skgpu::Budgeted); 49 50 MutableTextureState* mutableState() const; 51 52 void invokeReleaseProc() override; 53 54 void onDumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump, 55 const char* dumpName) const override; 56 57 private: 58 SkISize fDimensions; 59 TextureInfo fInfo; 60 sk_sp<MutableTextureState> fMutableState; 61 sk_sp<RefCntedCallback> fReleaseCallback; 62 }; 63 64 } // namespace skgpu::graphite 65 66 #endif // skgpu_graphite_Texture_DEFINED 67