blob: b90995cb3cfec594675a68729ec875fcb6278e78 [file] [log] [blame]
Robert Phillipsad8a43f2017-08-30 12:06:35 -04001/*
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 Wagner729a23f2019-05-17 16:29:34 -040011#include "include/core/SkRefCnt.h"
Mike Kleinc0bd9f92019-04-23 12:05:21 -050012#include "include/core/SkSurfaceCharacterization.h"
Ben Wagner729a23f2019-05-17 16:29:34 -040013#include "include/core/SkTypes.h"
Robert Phillips62000362018-02-01 09:10:04 -050014
Robert Phillipse8e2bb12018-09-27 14:26:47 -040015class SkDeferredDisplayListPriv;
Ben Wagner729a23f2019-05-17 16:29:34 -040016
17#if SK_SUPPORT_GPU
18#include "include/private/SkTArray.h"
19#include <map>
Chris Dalton6b498102019-08-01 14:14:52 -060020class GrRenderTask;
Ben Wagner729a23f2019-05-17 16:29:34 -040021class GrRenderTargetProxy;
Greg Danielf41b2bd2019-08-22 16:19:24 -040022struct GrCCPerOpsTaskPaths;
Ben Wagner729a23f2019-05-17 16:29:34 -040023#endif
24
Robert Phillipsad8a43f2017-08-30 12:06:35 -040025/*
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 Wagner729a23f2019-05-17 16:29:34 -040031class SkDeferredDisplayList {
Robert Phillipsad8a43f2017-08-30 12:06:35 -040032public:
Robert Phillips62000362018-02-01 09:10:04 -050033
Robert Phillips62000362018-02-01 09:10:04 -050034#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 Wagner729a23f2019-05-17 16:29:34 -040038 class SK_API LazyProxyData : public SkRefCnt {
Robert Phillips62000362018-02-01 09:10:04 -050039 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 Wagner729a23f2019-05-17 16:29:34 -040046 class SK_API LazyProxyData : public SkRefCnt {};
Robert Phillips62000362018-02-01 09:10:04 -050047#endif
48
Ben Wagner729a23f2019-05-17 16:29:34 -040049 SK_API SkDeferredDisplayList(const SkSurfaceCharacterization& characterization,
50 sk_sp<LazyProxyData>);
51 SK_API ~SkDeferredDisplayList();
Robert Phillips62000362018-02-01 09:10:04 -050052
Ben Wagner729a23f2019-05-17 16:29:34 -040053 SK_API const SkSurfaceCharacterization& characterization() const {
Robert Phillipsad8a43f2017-08-30 12:06:35 -040054 return fCharacterization;
55 }
56
Robert Phillipse8e2bb12018-09-27 14:26:47 -040057 // Provides access to functions that aren't part of the public API.
58 SkDeferredDisplayListPriv priv();
59 const SkDeferredDisplayListPriv priv() const;
60
Robert Phillipsad8a43f2017-08-30 12:06:35 -040061private:
Robert Phillips61fc7992019-10-22 11:58:17 -040062 friend class GrDrawingManager; // for access to 'fRenderTasks', 'fLazyProxyData', 'fOpPOD'
Robert Phillips62000362018-02-01 09:10:04 -050063 friend class SkDeferredDisplayListRecorder; // for access to 'fLazyProxyData'
Robert Phillipse8e2bb12018-09-27 14:26:47 -040064 friend class SkDeferredDisplayListPriv;
Robert Phillips62000362018-02-01 09:10:04 -050065
Robert Phillips61e51012017-11-30 11:22:14 -050066 const SkSurfaceCharacterization fCharacterization;
Robert Phillipsad8a43f2017-08-30 12:06:35 -040067
Robert Phillips62000362018-02-01 09:10:04 -050068#if SK_SUPPORT_GPU
Robert Phillips774168e2018-05-31 12:43:27 -040069 // This needs to match the same type in GrCoverageCountingPathRenderer.h
Greg Danielf41b2bd2019-08-22 16:19:24 -040070 using PendingPathsMap = std::map<uint32_t, sk_sp<GrCCPerOpsTaskPaths>>;
Robert Phillips774168e2018-05-31 12:43:27 -040071
Chris Dalton6b498102019-08-01 14:14:52 -060072 SkTArray<sk_sp<GrRenderTask>> fRenderTasks;
73 PendingPathsMap fPendingPaths; // This is the path data from CCPR.
Robert Phillips61fc7992019-10-22 11:58:17 -040074 std::unique_ptr<SkArenaAlloc> fOpPOD;
Robert Phillips62000362018-02-01 09:10:04 -050075#endif
Chris Dalton6b498102019-08-01 14:14:52 -060076 sk_sp<LazyProxyData> fLazyProxyData;
Robert Phillipsad8a43f2017-08-30 12:06:35 -040077};
78
79#endif