Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
GrSimpleMeshDrawOpHelper.cpp
Go to the documentation of this file.
1/*
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
9
14#include "src/gpu/ganesh/SkGr.h"
16
18 GrAAType aaType,
19 InputFlags inputFlags)
20 : fProcessors(processorSet)
21 , fPipelineFlags((GrPipeline::InputFlags)inputFlags)
22 , fAAType((int)aaType)
23 , fUsesLocalCoords(false)
24 , fCompatibleWithCoverageAsAlpha(false) {
25 SkDEBUGCODE(fDidAnalysis = false);
26 SkDEBUGCODE(fMadePipeline = false);
27}
28
34
39
41 const GrCaps& caps, const SkRect& thisBounds,
42 const SkRect& thatBounds, bool ignoreAAType) const {
44 return false;
45 }
46 if (fProcessors) {
47 if (*fProcessors != *that.fProcessors) {
48 return false;
49 }
50 }
51
52#ifdef SK_DEBUG
53 if (ignoreAAType) {
54 // If we're ignoring AA it should be bc we already know they are the same or that
55 // the are different but are compatible (i.e., one is AA and the other is None)
56 SkASSERT(fAAType == that.fAAType ||
57 GrMeshDrawOp::CanUpgradeAAOnMerge(this->aaType(), that.aaType()));
58 }
59#endif
60
61 bool result = fPipelineFlags == that.fPipelineFlags &&
62 (ignoreAAType || fAAType == that.fAAType);
65 return result;
66}
67
69 const GrCaps& caps, const GrAppliedClip* clip, GrClampType clampType,
70 GrProcessorAnalysisCoverage geometryCoverage, SkPMColor4f* geometryColor, bool* wideColor) {
71 GrProcessorAnalysisColor color = *geometryColor;
72 auto result = this->finalizeProcessors(caps, clip, clampType, geometryCoverage, &color);
73 color.isConstant(geometryColor);
74 if (wideColor) {
75 *wideColor = !geometryColor->fitsInBytes();
76 }
77 return result;
78}
79
81 const GrCaps& caps, const GrAppliedClip* clip, const GrUserStencilSettings* userStencil,
82 GrClampType clampType, GrProcessorAnalysisCoverage geometryCoverage,
83 GrProcessorAnalysisColor* geometryColor) {
84 SkDEBUGCODE(fDidAnalysis = true);
86 if (fProcessors) {
87 GrProcessorAnalysisCoverage coverage = geometryCoverage;
88 if (GrProcessorAnalysisCoverage::kNone == coverage) {
89 coverage = (clip && clip->hasCoverageFragmentProcessor())
92 }
93 SkPMColor4f overrideColor;
94 analysis = fProcessors->finalize(*geometryColor, coverage, clip, userStencil, caps,
95 clampType, &overrideColor);
96 if (analysis.inputColorIsOverridden()) {
97 *geometryColor = overrideColor;
98 }
99 } else {
101 }
104 return analysis;
105}
106
108 SkArenaAlloc* arena,
109 skgpu::Swizzle writeViewSwizzle,
110 GrAppliedClip&& appliedClip,
111 const GrDstProxyView& dstProxyView,
112 GrProcessorSet&& processorSet,
113 GrPipeline::InputFlags pipelineFlags) {
114 GrPipeline::InitArgs pipelineArgs;
115
116 pipelineArgs.fInputFlags = pipelineFlags;
117 pipelineArgs.fCaps = caps;
118 pipelineArgs.fDstProxyView = dstProxyView;
119 pipelineArgs.fWriteSwizzle = writeViewSwizzle;
120
121 return arena->make<GrPipeline>(pipelineArgs,
122 std::move(processorSet),
123 std::move(appliedClip));
124}
127 GrProcessorSet&& processorSet,
128 GrPipeline::InputFlags pipelineFlags) {
129 return CreatePipeline(&flushState->caps(),
130 flushState->allocator(),
131 flushState->writeView().swizzle(),
132 flushState->detachAppliedClip(),
133 flushState->dstProxyView(),
134 std::move(processorSet),
136}
137
139 return CreatePipeline(&flushState->caps(),
140 flushState->allocator(),
141 flushState->writeView().swizzle(),
142 flushState->detachAppliedClip(),
143 flushState->dstProxyView(),
144 this->detachProcessorSet(),
145 this->pipelineFlags());
146}
147
149 SkArenaAlloc* arena,
150 skgpu::Swizzle writeViewSwizzle,
151 GrAppliedClip&& appliedClip,
152 const GrDstProxyView& dstProxyView) {
154 arena,
155 writeViewSwizzle,
156 std::move(appliedClip),
157 dstProxyView,
158 this->detachProcessorSet(),
159 this->pipelineFlags());
160}
161
163 const GrCaps* caps,
164 SkArenaAlloc* arena,
165 const GrSurfaceProxyView& writeView,
166 bool usesMSAASurface,
167 GrAppliedClip&& appliedClip,
168 const GrDstProxyView& dstProxyView,
169 GrGeometryProcessor* geometryProcessor,
170 GrProcessorSet&& processorSet,
171 GrPrimitiveType primitiveType,
172 GrXferBarrierFlags renderPassXferBarriers,
173 GrLoadOp colorLoadOp,
174 GrPipeline::InputFlags pipelineFlags,
175 const GrUserStencilSettings* stencilSettings) {
176 auto pipeline = CreatePipeline(caps,
177 arena,
178 writeView.swizzle(),
179 std::move(appliedClip),
180 dstProxyView,
181 std::move(processorSet),
183
184 return CreateProgramInfo(caps, arena, pipeline, writeView, usesMSAASurface, geometryProcessor,
185 primitiveType, renderPassXferBarriers, colorLoadOp, stencilSettings);
186}
187
189 SkArenaAlloc* arena,
190 const GrPipeline* pipeline,
191 const GrSurfaceProxyView& writeView,
192 bool usesMSAASurface,
193 GrGeometryProcessor* geometryProcessor,
194 GrPrimitiveType primitiveType,
195 GrXferBarrierFlags xferBarrierFlags,
196 GrLoadOp colorLoadOp,
197 const GrUserStencilSettings* stencilSettings) {
198 auto tmp = arena->make<GrProgramInfo>(*caps,
199 writeView,
200 usesMSAASurface,
201 pipeline,
202 stencilSettings,
203 geometryProcessor,
204 primitiveType,
205 xferBarrierFlags,
206 colorLoadOp);
207 return tmp;
208}
209
211 const GrCaps* caps,
212 SkArenaAlloc* arena,
213 const GrSurfaceProxyView& writeView,
214 bool usesMSAASurface,
215 GrAppliedClip&& appliedClip,
216 const GrDstProxyView& dstProxyView,
218 GrPrimitiveType primType,
219 GrXferBarrierFlags renderPassXferBarriers,
220 GrLoadOp colorLoadOp) {
221 return CreateProgramInfo(caps,
222 arena,
223 writeView,
224 usesMSAASurface,
225 std::move(appliedClip),
226 dstProxyView,
227 gp,
228 this->detachProcessorSet(),
229 primType,
230 renderPassXferBarriers,
231 colorLoadOp,
232 this->pipelineFlags());
233}
234
235#if defined(GR_TEST_UTILS)
236static void dump_pipeline_flags(GrPipeline::InputFlags flags, SkString* result) {
239 result->append("Snap vertices to pixel center.\n");
240 }
242 result->append("Wireframe enabled.\n");
243 }
245 result->append("Conservative raster enabled.\n");
246 }
247 return;
248 }
249 result->append("No pipeline flags\n");
250}
251
252SkString GrSimpleMeshDrawOpHelper::dumpInfo() const {
254 SkString result = processors.dumpProcessors();
255 result.append("AA Type: ");
256 switch (this->aaType()) {
257 case GrAAType::kNone:
258 result.append(" none\n");
259 break;
261 result.append(" coverage\n");
262 break;
263 case GrAAType::kMSAA:
264 result.append(" msaa\n");
265 break;
266 }
267 dump_pipeline_flags(fPipelineFlags, &result);
268 return result;
269}
270#endif
GrProcessorAnalysisCoverage
GrClampType
GrPrimitiveType
Definition GrTypesPriv.h:42
static constexpr bool GrAATypeIsHW(GrAAType type)
GrAAType
GrLoadOp
GrXferBarrierFlags
SkColor4f color
#define SkASSERT(cond)
Definition SkAssert.h:116
#define SkDEBUGCODE(...)
Definition SkDebug.h:23
static SkPath clip(const SkPath &path, const SkHalfPlane &plane)
Definition SkPath.cpp:3824
static constexpr bool SkToBool(const T &x)
Definition SkTo.h:35
Type::kYUV Type::kRGBA() int(0.7 *637)
FixedFunctionFlags
Definition GrDrawOp.h:104
static bool CanUpgradeAAOnMerge(GrAAType aa1, GrAAType aa2)
const GrDstProxyView & dstProxyView() const final
SkArenaAlloc * allocator() override
const GrSurfaceProxyView & writeView() const final
GrAppliedClip detachAppliedClip() final
const GrCaps & caps() const final
bool inputColorIsOverridden() const
bool isCompatibleWithCoverageAsAlpha() const
static constexpr Analysis EmptySetAnalysis()
static const GrProcessorSet & EmptySet()
Analysis finalize(const GrProcessorAnalysisColor &, const GrProcessorAnalysisCoverage, const GrAppliedClip *, const GrUserStencilSettings *, const GrCaps &, GrClampType, SkPMColor4f *inputColorOverride)
GrPipeline::InputFlags fPipelineFlags
GrDrawOp::FixedFunctionFlags fixedFunctionFlags() const
GrProgramInfo * createProgramInfo(const GrCaps *, SkArenaAlloc *, const GrSurfaceProxyView &writeView, bool usesMSAASurface, GrAppliedClip &&, const GrDstProxyView &, GrGeometryProcessor *, GrPrimitiveType, GrXferBarrierFlags renderPassXferBarriers, GrLoadOp colorLoadOp)
GrPipeline::InputFlags pipelineFlags() const
static const GrPipeline * CreatePipeline(const GrCaps *, SkArenaAlloc *, skgpu::Swizzle writeViewSwizzle, GrAppliedClip &&, const GrDstProxyView &, GrProcessorSet &&, GrPipeline::InputFlags pipelineFlags)
GrProcessorSet::Analysis finalizeProcessors(const GrCaps &caps, const GrAppliedClip *clip, GrClampType clampType, GrProcessorAnalysisCoverage geometryCoverage, GrProcessorAnalysisColor *geometryColor)
static GrProgramInfo * CreateProgramInfo(const GrCaps *, SkArenaAlloc *, const GrPipeline *, const GrSurfaceProxyView &writeView, bool usesMSAASurface, GrGeometryProcessor *, GrPrimitiveType, GrXferBarrierFlags renderPassXferBarriers, GrLoadOp colorLoadOp, const GrUserStencilSettings *=&GrUserStencilSettings::kUnused)
const GrPipeline * createPipeline(GrOpFlushState *flushState)
bool isCompatible(const GrSimpleMeshDrawOpHelper &that, const GrCaps &, const SkRect &thisBounds, const SkRect &thatBounds, bool ignoreAAType=false) const
skgpu::Swizzle swizzle() const
auto make(Ctor &&ctor) -> decltype(ctor(nullptr))
void append(const char text[])
Definition SkString.h:203
FlutterSemanticsFlag flags
GAsyncResult * result
skgpu::Swizzle fWriteSwizzle
Definition GrPipeline.h:66
InputFlags fInputFlags
Definition GrPipeline.h:63
const GrCaps * fCaps
Definition GrPipeline.h:64
GrDstProxyView fDstProxyView
Definition GrPipeline.h:65
bool fitsInBytes() const
Definition SkColor.h:350