blob: a7a8a4dc849b508de657c39e6e584b081cb81081 [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#include "src/gpu/ops/GrSimpleMeshDrawOpHelperWithStencil.h"
9
Robert Phillips55f681f2020-02-28 08:58:15 -050010GrSimpleMeshDrawOpHelperWithStencil::GrSimpleMeshDrawOpHelperWithStencil(
Herb Derbyc76d4092020-10-07 16:46:15 -040011 GrProcessorSet* processorSet,
Robert Phillips360ec182020-03-26 13:29:50 -040012 GrAAType aaType,
13 const GrUserStencilSettings* stencilSettings,
14 InputFlags inputFlags)
Herb Derbyc76d4092020-10-07 16:46:15 -040015 : INHERITED(processorSet, aaType, inputFlags)
Robert Phillips55f681f2020-02-28 08:58:15 -050016 , fStencilSettings(stencilSettings ? stencilSettings : &GrUserStencilSettings::kUnused) {}
17
18GrDrawOp::FixedFunctionFlags GrSimpleMeshDrawOpHelperWithStencil::fixedFunctionFlags() const {
19 GrDrawOp::FixedFunctionFlags flags = INHERITED::fixedFunctionFlags();
20 if (fStencilSettings != &GrUserStencilSettings::kUnused) {
21 flags |= GrDrawOp::FixedFunctionFlags::kUsesStencil;
22 }
23 return flags;
24}
25
26GrProcessorSet::Analysis GrSimpleMeshDrawOpHelperWithStencil::finalizeProcessors(
Chris Dalton57ab06c2021-04-22 12:57:28 -060027 const GrCaps& caps, const GrAppliedClip* clip, GrClampType clampType,
28 GrProcessorAnalysisCoverage geometryCoverage, SkPMColor4f* geometryColor, bool* wideColor) {
Robert Phillips55f681f2020-02-28 08:58:15 -050029 GrProcessorAnalysisColor color = *geometryColor;
Chris Dalton57ab06c2021-04-22 12:57:28 -060030 auto result = this->finalizeProcessors(caps, clip, clampType, geometryCoverage, &color);
Robert Phillips55f681f2020-02-28 08:58:15 -050031 color.isConstant(geometryColor);
32 if (wideColor) {
33 *wideColor = !geometryColor->fitsInBytes();
34 }
35 return result;
36}
37
38bool GrSimpleMeshDrawOpHelperWithStencil::isCompatible(
39 const GrSimpleMeshDrawOpHelperWithStencil& that, const GrCaps& caps,
40 const SkRect& thisBounds, const SkRect& thatBounds, bool ignoreAAType) const {
41 return INHERITED::isCompatible(that, caps, thisBounds, thatBounds, ignoreAAType) &&
42 fStencilSettings == that.fStencilSettings;
43}
44
Robert Phillips50d7d6f2020-03-04 11:12:24 -050045GrProgramInfo* GrSimpleMeshDrawOpHelperWithStencil::createProgramInfoWithStencil(
46 const GrCaps* caps,
47 SkArenaAlloc* arena,
Chris Dalton2a26c502021-08-26 10:05:11 -060048 const GrSurfaceProxyView& writeView,
49 bool usesMSAASurface,
Robert Phillips50d7d6f2020-03-04 11:12:24 -050050 GrAppliedClip&& appliedClip,
John Stiles52cb1d02021-06-02 11:58:05 -040051 const GrDstProxyView& dstProxyView,
Robert Phillips50d7d6f2020-03-04 11:12:24 -050052 GrGeometryProcessor* gp,
Greg Danield358cbe2020-09-11 09:33:54 -040053 GrPrimitiveType primType,
Greg Daniel42dbca52020-11-20 10:22:43 -050054 GrXferBarrierFlags renderPassXferBarriers,
55 GrLoadOp colorLoadOp) {
Robert Phillips50d7d6f2020-03-04 11:12:24 -050056 return CreateProgramInfo(caps,
57 arena,
Chris Dalton2a26c502021-08-26 10:05:11 -060058 writeView,
59 usesMSAASurface,
Robert Phillips50d7d6f2020-03-04 11:12:24 -050060 std::move(appliedClip),
61 dstProxyView,
62 gp,
63 this->detachProcessorSet(),
64 primType,
Greg Danield358cbe2020-09-11 09:33:54 -040065 renderPassXferBarriers,
Greg Daniel42dbca52020-11-20 10:22:43 -050066 colorLoadOp,
Robert Phillips50d7d6f2020-03-04 11:12:24 -050067 this->pipelineFlags(),
68 this->stencilSettings());
69}
70
John Stiles8d9bf642020-08-12 15:07:45 -040071#if GR_TEST_UTILS
Robert Phillips55f681f2020-02-28 08:58:15 -050072SkString GrSimpleMeshDrawOpHelperWithStencil::dumpInfo() const {
73 SkString result = INHERITED::dumpInfo();
74 result.appendf("Stencil settings: %s\n", (fStencilSettings ? "yes" : "no"));
75 return result;
76}
77#endif