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