Follow up on the previous patch :
- Moved the SkStrokeRec class in its own file
- Replaced SkStroke by SkStrokeRec in Ganesh
- Moved path stroking to the Ganesh level in some cases (everytime it isn't required to do it directly in SkGpuDevice). PathEffect and MaskFilter still require path stroking at the SkGpuDevice for now.
- Renamed static functions in SkPath with proper names
* No functionality shold have changed with this patch. This is a step towards enabling Ganesh Path Renderers to decide whether or not to stroke the path rather than always receiving the stroked path as an input argument.
BUG=chromium:135111
TEST=Try path rendering tests from the gm
Review URL: https://codereview.appspot.com/6946072
git-svn-id: http://skia.googlecode.com/svn/trunk@6861 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index f688b7a..d00e062 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -23,10 +23,10 @@
#include "GrSoftwarePathRenderer.h"
#include "GrStencilBuffer.h"
#include "GrTextStrike.h"
+#include "SkStrokeRec.h"
#include "SkTLazy.h"
#include "SkTLS.h"
#include "SkTrace.h"
-#include "SkStroke.h"
SK_DEFINE_INST_COUNT(GrContext)
SK_DEFINE_INST_COUNT(GrDrawState)
@@ -720,7 +720,7 @@
return;
}
if (width >= 0) {
- GrVec strokeSize;;
+ GrVec strokeSize;
if (width > 0) {
strokeSize.set(width, width);
combinedMatrix.mapVectors(&strokeSize, 1);
@@ -982,11 +982,10 @@
SkPath path;
path.addOval(rect);
path.setFillType(SkPath::kWinding_FillType);
- SkStroke stroke;
- if (strokeWidth < 0) {
- stroke.setDoFill(true);
- } else {
- stroke.setWidth(strokeWidth);
+ SkStrokeRec stroke(0 == strokeWidth ? SkStrokeRec::kHairline_InitStyle :
+ SkStrokeRec::kFill_InitStyle);
+ if (strokeWidth > 0) {
+ stroke.setStrokeStyle(strokeWidth, true);
}
this->internalDrawPath(paint, path, stroke);
return;
@@ -1058,7 +1057,7 @@
target->drawNonIndexed(kTriangleStrip_GrPrimitiveType, 0, 4);
}
-void GrContext::drawPath(const GrPaint& paint, const SkPath& path, bool doHairLine) {
+void GrContext::drawPath(const GrPaint& paint, const SkPath& path, const SkStrokeRec& stroke) {
if (path.isEmpty()) {
if (path.isInverseFillType()) {
@@ -1067,24 +1066,27 @@
return;
}
+ const SkPath* pathPtr = &path;
+ SkPath tmpPath;
+ SkStrokeRec strokeRec(stroke);
+ if (!strokeRec.isHairlineStyle()) {
+ if (strokeRec.applyToPath(&tmpPath, *pathPtr)) {
+ pathPtr = &tmpPath;
+ strokeRec.setFillStyle();
+ }
+ }
+
SkRect ovalRect;
- if (!path.isInverseFillType() && path.isOval(&ovalRect)) {
- SkScalar width = doHairLine ? 0 : -SK_Scalar1;
+ if (!pathPtr->isInverseFillType() && pathPtr->isOval(&ovalRect)) {
+ SkScalar width = strokeRec.isHairlineStyle() ? 0 : -SK_Scalar1;
this->drawOval(paint, ovalRect, width);
return;
}
- SkStroke stroke;
- if (doHairLine) {
- stroke.setWidth(0);
- } else {
- stroke.setDoFill(true);
- }
-
- this->internalDrawPath(paint, path, stroke);
+ this->internalDrawPath(paint, *pathPtr, strokeRec);
}
-void GrContext::internalDrawPath(const GrPaint& paint, const SkPath& path, const SkStroke& stroke) {
+void GrContext::internalDrawPath(const GrPaint& paint, const SkPath& path, const SkStrokeRec& stroke) {
// Note that below we may sw-rasterize the path into a scratch texture.
// Scratch textures can be recycled after they are returned to the texture
@@ -1616,7 +1618,7 @@
* can be individually allowed/disallowed via the "allowSW" boolean.
*/
GrPathRenderer* GrContext::getPathRenderer(const SkPath& path,
- const SkStroke& stroke,
+ const SkStrokeRec& stroke,
const GrDrawTarget* target,
bool allowSW,
GrPathRendererChain::DrawType drawType,