Debian Codegraph @

src/gpu/graphite/Texture.h

raw
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 class SkColorInfo;
17
18 namespace skgpu {
19 class MutableTextureState;
20 class RefCntedCallback;
21 enum class Budgeted : bool;
22 }
23
24 namespace skgpu::graphite {
25
26 class UploadSource;
27
28 class Texture : public Resource {
29 public:
30 ~Texture() override;
31
32 SampleCount sampleCount() const { return fInfo.sampleCount(); }
33 Mipmapped mipmapped() const { return fInfo.mipmapped(); }
34
35 SkISize dimensions() const { return fDimensions; }
36 const TextureInfo& textureInfo() const { return fInfo; }
37
38 void setReleaseCallback(sk_sp<RefCntedCallback>);
39
40 const char* getResourceType() const override { return "Texture"; }
41
42 const Texture* asTexture() const override { return this; }
43
44 virtual bool canUploadOnHost(const UploadSource&) const { return false; }
45
46 // With the assumption that source.canUploadOnHost() is true, attempts to write to the
47 // texture on the host directly. Returns `false` only if driver calls fail.
48 virtual bool uploadDataOnHost(const UploadSource& source, const SkIRect& dstRect);
49
50 protected:
51 Texture(const SharedContext*,
52 SkISize dimensions,
53 const TextureInfo& info,
54 bool isTransient,
55 sk_sp<MutableTextureState> mutableState,
56 Ownership);
57
58 MutableTextureState* mutableState() const;
59
60 void invokeReleaseProc() override;
61
62 void onDumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump,
63 const char* dumpName) const override;
64
65 private:
66 SkISize fDimensions;
67 TextureInfo fInfo;
68 sk_sp<MutableTextureState> fMutableState;
69 sk_sp<RefCntedCallback> fReleaseCallback;
70 };
71
72 } // namespace skgpu::graphite
73
74 #endif // skgpu_graphite_Texture_DEFINED