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