GrPathProcessor.h revision cfc18867d982119d9dc2888bf09f1093012daadd
1/*
2 * Copyright 2013 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 GrPathProcessor_DEFINED
9#define GrPathProcessor_DEFINED
10
11#include "GrPrimitiveProcessor.h"
12
13struct PathBatchTracker {
14    GrGPInput fInputColorType;
15    GrGPInput fInputCoverageType;
16    GrColor fColor;
17    bool fUsesLocalCoords;
18};
19
20/*
21 * The path equivalent of the GP.  For now this just manages color. In the long term we plan on
22 * extending this class to handle all nvpr uniform / varying / program work.
23 */
24class GrPathProcessor : public GrPrimitiveProcessor {
25public:
26    static GrPathProcessor* Create(GrColor color,
27                                   const SkMatrix& viewMatrix = SkMatrix::I(),
28                                   const SkMatrix& localMatrix = SkMatrix::I()) {
29        return SkNEW_ARGS(GrPathProcessor, (color, viewMatrix, localMatrix));
30    }
31
32    void initBatchTracker(GrBatchTracker*, const GrPipelineInfo&) const override;
33
34    bool canMakeEqual(const GrBatchTracker& mine,
35                      const GrPrimitiveProcessor& that,
36                      const GrBatchTracker& theirs) const override;
37
38    const char* name() const override { return "PathProcessor"; }
39
40    GrColor color() const { return fColor; }
41
42    void getInvariantOutputColor(GrInitInvariantOutput* out) const override;
43    void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override;
44
45    bool willUseGeoShader() const override { return false; }
46
47    virtual void getGLProcessorKey(const GrBatchTracker& bt,
48                                   const GrGLSLCaps& caps,
49                                   GrProcessorKeyBuilder* b) const override;
50
51    virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt,
52                                                     const GrGLSLCaps& caps) const override;
53
54protected:
55    GrPathProcessor(GrColor color, const SkMatrix& viewMatrix, const SkMatrix& localMatrix);
56
57private:
58    bool hasExplicitLocalCoords() const override { return false; }
59
60    GrColor fColor;
61
62    typedef GrPrimitiveProcessor INHERITED;
63};
64
65#endif
66