bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 1 | /* |
| 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 | */ |
| 18 | class GR_API GrDefaultPathRenderer : public GrPathRenderer { |
| 19 | public: |
| 20 | GrDefaultPathRenderer(bool separateStencilSupport, |
| 21 | bool stencilWrapOpsSupport); |
| 22 | |
bsalomon@google.com | 289533a | 2011-10-27 12:34:25 +0000 | [diff] [blame] | 23 | virtual bool canDrawPath(const GrDrawTarget::Caps& targetCaps, |
bsalomon@google.com | aeb2160 | 2011-08-30 18:13:44 +0000 | [diff] [blame] | 24 | const SkPath& path, |
bsalomon@google.com | 289533a | 2011-10-27 12:34:25 +0000 | [diff] [blame] | 25 | GrPathFill fill, |
| 26 | bool antiAlias) const SK_OVERRIDE; |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 27 | |
| 28 | virtual bool requiresStencilPass(const GrDrawTarget* target, |
| 29 | const SkPath& path, |
bsalomon@google.com | 289533a | 2011-10-27 12:34:25 +0000 | [diff] [blame] | 30 | GrPathFill fill) const SK_OVERRIDE; |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 31 | |
bsalomon@google.com | 39ee0ff | 2011-12-06 15:32:52 +0000 | [diff] [blame] | 32 | virtual void drawPath(GrDrawState::StageMask stageMask) SK_OVERRIDE; |
bsalomon@google.com | 289533a | 2011-10-27 12:34:25 +0000 | [diff] [blame] | 33 | virtual void drawPathToStencil() SK_OVERRIDE; |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 34 | |
| 35 | protected: |
| 36 | virtual void pathWillClear(); |
| 37 | |
| 38 | private: |
| 39 | |
bsalomon@google.com | 39ee0ff | 2011-12-06 15:32:52 +0000 | [diff] [blame] | 40 | void onDrawPath(GrDrawState::StageMask stages, bool stencilOnly); |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 41 | |
| 42 | bool createGeom(GrScalar srcSpaceTol, |
bsalomon@google.com | 39ee0ff | 2011-12-06 15:32:52 +0000 | [diff] [blame] | 43 | GrDrawState::StageMask stages); |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 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; |
bsalomon@google.com | 39ee0ff | 2011-12-06 15:32:52 +0000 | [diff] [blame] | 53 | GrDrawState::StageMask fPreviousStages; |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 54 | GrPrimitiveType fPrimitiveType; |
| 55 | bool fUseIndexedDraw; |
| 56 | |
| 57 | typedef GrPathRenderer INHERITED; |
| 58 | }; |
| 59 | |
| 60 | #endif |