Robert Phillips | ad8a43f | 2017-08-30 12:06:35 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2017 Google Inc. |
| 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 SkDeferredDisplayList_DEFINED |
| 9 | #define SkDeferredDisplayList_DEFINED |
| 10 | |
| 11 | #include "SkSurfaceCharacterization.h" |
| 12 | |
Robert Phillips | 6200036 | 2018-02-01 09:10:04 -0500 | [diff] [blame^] | 13 | #if SK_SUPPORT_GPU |
| 14 | #include "GrOpList.h" |
| 15 | #endif |
| 16 | |
| 17 | #ifdef SK_RASTER_RECORDER_IMPLEMENTATION |
| 18 | class SkImage; // DDL TODO: rm this since it is just for the temporary placeholder implementation |
| 19 | #endif |
| 20 | |
Robert Phillips | 8def8bf | 2017-11-30 08:46:03 -0500 | [diff] [blame] | 21 | class SkSurface; |
Robert Phillips | ad8a43f | 2017-08-30 12:06:35 -0400 | [diff] [blame] | 22 | |
| 23 | /* |
| 24 | * This class contains pre-processed gpu operations that can be replayed into |
| 25 | * an SkSurface via draw(SkDeferredDisplayList*). |
| 26 | * |
| 27 | * TODO: we probably need to expose this class so users can query it for memory usage. |
| 28 | */ |
| 29 | class SkDeferredDisplayList { |
| 30 | public: |
Robert Phillips | 6200036 | 2018-02-01 09:10:04 -0500 | [diff] [blame^] | 31 | |
| 32 | #ifdef SK_RASTER_RECORDER_IMPLEMENTATION |
| 33 | SkDeferredDisplayList(const SkSurfaceCharacterization& characterization, sk_sp<SkImage> image) |
Robert Phillips | ad8a43f | 2017-08-30 12:06:35 -0400 | [diff] [blame] | 34 | : fCharacterization(characterization) |
| 35 | , fImage(std::move(image)) { |
| 36 | } |
| 37 | |
Robert Phillips | 6200036 | 2018-02-01 09:10:04 -0500 | [diff] [blame^] | 38 | // DDL TODO: remove this. It is just scaffolding to get something up & running |
| 39 | bool draw(SkSurface*) const; |
| 40 | #endif |
| 41 | |
| 42 | #if SK_SUPPORT_GPU |
| 43 | // This object is the source from which the lazy proxy backing the DDL will pull its backing |
| 44 | // texture when the DDL is replayed. It has to be separately ref counted bc the lazy proxy |
| 45 | // can outlive the DDL. |
| 46 | class LazyProxyData : public SkRefCnt { |
| 47 | public: |
| 48 | // Upon being replayed - this field will be filled in (by the DrawingManager) with the proxy |
| 49 | // backing the destination SkSurface. Note that, since there is no good place to clear it |
| 50 | // it can become a dangling pointer. |
| 51 | GrRenderTargetProxy* fReplayDest = nullptr; |
| 52 | }; |
| 53 | #else |
| 54 | class LazyProxyData : public SkRefCnt {}; |
| 55 | #endif |
| 56 | |
| 57 | SkDeferredDisplayList(const SkSurfaceCharacterization& characterization, |
| 58 | sk_sp<LazyProxyData>); |
| 59 | |
Robert Phillips | ad8a43f | 2017-08-30 12:06:35 -0400 | [diff] [blame] | 60 | const SkSurfaceCharacterization& characterization() const { |
| 61 | return fCharacterization; |
| 62 | } |
| 63 | |
Robert Phillips | ad8a43f | 2017-08-30 12:06:35 -0400 | [diff] [blame] | 64 | private: |
Robert Phillips | 6200036 | 2018-02-01 09:10:04 -0500 | [diff] [blame^] | 65 | friend class GrDrawingManager; // for access to 'fOpLists' and 'fLazyProxyData' |
| 66 | friend class SkDeferredDisplayListRecorder; // for access to 'fLazyProxyData' |
| 67 | |
Robert Phillips | 61e5101 | 2017-11-30 11:22:14 -0500 | [diff] [blame] | 68 | const SkSurfaceCharacterization fCharacterization; |
Robert Phillips | ad8a43f | 2017-08-30 12:06:35 -0400 | [diff] [blame] | 69 | |
Robert Phillips | 6200036 | 2018-02-01 09:10:04 -0500 | [diff] [blame^] | 70 | #ifdef SK_RASTER_RECORDER_IMPLEMENTATION |
| 71 | sk_sp<SkImage> fImage; |
| 72 | #else |
| 73 | |
| 74 | #if SK_SUPPORT_GPU |
| 75 | SkTArray<sk_sp<GrOpList>> fOpLists; |
| 76 | #endif |
| 77 | sk_sp<LazyProxyData> fLazyProxyData; |
| 78 | |
| 79 | #endif |
Robert Phillips | ad8a43f | 2017-08-30 12:06:35 -0400 | [diff] [blame] | 80 | }; |
| 81 | |
| 82 | #endif |