blob: e11716ed61846ffa4059517a6de91480a6015d42 [file] [log] [blame]
bsalomon@google.com30085192011-08-19 15:42:31 +00001/*
2 * Copyright 2011 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 GrDefaultPathRenderer_DEFINED
9#define GrDefaultPathRenderer_DEFINED
10
11#include "GrPathRenderer.h"
12#include "SkTemplates.h"
13
14/**
15 * Subclass that renders the path using the stencil buffer to resolve fill
16 * rules (e.g. winding, even-odd)
17 */
18class GR_API GrDefaultPathRenderer : public GrPathRenderer {
19public:
20 GrDefaultPathRenderer(bool separateStencilSupport,
21 bool stencilWrapOpsSupport);
22
23 virtual bool canDrawPath(const SkPath& path,
24 GrPathFill fill) const { return true; }
25
26 virtual bool requiresStencilPass(const GrDrawTarget* target,
27 const SkPath& path,
28 GrPathFill fill) const;
29
30 virtual void drawPath(GrDrawTarget::StageBitfield stages);
31 virtual void drawPathToStencil();
32
33protected:
34 virtual void pathWillClear();
35
36private:
37
38 void onDrawPath(GrDrawTarget::StageBitfield stages, bool stencilOnly);
39
40 bool createGeom(GrScalar srcSpaceTol,
41 GrDrawTarget::StageBitfield stages);
42
43 bool fSeparateStencil;
44 bool fStencilWrapOps;
45
46 int fSubpathCount;
47 SkAutoSTMalloc<8, uint16_t> fSubpathVertCount;
48 int fIndexCnt;
49 int fVertexCnt;
50 GrScalar fPreviousSrcTol;
51 GrDrawTarget::StageBitfield fPreviousStages;
52 GrPrimitiveType fPrimitiveType;
53 bool fUseIndexedDraw;
54
55 typedef GrPathRenderer INHERITED;
56};
57
58#endif