blob: adfe7d2de18daeb7c2b0d5f97056c8adc388b3e3 [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.com39ee0ff2011-12-06 15:32:52 +000032 virtual void drawPath(GrDrawState::StageMask stageMask) SK_OVERRIDE;
bsalomon@google.com289533a2011-10-27 12:34:25 +000033 virtual void drawPathToStencil() SK_OVERRIDE;
bsalomon@google.com30085192011-08-19 15:42:31 +000034
35protected:
36 virtual void pathWillClear();
37
38private:
39
bsalomon@google.com39ee0ff2011-12-06 15:32:52 +000040 void onDrawPath(GrDrawState::StageMask stages, bool stencilOnly);
bsalomon@google.com30085192011-08-19 15:42:31 +000041
42 bool createGeom(GrScalar srcSpaceTol,
bsalomon@google.com39ee0ff2011-12-06 15:32:52 +000043 GrDrawState::StageMask stages);
bsalomon@google.com30085192011-08-19 15:42:31 +000044
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;
bsalomon@google.com39ee0ff2011-12-06 15:32:52 +000053 GrDrawState::StageMask fPreviousStages;
bsalomon@google.com30085192011-08-19 15:42:31 +000054 GrPrimitiveType fPrimitiveType;
55 bool fUseIndexedDraw;
56
57 typedef GrPathRenderer INHERITED;
58};
59
60#endif