/src/skia/include/gpu/graphite/BackendTexture.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_BackendTexture_DEFINED |
9 | | #define skgpu_graphite_BackendTexture_DEFINED |
10 | | |
11 | | #include "include/core/SkRefCnt.h" |
12 | | #include "include/core/SkSize.h" |
13 | | #include "include/gpu/graphite/GraphiteTypes.h" |
14 | | #include "include/gpu/graphite/TextureInfo.h" |
15 | | #include "include/private/base/SkAnySubclass.h" |
16 | | |
17 | | namespace skgpu::graphite { |
18 | | |
19 | | class BackendTextureData; |
20 | | struct VulkanTextureInfo; |
21 | | |
22 | | class SK_API BackendTexture { |
23 | | public: |
24 | | BackendTexture(); |
25 | | BackendTexture(const BackendTexture&); |
26 | | |
27 | | ~BackendTexture(); |
28 | | |
29 | | BackendTexture& operator=(const BackendTexture&); |
30 | | |
31 | | bool operator==(const BackendTexture&) const; |
32 | 0 | bool operator!=(const BackendTexture& that) const { return !(*this == that); } |
33 | | |
34 | 0 | bool isValid() const { return fInfo.isValid(); } |
35 | 0 | BackendApi backend() const { return fInfo.backend(); } |
36 | | |
37 | 0 | SkISize dimensions() const { return fDimensions; } |
38 | | |
39 | 0 | const TextureInfo& info() const { return fInfo; } |
40 | | |
41 | | private: |
42 | | friend class BackendTextureData; |
43 | | friend class BackendTexturePriv; |
44 | | |
45 | | // Size determined by looking at the BackendTextureData subclasses, then guessing-and-checking. |
46 | | // Compiler will complain if this is too small - in that case, just increase the number. |
47 | | inline constexpr static size_t kMaxSubclassSize = 72; |
48 | | using AnyBackendTextureData = SkAnySubclass<BackendTextureData, kMaxSubclassSize>; |
49 | | |
50 | | template <typename SomeBackendTextureData> |
51 | | BackendTexture(SkISize dimensions, TextureInfo info, const SomeBackendTextureData& textureData) |
52 | 0 | : fDimensions(dimensions), fInfo(info) { |
53 | 0 | fTextureData.emplace<SomeBackendTextureData>(textureData); |
54 | 0 | } |
55 | | |
56 | | SkISize fDimensions; |
57 | | TextureInfo fInfo; |
58 | | AnyBackendTextureData fTextureData; |
59 | | }; |
60 | | |
61 | | } // namespace skgpu::graphite |
62 | | |
63 | | #endif // skgpu_graphite_BackendTexture_DEFINED |
64 | | |