blob: e76693a1dd982bf90ce4cc67d8083388e0926688 [file] [log] [blame]
Robert Phillips55f681f2020-02-28 08:58:15 -05001/*
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 */
18class GrSimpleMeshDrawOpHelperWithStencil : private GrSimpleMeshDrawOpHelper {
19public:
20 using MakeArgs = GrSimpleMeshDrawOpHelper::MakeArgs;
21 using InputFlags = GrSimpleMeshDrawOpHelper::InputFlags;
22
23 using GrSimpleMeshDrawOpHelper::visitProxies;
24
Robert Phillips4f93c572020-03-18 08:13:53 -040025 const GrPipeline* createPipelineWithStencil(const GrCaps*,
26 SkArenaAlloc*,
Brian Salomon8afde5f2020-04-01 16:22:00 -040027 GrSwizzle writeViewSwizzle,
Robert Phillips4f93c572020-03-18 08:13:53 -040028 GrAppliedClip&&,
29 const GrXferProcessor::DstProxyView&);
30
Robert Phillips55f681f2020-02-28 08:58:15 -050031 const GrPipeline* createPipelineWithStencil(GrOpFlushState* flushState);
32
Robert Phillips50d7d6f2020-03-04 11:12:24 -050033 GrProgramInfo* createProgramInfoWithStencil(const GrCaps*,
34 SkArenaAlloc*,
Brian Salomon8afde5f2020-04-01 16:22:00 -040035 const GrSurfaceProxyView* writeViewSwizzle,
Robert Phillips50d7d6f2020-03-04 11:12:24 -050036 GrAppliedClip&&,
37 const GrXferProcessor::DstProxyView&,
38 GrGeometryProcessor*,
39 GrPrimitiveType);
40
41
Robert Phillips55f681f2020-02-28 08:58:15 -050042 // 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
87private:
88 const GrUserStencilSettings* fStencilSettings;
89 typedef GrSimpleMeshDrawOpHelper INHERITED;
90};
91
92#endif