blob: 2e3f7dc2483423f99efa4ee3c748a4e741fd035a [file] [log] [blame]
Chris Dalton2c5e0112019-03-29 13:14:18 -05001/*
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
Mike Kleinc0bd9f92019-04-23 12:05:21 -050011#include "src/gpu/ccpr/GrCCCoverageProcessor.h"
Chris Dalton2c5e0112019-03-29 13:14:18 -050012
13/**
14 * This class implements GrCCCoverageProcessor with analytic coverage using geometry shaders.
15 */
16class GrGSCoverageProcessor : public GrCCCoverageProcessor {
17public:
18 GrGSCoverageProcessor() : GrCCCoverageProcessor(kGrGSCoverageProcessor_ClassID) {
19 this->setWillUseGeoShader();
20 }
21
22private:
23 void reset(PrimitiveType, GrResourceProvider*) override;
24
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