blob: 22e4e615a01e478010553b4c64ee047b84e9353e [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
10const GrPipeline* GrSimpleMeshDrawOpHelperWithStencil::createPipelineWithStencil(
Robert Phillips4f93c572020-03-18 08:13:53 -040011 const GrCaps* caps,
12 SkArenaAlloc* arena,
13 GrSwizzle outputViewSwizzle,
14 GrAppliedClip&& appliedClip,
15 const GrXferProcessor::DstProxyView& dstProxyView) {
16 return GrSimpleMeshDrawOpHelper::CreatePipeline(caps,
17 arena,
18 outputViewSwizzle,
19 std::move(appliedClip),
20 dstProxyView,
Robert Phillips55f681f2020-02-28 08:58:15 -050021 this->detachProcessorSet(),
22 this->pipelineFlags(),
23 this->stencilSettings());
24}
25
Robert Phillips4f93c572020-03-18 08:13:53 -040026const GrPipeline* GrSimpleMeshDrawOpHelperWithStencil::createPipelineWithStencil(
27 GrOpFlushState* flushState) {
28 return this->createPipelineWithStencil(&flushState->caps(),
29 flushState->allocator(),
30 flushState->outputView()->swizzle(),
31 flushState->detachAppliedClip(),
32 flushState->dstProxyView());
33}
34
Robert Phillips55f681f2020-02-28 08:58:15 -050035GrSimpleMeshDrawOpHelperWithStencil::GrSimpleMeshDrawOpHelperWithStencil(
Robert Phillips360ec182020-03-26 13:29:50 -040036 const MakeArgs& args,
37 GrAAType aaType,
38 const GrUserStencilSettings* stencilSettings,
39 InputFlags inputFlags)
Robert Phillips55f681f2020-02-28 08:58:15 -050040 : INHERITED(args, aaType, inputFlags)
41 , fStencilSettings(stencilSettings ? stencilSettings : &GrUserStencilSettings::kUnused) {}
42
43GrDrawOp::FixedFunctionFlags GrSimpleMeshDrawOpHelperWithStencil::fixedFunctionFlags() const {
44 GrDrawOp::FixedFunctionFlags flags = INHERITED::fixedFunctionFlags();
45 if (fStencilSettings != &GrUserStencilSettings::kUnused) {
46 flags |= GrDrawOp::FixedFunctionFlags::kUsesStencil;
47 }
48 return flags;
49}
50
51GrProcessorSet::Analysis GrSimpleMeshDrawOpHelperWithStencil::finalizeProcessors(
52 const GrCaps& caps, const GrAppliedClip* clip, bool hasMixedSampledCoverage,
53 GrClampType clampType, GrProcessorAnalysisCoverage geometryCoverage,
54 SkPMColor4f* geometryColor, bool* wideColor) {
55 GrProcessorAnalysisColor color = *geometryColor;
56 auto result = this->finalizeProcessors(
57 caps, clip, hasMixedSampledCoverage, clampType, geometryCoverage, &color);
58 color.isConstant(geometryColor);
59 if (wideColor) {
60 *wideColor = !geometryColor->fitsInBytes();
61 }
62 return result;
63}
64
65bool GrSimpleMeshDrawOpHelperWithStencil::isCompatible(
66 const GrSimpleMeshDrawOpHelperWithStencil& that, const GrCaps& caps,
67 const SkRect& thisBounds, const SkRect& thatBounds, bool ignoreAAType) const {
68 return INHERITED::isCompatible(that, caps, thisBounds, thatBounds, ignoreAAType) &&
69 fStencilSettings == that.fStencilSettings;
70}
71
Robert Phillips50d7d6f2020-03-04 11:12:24 -050072GrProgramInfo* GrSimpleMeshDrawOpHelperWithStencil::createProgramInfoWithStencil(
73 const GrCaps* caps,
74 SkArenaAlloc* arena,
75 const GrSurfaceProxyView* outputView,
76 GrAppliedClip&& appliedClip,
77 const GrXferProcessor::DstProxyView& dstProxyView,
78 GrGeometryProcessor* gp,
79 GrPrimitiveType primType) {
80 return CreateProgramInfo(caps,
81 arena,
82 outputView,
83 std::move(appliedClip),
84 dstProxyView,
85 gp,
86 this->detachProcessorSet(),
87 primType,
88 this->pipelineFlags(),
89 this->stencilSettings());
90}
91
Robert Phillips55f681f2020-02-28 08:58:15 -050092#ifdef SK_DEBUG
93SkString GrSimpleMeshDrawOpHelperWithStencil::dumpInfo() const {
94 SkString result = INHERITED::dumpInfo();
95 result.appendf("Stencil settings: %s\n", (fStencilSettings ? "yes" : "no"));
96 return result;
97}
98#endif