Debian Codegraph @

src/gpu/graphite/Image_Graphite.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_Image_Graphite_DEFINED
9 #define skgpu_graphite_Image_Graphite_DEFINED
10
11 #include "src/gpu/graphite/Image_Base_Graphite.h"
12
13 #include "src/gpu/graphite/TextureProxyView.h"
14
15 namespace skgpu {
16 class RefCntedCallback;
17 }
18
19 namespace skgpu::graphite {
20
21 class Context;
22 class Device;
23 class DrawContext;
24 class Recorder;
25
26 class Image final : public Image_Base {
27 public:
28 Image(TextureProxyView, const SkColorInfo&);
29 ~Image() override;
30
31 // Create an Image that wraps the Device and automatically flushes or references the Device's
32 // pending tasks when the Image is used in a draw to another canvas.
33 static sk_sp<Image> WrapDevice(sk_sp<Device> device);
34
35 // Create an Image by copying the provided texture proxy view into a new texturable proxy.
36 // The source texture does not have to be texturable if it is blittable.
37 //
38 // If provided with a drawContext (e.g. not nullptr), the tasks from this function call will be
39 // added to the drawContext's task list. Otherwise, they will be added to the root task list.
40 static sk_sp<Image> Copy(Recorder*,
41 DrawContext* drawContext,
42 const TextureProxyView& srcView,
43 const SkColorInfo&,
44 const SkIRect& subset,
45 Budgeted,
46 Mipmapped,
47 SkBackingFit,
48 std::string_view label);
49
50 const TextureProxyView& textureProxyView() const { return fTextureProxyView; }
51
52 SkImage_Base::Type type() const override { return SkImage_Base::Type::kGraphite; }
53
54 bool onHasMipmaps() const override {
55 return fTextureProxyView.proxy()->mipmapped() == Mipmapped::kYes;
56 }
57
58 bool onIsProtected() const override {
59 return fTextureProxyView.proxy()->isProtected() == Protected::kYes;
60 }
61
62 size_t textureSize() const override;
63
64 sk_sp<Image> copyImage(Recorder*,
65 const SkIRect& subset,
66 Budgeted,
67 Mipmapped,
68 SkBackingFit,
69 std::string_view label) const override;
70
71 sk_sp<SkImage> onReinterpretColorSpace(sk_sp<SkColorSpace>) const override;
72
73 #if defined(GPU_TEST_UTILS)
74 bool readPixelsGraphite(SkRecorder*, const SkPixmap& dst, int srcX, int srcY) const override;
75 #endif
76
77 private:
78
79 TextureProxyView fTextureProxyView;
80 };
81
82 } // namespace skgpu::graphite
83
84 #endif // skgpu_graphite_Image_Graphite_DEFINED