GrPathProcessor.h revision 2279325d539700ee3da29d6e874b3b3ce1dcf49c
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
13/*
14 * The path equivalent of the GP.  For now this just manages color. In the long term we plan on
15 * extending this class to handle all nvpr uniform / varying / program work.
16 */
17class GrPathProcessor : public GrPrimitiveProcessor {
18public:
19    static GrPathProcessor* Create(GrColor color,
20                                   const GrXPOverridesForBatch& overrides,
21                                   const SkMatrix& viewMatrix = SkMatrix::I(),
22                                   const SkMatrix& localMatrix = SkMatrix::I()) {
23        return new GrPathProcessor(color, overrides, viewMatrix, localMatrix);
24    }
25
26    const char* name() const override { return "PathProcessor"; }
27
28    GrColor color() const { return fColor; }
29    const SkMatrix& viewMatrix() const { return fViewMatrix; }
30    const SkMatrix& localMatrix() const { return fLocalMatrix; }
31
32    bool willUseGeoShader() const override { return false; }
33
34    virtual void getGLSLProcessorKey(const GrGLSLCaps& caps,
35                                     GrProcessorKeyBuilder* b) const override;
36
37    virtual GrGLSLPrimitiveProcessor* createGLSLInstance(const GrGLSLCaps& caps) const override;
38
39    bool hasTransformedLocalCoords() const override { return false; }
40
41    const GrXPOverridesForBatch& overrides() const { return fOverrides; }
42
43    virtual bool isPathRendering() const override { return true; }
44
45private:
46    GrPathProcessor(GrColor color, const GrXPOverridesForBatch& overrides,
47                    const SkMatrix& viewMatrix, const SkMatrix& localMatrix);
48
49    bool hasExplicitLocalCoords() const override { return false; }
50
51    GrColor fColor;
52    const SkMatrix fViewMatrix;
53    const SkMatrix fLocalMatrix;
54    GrXPOverridesForBatch fOverrides;
55
56    typedef GrPrimitiveProcessor INHERITED;
57};
58
59#endif
60