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