• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 & writeViewSwizzle,GrAppliedClip && appliedClip,const GrXferProcessor::DstProxyView & dstProxyView,GrGeometryProcessor * gp,GrPrimitiveType primType,GrXferBarrierFlags renderPassXferBarriers,GrLoadOp colorLoadOp)45 GrProgramInfo* GrSimpleMeshDrawOpHelperWithStencil::createProgramInfoWithStencil(
46                                             const GrCaps* caps,
47                                             SkArenaAlloc* arena,
48                                             const GrSurfaceProxyView& writeViewSwizzle,
49                                             GrAppliedClip&& appliedClip,
50                                             const GrXferProcessor::DstProxyView& dstProxyView,
51                                             GrGeometryProcessor* gp,
52                                             GrPrimitiveType primType,
53                                             GrXferBarrierFlags renderPassXferBarriers,
54                                             GrLoadOp colorLoadOp) {
55     return CreateProgramInfo(caps,
56                              arena,
57                              writeViewSwizzle,
58                              std::move(appliedClip),
59                              dstProxyView,
60                              gp,
61                              this->detachProcessorSet(),
62                              primType,
63                              renderPassXferBarriers,
64                              colorLoadOp,
65                              this->pipelineFlags(),
66                              this->stencilSettings());
67 }
68 
69 #if GR_TEST_UTILS
dumpInfo() const70 SkString GrSimpleMeshDrawOpHelperWithStencil::dumpInfo() const {
71     SkString result = INHERITED::dumpInfo();
72     result.appendf("Stencil settings: %s\n", (fStencilSettings ? "yes" : "no"));
73     return result;
74 }
75 #endif
76