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 | |
Robert Phillips | 55f681f | 2020-02-28 08:58:15 -0500 | [diff] [blame] | 10 | GrSimpleMeshDrawOpHelperWithStencil::GrSimpleMeshDrawOpHelperWithStencil( |
Herb Derby | c76d409 | 2020-10-07 16:46:15 -0400 | [diff] [blame^] | 11 | GrProcessorSet* processorSet, |
Robert Phillips | 360ec18 | 2020-03-26 13:29:50 -0400 | [diff] [blame] | 12 | GrAAType aaType, |
| 13 | const GrUserStencilSettings* stencilSettings, |
| 14 | InputFlags inputFlags) |
Herb Derby | c76d409 | 2020-10-07 16:46:15 -0400 | [diff] [blame^] | 15 | : INHERITED(processorSet, aaType, inputFlags) |
Robert Phillips | 55f681f | 2020-02-28 08:58:15 -0500 | [diff] [blame] | 16 | , fStencilSettings(stencilSettings ? stencilSettings : &GrUserStencilSettings::kUnused) {} |
| 17 | |
| 18 | GrDrawOp::FixedFunctionFlags GrSimpleMeshDrawOpHelperWithStencil::fixedFunctionFlags() const { |
| 19 | GrDrawOp::FixedFunctionFlags flags = INHERITED::fixedFunctionFlags(); |
| 20 | if (fStencilSettings != &GrUserStencilSettings::kUnused) { |
| 21 | flags |= GrDrawOp::FixedFunctionFlags::kUsesStencil; |
| 22 | } |
| 23 | return flags; |
| 24 | } |
| 25 | |
| 26 | GrProcessorSet::Analysis GrSimpleMeshDrawOpHelperWithStencil::finalizeProcessors( |
| 27 | const GrCaps& caps, const GrAppliedClip* clip, bool hasMixedSampledCoverage, |
| 28 | GrClampType clampType, GrProcessorAnalysisCoverage geometryCoverage, |
| 29 | SkPMColor4f* geometryColor, bool* wideColor) { |
| 30 | GrProcessorAnalysisColor color = *geometryColor; |
| 31 | auto result = this->finalizeProcessors( |
| 32 | caps, clip, hasMixedSampledCoverage, clampType, geometryCoverage, &color); |
| 33 | color.isConstant(geometryColor); |
| 34 | if (wideColor) { |
| 35 | *wideColor = !geometryColor->fitsInBytes(); |
| 36 | } |
| 37 | return result; |
| 38 | } |
| 39 | |
| 40 | bool GrSimpleMeshDrawOpHelperWithStencil::isCompatible( |
| 41 | const GrSimpleMeshDrawOpHelperWithStencil& that, const GrCaps& caps, |
| 42 | const SkRect& thisBounds, const SkRect& thatBounds, bool ignoreAAType) const { |
| 43 | return INHERITED::isCompatible(that, caps, thisBounds, thatBounds, ignoreAAType) && |
| 44 | fStencilSettings == that.fStencilSettings; |
| 45 | } |
| 46 | |
Robert Phillips | 50d7d6f | 2020-03-04 11:12:24 -0500 | [diff] [blame] | 47 | GrProgramInfo* GrSimpleMeshDrawOpHelperWithStencil::createProgramInfoWithStencil( |
| 48 | const GrCaps* caps, |
| 49 | SkArenaAlloc* arena, |
Brian Salomon | 8afde5f | 2020-04-01 16:22:00 -0400 | [diff] [blame] | 50 | const GrSurfaceProxyView* writeViewSwizzle, |
Robert Phillips | 50d7d6f | 2020-03-04 11:12:24 -0500 | [diff] [blame] | 51 | GrAppliedClip&& appliedClip, |
| 52 | const GrXferProcessor::DstProxyView& dstProxyView, |
| 53 | GrGeometryProcessor* gp, |
Greg Daniel | d358cbe | 2020-09-11 09:33:54 -0400 | [diff] [blame] | 54 | GrPrimitiveType primType, |
| 55 | GrXferBarrierFlags renderPassXferBarriers) { |
Robert Phillips | 50d7d6f | 2020-03-04 11:12:24 -0500 | [diff] [blame] | 56 | return CreateProgramInfo(caps, |
| 57 | arena, |
Brian Salomon | 8afde5f | 2020-04-01 16:22:00 -0400 | [diff] [blame] | 58 | writeViewSwizzle, |
Robert Phillips | 50d7d6f | 2020-03-04 11:12:24 -0500 | [diff] [blame] | 59 | std::move(appliedClip), |
| 60 | dstProxyView, |
| 61 | gp, |
| 62 | this->detachProcessorSet(), |
| 63 | primType, |
Greg Daniel | d358cbe | 2020-09-11 09:33:54 -0400 | [diff] [blame] | 64 | renderPassXferBarriers, |
Robert Phillips | 50d7d6f | 2020-03-04 11:12:24 -0500 | [diff] [blame] | 65 | this->pipelineFlags(), |
| 66 | this->stencilSettings()); |
| 67 | } |
| 68 | |
John Stiles | 8d9bf64 | 2020-08-12 15:07:45 -0400 | [diff] [blame] | 69 | #if GR_TEST_UTILS |
Robert Phillips | 55f681f | 2020-02-28 08:58:15 -0500 | [diff] [blame] | 70 | SkString GrSimpleMeshDrawOpHelperWithStencil::dumpInfo() const { |
| 71 | SkString result = INHERITED::dumpInfo(); |
| 72 | result.appendf("Stencil settings: %s\n", (fStencilSettings ? "yes" : "no")); |
| 73 | return result; |
| 74 | } |
| 75 | #endif |