Robert Phillips | 09b2bcb | 2021-05-12 11:56:47 -0400 | [diff] [blame] | 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 | |
Robert Phillips | cc44feb | 2021-07-06 12:21:37 -0400 | [diff] [blame] | 8 | #ifndef BaseDevice_DEFINED |
| 9 | #define BaseDevice_DEFINED |
Robert Phillips | c2132ea | 2021-05-17 14:32:29 -0400 | [diff] [blame] | 10 | |
Robert Phillips | dca342a | 2021-06-02 15:48:59 -0400 | [diff] [blame] | 11 | #include "include/core/SkImage.h" |
Robert Phillips | cc44feb | 2021-07-06 12:21:37 -0400 | [diff] [blame] | 12 | #include "include/private/GrTypesPriv.h" |
Michael Ludwig | e1d0040 | 2021-08-09 12:21:52 -0400 | [diff] [blame^] | 13 | #include "src/core/SkDevice.h" |
Robert Phillips | cc44feb | 2021-07-06 12:21:37 -0400 | [diff] [blame] | 14 | |
Robert Phillips | 04f22ea | 2021-07-22 15:11:03 -0400 | [diff] [blame] | 15 | class GrRenderTargetProxy; |
Robert Phillips | f386862 | 2021-08-04 13:27:43 -0400 | [diff] [blame] | 16 | namespace skgpu { |
| 17 | class SurfaceFillContext; |
| 18 | #if SK_GPU_V1 |
| 19 | namespace v1 { class SurfaceDrawContext; } |
| 20 | #endif // SK_GPU_V1 |
| 21 | } |
Robert Phillips | cc44feb | 2021-07-06 12:21:37 -0400 | [diff] [blame] | 22 | class GrSurfaceProxyView; |
Robert Phillips | dca342a | 2021-06-02 15:48:59 -0400 | [diff] [blame] | 23 | |
Robert Phillips | cc44feb | 2021-07-06 12:21:37 -0400 | [diff] [blame] | 24 | namespace skgpu { |
| 25 | |
Michael Ludwig | e1d0040 | 2021-08-09 12:21:52 -0400 | [diff] [blame^] | 26 | class BaseDevice : public SkBaseDevice { |
Robert Phillips | 09b2bcb | 2021-05-12 11:56:47 -0400 | [diff] [blame] | 27 | public: |
Robert Phillips | 54c878e | 2021-05-20 13:22:52 -0400 | [diff] [blame] | 28 | enum InitContents { |
| 29 | kClear_InitContents, |
| 30 | kUninit_InitContents |
| 31 | }; |
| 32 | |
Robert Phillips | 04f22ea | 2021-07-22 15:11:03 -0400 | [diff] [blame] | 33 | BaseDevice(sk_sp<GrRecordingContext>, const SkImageInfo&, const SkSurfaceProps&); |
Robert Phillips | 09b2bcb | 2021-05-12 11:56:47 -0400 | [diff] [blame] | 34 | |
Robert Phillips | c2132ea | 2021-05-17 14:32:29 -0400 | [diff] [blame] | 35 | virtual GrSurfaceProxyView readSurfaceView() = 0; |
Robert Phillips | 09b2bcb | 2021-05-12 11:56:47 -0400 | [diff] [blame] | 36 | |
Robert Phillips | 04f22ea | 2021-07-22 15:11:03 -0400 | [diff] [blame] | 37 | BaseDevice* asGpuDevice() override { return this; } |
| 38 | |
| 39 | #if SK_GPU_V1 |
Robert Phillips | 4dca831 | 2021-07-28 15:13:20 -0400 | [diff] [blame] | 40 | virtual skgpu::v1::SurfaceDrawContext* surfaceDrawContext() { return nullptr; } |
Robert Phillips | 04f22ea | 2021-07-22 15:11:03 -0400 | [diff] [blame] | 41 | #endif |
| 42 | |
Robert Phillips | f386862 | 2021-08-04 13:27:43 -0400 | [diff] [blame] | 43 | virtual skgpu::SurfaceFillContext* surfaceFillContext() = 0; |
Robert Phillips | 04f22ea | 2021-07-22 15:11:03 -0400 | [diff] [blame] | 44 | GrRenderTargetProxy* targetProxy(); |
| 45 | GrRecordingContext* recordingContext() const { return fContext.get(); } |
Robert Phillips | 4275492 | 2021-06-01 13:12:51 -0400 | [diff] [blame] | 46 | |
Robert Phillips | 0095fcb | 2021-05-24 14:34:01 -0400 | [diff] [blame] | 47 | virtual bool wait(int numSemaphores, |
| 48 | const GrBackendSemaphore* waitSemaphores, |
| 49 | bool deleteSemaphoresAfterWait) = 0; |
Robert Phillips | dca342a | 2021-06-02 15:48:59 -0400 | [diff] [blame] | 50 | virtual void discard() = 0; |
Robert Phillips | 0095fcb | 2021-05-24 14:34:01 -0400 | [diff] [blame] | 51 | |
Robert Phillips | 1e3121a | 2021-06-02 09:34:57 -0400 | [diff] [blame] | 52 | virtual bool replaceBackingProxy(SkSurface::ContentChangeMode, |
| 53 | sk_sp<GrRenderTargetProxy>, |
| 54 | GrColorType, |
| 55 | sk_sp<SkColorSpace>, |
| 56 | GrSurfaceOrigin, |
| 57 | const SkSurfaceProps&) = 0; |
| 58 | bool replaceBackingProxy(SkSurface::ContentChangeMode); |
| 59 | |
Robert Phillips | dca342a | 2021-06-02 15:48:59 -0400 | [diff] [blame] | 60 | using RescaleGamma = SkImage::RescaleGamma; |
| 61 | using RescaleMode = SkImage::RescaleMode; |
| 62 | using ReadPixelsCallback = SkImage::ReadPixelsCallback; |
| 63 | using ReadPixelsContext = SkImage::ReadPixelsContext; |
| 64 | |
| 65 | virtual void asyncRescaleAndReadPixels(const SkImageInfo& info, |
| 66 | const SkIRect& srcRect, |
| 67 | RescaleGamma rescaleGamma, |
| 68 | RescaleMode rescaleMode, |
| 69 | ReadPixelsCallback callback, |
| 70 | ReadPixelsContext context) = 0; |
| 71 | |
| 72 | virtual void asyncRescaleAndReadPixelsYUV420(SkYUVColorSpace yuvColorSpace, |
| 73 | sk_sp<SkColorSpace> dstColorSpace, |
| 74 | const SkIRect& srcRect, |
| 75 | SkISize dstSize, |
| 76 | RescaleGamma rescaleGamma, |
| 77 | RescaleMode, |
| 78 | ReadPixelsCallback callback, |
| 79 | ReadPixelsContext context) = 0; |
| 80 | |
Robert Phillips | 09b2bcb | 2021-05-12 11:56:47 -0400 | [diff] [blame] | 81 | protected: |
Robert Phillips | 4275492 | 2021-06-01 13:12:51 -0400 | [diff] [blame] | 82 | sk_sp<GrRecordingContext> fContext; |
Robert Phillips | 09b2bcb | 2021-05-12 11:56:47 -0400 | [diff] [blame] | 83 | |
| 84 | private: |
Michael Ludwig | e1d0040 | 2021-08-09 12:21:52 -0400 | [diff] [blame^] | 85 | using INHERITED = SkBaseDevice; |
Robert Phillips | 09b2bcb | 2021-05-12 11:56:47 -0400 | [diff] [blame] | 86 | }; |
| 87 | |
Robert Phillips | cc44feb | 2021-07-06 12:21:37 -0400 | [diff] [blame] | 88 | } // namespace skgpu |
| 89 | |
Robert Phillips | cc44feb | 2021-07-06 12:21:37 -0400 | [diff] [blame] | 90 | #endif // BaseDevice_DEFINED |