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 36 GrGLSLPrimitiveProcessor* onCreateGLSLInstance(std::unique_ptr<Shader>) const override; 37 38 // The geometry shader impl draws primitives in two subpasses. The first pass fills the interior 39 // and does edge AA. The second pass does touch up on corner pixels. 40 enum class Subpass : bool { 41 kHulls, 42 kCorners 43 }; 44 45 Attribute fInputXOrYValues; 46 mutable Subpass fSubpass = Subpass::kHulls; 47 48 class Impl; 49 class TriangleHullImpl; 50 class CurveHullImpl; 51 class CornerImpl; 52 }; 53 54 #endif 55