| 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 | const GrCaps* caps, | 
|---|
| 12 | SkArenaAlloc* arena, | 
|---|
| 13 | GrSwizzle writeViewSwizzle, | 
|---|
| 14 | GrAppliedClip&& appliedClip, | 
|---|
| 15 | const GrXferProcessor::DstProxyView& dstProxyView) { | 
|---|
| 16 | return GrSimpleMeshDrawOpHelper::CreatePipeline(caps, | 
|---|
| 17 | arena, | 
|---|
| 18 | writeViewSwizzle, | 
|---|
| 19 | std::move(appliedClip), | 
|---|
| 20 | dstProxyView, | 
|---|
| 21 | this->detachProcessorSet(), | 
|---|
| 22 | this->pipelineFlags(), | 
|---|
| 23 | this->stencilSettings()); | 
|---|
| 24 | } | 
|---|
| 25 |  | 
|---|
| 26 | const GrPipeline* GrSimpleMeshDrawOpHelperWithStencil::createPipelineWithStencil( | 
|---|
| 27 | GrOpFlushState* flushState) { | 
|---|
| 28 | return this->createPipelineWithStencil(&flushState->caps(), | 
|---|
| 29 | flushState->allocator(), | 
|---|
| 30 | flushState->writeView()->swizzle(), | 
|---|
| 31 | flushState->detachAppliedClip(), | 
|---|
| 32 | flushState->dstProxyView()); | 
|---|
| 33 | } | 
|---|
| 34 |  | 
|---|
| 35 | GrSimpleMeshDrawOpHelperWithStencil::GrSimpleMeshDrawOpHelperWithStencil( | 
|---|
| 36 | const MakeArgs& args, | 
|---|
| 37 | GrAAType aaType, | 
|---|
| 38 | const GrUserStencilSettings* stencilSettings, | 
|---|
| 39 | InputFlags inputFlags) | 
|---|
| 40 | : INHERITED(args, aaType, inputFlags) | 
|---|
| 41 | , fStencilSettings(stencilSettings ? stencilSettings : &GrUserStencilSettings::kUnused) {} | 
|---|
| 42 |  | 
|---|
| 43 | GrDrawOp::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 |  | 
|---|
| 51 | GrProcessorSet::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 |  | 
|---|
| 65 | bool 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 |  | 
|---|
| 72 | GrProgramInfo* GrSimpleMeshDrawOpHelperWithStencil::createProgramInfoWithStencil( | 
|---|
| 73 | const GrCaps* caps, | 
|---|
| 74 | SkArenaAlloc* arena, | 
|---|
| 75 | const GrSurfaceProxyView* writeViewSwizzle, | 
|---|
| 76 | GrAppliedClip&& appliedClip, | 
|---|
| 77 | const GrXferProcessor::DstProxyView& dstProxyView, | 
|---|
| 78 | GrGeometryProcessor* gp, | 
|---|
| 79 | GrPrimitiveType primType) { | 
|---|
| 80 | return CreateProgramInfo(caps, | 
|---|
| 81 | arena, | 
|---|
| 82 | writeViewSwizzle, | 
|---|
| 83 | std::move(appliedClip), | 
|---|
| 84 | dstProxyView, | 
|---|
| 85 | gp, | 
|---|
| 86 | this->detachProcessorSet(), | 
|---|
| 87 | primType, | 
|---|
| 88 | this->pipelineFlags(), | 
|---|
| 89 | this->stencilSettings()); | 
|---|
| 90 | } | 
|---|
| 91 |  | 
|---|
| 92 | #ifdef SK_DEBUG | 
|---|
| 93 | SkString GrSimpleMeshDrawOpHelperWithStencil::dumpInfo() const { | 
|---|
| 94 | SkString result = INHERITED::dumpInfo(); | 
|---|
| 95 | result.appendf( "Stencil settings: %s\n", (fStencilSettings ? "yes": "no")); | 
|---|
| 96 | return result; | 
|---|
| 97 | } | 
|---|
| 98 | #endif | 
|---|
| 99 |  | 
|---|