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( |
Chris Dalton | 57ab06c | 2021-04-22 12:57:28 -0600 | [diff] [blame] | 27 | const GrCaps& caps, const GrAppliedClip* clip, GrClampType clampType, |
| 28 | GrProcessorAnalysisCoverage geometryCoverage, SkPMColor4f* geometryColor, bool* wideColor) { |
Robert Phillips | 55f681f | 2020-02-28 08:58:15 -0500 | [diff] [blame] | 29 | GrProcessorAnalysisColor color = *geometryColor; |
Chris Dalton | 57ab06c | 2021-04-22 12:57:28 -0600 | [diff] [blame] | 30 | auto result = this->finalizeProcessors(caps, clip, clampType, geometryCoverage, &color); |
Robert Phillips | 55f681f | 2020-02-28 08:58:15 -0500 | [diff] [blame] | 31 | color.isConstant(geometryColor); |
| 32 | if (wideColor) { |
| 33 | *wideColor = !geometryColor->fitsInBytes(); |
| 34 | } |
| 35 | return result; |
| 36 | } |
| 37 | |
| 38 | bool GrSimpleMeshDrawOpHelperWithStencil::isCompatible( |
| 39 | const GrSimpleMeshDrawOpHelperWithStencil& that, const GrCaps& caps, |
| 40 | const SkRect& thisBounds, const SkRect& thatBounds, bool ignoreAAType) const { |
| 41 | return INHERITED::isCompatible(that, caps, thisBounds, thatBounds, ignoreAAType) && |
| 42 | fStencilSettings == that.fStencilSettings; |
| 43 | } |
| 44 | |
Robert Phillips | 50d7d6f | 2020-03-04 11:12:24 -0500 | [diff] [blame] | 45 | GrProgramInfo* GrSimpleMeshDrawOpHelperWithStencil::createProgramInfoWithStencil( |
| 46 | const GrCaps* caps, |
| 47 | SkArenaAlloc* arena, |
Chris Dalton | 2a26c50 | 2021-08-26 10:05:11 -0600 | [diff] [blame] | 48 | const GrSurfaceProxyView& writeView, |
| 49 | bool usesMSAASurface, |
Robert Phillips | 50d7d6f | 2020-03-04 11:12:24 -0500 | [diff] [blame] | 50 | GrAppliedClip&& appliedClip, |
John Stiles | 52cb1d0 | 2021-06-02 11:58:05 -0400 | [diff] [blame] | 51 | const GrDstProxyView& dstProxyView, |
Robert Phillips | 50d7d6f | 2020-03-04 11:12:24 -0500 | [diff] [blame] | 52 | GrGeometryProcessor* gp, |
Greg Daniel | d358cbe | 2020-09-11 09:33:54 -0400 | [diff] [blame] | 53 | GrPrimitiveType primType, |
Greg Daniel | 42dbca5 | 2020-11-20 10:22:43 -0500 | [diff] [blame] | 54 | GrXferBarrierFlags renderPassXferBarriers, |
| 55 | GrLoadOp colorLoadOp) { |
Robert Phillips | 50d7d6f | 2020-03-04 11:12:24 -0500 | [diff] [blame] | 56 | return CreateProgramInfo(caps, |
| 57 | arena, |
Chris Dalton | 2a26c50 | 2021-08-26 10:05:11 -0600 | [diff] [blame] | 58 | writeView, |
| 59 | usesMSAASurface, |
Robert Phillips | 50d7d6f | 2020-03-04 11:12:24 -0500 | [diff] [blame] | 60 | std::move(appliedClip), |
| 61 | dstProxyView, |
| 62 | gp, |
| 63 | this->detachProcessorSet(), |
| 64 | primType, |
Greg Daniel | d358cbe | 2020-09-11 09:33:54 -0400 | [diff] [blame] | 65 | renderPassXferBarriers, |
Greg Daniel | 42dbca5 | 2020-11-20 10:22:43 -0500 | [diff] [blame] | 66 | colorLoadOp, |
Robert Phillips | 50d7d6f | 2020-03-04 11:12:24 -0500 | [diff] [blame] | 67 | this->pipelineFlags(), |
| 68 | this->stencilSettings()); |
| 69 | } |
| 70 | |
John Stiles | 8d9bf64 | 2020-08-12 15:07:45 -0400 | [diff] [blame] | 71 | #if GR_TEST_UTILS |
Robert Phillips | 55f681f | 2020-02-28 08:58:15 -0500 | [diff] [blame] | 72 | SkString GrSimpleMeshDrawOpHelperWithStencil::dumpInfo() const { |
| 73 | SkString result = INHERITED::dumpInfo(); |
| 74 | result.appendf("Stencil settings: %s\n", (fStencilSettings ? "yes" : "no")); |
| 75 | return result; |
| 76 | } |
| 77 | #endif |