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