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 |
Robert Phillips | 774168e | 2018-05-31 12:43:27 -0400 | [diff] [blame] | 14 | #include "GrCCPerOpListPaths.h" |
Robert Phillips | 6200036 | 2018-02-01 09:10:04 -0500 | [diff] [blame] | 15 | #include "GrOpList.h" |
Hal Canary | c2d0fb1 | 2018-09-19 10:28:59 -0400 | [diff] [blame^] | 16 | |
| 17 | #include <map> |
Robert Phillips | 6200036 | 2018-02-01 09:10:04 -0500 | [diff] [blame] | 18 | #endif |
| 19 | |
Robert Phillips | 8def8bf | 2017-11-30 08:46:03 -0500 | [diff] [blame] | 20 | class SkSurface; |
Robert Phillips | ad8a43f | 2017-08-30 12:06:35 -0400 | [diff] [blame] | 21 | |
| 22 | /* |
| 23 | * This class contains pre-processed gpu operations that can be replayed into |
| 24 | * an SkSurface via draw(SkDeferredDisplayList*). |
| 25 | * |
| 26 | * TODO: we probably need to expose this class so users can query it for memory usage. |
| 27 | */ |
Robert Phillips | 774168e | 2018-05-31 12:43:27 -0400 | [diff] [blame] | 28 | class SK_API SkDeferredDisplayList { |
Robert Phillips | ad8a43f | 2017-08-30 12:06:35 -0400 | [diff] [blame] | 29 | public: |
Robert Phillips | 6200036 | 2018-02-01 09:10:04 -0500 | [diff] [blame] | 30 | |
Robert Phillips | 6200036 | 2018-02-01 09:10:04 -0500 | [diff] [blame] | 31 | #if SK_SUPPORT_GPU |
| 32 | // This object is the source from which the lazy proxy backing the DDL will pull its backing |
| 33 | // texture when the DDL is replayed. It has to be separately ref counted bc the lazy proxy |
| 34 | // can outlive the DDL. |
| 35 | class LazyProxyData : public SkRefCnt { |
| 36 | public: |
| 37 | // Upon being replayed - this field will be filled in (by the DrawingManager) with the proxy |
| 38 | // backing the destination SkSurface. Note that, since there is no good place to clear it |
| 39 | // it can become a dangling pointer. |
| 40 | GrRenderTargetProxy* fReplayDest = nullptr; |
| 41 | }; |
| 42 | #else |
| 43 | class LazyProxyData : public SkRefCnt {}; |
| 44 | #endif |
| 45 | |
| 46 | SkDeferredDisplayList(const SkSurfaceCharacterization& characterization, |
| 47 | sk_sp<LazyProxyData>); |
Robert Phillips | 774168e | 2018-05-31 12:43:27 -0400 | [diff] [blame] | 48 | ~SkDeferredDisplayList(); |
Robert Phillips | 6200036 | 2018-02-01 09:10:04 -0500 | [diff] [blame] | 49 | |
Robert Phillips | ad8a43f | 2017-08-30 12:06:35 -0400 | [diff] [blame] | 50 | const SkSurfaceCharacterization& characterization() const { |
| 51 | return fCharacterization; |
| 52 | } |
| 53 | |
Robert Phillips | ad8a43f | 2017-08-30 12:06:35 -0400 | [diff] [blame] | 54 | private: |
Robert Phillips | 6200036 | 2018-02-01 09:10:04 -0500 | [diff] [blame] | 55 | friend class GrDrawingManager; // for access to 'fOpLists' and 'fLazyProxyData' |
| 56 | friend class SkDeferredDisplayListRecorder; // for access to 'fLazyProxyData' |
| 57 | |
Robert Phillips | 61e5101 | 2017-11-30 11:22:14 -0500 | [diff] [blame] | 58 | const SkSurfaceCharacterization fCharacterization; |
Robert Phillips | ad8a43f | 2017-08-30 12:06:35 -0400 | [diff] [blame] | 59 | |
Robert Phillips | 6200036 | 2018-02-01 09:10:04 -0500 | [diff] [blame] | 60 | #if SK_SUPPORT_GPU |
Robert Phillips | 774168e | 2018-05-31 12:43:27 -0400 | [diff] [blame] | 61 | // This needs to match the same type in GrCoverageCountingPathRenderer.h |
| 62 | using PendingPathsMap = std::map<uint32_t, sk_sp<GrCCPerOpListPaths>>; |
| 63 | |
Robert Phillips | 6200036 | 2018-02-01 09:10:04 -0500 | [diff] [blame] | 64 | SkTArray<sk_sp<GrOpList>> fOpLists; |
Robert Phillips | 774168e | 2018-05-31 12:43:27 -0400 | [diff] [blame] | 65 | PendingPathsMap fPendingPaths; // This is the path data from CCPR. |
Robert Phillips | 6200036 | 2018-02-01 09:10:04 -0500 | [diff] [blame] | 66 | #endif |
| 67 | sk_sp<LazyProxyData> fLazyProxyData; |
Robert Phillips | ad8a43f | 2017-08-30 12:06:35 -0400 | [diff] [blame] | 68 | }; |
| 69 | |
| 70 | #endif |