Chromium Code Reviews| Index: src/gpu/GrPathRenderer.h |
| =================================================================== |
| --- src/gpu/GrPathRenderer.h (revision 11314) |
| +++ src/gpu/GrPathRenderer.h (working copy) |
| @@ -73,76 +73,80 @@ |
| GrPathRendererChain::kNoRestriction_StencilSupport; |
| /** |
| - * This function is to get the stencil support for a particular path. The path's fill must |
| + * This function is to get the stencil support for the current path. The path's fill must |
| * not be an inverse type. |
| * |
| + * @param stroke the stroke information (width, join, cap). |
| * @param target target that the path will be rendered to |
| - * @param path the path that will be drawn |
| - * @param stroke the stroke information (width, join, cap). |
| */ |
| - StencilSupport getStencilSupport(const SkPath& path, |
| - const SkStrokeRec& stroke, |
| + StencilSupport getStencilSupport(const SkStrokeRec& stroke, |
| const GrDrawTarget* target) const { |
| - SkASSERT(!path.isInverseFillType()); |
| - return this->onGetStencilSupport(path, stroke, target); |
| + SkASSERT(!fPath.isInverseFillType()); |
| + return this->onGetStencilSupport(stroke, target); |
| } |
| + // Set the path and fill type the path renderer is to use. |
| + // 'fillType' is included as a parameter b.c. we often want to draw |
| + // inverse filled paths normally filled. |
| + void setPath(const SkPath& path, SkPath::FillType fillType) { |
| + fPath = path; |
| + fPath.setFillType(fillType); |
| + } |
| + |
| /** |
| - * Returns true if this path renderer is able to render the path. Returning false allows the |
| - * caller to fallback to another path renderer This function is called when searching for a path |
| - * renderer capable of rendering a path. |
| + * Returns true if this path renderer is able to render the current path. Returning false |
| + * allows the caller to fallback to another path renderer This function is called when |
| + * searching for a path renderer capable of rendering a path. |
| * |
| - * @param path The path to draw |
| * @param stroke The stroke information (width, join, cap) |
| * @param target The target that the path will be rendered to |
| * @param antiAlias True if anti-aliasing is required. |
| * |
| * @return true if the path can be drawn by this object, false otherwise. |
| */ |
| - virtual bool canDrawPath(const SkPath& path, |
| - const SkStrokeRec& rec, |
| + virtual bool canDrawPath(const SkStrokeRec& stroke, |
| const GrDrawTarget* target, |
| bool antiAlias) const = 0; |
| /** |
| - * Draws the path into the draw target. If getStencilSupport() would return kNoRestriction then |
| - * the subclass must respect the stencil settings of the target's draw state. |
| + * Draws the current path into the draw target. If getStencilSupport() would return |
| + * kNoRestriction then the subclass must respect the stencil settings of the |
| + * target's draw state. |
| * |
| - * @param path the path to draw. |
| * @param stroke the stroke information (width, join, cap) |
| * @param target target that the path will be rendered to |
| * @param antiAlias true if anti-aliasing is required. |
| */ |
| - bool drawPath(const SkPath& path, |
| - const SkStrokeRec& stroke, |
| + bool drawPath(const SkStrokeRec& stroke, |
| GrDrawTarget* target, |
| bool antiAlias) { |
| - SkASSERT(!path.isEmpty()); |
| - SkASSERT(this->canDrawPath(path, stroke, target, antiAlias)); |
| + SkASSERT(!fPath.isEmpty()); |
| + SkASSERT(this->canDrawPath(stroke, target, antiAlias)); |
| SkASSERT(target->drawState()->getStencil().isDisabled() || |
| - kNoRestriction_StencilSupport == this->getStencilSupport(path, stroke, target)); |
| - return this->onDrawPath(path, stroke, target, antiAlias); |
| + kNoRestriction_StencilSupport == this->getStencilSupport(stroke, target)); |
| + return this->onDrawPath(stroke, target, antiAlias); |
| } |
| /** |
| - * Draws the path to the stencil buffer. Assume the writable stencil bits are already |
| - * initialized to zero. The pixels inside the path will have non-zero stencil values afterwards. |
| + * Draws the current path to the stencil buffer. Assume the writable stencil bits are already |
| + * initialized to zero. The pixels inside the path will have non-zero stencil values |
| + * afterwards. |
| * |
| - * @param path the path to draw. |
| * @param stroke the stroke information (width, join, cap) |
| * @param target target that the path will be rendered to |
| */ |
| - void stencilPath(const SkPath& path, const SkStrokeRec& stroke, GrDrawTarget* target) { |
| - SkASSERT(!path.isEmpty()); |
| - SkASSERT(kNoSupport_StencilSupport != this->getStencilSupport(path, stroke, target)); |
| - this->onStencilPath(path, stroke, target); |
| + void stencilPath(const SkStrokeRec& stroke, GrDrawTarget* target) { |
| + SkASSERT(!fPath.isEmpty()); |
| + SkASSERT(kNoSupport_StencilSupport != this->getStencilSupport(stroke, target)); |
| + this->onStencilPath(stroke, target); |
| } |
| protected: |
| + SkPath fPath; |
|
bsalomon
2013/09/17 18:16:49
private w/ a const getter? I wonder if we ever wan
robertphillips
2013/09/17 19:51:16
Done.
|
| + |
| /** |
| * Subclass overrides if it has any limitations of stenciling support. |
| */ |
| - virtual StencilSupport onGetStencilSupport(const SkPath&, |
| - const SkStrokeRec&, |
| + virtual StencilSupport onGetStencilSupport(const SkStrokeRec&, |
| const GrDrawTarget*) const { |
| return kNoRestriction_StencilSupport; |
| } |
| @@ -150,8 +154,7 @@ |
| /** |
| * Subclass implementation of drawPath() |
| */ |
| - virtual bool onDrawPath(const SkPath& path, |
| - const SkStrokeRec& stroke, |
| + virtual bool onDrawPath(const SkStrokeRec& stroke, |
| GrDrawTarget* target, |
| bool antiAlias) = 0; |
| @@ -159,7 +162,7 @@ |
| * Subclass implementation of stencilPath(). Subclass must override iff it ever returns |
| * kStencilOnly in onGetStencilSupport(). |
| */ |
| - virtual void onStencilPath(const SkPath& path, const SkStrokeRec& stroke, GrDrawTarget* target) { |
| + virtual void onStencilPath(const SkStrokeRec& stroke, GrDrawTarget* target) { |
| GrDrawTarget::AutoStateRestore asr(target, GrDrawTarget::kPreserve_ASRInit); |
| GrDrawState* drawState = target->drawState(); |
| GR_STATIC_CONST_SAME_STENCIL(kIncrementStencil, |
| @@ -171,7 +174,7 @@ |
| 0xffff); |
| drawState->setStencil(kIncrementStencil); |
| drawState->enableState(GrDrawState::kNoColorWrites_StateBit); |
| - this->drawPath(path, stroke, target, false); |
| + this->drawPath(stroke, target, false); |
| } |
| // Helper for getting the device bounds of a path. Inverse filled paths will have bounds set |
| @@ -191,7 +194,6 @@ |
| } |
| private: |
| - |
| typedef SkRefCnt INHERITED; |
| }; |