blob: 331763104debbcdb13c9de4452b61d805b7f5f60 [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(),
14 flushState->view(),
15 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
57#ifdef SK_DEBUG
58SkString GrSimpleMeshDrawOpHelperWithStencil::dumpInfo() const {
59 SkString result = INHERITED::dumpInfo();
60 result.appendf("Stencil settings: %s\n", (fStencilSettings ? "yes" : "no"));
61 return result;
62}
63#endif