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