/src/skia/include/gpu/graphite/TextureInfo.h
Line | Count | Source (jump to first uncovered line) |
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_TextureInfo_DEFINED |
9 | | #define skgpu_graphite_TextureInfo_DEFINED |
10 | | |
11 | | #include "include/core/SkString.h" |
12 | | #include "include/core/SkTextureCompressionType.h" |
13 | | #include "include/gpu/graphite/GraphiteTypes.h" |
14 | | #include "include/private/base/SkAPI.h" |
15 | | #include "include/private/base/SkAnySubclass.h" |
16 | | |
17 | | struct SkISize; |
18 | | |
19 | | namespace skgpu::graphite { |
20 | | |
21 | | class TextureInfoData; |
22 | | |
23 | | class SK_API TextureInfo { |
24 | | public: |
25 | | TextureInfo(); |
26 | | ~TextureInfo(); |
27 | | TextureInfo(const TextureInfo&); |
28 | | TextureInfo& operator=(const TextureInfo&); |
29 | | |
30 | | bool operator==(const TextureInfo&) const; |
31 | 0 | bool operator!=(const TextureInfo& that) const { return !(*this == that); } |
32 | | |
33 | 0 | bool isValid() const { return fValid; } |
34 | 0 | BackendApi backend() const { return fBackend; } |
35 | | |
36 | 0 | uint32_t numSamples() const { return fSampleCount; } |
37 | 0 | Mipmapped mipmapped() const { return fMipmapped; } |
38 | 0 | Protected isProtected() const { return fProtected; } |
39 | | SkTextureCompressionType compressionType() const; |
40 | | bool isMemoryless() const; |
41 | | |
42 | | bool isCompatible(const TextureInfo& that) const; |
43 | | // Return a string containing the full description of this TextureInfo. |
44 | | SkString toString() const; |
45 | | // Return a string containing only the info relevant for its use as a RenderPass attachment. |
46 | | SkString toRPAttachmentString() const; |
47 | | |
48 | | private: |
49 | | friend class TextureInfoData; |
50 | | friend class TextureInfoPriv; |
51 | | |
52 | | // Size determined by looking at the TextureInfoData subclasses, then guessing-and-checking. |
53 | | // Compiler will complain if this is too small - in that case, just increase the number. |
54 | | inline constexpr static size_t kMaxSubclassSize = 112; |
55 | | using AnyTextureInfoData = SkAnySubclass<TextureInfoData, kMaxSubclassSize>; |
56 | | |
57 | | template <typename SomeTextureInfoData> |
58 | | TextureInfo(BackendApi backend, |
59 | | uint32_t sampleCount, |
60 | | skgpu::Mipmapped mipped, |
61 | | skgpu::Protected isProtected, |
62 | | const SomeTextureInfoData& textureInfoData) |
63 | | : fBackend(backend) |
64 | | , fValid(true) |
65 | | , fSampleCount(sampleCount) |
66 | | , fMipmapped(mipped) |
67 | 0 | , fProtected(isProtected) { |
68 | 0 | fTextureInfoData.emplace<SomeTextureInfoData>(textureInfoData); |
69 | 0 | } |
70 | | |
71 | | friend size_t ComputeSize(SkISize dimensions, const TextureInfo&); // for bytesPerPixel |
72 | | |
73 | | size_t bytesPerPixel() const; |
74 | | |
75 | | BackendApi fBackend = BackendApi::kMock; |
76 | | bool fValid = false; |
77 | | |
78 | | uint32_t fSampleCount = 1; |
79 | | Mipmapped fMipmapped = Mipmapped::kNo; |
80 | | Protected fProtected = Protected::kNo; |
81 | | |
82 | | AnyTextureInfoData fTextureInfoData; |
83 | | }; |
84 | | |
85 | | } // namespace skgpu::graphite |
86 | | |
87 | | #endif //skgpu_graphite_TextureInfo_DEFINED |