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