| 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: |
| 18 | GrGSCoverageProcessor() : GrCCCoverageProcessor(kGrGSCoverageProcessor_ClassID) { |
| 19 | this->setWillUseGeoShader(); |
| 20 | } |
| 21 | |
| 22 | private: |
| 23 | void getGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder* b) const override { |
| 24 | SkDEBUGCODE(this->getDebugBloatKey(b)); |
| 25 | b->add32(((int)fPrimitiveType << 16) | (int)fSubpass); |
| 26 | } |
| 27 | |
| 28 | GrPrimitiveType primType() const final { return GrPrimitiveType::kLines; } |
| 29 | int numSubpasses() const override { return 2; } |
| 30 | void reset(PrimitiveType, int subpassIdx, GrResourceProvider*) override; |
| 31 | void bindBuffers(GrOpsRenderPass*, const GrBuffer* instanceBuffer) const override; |
| 32 | void drawInstances(GrOpsRenderPass*, int instanceCount, int baseInstance) const override; |
| 33 | |
| 34 | GrGLSLPrimitiveProcessor* onCreateGLSLInstance(std::unique_ptr<Shader>) const override; |
| 35 | |
| 36 | // The geometry shader impl draws primitives in two subpasses. The first pass fills the interior |
| 37 | // and does edge AA. The second pass does touch up on corner pixels. |
| 38 | enum class Subpass : bool { |
| 39 | kHulls, |
| 40 | kCorners |
| 41 | }; |
| 42 | |
| 43 | Attribute fInputXOrYValues; |
| 44 | mutable Subpass fSubpass = Subpass::kHulls; |
| 45 | |
| 46 | class Impl; |
| 47 | class TriangleHullImpl; |
| 48 | class CurveHullImpl; |
| 49 | class CornerImpl; |
| 50 | |
| 51 | typedef GrCCCoverageProcessor INHERITED; |
| 52 | }; |
| 53 | |
| 54 | #endif |
| 55 |