blob: 2a34a3d2ca1191a051972c6c8657a8a618f47dd1 [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
bsalomon@google.com289533a2011-10-27 12:34:25 +000023 virtual bool canDrawPath(const GrDrawTarget::Caps& targetCaps,
bsalomon@google.comaeb21602011-08-30 18:13:44 +000024 const SkPath& path,
bsalomon@google.com289533a2011-10-27 12:34:25 +000025 GrPathFill fill,
26 bool antiAlias) const SK_OVERRIDE;
bsalomon@google.com30085192011-08-19 15:42:31 +000027
28 virtual bool requiresStencilPass(const GrDrawTarget* target,
29 const SkPath& path,
bsalomon@google.com289533a2011-10-27 12:34:25 +000030 GrPathFill fill) const SK_OVERRIDE;
bsalomon@google.com30085192011-08-19 15:42:31 +000031
bsalomon@google.com289533a2011-10-27 12:34:25 +000032 virtual void drawPath(GrDrawTarget::StageBitfield stages) SK_OVERRIDE;
33 virtual void drawPathToStencil() SK_OVERRIDE;
bsalomon@google.com30085192011-08-19 15:42:31 +000034
35protected:
36 virtual void pathWillClear();
37
38private:
39
40 void onDrawPath(GrDrawTarget::StageBitfield stages, bool stencilOnly);
41
42 bool createGeom(GrScalar srcSpaceTol,
43 GrDrawTarget::StageBitfield stages);
44
45 bool fSeparateStencil;
46 bool fStencilWrapOps;
47
48 int fSubpathCount;
49 SkAutoSTMalloc<8, uint16_t> fSubpathVertCount;
50 int fIndexCnt;
51 int fVertexCnt;
52 GrScalar fPreviousSrcTol;
53 GrDrawTarget::StageBitfield fPreviousStages;
54 GrPrimitiveType fPrimitiveType;
55 bool fUseIndexedDraw;
56
57 typedef GrPathRenderer INHERITED;
58};
59
60#endif