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" |
| 13 | |
Robert Phillips | 04f22ea | 2021-07-22 15:11:03 -0400 | [diff] [blame^] | 14 | class GrRenderTargetProxy; |
| 15 | class GrSurfaceDrawContext; |
| 16 | class GrSurfaceFillContext; |
Robert Phillips | cc44feb | 2021-07-06 12:21:37 -0400 | [diff] [blame] | 17 | class GrSurfaceProxyView; |
Robert Phillips | dca342a | 2021-06-02 15:48:59 -0400 | [diff] [blame] | 18 | |
Robert Phillips | 09b2bcb | 2021-05-12 11:56:47 -0400 | [diff] [blame] | 19 | // NOTE: when not defined, SkGpuDevice extends SkBaseDevice directly and manages its clip stack |
| 20 | // using GrClipStack. When false, SkGpuDevice continues to extend SkClipStackDevice and uses |
| 21 | // SkClipStack and GrClipStackClip to manage the clip stack. |
| 22 | #if !defined(SK_DISABLE_NEW_GR_CLIP_STACK) |
| 23 | // For staging purposes, disable this for Android Framework |
| 24 | #if defined(SK_BUILD_FOR_ANDROID_FRAMEWORK) |
| 25 | #define SK_DISABLE_NEW_GR_CLIP_STACK |
| 26 | #endif |
| 27 | #endif |
| 28 | |
| 29 | #if !defined(SK_DISABLE_NEW_GR_CLIP_STACK) |
| 30 | #include "src/core/SkDevice.h" |
| 31 | #define BASE_DEVICE SkBaseDevice |
| 32 | #else |
| 33 | #include "src/core/SkClipStackDevice.h" |
| 34 | #define BASE_DEVICE SkClipStackDevice |
| 35 | #endif |
| 36 | |
Robert Phillips | cc44feb | 2021-07-06 12:21:37 -0400 | [diff] [blame] | 37 | namespace skgpu { |
| 38 | |
| 39 | class BaseDevice : public BASE_DEVICE { |
Robert Phillips | 09b2bcb | 2021-05-12 11:56:47 -0400 | [diff] [blame] | 40 | public: |
Robert Phillips | 54c878e | 2021-05-20 13:22:52 -0400 | [diff] [blame] | 41 | enum InitContents { |
| 42 | kClear_InitContents, |
| 43 | kUninit_InitContents |
| 44 | }; |
| 45 | |
Robert Phillips | 04f22ea | 2021-07-22 15:11:03 -0400 | [diff] [blame^] | 46 | BaseDevice(sk_sp<GrRecordingContext>, const SkImageInfo&, const SkSurfaceProps&); |
Robert Phillips | 09b2bcb | 2021-05-12 11:56:47 -0400 | [diff] [blame] | 47 | |
Robert Phillips | c2132ea | 2021-05-17 14:32:29 -0400 | [diff] [blame] | 48 | virtual GrSurfaceProxyView readSurfaceView() = 0; |
Robert Phillips | 09b2bcb | 2021-05-12 11:56:47 -0400 | [diff] [blame] | 49 | |
Robert Phillips | 04f22ea | 2021-07-22 15:11:03 -0400 | [diff] [blame^] | 50 | BaseDevice* asGpuDevice() override { return this; } |
| 51 | |
| 52 | #if SK_GPU_V1 |
| 53 | // TODO: make this return a skgpu::v1:SurfaceDrawContext |
| 54 | virtual GrSurfaceDrawContext* surfaceDrawContext() { return nullptr; } |
| 55 | #endif |
| 56 | |
| 57 | virtual GrSurfaceFillContext* surfaceFillContext() = 0; |
| 58 | GrRenderTargetProxy* targetProxy(); |
| 59 | GrRecordingContext* recordingContext() const { return fContext.get(); } |
Robert Phillips | 4275492 | 2021-06-01 13:12:51 -0400 | [diff] [blame] | 60 | |
Robert Phillips | 0095fcb | 2021-05-24 14:34:01 -0400 | [diff] [blame] | 61 | virtual bool wait(int numSemaphores, |
| 62 | const GrBackendSemaphore* waitSemaphores, |
| 63 | bool deleteSemaphoresAfterWait) = 0; |
Robert Phillips | dca342a | 2021-06-02 15:48:59 -0400 | [diff] [blame] | 64 | virtual void discard() = 0; |
Robert Phillips | 0095fcb | 2021-05-24 14:34:01 -0400 | [diff] [blame] | 65 | |
Robert Phillips | 1e3121a | 2021-06-02 09:34:57 -0400 | [diff] [blame] | 66 | virtual bool replaceBackingProxy(SkSurface::ContentChangeMode, |
| 67 | sk_sp<GrRenderTargetProxy>, |
| 68 | GrColorType, |
| 69 | sk_sp<SkColorSpace>, |
| 70 | GrSurfaceOrigin, |
| 71 | const SkSurfaceProps&) = 0; |
| 72 | bool replaceBackingProxy(SkSurface::ContentChangeMode); |
| 73 | |
Robert Phillips | dca342a | 2021-06-02 15:48:59 -0400 | [diff] [blame] | 74 | using RescaleGamma = SkImage::RescaleGamma; |
| 75 | using RescaleMode = SkImage::RescaleMode; |
| 76 | using ReadPixelsCallback = SkImage::ReadPixelsCallback; |
| 77 | using ReadPixelsContext = SkImage::ReadPixelsContext; |
| 78 | |
| 79 | virtual void asyncRescaleAndReadPixels(const SkImageInfo& info, |
| 80 | const SkIRect& srcRect, |
| 81 | RescaleGamma rescaleGamma, |
| 82 | RescaleMode rescaleMode, |
| 83 | ReadPixelsCallback callback, |
| 84 | ReadPixelsContext context) = 0; |
| 85 | |
| 86 | virtual void asyncRescaleAndReadPixelsYUV420(SkYUVColorSpace yuvColorSpace, |
| 87 | sk_sp<SkColorSpace> dstColorSpace, |
| 88 | const SkIRect& srcRect, |
| 89 | SkISize dstSize, |
| 90 | RescaleGamma rescaleGamma, |
| 91 | RescaleMode, |
| 92 | ReadPixelsCallback callback, |
| 93 | ReadPixelsContext context) = 0; |
| 94 | |
Robert Phillips | 09b2bcb | 2021-05-12 11:56:47 -0400 | [diff] [blame] | 95 | protected: |
Robert Phillips | 4275492 | 2021-06-01 13:12:51 -0400 | [diff] [blame] | 96 | sk_sp<GrRecordingContext> fContext; |
Robert Phillips | 09b2bcb | 2021-05-12 11:56:47 -0400 | [diff] [blame] | 97 | |
| 98 | private: |
| 99 | using INHERITED = BASE_DEVICE; |
| 100 | }; |
| 101 | |
Robert Phillips | cc44feb | 2021-07-06 12:21:37 -0400 | [diff] [blame] | 102 | } // namespace skgpu |
| 103 | |
Robert Phillips | 09b2bcb | 2021-05-12 11:56:47 -0400 | [diff] [blame] | 104 | #undef BASE_DEVICE |
| 105 | |
Robert Phillips | cc44feb | 2021-07-06 12:21:37 -0400 | [diff] [blame] | 106 | #endif // BaseDevice_DEFINED |