blob: 00afd85df1fbff398f177b2a087821b5adac8af1 [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 <map>
15#include "GrCCPerOpListPaths.h"
Robert Phillips62000362018-02-01 09:10:04 -050016#include "GrOpList.h"
17#endif
18
Robert Phillips8def8bf2017-11-30 08:46:03 -050019class SkSurface;
Robert Phillipsad8a43f2017-08-30 12:06:35 -040020
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 Phillips774168e2018-05-31 12:43:27 -040027class SK_API SkDeferredDisplayList {
Robert Phillipsad8a43f2017-08-30 12:06:35 -040028public:
Robert Phillips62000362018-02-01 09:10:04 -050029
Robert Phillips62000362018-02-01 09:10:04 -050030#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 Phillips774168e2018-05-31 12:43:27 -040047 ~SkDeferredDisplayList();
Robert Phillips62000362018-02-01 09:10:04 -050048
Robert Phillipsad8a43f2017-08-30 12:06:35 -040049 const SkSurfaceCharacterization& characterization() const {
50 return fCharacterization;
51 }
52
Robert Phillipsad8a43f2017-08-30 12:06:35 -040053private:
Robert Phillips62000362018-02-01 09:10:04 -050054 friend class GrDrawingManager; // for access to 'fOpLists' and 'fLazyProxyData'
55 friend class SkDeferredDisplayListRecorder; // for access to 'fLazyProxyData'
56
Robert Phillips61e51012017-11-30 11:22:14 -050057 const SkSurfaceCharacterization fCharacterization;
Robert Phillipsad8a43f2017-08-30 12:06:35 -040058
Robert Phillips62000362018-02-01 09:10:04 -050059#if SK_SUPPORT_GPU
Robert Phillips774168e2018-05-31 12:43:27 -040060 // This needs to match the same type in GrCoverageCountingPathRenderer.h
61 using PendingPathsMap = std::map<uint32_t, sk_sp<GrCCPerOpListPaths>>;
62
Robert Phillips62000362018-02-01 09:10:04 -050063 SkTArray<sk_sp<GrOpList>> fOpLists;
Robert Phillips774168e2018-05-31 12:43:27 -040064 PendingPathsMap fPendingPaths; // This is the path data from CCPR.
Robert Phillips62000362018-02-01 09:10:04 -050065#endif
66 sk_sp<LazyProxyData> fLazyProxyData;
Robert Phillipsad8a43f2017-08-30 12:06:35 -040067};
68
69#endif