Debian Codegraph @

src/gpu/graphite/BackendTexturePriv.h

raw
1 /*
2 * Copyright 2024 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 #ifndef skgpu_graphite_BackendTexturePriv_DEFINED
8 #define skgpu_graphite_BackendTexturePriv_DEFINED
9
10 #include "include/core/SkSize.h"
11 #include "include/gpu/graphite/BackendTexture.h"
12 #include "include/gpu/graphite/TextureInfo.h"
13 #include "include/private/base/SkAssert.h"
14 #include "include/private/base/SkDebug.h"
15
16 namespace skgpu { enum class BackendApi : unsigned int; }
17
18 namespace skgpu::graphite {
19
20 class BackendTextureData {
21 public:
22 virtual ~BackendTextureData();
23
24 #if defined(SK_DEBUG)
25 virtual skgpu::BackendApi type() const = 0;
26 #endif
27 protected:
28 BackendTextureData() = default;
29 BackendTextureData(const BackendTextureData&) = default;
30
31 using AnyBackendTextureData = BackendTexture::AnyBackendTextureData;
32
33 private:
34 friend class BackendTexture;
35
36 virtual void copyTo(AnyBackendTextureData& dstData) const = 0;
37 virtual bool equal(const BackendTextureData* that) const = 0;
38 };
39
40 class BackendTexturePriv {
41 public:
42 template <typename SomeBackendTextureData>
43 static BackendTexture Make(SkISize dimensions,
44 TextureInfo info,
45 const SomeBackendTextureData& textureData) {
46 return BackendTexture(dimensions, info, textureData);
47 }
48
49 static const BackendTextureData* GetData(const BackendTexture& info) {
50 return info.fTextureData.get();
51 }
52
53 static BackendTextureData* GetData(BackendTexture* info) {
54 SkASSERT(info);
55 return info->fTextureData.get();
56 }
57 };
58
59 } // namespace skgpu::graphite
60
61 #endif