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( |
Robert Phillips | 4f93c57 | 2020-03-18 08:13:53 -0400 | [diff] [blame] | 11 | const GrCaps* caps, |
| 12 | SkArenaAlloc* arena, |
Brian Salomon | 8afde5f | 2020-04-01 16:22:00 -0400 | [diff] [blame^] | 13 | GrSwizzle writeViewSwizzle, |
Robert Phillips | 4f93c57 | 2020-03-18 08:13:53 -0400 | [diff] [blame] | 14 | GrAppliedClip&& appliedClip, |
| 15 | const GrXferProcessor::DstProxyView& dstProxyView) { |
| 16 | return GrSimpleMeshDrawOpHelper::CreatePipeline(caps, |
| 17 | arena, |
Brian Salomon | 8afde5f | 2020-04-01 16:22:00 -0400 | [diff] [blame^] | 18 | writeViewSwizzle, |
Robert Phillips | 4f93c57 | 2020-03-18 08:13:53 -0400 | [diff] [blame] | 19 | std::move(appliedClip), |
| 20 | dstProxyView, |
Robert Phillips | 55f681f | 2020-02-28 08:58:15 -0500 | [diff] [blame] | 21 | this->detachProcessorSet(), |
| 22 | this->pipelineFlags(), |
| 23 | this->stencilSettings()); |
| 24 | } |
| 25 | |
Robert Phillips | 4f93c57 | 2020-03-18 08:13:53 -0400 | [diff] [blame] | 26 | const GrPipeline* GrSimpleMeshDrawOpHelperWithStencil::createPipelineWithStencil( |
| 27 | GrOpFlushState* flushState) { |
| 28 | return this->createPipelineWithStencil(&flushState->caps(), |
| 29 | flushState->allocator(), |
Brian Salomon | 8afde5f | 2020-04-01 16:22:00 -0400 | [diff] [blame^] | 30 | flushState->writeView()->swizzle(), |
Robert Phillips | 4f93c57 | 2020-03-18 08:13:53 -0400 | [diff] [blame] | 31 | flushState->detachAppliedClip(), |
| 32 | flushState->dstProxyView()); |
| 33 | } |
| 34 | |
Robert Phillips | 55f681f | 2020-02-28 08:58:15 -0500 | [diff] [blame] | 35 | GrSimpleMeshDrawOpHelperWithStencil::GrSimpleMeshDrawOpHelperWithStencil( |
Robert Phillips | 360ec18 | 2020-03-26 13:29:50 -0400 | [diff] [blame] | 36 | const MakeArgs& args, |
| 37 | GrAAType aaType, |
| 38 | const GrUserStencilSettings* stencilSettings, |
| 39 | InputFlags inputFlags) |
Robert Phillips | 55f681f | 2020-02-28 08:58:15 -0500 | [diff] [blame] | 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 | |
Robert Phillips | 50d7d6f | 2020-03-04 11:12:24 -0500 | [diff] [blame] | 72 | GrProgramInfo* GrSimpleMeshDrawOpHelperWithStencil::createProgramInfoWithStencil( |
| 73 | const GrCaps* caps, |
| 74 | SkArenaAlloc* arena, |
Brian Salomon | 8afde5f | 2020-04-01 16:22:00 -0400 | [diff] [blame^] | 75 | const GrSurfaceProxyView* writeViewSwizzle, |
Robert Phillips | 50d7d6f | 2020-03-04 11:12:24 -0500 | [diff] [blame] | 76 | GrAppliedClip&& appliedClip, |
| 77 | const GrXferProcessor::DstProxyView& dstProxyView, |
| 78 | GrGeometryProcessor* gp, |
| 79 | GrPrimitiveType primType) { |
| 80 | return CreateProgramInfo(caps, |
| 81 | arena, |
Brian Salomon | 8afde5f | 2020-04-01 16:22:00 -0400 | [diff] [blame^] | 82 | writeViewSwizzle, |
Robert Phillips | 50d7d6f | 2020-03-04 11:12:24 -0500 | [diff] [blame] | 83 | std::move(appliedClip), |
| 84 | dstProxyView, |
| 85 | gp, |
| 86 | this->detachProcessorSet(), |
| 87 | primType, |
| 88 | this->pipelineFlags(), |
| 89 | this->stencilSettings()); |
| 90 | } |
| 91 | |
Robert Phillips | 55f681f | 2020-02-28 08:58:15 -0500 | [diff] [blame] | 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 |