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 #ifndef GrSimpleMeshDrawOpHelperWithStencil_DEFINED 9 #define GrSimpleMeshDrawOpHelperWithStencil_DEFINED 10 11 #include "include/core/SkString.h" 12 #include "include/private/SkColorData.h" 13 #include "src/gpu/ganesh/GrCaps.h" 14 #include "src/gpu/ganesh/GrPaint.h" 15 #include "src/gpu/ganesh/GrProcessorSet.h" 16 #include "src/gpu/ganesh/ops/GrDrawOp.h" 17 #include "src/gpu/ganesh/ops/GrOp.h" 18 #include "src/gpu/ganesh/ops/GrSimpleMeshDrawOpHelper.h" 19 20 #include <cstdint> 21 #include <utility> 22 23 class GrAppliedClip; 24 class GrDstProxyView; 25 class GrGeometryProcessor; 26 class GrProcessorAnalysisColor; 27 class GrProgramInfo; 28 class GrRecordingContext; 29 class GrSurfaceProxyView; 30 class SkArenaAlloc; 31 enum class GrAAType : unsigned int; 32 enum class GrClampType; 33 enum class GrLoadOp; 34 enum class GrPrimitiveType : uint8_t; 35 enum class GrProcessorAnalysisCoverage; 36 enum class GrXferBarrierFlags; 37 struct GrUserStencilSettings; 38 struct SkRect; 39 40 /** 41 * This class extends GrSimpleMeshDrawOpHelper to support an optional GrUserStencilSettings. This 42 * uses private inheritance because it non-virtually overrides methods in the base class and should 43 * never be used with a GrSimpleMeshDrawOpHelper pointer or reference. 44 */ 45 class GrSimpleMeshDrawOpHelperWithStencil : private GrSimpleMeshDrawOpHelper { 46 public: 47 using InputFlags = GrSimpleMeshDrawOpHelper::InputFlags; 48 49 using GrSimpleMeshDrawOpHelper::visitProxies; 50 using GrSimpleMeshDrawOpHelper::createPipeline; 51 52 GrProgramInfo* createProgramInfoWithStencil(const GrCaps*, 53 SkArenaAlloc*, 54 const GrSurfaceProxyView& writeView, 55 bool usesMSAASurface, 56 GrAppliedClip&&, 57 const GrDstProxyView&, 58 GrGeometryProcessor*, 59 GrPrimitiveType, 60 GrXferBarrierFlags renderPassXferBarriers, 61 GrLoadOp colorLoadOp); 62 63 // using declarations can't be templated, so this is a pass through function instead. 64 template <typename Op, typename... OpArgs> FactoryHelper(GrRecordingContext * context,GrPaint && paint,OpArgs...opArgs)65 static GrOp::Owner FactoryHelper(GrRecordingContext* context, GrPaint&& paint, 66 OpArgs... opArgs) { 67 return GrSimpleMeshDrawOpHelper::FactoryHelper<Op, OpArgs...>( 68 context, std::move(paint), std::forward<OpArgs>(opArgs)...); 69 } 70 71 GrSimpleMeshDrawOpHelperWithStencil(GrProcessorSet*, GrAAType, const GrUserStencilSettings*, 72 InputFlags = InputFlags::kNone); 73 74 GrDrawOp::FixedFunctionFlags fixedFunctionFlags() const; 75 finalizeProcessors(const GrCaps & caps,const GrAppliedClip * clip,GrClampType clampType,GrProcessorAnalysisCoverage geometryCoverage,GrProcessorAnalysisColor * geometryColor)76 GrProcessorSet::Analysis finalizeProcessors(const GrCaps& caps, const GrAppliedClip* clip, 77 GrClampType clampType, 78 GrProcessorAnalysisCoverage geometryCoverage, 79 GrProcessorAnalysisColor* geometryColor) { 80 return this->INHERITED::finalizeProcessors(caps, clip, fStencilSettings, clampType, 81 geometryCoverage, geometryColor); 82 } 83 84 GrProcessorSet::Analysis finalizeProcessors(const GrCaps&, const GrAppliedClip*, GrClampType, 85 GrProcessorAnalysisCoverage geometryCoverage, 86 SkPMColor4f* geometryColor, bool* wideColor); 87 88 using GrSimpleMeshDrawOpHelper::aaType; 89 using GrSimpleMeshDrawOpHelper::setAAType; 90 using GrSimpleMeshDrawOpHelper::isTrivial; 91 using GrSimpleMeshDrawOpHelper::usesLocalCoords; 92 using GrSimpleMeshDrawOpHelper::compatibleWithCoverageAsAlpha; 93 using GrSimpleMeshDrawOpHelper::detachProcessorSet; 94 using GrSimpleMeshDrawOpHelper::pipelineFlags; 95 96 bool isCompatible(const GrSimpleMeshDrawOpHelperWithStencil& that, const GrCaps&, 97 const SkRect& thisBounds, const SkRect& thatBounds, 98 bool ignoreAAType = false) const; 99 100 #if defined(GPU_TEST_UTILS) 101 SkString dumpInfo() const; 102 #endif 103 stencilSettings()104 const GrUserStencilSettings* stencilSettings() const { return fStencilSettings; } 105 106 private: 107 const GrUserStencilSettings* fStencilSettings; 108 using INHERITED = GrSimpleMeshDrawOpHelper; 109 }; 110 111 #endif 112