blob: 1aa5b6f36d15a9c7f11fa3c085cc0477bcc1f7f4 [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:
Robert Phillips55f681f2020-02-28 08:58:15 -050020 using InputFlags = GrSimpleMeshDrawOpHelper::InputFlags;
21
22 using GrSimpleMeshDrawOpHelper::visitProxies;
Chris Dalton1b6a43c2020-09-25 12:21:18 -060023 using GrSimpleMeshDrawOpHelper::createPipeline;
Robert Phillips55f681f2020-02-28 08:58:15 -050024
Robert Phillips50d7d6f2020-03-04 11:12:24 -050025 GrProgramInfo* createProgramInfoWithStencil(const GrCaps*,
26 SkArenaAlloc*,
Adlai Hollere2296f72020-11-19 13:41:26 -050027 const GrSurfaceProxyView& writeViewSwizzle,
Robert Phillips50d7d6f2020-03-04 11:12:24 -050028 GrAppliedClip&&,
29 const GrXferProcessor::DstProxyView&,
30 GrGeometryProcessor*,
Greg Danield358cbe2020-09-11 09:33:54 -040031 GrPrimitiveType,
32 GrXferBarrierFlags renderPassXferBarriers);
Robert Phillips50d7d6f2020-03-04 11:12:24 -050033
Robert Phillips55f681f2020-02-28 08:58:15 -050034 // using declarations can't be templated, so this is a pass through function instead.
35 template <typename Op, typename... OpArgs>
Herb Derbyc76d4092020-10-07 16:46:15 -040036 static GrOp::Owner FactoryHelper(GrRecordingContext* context, GrPaint&& paint,
37 OpArgs... opArgs) {
Robert Phillips55f681f2020-02-28 08:58:15 -050038 return GrSimpleMeshDrawOpHelper::FactoryHelper<Op, OpArgs...>(
39 context, std::move(paint), std::forward<OpArgs>(opArgs)...);
40 }
41
Herb Derbyc76d4092020-10-07 16:46:15 -040042 GrSimpleMeshDrawOpHelperWithStencil(GrProcessorSet*, GrAAType, const GrUserStencilSettings*,
Robert Phillips55f681f2020-02-28 08:58:15 -050043 InputFlags = InputFlags::kNone);
44
45 GrDrawOp::FixedFunctionFlags fixedFunctionFlags() const;
46
47 GrProcessorSet::Analysis finalizeProcessors(
48 const GrCaps& caps, const GrAppliedClip* clip, bool hasMixedSampledCoverage,
49 GrClampType clampType, GrProcessorAnalysisCoverage geometryCoverage,
50 GrProcessorAnalysisColor* geometryColor) {
51 return this->INHERITED::finalizeProcessors(
52 caps, clip, fStencilSettings, hasMixedSampledCoverage, clampType, geometryCoverage,
53 geometryColor);
54 }
55
56 GrProcessorSet::Analysis finalizeProcessors(
57 const GrCaps&, const GrAppliedClip*, bool hasMixedSampledCoverage, GrClampType,
58 GrProcessorAnalysisCoverage geometryCoverage, SkPMColor4f* geometryColor, bool*
59 wideColor);
60
61 using GrSimpleMeshDrawOpHelper::aaType;
62 using GrSimpleMeshDrawOpHelper::setAAType;
63 using GrSimpleMeshDrawOpHelper::isTrivial;
64 using GrSimpleMeshDrawOpHelper::usesLocalCoords;
65 using GrSimpleMeshDrawOpHelper::compatibleWithCoverageAsAlpha;
66 using GrSimpleMeshDrawOpHelper::detachProcessorSet;
67 using GrSimpleMeshDrawOpHelper::pipelineFlags;
68
69 bool isCompatible(const GrSimpleMeshDrawOpHelperWithStencil& that, const GrCaps&,
70 const SkRect& thisBounds, const SkRect& thatBounds,
71 bool ignoreAAType = false) const;
72
John Stiles8d9bf642020-08-12 15:07:45 -040073#if GR_TEST_UTILS
Robert Phillips55f681f2020-02-28 08:58:15 -050074 SkString dumpInfo() const;
75#endif
76
77 const GrUserStencilSettings* stencilSettings() const { return fStencilSettings; }
78
79private:
80 const GrUserStencilSettings* fStencilSettings;
John Stiles7571f9e2020-09-02 22:42:33 -040081 using INHERITED = GrSimpleMeshDrawOpHelper;
Robert Phillips55f681f2020-02-28 08:58:15 -050082};
83
84#endif