• 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 #ifdef SK_ENABLE_STENCIL_CULLING_OHOS
23         for (int i = 0; i < kStencilLayersMax; i++) {
24             if (fStencilSettings == GrUserStencilSettings::kGE[i]) {
25                 flags = GrDrawOp::FixedFunctionFlags::kUsesStencil;
26                 break;
27             }
28         }
29 #endif
30     }
31     return flags;
32 }
33 
finalizeProcessors(const GrCaps & caps,const GrAppliedClip * clip,GrClampType clampType,GrProcessorAnalysisCoverage geometryCoverage,SkPMColor4f * geometryColor,bool * wideColor)34 GrProcessorSet::Analysis GrSimpleMeshDrawOpHelperWithStencil::finalizeProcessors(
35         const GrCaps& caps, const GrAppliedClip* clip, GrClampType clampType,
36         GrProcessorAnalysisCoverage geometryCoverage, SkPMColor4f* geometryColor, bool* wideColor) {
37     GrProcessorAnalysisColor color = *geometryColor;
38     auto result = this->finalizeProcessors(caps, clip, clampType, geometryCoverage, &color);
39     color.isConstant(geometryColor);
40     if (wideColor) {
41         *wideColor = !geometryColor->fitsInBytes();
42     }
43     return result;
44 }
45 
isCompatible(const GrSimpleMeshDrawOpHelperWithStencil & that,const GrCaps & caps,const SkRect & thisBounds,const SkRect & thatBounds,bool ignoreAAType) const46 bool GrSimpleMeshDrawOpHelperWithStencil::isCompatible(
47         const GrSimpleMeshDrawOpHelperWithStencil& that, const GrCaps& caps,
48         const SkRect& thisBounds, const SkRect& thatBounds, bool ignoreAAType) const {
49     return INHERITED::isCompatible(that, caps, thisBounds, thatBounds, ignoreAAType) &&
50            fStencilSettings == that.fStencilSettings;
51 }
52 
createProgramInfoWithStencil(const GrCaps * caps,SkArenaAlloc * arena,const GrSurfaceProxyView & writeView,bool usesMSAASurface,GrAppliedClip && appliedClip,const GrDstProxyView & dstProxyView,GrGeometryProcessor * gp,GrPrimitiveType primType,GrXferBarrierFlags renderPassXferBarriers,GrLoadOp colorLoadOp)53 GrProgramInfo* GrSimpleMeshDrawOpHelperWithStencil::createProgramInfoWithStencil(
54                                             const GrCaps* caps,
55                                             SkArenaAlloc* arena,
56                                             const GrSurfaceProxyView& writeView,
57                                             bool usesMSAASurface,
58                                             GrAppliedClip&& appliedClip,
59                                             const GrDstProxyView& dstProxyView,
60                                             GrGeometryProcessor* gp,
61                                             GrPrimitiveType primType,
62                                             GrXferBarrierFlags renderPassXferBarriers,
63                                             GrLoadOp colorLoadOp) {
64     return CreateProgramInfo(caps,
65                              arena,
66                              writeView,
67                              usesMSAASurface,
68                              std::move(appliedClip),
69                              dstProxyView,
70                              gp,
71                              this->detachProcessorSet(),
72                              primType,
73                              renderPassXferBarriers,
74                              colorLoadOp,
75                              this->pipelineFlags(),
76                              this->stencilSettings());
77 }
78 
79 #if GR_TEST_UTILS
dumpInfo() const80 SkString GrSimpleMeshDrawOpHelperWithStencil::dumpInfo() const {
81     SkString result = INHERITED::dumpInfo();
82     result.appendf("Stencil settings: %s\n", (fStencilSettings ? "yes" : "no"));
83     return result;
84 }
85 #endif
86