1 /*
2 * Copyright 2020 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 #include "src/gpu/ganesh/ops/GrSimpleMeshDrawOpHelperWithStencil.h"
9
10 #include "src/gpu/ganesh/GrProcessorAnalysis.h"
11 #include "src/gpu/ganesh/GrUserStencilSettings.h"
12
GrSimpleMeshDrawOpHelperWithStencil(GrProcessorSet * processorSet,GrAAType aaType,const GrUserStencilSettings * stencilSettings,InputFlags inputFlags)13 GrSimpleMeshDrawOpHelperWithStencil::GrSimpleMeshDrawOpHelperWithStencil(
14 GrProcessorSet* processorSet,
15 GrAAType aaType,
16 const GrUserStencilSettings* stencilSettings,
17 InputFlags inputFlags)
18 : INHERITED(processorSet, aaType, inputFlags)
19 , fStencilSettings(stencilSettings ? stencilSettings : &GrUserStencilSettings::kUnused) {}
20
fixedFunctionFlags() const21 GrDrawOp::FixedFunctionFlags GrSimpleMeshDrawOpHelperWithStencil::fixedFunctionFlags() const {
22 GrDrawOp::FixedFunctionFlags flags = INHERITED::fixedFunctionFlags();
23 if (fStencilSettings != &GrUserStencilSettings::kUnused) {
24 flags |= GrDrawOp::FixedFunctionFlags::kUsesStencil;
25 }
26 return flags;
27 }
28
finalizeProcessors(const GrCaps & caps,const GrAppliedClip * clip,GrClampType clampType,GrProcessorAnalysisCoverage geometryCoverage,SkPMColor4f * geometryColor,bool * wideColor)29 GrProcessorSet::Analysis GrSimpleMeshDrawOpHelperWithStencil::finalizeProcessors(
30 const GrCaps& caps, const GrAppliedClip* clip, GrClampType clampType,
31 GrProcessorAnalysisCoverage geometryCoverage, SkPMColor4f* geometryColor, bool* wideColor) {
32 GrProcessorAnalysisColor color = *geometryColor;
33 auto result = this->finalizeProcessors(caps, clip, clampType, geometryCoverage, &color);
34 color.isConstant(geometryColor);
35 if (wideColor) {
36 *wideColor = !geometryColor->fitsInBytes();
37 }
38 return result;
39 }
40
isCompatible(const GrSimpleMeshDrawOpHelperWithStencil & that,const GrCaps & caps,const SkRect & thisBounds,const SkRect & thatBounds,bool ignoreAAType) const41 bool GrSimpleMeshDrawOpHelperWithStencil::isCompatible(
42 const GrSimpleMeshDrawOpHelperWithStencil& that, const GrCaps& caps,
43 const SkRect& thisBounds, const SkRect& thatBounds, bool ignoreAAType) const {
44 return INHERITED::isCompatible(that, caps, thisBounds, thatBounds, ignoreAAType) &&
45 fStencilSettings == that.fStencilSettings;
46 }
47
createProgramInfoWithStencil(const GrCaps * caps,SkArenaAlloc * arena,const GrSurfaceProxyView & writeView,bool usesMSAASurface,GrAppliedClip && appliedClip,const GrDstProxyView & dstProxyView,GrGeometryProcessor * gp,GrPrimitiveType primType,GrXferBarrierFlags renderPassXferBarriers,GrLoadOp colorLoadOp)48 GrProgramInfo* GrSimpleMeshDrawOpHelperWithStencil::createProgramInfoWithStencil(
49 const GrCaps* caps,
50 SkArenaAlloc* arena,
51 const GrSurfaceProxyView& writeView,
52 bool usesMSAASurface,
53 GrAppliedClip&& appliedClip,
54 const GrDstProxyView& dstProxyView,
55 GrGeometryProcessor* gp,
56 GrPrimitiveType primType,
57 GrXferBarrierFlags renderPassXferBarriers,
58 GrLoadOp colorLoadOp) {
59 return CreateProgramInfo(caps,
60 arena,
61 writeView,
62 usesMSAASurface,
63 std::move(appliedClip),
64 dstProxyView,
65 gp,
66 this->detachProcessorSet(),
67 primType,
68 renderPassXferBarriers,
69 colorLoadOp,
70 this->pipelineFlags(),
71 this->stencilSettings());
72 }
73
74 #if defined(GPU_TEST_UTILS)
dumpInfo() const75 SkString GrSimpleMeshDrawOpHelperWithStencil::dumpInfo() const {
76 SkString result = INHERITED::dumpInfo();
77 result.appendf("Stencil settings: %s\n", (fStencilSettings ? "yes" : "no"));
78 return result;
79 }
80 #endif
81