Flutter Engine
The Flutter Engine
GrDeferredDisplayList.h
Go to the documentation of this file.
1/*
2 * Copyright 2023 Google LLC
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 GrDeferredDisplayList_DEFINED
9#define GrDeferredDisplayList_DEFINED
10
16
17class GrDirectContext;
19class GrRenderTask;
21class SkSurface;
22
23/*
24 * This class contains pre-processed gpu operations that can be replayed into
25 * an SkSurface via SkSurface::draw(GrDeferredDisplayList*).
26 */
27class GrDeferredDisplayList : public SkNVRefCnt<GrDeferredDisplayList> {
28public:
30
32 return fCharacterization;
33 }
34 /**
35 * Iterate through the programs required by the DDL.
36 */
38 public:
41
42 // This returns true if any work was done. Getting a cache hit does not count as work.
43 bool compile();
44 bool done() const;
45 void next();
46
47 private:
50 int fIndex;
51 };
52
53 // Provides access to functions that aren't part of the public API.
55 const GrDeferredDisplayListPriv priv() const; // NOLINT(readability-const-return-type)
56
57private:
58 friend class GrDrawingManager; // for access to 'fRenderTasks', 'fLazyProxyData', 'fArenas'
59 friend class GrDeferredDisplayListRecorder; // for access to 'fLazyProxyData'
61
62 // This object is the source from which the lazy proxy backing the DDL will pull its backing
63 // texture when the DDL is replayed. It has to be separately ref counted bc the lazy proxy
64 // can outlive the DDL.
65 class LazyProxyData : public SkRefCnt {
66 public:
67 // Upon being replayed - this field will be filled in (by the DrawingManager) with the
68 // proxy backing the destination SkSurface. Note that, since there is no good place to
69 // clear it, it can become a dangling pointer. Additionally, since the renderTargetProxy
70 // doesn't get a ref here, the SkSurface that owns it must remain alive until the DDL
71 // is flushed.
72 // TODO: the drawing manager could ref the renderTargetProxy for the DDL and then add
73 // a renderingTask to unref it after the DDL's ops have been executed.
74 GrRenderTargetProxy* fReplayDest = nullptr;
75 };
76
78 sk_sp<GrRenderTargetProxy> fTargetProxy,
80
82 return fProgramData;
83 }
84
85 const GrSurfaceCharacterization fCharacterization;
86
87 // These are ordered such that the destructor cleans op tasks up first (which may refer back
88 // to the arena and memory pool in their destructors).
91
93 sk_sp<GrRenderTargetProxy> fTargetProxy;
94 sk_sp<LazyProxyData> fLazyProxyData;
95};
96
97namespace skgpu::ganesh {
98/** Draws the deferred display list created via a GrDeferredDisplayListRecorder.
99 If the deferred display list is not compatible with the surface, the draw is skipped
100 and false is return.
101
102 The xOffset and yOffset parameters are experimental and, if not both zero, will cause
103 the draw to be ignored.
104 When implemented, if xOffset or yOffset are non-zero, the DDL will be drawn offset by that
105 amount into the surface.
106
107 @param SkSurface The surface to apply the commands to, cannot be nullptr.
108 @param ddl drawing commands, cannot be nullptr.
109 @return false if ddl is not compatible
110
111 example: https://fiddle.skia.org/c/@Surface_draw_2
112*/
115
118}
119
120#endif
static void done(const char *config, const char *src, const char *srcOptions, const char *name)
Definition: DM.cpp:263
static float next(float f)
#define SK_API
Definition: SkAPI.h:35
GrDirectContext * fDContext
GrDeferredDisplayListPriv priv()
SK_API const GrSurfaceCharacterization & characterization() const
SK_API bool DrawDDL(SkSurface *, sk_sp< const GrDeferredDisplayList > ddl)