blob: a3517bb6a0f9778b2f051f84a2c05711b4a26c63 [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
14#include "GrOpList.h"
15#endif
16
17#ifdef SK_RASTER_RECORDER_IMPLEMENTATION
18class SkImage; // DDL TODO: rm this since it is just for the temporary placeholder implementation
19#endif
20
Robert Phillips8def8bf2017-11-30 08:46:03 -050021class SkSurface;
Robert Phillipsad8a43f2017-08-30 12:06:35 -040022
23/*
24 * This class contains pre-processed gpu operations that can be replayed into
25 * an SkSurface via draw(SkDeferredDisplayList*).
26 *
27 * TODO: we probably need to expose this class so users can query it for memory usage.
28 */
29class SkDeferredDisplayList {
30public:
Robert Phillips62000362018-02-01 09:10:04 -050031
32#ifdef SK_RASTER_RECORDER_IMPLEMENTATION
33 SkDeferredDisplayList(const SkSurfaceCharacterization& characterization, sk_sp<SkImage> image)
Robert Phillipsad8a43f2017-08-30 12:06:35 -040034 : fCharacterization(characterization)
35 , fImage(std::move(image)) {
36 }
37
Robert Phillips62000362018-02-01 09:10:04 -050038 // DDL TODO: remove this. It is just scaffolding to get something up & running
39 bool draw(SkSurface*) const;
40#endif
41
42#if SK_SUPPORT_GPU
43 // This object is the source from which the lazy proxy backing the DDL will pull its backing
44 // texture when the DDL is replayed. It has to be separately ref counted bc the lazy proxy
45 // can outlive the DDL.
46 class LazyProxyData : public SkRefCnt {
47 public:
48 // Upon being replayed - this field will be filled in (by the DrawingManager) with the proxy
49 // backing the destination SkSurface. Note that, since there is no good place to clear it
50 // it can become a dangling pointer.
51 GrRenderTargetProxy* fReplayDest = nullptr;
52 };
53#else
54 class LazyProxyData : public SkRefCnt {};
55#endif
56
57 SkDeferredDisplayList(const SkSurfaceCharacterization& characterization,
58 sk_sp<LazyProxyData>);
59
Robert Phillipsad8a43f2017-08-30 12:06:35 -040060 const SkSurfaceCharacterization& characterization() const {
61 return fCharacterization;
62 }
63
Robert Phillipsad8a43f2017-08-30 12:06:35 -040064private:
Robert Phillips62000362018-02-01 09:10:04 -050065 friend class GrDrawingManager; // for access to 'fOpLists' and 'fLazyProxyData'
66 friend class SkDeferredDisplayListRecorder; // for access to 'fLazyProxyData'
67
Robert Phillips61e51012017-11-30 11:22:14 -050068 const SkSurfaceCharacterization fCharacterization;
Robert Phillipsad8a43f2017-08-30 12:06:35 -040069
Robert Phillips62000362018-02-01 09:10:04 -050070#ifdef SK_RASTER_RECORDER_IMPLEMENTATION
71 sk_sp<SkImage> fImage;
72#else
73
74#if SK_SUPPORT_GPU
75 SkTArray<sk_sp<GrOpList>> fOpLists;
76#endif
77 sk_sp<LazyProxyData> fLazyProxyData;
78
79#endif
Robert Phillipsad8a43f2017-08-30 12:06:35 -040080};
81
82#endif