blob: 460877f13e9919e07465d32eb10541a617c381c4 [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&&,
John Stiles52cb1d02021-06-02 11:58:05 -040029 const GrDstProxyView&,
Robert Phillips50d7d6f2020-03-04 11:12:24 -050030 GrGeometryProcessor*,
Greg Danield358cbe2020-09-11 09:33:54 -040031 GrPrimitiveType,
Greg Daniel42dbca52020-11-20 10:22:43 -050032 GrXferBarrierFlags renderPassXferBarriers,
33 GrLoadOp colorLoadOp);
Robert Phillips50d7d6f2020-03-04 11:12:24 -050034
Robert Phillips55f681f2020-02-28 08:58:15 -050035 // using declarations can't be templated, so this is a pass through function instead.
36 template <typename Op, typename... OpArgs>
Herb Derbyc76d4092020-10-07 16:46:15 -040037 static GrOp::Owner FactoryHelper(GrRecordingContext* context, GrPaint&& paint,
38 OpArgs... opArgs) {
Robert Phillips55f681f2020-02-28 08:58:15 -050039 return GrSimpleMeshDrawOpHelper::FactoryHelper<Op, OpArgs...>(
40 context, std::move(paint), std::forward<OpArgs>(opArgs)...);
41 }
42
Herb Derbyc76d4092020-10-07 16:46:15 -040043 GrSimpleMeshDrawOpHelperWithStencil(GrProcessorSet*, GrAAType, const GrUserStencilSettings*,
Robert Phillips55f681f2020-02-28 08:58:15 -050044 InputFlags = InputFlags::kNone);
45
46 GrDrawOp::FixedFunctionFlags fixedFunctionFlags() const;
47
Chris Dalton57ab06c2021-04-22 12:57:28 -060048 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);
Robert Phillips55f681f2020-02-28 08:58:15 -050054 }
55
Chris Dalton57ab06c2021-04-22 12:57:28 -060056 GrProcessorSet::Analysis finalizeProcessors(const GrCaps&, const GrAppliedClip*, GrClampType,
57 GrProcessorAnalysisCoverage geometryCoverage,
58 SkPMColor4f* geometryColor, bool* wideColor);
Robert Phillips55f681f2020-02-28 08:58:15 -050059
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
John Stiles8d9bf642020-08-12 15:07:45 -040072#if GR_TEST_UTILS
Robert Phillips55f681f2020-02-28 08:58:15 -050073 SkString dumpInfo() const;
74#endif
75
76 const GrUserStencilSettings* stencilSettings() const { return fStencilSettings; }
77
78private:
79 const GrUserStencilSettings* fStencilSettings;
John Stiles7571f9e2020-09-02 22:42:33 -040080 using INHERITED = GrSimpleMeshDrawOpHelper;
Robert Phillips55f681f2020-02-28 08:58:15 -050081};
82
83#endif