Flutter Engine
The Flutter Engine
GraphiteTypes.h
Go to the documentation of this file.
1/*
2 * Copyright 2021 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 skgpu_graphite_GraphiteTypes_DEFINED
9#define skgpu_graphite_GraphiteTypes_DEFINED
10
14
15#include <memory>
16
17class SkSurface;
18
19namespace skgpu {
20class MutableTextureState;
21}
22
23namespace skgpu::graphite {
24
25class BackendSemaphore;
26class Recording;
27class Task;
28
29using GpuFinishedContext = void*;
30using GpuFinishedProc = void (*)(GpuFinishedContext finishedContext, CallbackResult);
31
32/**
33 * The fFinishedProc is called when the Recording has been submitted and finished on the GPU, or
34 * when there is a failure that caused it not to be submitted. The callback will always be called
35 * and the caller can use the callback to know it is safe to free any resources associated with
36 * the Recording that they may be holding onto. If the Recording is successfully submitted to the
37 * GPU the callback will be called with CallbackResult::kSuccess once the GPU has finished. All
38 * other cases where some failure occured it will be called with CallbackResult::kFailed.
39 *
40 * The fTargetSurface, if provided, is used as a target for any draws recorded onto a deferred
41 * canvas returned from Recorder::makeDeferredCanvas. This target surface must be provided iff
42 * the Recording contains any such draws. It must be Graphite-backed and its backing texture's
43 * TextureInfo must match the info provided to the Recorder when making the deferred canvas.
44 *
45 * fTargetTranslation is an additional translation applied to draws targeting fTargetSurface.
46 *
47 * The client may pass in two arrays of initialized BackendSemaphores to be included in the
48 * command stream. At some time before issuing commands in the Recording, the fWaitSemaphores will
49 * be waited on by the gpu. We only guarantee these wait semaphores block transfer and fragment
50 * shader work. Similarly, at some time after issuing the Recording's commands, the
51 * fSignalSemaphores will be signaled by the gpu. Depending on the platform, the timing of the wait
52 * and signal operations will either be immediately before or after the given Recording's command
53 * stream, respectively, or before and after the entire CommandBuffer's command stream. The
54 * semaphores are not sent to the GPU until the next Context::submit call is made.
55 *
56 * The client will own and be responsible for deleting the underlying semaphore objects after the
57 * submission completes, however the BackendSemaphore objects themselves can be deleted as soon
58 * as this function returns.
59 */
62
66
71
74};
75
76/**
77 * The fFinishedProc is called when the Recording has been submitted and finished on the GPU, or
78 * when there is a failure that caused it not to be submitted. The callback will always be called
79 * and the caller can use the callback to know it is safe to free any resources associated with
80 * the Recording that they may be holding onto. If the Recording is successfully submitted to the
81 * GPU the callback will be called with CallbackResult::kSuccess once the GPU has finished. All
82 * other cases where some failure occured it will be called with CallbackResult::kFailed.
83 */
87};
88
89/**
90 * Actually submit work to the GPU and track its completion
91 */
92enum class SyncToCpu : bool {
93 kYes = true,
94 kNo = false
95};
96
97/*
98 * For Promise Images - should the Promise Image be fulfilled every time a Recording that references
99 * it is inserted into the Context.
100 */
101enum class Volatile : bool {
102 kNo = false, // only fulfilled once
103 kYes = true // fulfilled on every insertion call
104};
105
106/*
107 * Graphite's different rendering methods each only apply to certain types of draws. This
108 * enum supports decision-making regarding the different renderers and what is being drawn.
109 */
110enum DrawTypeFlags : uint8_t {
111
112 kNone = 0b0000,
113
114 // SkCanvas:: drawSimpleText, drawString, drawGlyphs, drawTextBlob, drawSlug
115 kText = 0b0001,
116
117 // SkCanvas::drawVertices
119
120 // SkCanvas::experimental_DrawEdgeAAQuad, experimental_DrawEdgeAAImageSet
121 // SkCanvas:: drawRect, drawRRect, drawLine for:
122 // regular filled and hairline [r]rects,
123 // stroked rects,
124 // stroked and hairline lines,
125 // stroked circular rrects
126 // Note: clipping can bump a draw out of the simple shape path
127 kSimpleShape = 0b0100,
128 // All other shapes (e.g., any strokeAndFill shape, non-circular-stroked RRects, SkPaths, ...)
130
132
136
137} // namespace skgpu::graphite
138
139#endif // skgpu_graphite_GraphiteTypes_DEFINED
@ kYes
Do pre-clip the geometry before applying the (perspective) matrix.
@ kNo
Don't pre-clip the geometry before applying the (perspective) matrix.
void * GpuFinishedContext
Definition: GraphiteTypes.h:29
void(*)(GpuFinishedContext finishedContext, CallbackResult) GpuFinishedProc
Definition: GraphiteTypes.h:30
Definition: GpuTools.h:21
CallbackResult
Definition: GpuTypes.h:45
Definition: DM.cpp:1161
GpuFinishedContext fFinishedContext
Definition: GraphiteTypes.h:85
MutableTextureState * fTargetTextureState
Definition: GraphiteTypes.h:65