• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2023 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_Base_Graphite_DEFINED
9 #define skgpu_graphite_Image_Base_Graphite_DEFINED
10 
11 #include "src/image/SkImage_Base.h"
12 
13 #if defined(SK_GANESH)
14 #include "src/gpu/ganesh/GrSurfaceProxyView.h"
15 #endif
16 
17 namespace skgpu::graphite {
18 
19 class Context;
20 class Recorder;
21 class TextureProxy;
22 
23 class Image_Base : public SkImage_Base {
24 public:
~Image_Base()25     ~Image_Base() override {}
26 
onReadPixels(GrDirectContext *,const SkImageInfo & dstInfo,void * dstPixels,size_t dstRowBytes,int srcX,int srcY,CachingHint)27     bool onReadPixels(GrDirectContext*,
28                       const SkImageInfo& dstInfo,
29                       void* dstPixels,
30                       size_t dstRowBytes,
31                       int srcX,
32                       int srcY,
33                       CachingHint) const override { return false; }
34 
isGraphiteBacked()35     bool isGraphiteBacked() const override { return true; }
36 
37     bool getROPixels(GrDirectContext*,
38                      SkBitmap*,
39                      CachingHint = kAllow_CachingHint) const override { return false; }
40 
41     sk_sp<SkImage> onMakeSubset(const SkIRect&, GrDirectContext*) const override;
42 
onIsValid(GrRecordingContext *)43     bool onIsValid(GrRecordingContext*) const override { return true; }
44 
45     sk_sp<SkImage> onMakeColorTypeAndColorSpace(SkColorType,
46                                                 sk_sp<SkColorSpace>,
47                                                 GrDirectContext*) const override;
48 
49     void onAsyncRescaleAndReadPixels(const SkImageInfo&,
50                                      SkIRect srcRect,
51                                      RescaleGamma,
52                                      RescaleMode,
53                                      ReadPixelsCallback,
54                                      ReadPixelsContext) const override;
55 
56     void onAsyncRescaleAndReadPixelsYUV420(SkYUVColorSpace,
57                                            sk_sp<SkColorSpace>,
58                                            SkIRect srcRect,
59                                            SkISize dstSize,
60                                            RescaleGamma,
61                                            RescaleMode,
62                                            ReadPixelsCallback,
63                                            ReadPixelsContext) const override;
64 
65 protected:
Image_Base(const SkImageInfo & info,uint32_t uniqueID)66     Image_Base(const SkImageInfo& info, uint32_t uniqueID)
67         : SkImage_Base(info, uniqueID) {}
68 
69 private:
70 
71 #if defined(SK_GANESH)
72     std::unique_ptr<GrFragmentProcessor> onAsFragmentProcessor(
73             GrRecordingContext*,
74             SkSamplingOptions,
75             const SkTileMode[2],
76             const SkMatrix&,
77             const SkRect* subset,
78             const SkRect* domain) const override;
79 
onAsView(GrRecordingContext *,GrMipmapped,GrImageTexGenPolicy policy)80     std::tuple<GrSurfaceProxyView, GrColorType> onAsView(
81             GrRecordingContext*,
82             GrMipmapped,
83             GrImageTexGenPolicy policy) const override {
84         return {};
85     }
86 #endif
87 };
88 
89 } // namespace skgpu::graphite
90 
91 #endif // skgpu_graphite_Image_Base_Graphite_DEFINED
92