Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1606)

Unified Diff: src/gpu/GrPathRenderer.h

Issue 142543007: Revert of r13384 (Stateful PathRenderer implementation) (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/GrDefaultPathRenderer.cpp ('k') | src/gpu/GrPathRendererChain.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrPathRenderer.h
===================================================================
--- src/gpu/GrPathRenderer.h (revision 13407)
+++ src/gpu/GrPathRenderer.h (working copy)
@@ -74,108 +74,70 @@
GrPathRendererChain::kNoRestriction_StencilSupport;
/**
- * This function is to get the stencil support for the current path. The path's fill must
+ * This function is to get the stencil support for a particular 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 SkStrokeRec& stroke,
+ StencilSupport getStencilSupport(const SkPath& path,
+ const SkStrokeRec& stroke,
const GrDrawTarget* target) const {
- SkASSERT(!fPath.isInverseFillType());
- return this->onGetStencilSupport(stroke, target);
+ SkASSERT(!path.isInverseFillType());
+ return this->onGetStencilSupport(path, 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) {
- SkASSERT(fPath.isEmpty());
- fPath = path;
- fPath.setFillType(fillType);
- }
-
- void resetPath() {
- fPath.reset();
- }
-
/**
- * 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.
+ * 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.
*
+ * @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 SkStrokeRec& stroke,
+ virtual bool canDrawPath(const SkPath& path,
+ const SkStrokeRec& rec,
const GrDrawTarget* target,
bool antiAlias) const = 0;
/**
- * 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.
+ * 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.
*
+ * @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 SkStrokeRec& stroke,
+ bool drawPath(const SkPath& path,
+ const SkStrokeRec& stroke,
GrDrawTarget* target,
bool antiAlias) {
- SkASSERT(!fPath.isEmpty());
- SkASSERT(this->canDrawPath(stroke, target, antiAlias));
+ SkASSERT(!path.isEmpty());
+ SkASSERT(this->canDrawPath(path, stroke, target, antiAlias));
SkASSERT(target->drawState()->getStencil().isDisabled() ||
- kNoRestriction_StencilSupport == this->getStencilSupport(stroke, target));
- return this->onDrawPath(stroke, target, antiAlias);
+ kNoRestriction_StencilSupport == this->getStencilSupport(path, stroke, target));
+ return this->onDrawPath(path, stroke, target, antiAlias);
}
/**
- * 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.
+ * 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.
*
+ * @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 SkStrokeRec& stroke, GrDrawTarget* target) {
- SkASSERT(!fPath.isEmpty());
- SkASSERT(kNoSupport_StencilSupport != this->getStencilSupport(stroke, target));
- this->onStencilPath(stroke, target);
+ 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);
}
- class AutoClearPath : ::SkNoncopyable {
- public:
- AutoClearPath(GrPathRenderer* renderer) : fRenderer(renderer) {}
- AutoClearPath() : fRenderer(NULL) {}
- ~AutoClearPath() {
- this->reset();
- }
-
- GrPathRenderer* renderer() {
- return fRenderer;
- }
-
- void set(GrPathRenderer* renderer) {
- this->reset();
- fRenderer = renderer;
- }
-
- GrPathRenderer* operator->() { return fRenderer; }
-
- private:
- void reset() {
- if (NULL != fRenderer) {
- fRenderer->resetPath();
- }
- fRenderer = NULL;
- }
-
- GrPathRenderer* fRenderer;
- };
-
// Helper for determining if we can treat a thin stroke as a hairline w/ coverage.
// If we can, we draw lots faster (raster device does this same test).
static bool IsStrokeHairlineOrEquivalent(const SkStrokeRec& stroke, const SkMatrix& matrix,
@@ -191,14 +153,11 @@
}
protected:
- const SkPath& path() const {
- return fPath;
- }
-
/**
* Subclass overrides if it has any limitations of stenciling support.
*/
- virtual StencilSupport onGetStencilSupport(const SkStrokeRec&,
+ virtual StencilSupport onGetStencilSupport(const SkPath&,
+ const SkStrokeRec&,
const GrDrawTarget*) const {
return kNoRestriction_StencilSupport;
}
@@ -206,7 +165,8 @@
/**
* Subclass implementation of drawPath()
*/
- virtual bool onDrawPath(const SkStrokeRec& stroke,
+ virtual bool onDrawPath(const SkPath& path,
+ const SkStrokeRec& stroke,
GrDrawTarget* target,
bool antiAlias) = 0;
@@ -214,7 +174,7 @@
* Subclass implementation of stencilPath(). Subclass must override iff it ever returns
* kStencilOnly in onGetStencilSupport().
*/
- virtual void onStencilPath(const SkStrokeRec& stroke, GrDrawTarget* target) {
+ virtual void onStencilPath(const SkPath& path, const SkStrokeRec& stroke, GrDrawTarget* target) {
GrDrawTarget::AutoStateRestore asr(target, GrDrawTarget::kPreserve_ASRInit);
GrDrawState* drawState = target->drawState();
GR_STATIC_CONST_SAME_STENCIL(kIncrementStencil,
@@ -226,7 +186,7 @@
0xffff);
drawState->setStencil(kIncrementStencil);
drawState->enableState(GrDrawState::kNoColorWrites_StateBit);
- this->drawPath(stroke, target, false);
+ this->drawPath(path, stroke, target, false);
}
// Helper for getting the device bounds of a path. Inverse filled paths will have bounds set
@@ -246,7 +206,6 @@
}
private:
- SkPath fPath;
typedef SkRefCnt INHERITED;
};
« no previous file with comments | « src/gpu/GrDefaultPathRenderer.cpp ('k') | src/gpu/GrPathRendererChain.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698