| 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 MakeArgs = GrSimpleMeshDrawOpHelper::MakeArgs; | 
|---|
| 21 | using InputFlags = GrSimpleMeshDrawOpHelper::InputFlags; | 
|---|
| 22 |  | 
|---|
| 23 | using GrSimpleMeshDrawOpHelper::visitProxies; | 
|---|
| 24 |  | 
|---|
| 25 | const GrPipeline* createPipelineWithStencil(const GrCaps*, | 
|---|
| 26 | SkArenaAlloc*, | 
|---|
| 27 | GrSwizzle writeViewSwizzle, | 
|---|
| 28 | GrAppliedClip&&, | 
|---|
| 29 | const GrXferProcessor::DstProxyView&); | 
|---|
| 30 |  | 
|---|
| 31 | const GrPipeline* createPipelineWithStencil(GrOpFlushState* flushState); | 
|---|
| 32 |  | 
|---|
| 33 | GrProgramInfo* createProgramInfoWithStencil(const GrCaps*, | 
|---|
| 34 | SkArenaAlloc*, | 
|---|
| 35 | const GrSurfaceProxyView* writeViewSwizzle, | 
|---|
| 36 | GrAppliedClip&&, | 
|---|
| 37 | const GrXferProcessor::DstProxyView&, | 
|---|
| 38 | GrGeometryProcessor*, | 
|---|
| 39 | GrPrimitiveType); | 
|---|
| 40 |  | 
|---|
| 41 |  | 
|---|
| 42 | // using declarations can't be templated, so this is a pass through function instead. | 
|---|
| 43 | template <typename Op, typename... OpArgs> | 
|---|
| 44 | static std::unique_ptr<GrDrawOp> FactoryHelper(GrRecordingContext* context, GrPaint&& paint, | 
|---|
| 45 | OpArgs... opArgs) { | 
|---|
| 46 | return GrSimpleMeshDrawOpHelper::FactoryHelper<Op, OpArgs...>( | 
|---|
| 47 | context, std::move(paint), std::forward<OpArgs>(opArgs)...); | 
|---|
| 48 | } | 
|---|
| 49 |  | 
|---|
| 50 | GrSimpleMeshDrawOpHelperWithStencil(const MakeArgs&, GrAAType, const GrUserStencilSettings*, | 
|---|
| 51 | InputFlags = InputFlags::kNone); | 
|---|
| 52 |  | 
|---|
| 53 | GrDrawOp::FixedFunctionFlags fixedFunctionFlags() const; | 
|---|
| 54 |  | 
|---|
| 55 | GrProcessorSet::Analysis finalizeProcessors( | 
|---|
| 56 | const GrCaps& caps, const GrAppliedClip* clip, bool hasMixedSampledCoverage, | 
|---|
| 57 | GrClampType clampType, GrProcessorAnalysisCoverage geometryCoverage, | 
|---|
| 58 | GrProcessorAnalysisColor* geometryColor) { | 
|---|
| 59 | return this->INHERITED::finalizeProcessors( | 
|---|
| 60 | caps, clip, fStencilSettings, hasMixedSampledCoverage, clampType, geometryCoverage, | 
|---|
| 61 | geometryColor); | 
|---|
| 62 | } | 
|---|
| 63 |  | 
|---|
| 64 | GrProcessorSet::Analysis finalizeProcessors( | 
|---|
| 65 | const GrCaps&, const GrAppliedClip*, bool hasMixedSampledCoverage, GrClampType, | 
|---|
| 66 | GrProcessorAnalysisCoverage geometryCoverage, SkPMColor4f* geometryColor, bool* | 
|---|
| 67 | wideColor); | 
|---|
| 68 |  | 
|---|
| 69 | using GrSimpleMeshDrawOpHelper::aaType; | 
|---|
| 70 | using GrSimpleMeshDrawOpHelper::setAAType; | 
|---|
| 71 | using GrSimpleMeshDrawOpHelper::isTrivial; | 
|---|
| 72 | using GrSimpleMeshDrawOpHelper::usesLocalCoords; | 
|---|
| 73 | using GrSimpleMeshDrawOpHelper::compatibleWithCoverageAsAlpha; | 
|---|
| 74 | using GrSimpleMeshDrawOpHelper::detachProcessorSet; | 
|---|
| 75 | using GrSimpleMeshDrawOpHelper::pipelineFlags; | 
|---|
| 76 |  | 
|---|
| 77 | bool isCompatible(const GrSimpleMeshDrawOpHelperWithStencil& that, const GrCaps&, | 
|---|
| 78 | const SkRect& thisBounds, const SkRect& thatBounds, | 
|---|
| 79 | bool ignoreAAType = false) const; | 
|---|
| 80 |  | 
|---|
| 81 | #ifdef SK_DEBUG | 
|---|
| 82 | SkString dumpInfo() const; | 
|---|
| 83 | #endif | 
|---|
| 84 |  | 
|---|
| 85 | const GrUserStencilSettings* stencilSettings() const { return fStencilSettings; } | 
|---|
| 86 |  | 
|---|
| 87 | private: | 
|---|
| 88 | const GrUserStencilSettings* fStencilSettings; | 
|---|
| 89 | typedef GrSimpleMeshDrawOpHelper INHERITED; | 
|---|
| 90 | }; | 
|---|
| 91 |  | 
|---|
| 92 | #endif | 
|---|
| 93 |  | 
|---|