Update rive-cpp to 2.0 version
[platform/core/uifw/rive-tizen.git] / submodule / skia / src / gpu / ganesh / BaseDevice.h
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 BaseDevice_DEFINED
9 #define BaseDevice_DEFINED
10
11 #include "include/core/SkImage.h"
12 #include "include/private/gpu/ganesh/GrTypesPriv.h"
13 #include "src/core/SkDevice.h"
14
15 class GrRenderTargetProxy;
16 class GrSurfaceProxyView;
17
18 namespace skgpu {
19
20 class SurfaceContext;
21 class SurfaceFillContext;
22 #if SK_GPU_V1
23 namespace v1 { class SurfaceDrawContext; }
24 #endif // SK_GPU_V1
25
26 /*
27  * This class is left over from the initial v1/v2 split. It should be merged into the v1::Device.
28  */
29 class BaseDevice : public SkBaseDevice {
30 public:
31     enum class InitContents {
32         kClear,
33         kUninit
34     };
35
36     BaseDevice(sk_sp<GrRecordingContext>, const SkImageInfo&, const SkSurfaceProps&);
37
38     GrSurfaceProxyView readSurfaceView();
39
40     BaseDevice* asGaneshDevice() override { return this; }
41
42 #if SK_GPU_V1
43     virtual v1::SurfaceDrawContext* surfaceDrawContext() { return nullptr; }
44 #endif
45
46     virtual SurfaceFillContext* surfaceFillContext() = 0;
47     GrRenderTargetProxy* targetProxy();
48     GrRecordingContext* recordingContext() const { return fContext.get(); }
49
50     virtual bool wait(int numSemaphores,
51                       const GrBackendSemaphore* waitSemaphores,
52                       bool deleteSemaphoresAfterWait) = 0;
53     virtual void discard() = 0;
54     virtual void resolveMSAA() = 0;
55
56     virtual bool replaceBackingProxy(SkSurface::ContentChangeMode,
57                                      sk_sp<GrRenderTargetProxy>,
58                                      GrColorType,
59                                      sk_sp<SkColorSpace>,
60                                      GrSurfaceOrigin,
61                                      const SkSurfaceProps&) = 0;
62     bool replaceBackingProxy(SkSurface::ContentChangeMode);
63
64     using RescaleGamma       = SkImage::RescaleGamma;
65     using RescaleMode        = SkImage::RescaleMode;
66     using ReadPixelsCallback = SkImage::ReadPixelsCallback;
67     using ReadPixelsContext  = SkImage::ReadPixelsContext;
68
69     virtual void asyncRescaleAndReadPixels(const SkImageInfo& info,
70                                            const SkIRect& srcRect,
71                                            RescaleGamma rescaleGamma,
72                                            RescaleMode rescaleMode,
73                                            ReadPixelsCallback callback,
74                                            ReadPixelsContext context) = 0;
75
76     virtual void asyncRescaleAndReadPixelsYUV420(SkYUVColorSpace yuvColorSpace,
77                                                  sk_sp<SkColorSpace> dstColorSpace,
78                                                  const SkIRect& srcRect,
79                                                  SkISize dstSize,
80                                                  RescaleGamma rescaleGamma,
81                                                  RescaleMode,
82                                                  ReadPixelsCallback callback,
83                                                  ReadPixelsContext context) = 0;
84
85 protected:
86     enum class DeviceFlags {
87         kNone      = 0,
88         kNeedClear = 1 << 0,  //!< Surface requires an initial clear
89         kIsOpaque  = 1 << 1,  //!< Hint from client that rendering to this device will be
90                               //   opaque even if the config supports alpha.
91     };
92     GR_DECL_BITFIELD_CLASS_OPS_FRIENDS(DeviceFlags);
93
94     static bool CheckAlphaTypeAndGetFlags(SkAlphaType, InitContents, DeviceFlags*);
95     static SkImageInfo MakeInfo(SurfaceContext*,  DeviceFlags);
96
97     sk_sp<GrRecordingContext> fContext;
98
99 private:
100     using INHERITED = SkBaseDevice;
101 };
102
103 GR_MAKE_BITFIELD_CLASS_OPS(BaseDevice::DeviceFlags)
104
105 } // namespace skgpu
106
107 #endif // BaseDevice_DEFINED