blob: a236c01b35feaad7dd88a30bdd06c0a161095afc [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
11#include "SkSurfaceCharacterization.h"
12
Robert Phillips62000362018-02-01 09:10:04 -050013#if SK_SUPPORT_GPU
Robert Phillips774168e2018-05-31 12:43:27 -040014#include "GrCCPerOpListPaths.h"
Robert Phillips62000362018-02-01 09:10:04 -050015#include "GrOpList.h"
Hal Canaryc2d0fb12018-09-19 10:28:59 -040016
17#include <map>
Robert Phillips62000362018-02-01 09:10:04 -050018#endif
19
Robert Phillips8def8bf2017-11-30 08:46:03 -050020class SkSurface;
Robert Phillipsad8a43f2017-08-30 12:06:35 -040021
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 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 Phillipsad8a43f2017-08-30 12:06:35 -040054private:
Robert Phillips62000362018-02-01 09:10:04 -050055 friend class GrDrawingManager; // for access to 'fOpLists' and 'fLazyProxyData'
56 friend class SkDeferredDisplayListRecorder; // for access to 'fLazyProxyData'
57
Robert Phillips61e51012017-11-30 11:22:14 -050058 const SkSurfaceCharacterization fCharacterization;
Robert Phillipsad8a43f2017-08-30 12:06:35 -040059
Robert Phillips62000362018-02-01 09:10:04 -050060#if SK_SUPPORT_GPU
Robert Phillips774168e2018-05-31 12:43:27 -040061 // This needs to match the same type in GrCoverageCountingPathRenderer.h
62 using PendingPathsMap = std::map<uint32_t, sk_sp<GrCCPerOpListPaths>>;
63
Robert Phillips62000362018-02-01 09:10:04 -050064 SkTArray<sk_sp<GrOpList>> fOpLists;
Robert Phillips774168e2018-05-31 12:43:27 -040065 PendingPathsMap fPendingPaths; // This is the path data from CCPR.
Robert Phillips62000362018-02-01 09:10:04 -050066#endif
67 sk_sp<LazyProxyData> fLazyProxyData;
Robert Phillipsad8a43f2017-08-30 12:06:35 -040068};
69
70#endif