blob: 1f34beb6b8eaa1505af93e0f25a2c32f983e52c6 [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
Mike Kleinc0bd9f92019-04-23 12:05:21 -050011#include "include/core/SkSurfaceCharacterization.h"
Robert Phillipsad8a43f2017-08-30 12:06:35 -040012
Robert Phillips62000362018-02-01 09:10:04 -050013#if SK_SUPPORT_GPU
Mike Kleinc0bd9f92019-04-23 12:05:21 -050014#include "include/private/GrCCPerOpListPaths.h"
15#include "include/private/GrOpList.h"
Hal Canaryc2d0fb12018-09-19 10:28:59 -040016
17#include <map>
Robert Phillips62000362018-02-01 09:10:04 -050018#endif
19
Robert Phillipse8e2bb12018-09-27 14:26:47 -040020class SkDeferredDisplayListPriv;
Robert Phillips8def8bf2017-11-30 08:46:03 -050021class SkSurface;
Robert Phillipsad8a43f2017-08-30 12:06:35 -040022/*
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 Phillips774168e2018-05-31 12:43:27 -040028class SK_API SkDeferredDisplayList {
Robert Phillipsad8a43f2017-08-30 12:06:35 -040029public:
Robert Phillips62000362018-02-01 09:10:04 -050030
Robert Phillips62000362018-02-01 09:10:04 -050031#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 Phillips774168e2018-05-31 12:43:27 -040048 ~SkDeferredDisplayList();
Robert Phillips62000362018-02-01 09:10:04 -050049
Robert Phillipsad8a43f2017-08-30 12:06:35 -040050 const SkSurfaceCharacterization& characterization() const {
51 return fCharacterization;
52 }
53
Robert Phillipse8e2bb12018-09-27 14:26:47 -040054 // Provides access to functions that aren't part of the public API.
55 SkDeferredDisplayListPriv priv();
56 const SkDeferredDisplayListPriv priv() const;
57
Robert Phillipsad8a43f2017-08-30 12:06:35 -040058private:
Robert Phillips62000362018-02-01 09:10:04 -050059 friend class GrDrawingManager; // for access to 'fOpLists' and 'fLazyProxyData'
60 friend class SkDeferredDisplayListRecorder; // for access to 'fLazyProxyData'
Robert Phillipse8e2bb12018-09-27 14:26:47 -040061 friend class SkDeferredDisplayListPriv;
Robert Phillips62000362018-02-01 09:10:04 -050062
Robert Phillips61e51012017-11-30 11:22:14 -050063 const SkSurfaceCharacterization fCharacterization;
Robert Phillipsad8a43f2017-08-30 12:06:35 -040064
Robert Phillips62000362018-02-01 09:10:04 -050065#if SK_SUPPORT_GPU
Robert Phillips774168e2018-05-31 12:43:27 -040066 // This needs to match the same type in GrCoverageCountingPathRenderer.h
67 using PendingPathsMap = std::map<uint32_t, sk_sp<GrCCPerOpListPaths>>;
68
Robert Phillips62000362018-02-01 09:10:04 -050069 SkTArray<sk_sp<GrOpList>> fOpLists;
Robert Phillips774168e2018-05-31 12:43:27 -040070 PendingPathsMap fPendingPaths; // This is the path data from CCPR.
Robert Phillips62000362018-02-01 09:10:04 -050071#endif
72 sk_sp<LazyProxyData> fLazyProxyData;
Robert Phillipsad8a43f2017-08-30 12:06:35 -040073};
74
75#endif