• 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 #ifndef GrSimpleMeshDrawOpHelperWithStencil_DEFINED
9 #define GrSimpleMeshDrawOpHelperWithStencil_DEFINED
10 
11 #include "src/gpu/ops/GrSimpleMeshDrawOpHelper.h"
12 
13 /**
14  * This class extends GrSimpleMeshDrawOpHelper to support an optional GrUserStencilSettings. This
15  * uses private inheritance because it non-virtually overrides methods in the base class and should
16  * never be used with a GrSimpleMeshDrawOpHelper pointer or reference.
17  */
18 class GrSimpleMeshDrawOpHelperWithStencil : private GrSimpleMeshDrawOpHelper {
19 public:
20     using InputFlags = GrSimpleMeshDrawOpHelper::InputFlags;
21 
22     using GrSimpleMeshDrawOpHelper::visitProxies;
23     using GrSimpleMeshDrawOpHelper::createPipeline;
24 
25     GrProgramInfo* createProgramInfoWithStencil(const GrCaps*,
26                                                 SkArenaAlloc*,
27                                                 const GrSurfaceProxyView& writeViewSwizzle,
28                                                 GrAppliedClip&&,
29                                                 const GrXferProcessor::DstProxyView&,
30                                                 GrGeometryProcessor*,
31                                                 GrPrimitiveType,
32                                                 GrXferBarrierFlags renderPassXferBarriers,
33                                                 GrLoadOp colorLoadOp);
34 
35     // using declarations can't be templated, so this is a pass through function instead.
36     template <typename Op, typename... OpArgs>
FactoryHelper(GrRecordingContext * context,GrPaint && paint,OpArgs...opArgs)37     static GrOp::Owner FactoryHelper(GrRecordingContext* context, GrPaint&& paint,
38                                      OpArgs... opArgs) {
39         return GrSimpleMeshDrawOpHelper::FactoryHelper<Op, OpArgs...>(
40                 context, std::move(paint), std::forward<OpArgs>(opArgs)...);
41     }
42 
43     GrSimpleMeshDrawOpHelperWithStencil(GrProcessorSet*, GrAAType, const GrUserStencilSettings*,
44                                         InputFlags = InputFlags::kNone);
45 
46     GrDrawOp::FixedFunctionFlags fixedFunctionFlags() const;
47 
finalizeProcessors(const GrCaps & caps,const GrAppliedClip * clip,GrClampType clampType,GrProcessorAnalysisCoverage geometryCoverage,GrProcessorAnalysisColor * geometryColor)48     GrProcessorSet::Analysis finalizeProcessors(const GrCaps& caps, const GrAppliedClip* clip,
49                                                 GrClampType clampType,
50                                                 GrProcessorAnalysisCoverage geometryCoverage,
51                                                 GrProcessorAnalysisColor* geometryColor) {
52         return this->INHERITED::finalizeProcessors(caps, clip, fStencilSettings, clampType,
53                                                    geometryCoverage, geometryColor);
54     }
55 
56     GrProcessorSet::Analysis finalizeProcessors(const GrCaps&, const GrAppliedClip*, GrClampType,
57                                                 GrProcessorAnalysisCoverage geometryCoverage,
58                                                 SkPMColor4f* geometryColor, bool* wideColor);
59 
60     using GrSimpleMeshDrawOpHelper::aaType;
61     using GrSimpleMeshDrawOpHelper::setAAType;
62     using GrSimpleMeshDrawOpHelper::isTrivial;
63     using GrSimpleMeshDrawOpHelper::usesLocalCoords;
64     using GrSimpleMeshDrawOpHelper::compatibleWithCoverageAsAlpha;
65     using GrSimpleMeshDrawOpHelper::detachProcessorSet;
66     using GrSimpleMeshDrawOpHelper::pipelineFlags;
67 
68     bool isCompatible(const GrSimpleMeshDrawOpHelperWithStencil& that, const GrCaps&,
69                       const SkRect& thisBounds, const SkRect& thatBounds,
70                       bool ignoreAAType = false) const;
71 
72 #if GR_TEST_UTILS
73     SkString dumpInfo() const;
74 #endif
75 
stencilSettings()76     const GrUserStencilSettings* stencilSettings() const { return fStencilSettings; }
77 
78 private:
79     const GrUserStencilSettings* fStencilSettings;
80     using INHERITED = GrSimpleMeshDrawOpHelper;
81 };
82 
83 #endif
84