| /* | |
| * Copyright 2021 Google LLC | |
| * | |
| * Use of this source code is governed by a BSD-style license that can be | |
| * found in the LICENSE file. | |
| */ | |
| #ifndef skgpu_graphite_Texture_DEFINED | |
| #define skgpu_graphite_Texture_DEFINED | |
| #include "include/core/SkSize.h" | |
| #include "include/gpu/graphite/TextureInfo.h" | |
| #include "src/gpu/graphite/Resource.h" | |
| #include "src/gpu/graphite/ResourceTypes.h" | |
| class SkColorInfo; | |
| namespace skgpu { | |
| class MutableTextureState; | |
| class RefCntedCallback; | |
| enum class Budgeted : bool; | |
| } | |
| namespace skgpu::graphite { | |
| class UploadSource; | |
| class Texture : public Resource { | |
| public: | |
| ~Texture() override; | |
| SampleCount sampleCount() const { return fInfo.sampleCount(); } | |
| Mipmapped mipmapped() const { return fInfo.mipmapped(); } | |
| SkISize dimensions() const { return fDimensions; } | |
| const TextureInfo& textureInfo() const { return fInfo; } | |
| void setReleaseCallback(sk_sp<RefCntedCallback>); | |
| const char* getResourceType() const override { return "Texture"; } | |
| const Texture* asTexture() const override { return this; } | |
| Protected isProtected() const override { return fInfo.isProtected(); } | |
| virtual bool canUploadOnHost() const { return false; } | |
| // With the assumption that the source data can upload on the host, attempts to write to the | |
| // texture on the host directly. Returns `false` only if driver calls fail. | |
| virtual bool uploadDataOnHost(const UploadSource& source); | |
| protected: | |
| Texture(const SharedContext*, | |
| SkISize dimensions, | |
| const TextureInfo&, | |
| bool isTransient, | |
| sk_sp<MutableTextureState>, | |
| Ownership, | |
| std::string_view label); | |
| MutableTextureState* mutableState() const; | |
| void invokeReleaseProc() override; | |
| void onDumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump, | |
| const char* dumpName) const override; | |
| private: | |
| SkISize fDimensions; | |
| TextureInfo fInfo; | |
| sk_sp<MutableTextureState> fMutableState; | |
| sk_sp<RefCntedCallback> fReleaseCallback; | |
| }; | |
| } // namespace skgpu::graphite | |
| #endif // skgpu_graphite_Texture_DEFINED |