1 /* 2 * Copyright 2019 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 GrGSCoverageProcessor_DEFINED 9 #define GrGSCoverageProcessor_DEFINED 10 11 #include "src/gpu/ccpr/GrCCCoverageProcessor.h" 12 13 /** 14 * This class implements GrCCCoverageProcessor with analytic coverage using geometry shaders. 15 */ 16 class GrGSCoverageProcessor : public GrCCCoverageProcessor { 17 public: GrGSCoverageProcessor()18 GrGSCoverageProcessor() : GrCCCoverageProcessor(kGrGSCoverageProcessor_ClassID) { 19 this->setWillUseGeoShader(); 20 } 21 22 private: 23 void reset(PrimitiveType, GrResourceProvider*) override; 24 getGLSLProcessorKey(const GrShaderCaps &,GrProcessorKeyBuilder * b)25 void getGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder* b) const override { 26 SkDEBUGCODE(this->getDebugBloatKey(b)); 27 b->add32(((int)fPrimitiveType << 16) | (int)fSubpass); 28 } 29 30 void appendMesh(sk_sp<const GrGpuBuffer> instanceBuffer, int instanceCount, int baseInstance, 31 SkTArray<GrMesh>* out) const override; 32 33 void draw(GrOpFlushState*, const GrPipeline&, const SkIRect scissorRects[], const GrMesh[], 34 int meshCount, const SkRect& drawBounds) const override; 35 primType()36 GrPrimitiveType primType() const final { return GrPrimitiveType::kLines; } 37 38 GrGLSLPrimitiveProcessor* onCreateGLSLInstance(std::unique_ptr<Shader>) const override; 39 40 // The geometry shader impl draws primitives in two subpasses. The first pass fills the interior 41 // and does edge AA. The second pass does touch up on corner pixels. 42 enum class Subpass : bool { 43 kHulls, 44 kCorners 45 }; 46 47 Attribute fInputXOrYValues; 48 mutable Subpass fSubpass = Subpass::kHulls; 49 50 class Impl; 51 class TriangleHullImpl; 52 class CurveHullImpl; 53 class CornerImpl; 54 55 typedef GrCCCoverageProcessor INHERITED; 56 }; 57 58 #endif 59