blob: 000b6990b196219588f31dd6af9461b759d2eea6 [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,
Brian Salomon8afde5f2020-04-01 16:22:00 -040013 GrSwizzle writeViewSwizzle,
Robert Phillips4f93c572020-03-18 08:13:53 -040014 GrAppliedClip&& appliedClip,
15 const GrXferProcessor::DstProxyView& dstProxyView) {
16 return GrSimpleMeshDrawOpHelper::CreatePipeline(caps,
17 arena,
Brian Salomon8afde5f2020-04-01 16:22:00 -040018 writeViewSwizzle,
Robert Phillips4f93c572020-03-18 08:13:53 -040019 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(),
Brian Salomon8afde5f2020-04-01 16:22:00 -040030 flushState->writeView()->swizzle(),
Robert Phillips4f93c572020-03-18 08:13:53 -040031 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,
Brian Salomon8afde5f2020-04-01 16:22:00 -040075 const GrSurfaceProxyView* writeViewSwizzle,
Robert Phillips50d7d6f2020-03-04 11:12:24 -050076 GrAppliedClip&& appliedClip,
77 const GrXferProcessor::DstProxyView& dstProxyView,
78 GrGeometryProcessor* gp,
Greg Danield358cbe2020-09-11 09:33:54 -040079 GrPrimitiveType primType,
80 GrXferBarrierFlags renderPassXferBarriers) {
Robert Phillips50d7d6f2020-03-04 11:12:24 -050081 return CreateProgramInfo(caps,
82 arena,
Brian Salomon8afde5f2020-04-01 16:22:00 -040083 writeViewSwizzle,
Robert Phillips50d7d6f2020-03-04 11:12:24 -050084 std::move(appliedClip),
85 dstProxyView,
86 gp,
87 this->detachProcessorSet(),
88 primType,
Greg Danield358cbe2020-09-11 09:33:54 -040089 renderPassXferBarriers,
Robert Phillips50d7d6f2020-03-04 11:12:24 -050090 this->pipelineFlags(),
91 this->stencilSettings());
92}
93
John Stiles8d9bf642020-08-12 15:07:45 -040094#if GR_TEST_UTILS
Robert Phillips55f681f2020-02-28 08:58:15 -050095SkString GrSimpleMeshDrawOpHelperWithStencil::dumpInfo() const {
96 SkString result = INHERITED::dumpInfo();
97 result.appendf("Stencil settings: %s\n", (fStencilSettings ? "yes" : "no"));
98 return result;
99}
100#endif