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 | |
| 8 | #ifndef SkBaseGpuDevice_DEFINED |
| 9 | #define SkBaseGpuDevice_DEFINED |
| 10 | |
Robert Phillips | c2132ea | 2021-05-17 14:32:29 -0400 | [diff] [blame] | 11 | #include "src/gpu/GrSurfaceProxyView.h" |
| 12 | |
Robert Phillips | 09b2bcb | 2021-05-12 11:56:47 -0400 | [diff] [blame] | 13 | // NOTE: when not defined, SkGpuDevice extends SkBaseDevice directly and manages its clip stack |
| 14 | // using GrClipStack. When false, SkGpuDevice continues to extend SkClipStackDevice and uses |
| 15 | // SkClipStack and GrClipStackClip to manage the clip stack. |
| 16 | #if !defined(SK_DISABLE_NEW_GR_CLIP_STACK) |
| 17 | // For staging purposes, disable this for Android Framework |
| 18 | #if defined(SK_BUILD_FOR_ANDROID_FRAMEWORK) |
| 19 | #define SK_DISABLE_NEW_GR_CLIP_STACK |
| 20 | #endif |
| 21 | #endif |
| 22 | |
| 23 | #if !defined(SK_DISABLE_NEW_GR_CLIP_STACK) |
| 24 | #include "src/core/SkDevice.h" |
| 25 | #define BASE_DEVICE SkBaseDevice |
| 26 | #else |
| 27 | #include "src/core/SkClipStackDevice.h" |
| 28 | #define BASE_DEVICE SkClipStackDevice |
| 29 | #endif |
| 30 | |
| 31 | class SkBaseGpuDevice : public BASE_DEVICE { |
| 32 | public: |
Robert Phillips | 54c878e | 2021-05-20 13:22:52 -0400 | [diff] [blame] | 33 | enum InitContents { |
| 34 | kClear_InitContents, |
| 35 | kUninit_InitContents |
| 36 | }; |
| 37 | |
Robert Phillips | 4275492 | 2021-06-01 13:12:51 -0400 | [diff] [blame^] | 38 | SkBaseGpuDevice(sk_sp<GrRecordingContext> rContext, |
| 39 | const SkImageInfo& ii, |
| 40 | const SkSurfaceProps& props) |
| 41 | : INHERITED(ii, props) |
| 42 | , fContext(std::move(rContext)) { |
Robert Phillips | 09b2bcb | 2021-05-12 11:56:47 -0400 | [diff] [blame] | 43 | } |
| 44 | |
Robert Phillips | c2132ea | 2021-05-17 14:32:29 -0400 | [diff] [blame] | 45 | virtual GrSurfaceProxyView readSurfaceView() = 0; |
| 46 | GrRenderTargetProxy* targetProxy() { |
| 47 | return this->readSurfaceView().asRenderTargetProxy(); |
| 48 | } |
Robert Phillips | 09b2bcb | 2021-05-12 11:56:47 -0400 | [diff] [blame] | 49 | |
Robert Phillips | 4275492 | 2021-06-01 13:12:51 -0400 | [diff] [blame^] | 50 | GrRecordingContext* recordingContext() const override { return fContext.get(); } |
| 51 | |
Robert Phillips | 0095fcb | 2021-05-24 14:34:01 -0400 | [diff] [blame] | 52 | virtual bool wait(int numSemaphores, |
| 53 | const GrBackendSemaphore* waitSemaphores, |
| 54 | bool deleteSemaphoresAfterWait) = 0; |
| 55 | |
Robert Phillips | 09b2bcb | 2021-05-12 11:56:47 -0400 | [diff] [blame] | 56 | protected: |
Robert Phillips | 4275492 | 2021-06-01 13:12:51 -0400 | [diff] [blame^] | 57 | sk_sp<GrRecordingContext> fContext; |
Robert Phillips | 09b2bcb | 2021-05-12 11:56:47 -0400 | [diff] [blame] | 58 | |
| 59 | private: |
| 60 | using INHERITED = BASE_DEVICE; |
| 61 | }; |
| 62 | |
| 63 | #undef BASE_DEVICE |
| 64 | |
| 65 | #endif |