Robert Phillips | 55f681f | 2020-02-28 08:58:15 -0500 | [diff] [blame] | 1 | /* |
| 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 | |
| 10 | const GrPipeline* GrSimpleMeshDrawOpHelperWithStencil::createPipelineWithStencil( |
| 11 | GrOpFlushState* flushState) { |
| 12 | return GrSimpleMeshDrawOpHelper::CreatePipeline(&flushState->caps(), |
| 13 | flushState->allocator(), |
Robert Phillips | b58098f | 2020-03-02 16:25:29 -0500 | [diff] [blame] | 14 | flushState->outputView(), |
Robert Phillips | 55f681f | 2020-02-28 08:58:15 -0500 | [diff] [blame] | 15 | flushState->detachAppliedClip(), |
| 16 | flushState->dstProxyView(), |
| 17 | this->detachProcessorSet(), |
| 18 | this->pipelineFlags(), |
| 19 | this->stencilSettings()); |
| 20 | } |
| 21 | |
| 22 | GrSimpleMeshDrawOpHelperWithStencil::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 | |
| 28 | GrDrawOp::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 | |
| 36 | GrProcessorSet::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 | |
| 50 | bool 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 Phillips | 50d7d6f | 2020-03-04 11:12:24 -0500 | [diff] [blame^] | 57 | GrProgramInfo* 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 Phillips | 55f681f | 2020-02-28 08:58:15 -0500 | [diff] [blame] | 77 | #ifdef SK_DEBUG |
| 78 | SkString GrSimpleMeshDrawOpHelperWithStencil::dumpInfo() const { |
| 79 | SkString result = INHERITED::dumpInfo(); |
| 80 | result.appendf("Stencil settings: %s\n", (fStencilSettings ? "yes" : "no")); |
| 81 | return result; |
| 82 | } |
| 83 | #endif |