18072caa80384292858d31ae34b7e19768875866bjoshualitt/*
28072caa80384292858d31ae34b7e19768875866bjoshualitt * Copyright 2013 Google Inc.
38072caa80384292858d31ae34b7e19768875866bjoshualitt *
48072caa80384292858d31ae34b7e19768875866bjoshualitt * Use of this source code is governed by a BSD-style license that can be
58072caa80384292858d31ae34b7e19768875866bjoshualitt * found in the LICENSE file.
68072caa80384292858d31ae34b7e19768875866bjoshualitt */
78072caa80384292858d31ae34b7e19768875866bjoshualitt
88072caa80384292858d31ae34b7e19768875866bjoshualitt#ifndef GrPathProcessor_DEFINED
98072caa80384292858d31ae34b7e19768875866bjoshualitt#define GrPathProcessor_DEFINED
108072caa80384292858d31ae34b7e19768875866bjoshualitt
118072caa80384292858d31ae34b7e19768875866bjoshualitt#include "GrPrimitiveProcessor.h"
128072caa80384292858d31ae34b7e19768875866bjoshualitt
138072caa80384292858d31ae34b7e19768875866bjoshualitt/*
148072caa80384292858d31ae34b7e19768875866bjoshualitt * The path equivalent of the GP.  For now this just manages color. In the long term we plan on
158072caa80384292858d31ae34b7e19768875866bjoshualitt * extending this class to handle all nvpr uniform / varying / program work.
168072caa80384292858d31ae34b7e19768875866bjoshualitt */
178072caa80384292858d31ae34b7e19768875866bjoshualittclass GrPathProcessor : public GrPrimitiveProcessor {
188072caa80384292858d31ae34b7e19768875866bjoshualittpublic:
198072caa80384292858d31ae34b7e19768875866bjoshualitt    static GrPathProcessor* Create(GrColor color,
208072caa80384292858d31ae34b7e19768875866bjoshualitt                                   const SkMatrix& viewMatrix = SkMatrix::I(),
218072caa80384292858d31ae34b7e19768875866bjoshualitt                                   const SkMatrix& localMatrix = SkMatrix::I()) {
22ecea86af4170a52cda5c64dd187ddbe157a682eeBrian Salomon        return new GrPathProcessor(color, viewMatrix, localMatrix);
238072caa80384292858d31ae34b7e19768875866bjoshualitt    }
248072caa80384292858d31ae34b7e19768875866bjoshualitt
2536352bf5e38f45a70ee4f4fc132a38048d38206dmtklein    const char* name() const override { return "PathProcessor"; }
268072caa80384292858d31ae34b7e19768875866bjoshualitt
278072caa80384292858d31ae34b7e19768875866bjoshualitt    GrColor color() const { return fColor; }
28e3ababe44315452cd33b96a18ce316ede09ff3c3joshualitt    const SkMatrix& viewMatrix() const { return fViewMatrix; }
29e3ababe44315452cd33b96a18ce316ede09ff3c3joshualitt    const SkMatrix& localMatrix() const { return fLocalMatrix; }
30e3ababe44315452cd33b96a18ce316ede09ff3c3joshualitt
3136352bf5e38f45a70ee4f4fc132a38048d38206dmtklein    bool willUseGeoShader() const override { return false; }
328072caa80384292858d31ae34b7e19768875866bjoshualitt
3394efbf51f5a88d9e8aa961d3fbe38c5e335d6108Brian Salomon    virtual void getGLSLProcessorKey(const GrShaderCaps& caps,
3457d3b039c635945e1dc2fcbac3462ed8bfedb068egdaniel                                     GrProcessorKeyBuilder* b) const override;
358072caa80384292858d31ae34b7e19768875866bjoshualitt
3694efbf51f5a88d9e8aa961d3fbe38c5e335d6108Brian Salomon    virtual GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps& caps) const override;
378072caa80384292858d31ae34b7e19768875866bjoshualitt
382279325d539700ee3da29d6e874b3b3ce1dcf49cethannicholas    virtual bool isPathRendering() const override { return true; }
392279325d539700ee3da29d6e874b3b3ce1dcf49cethannicholas
408072caa80384292858d31ae34b7e19768875866bjoshualittprivate:
41ecea86af4170a52cda5c64dd187ddbe157a682eeBrian Salomon    GrPathProcessor(GrColor, const SkMatrix& viewMatrix, const SkMatrix& localMatrix);
42e3ababe44315452cd33b96a18ce316ede09ff3c3joshualitt
4336352bf5e38f45a70ee4f4fc132a38048d38206dmtklein    bool hasExplicitLocalCoords() const override { return false; }
448072caa80384292858d31ae34b7e19768875866bjoshualitt
458072caa80384292858d31ae34b7e19768875866bjoshualitt    GrColor fColor;
46e3ababe44315452cd33b96a18ce316ede09ff3c3joshualitt    const SkMatrix fViewMatrix;
47e3ababe44315452cd33b96a18ce316ede09ff3c3joshualitt    const SkMatrix fLocalMatrix;
488072caa80384292858d31ae34b7e19768875866bjoshualitt
498072caa80384292858d31ae34b7e19768875866bjoshualitt    typedef GrPrimitiveProcessor INHERITED;
508072caa80384292858d31ae34b7e19768875866bjoshualitt};
518072caa80384292858d31ae34b7e19768875866bjoshualitt
528072caa80384292858d31ae34b7e19768875866bjoshualitt#endif
53