aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrContext.cpp
diff options
context:
space:
mode:
authorGravatar sugoi@google.com <sugoi@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-12-17 21:16:45 +0000
committerGravatar sugoi@google.com <sugoi@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-12-17 21:16:45 +0000
commit5f74cf8c49701f514b69dc6f1a8b5c0ffd78af0a (patch)
tree3cec664355e570c921cd903dda21146806279185 /src/gpu/GrContext.cpp
parent9f6a557548b4aec8aa0d3345488089b3d75f471c (diff)
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
Diffstat (limited to 'src/gpu/GrContext.cpp')
-rw-r--r--src/gpu/GrContext.cpp42
1 files changed, 22 insertions, 20 deletions
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index f688b7ab67..d00e062fae 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 @@ void GrContext::drawRect(const GrPaint& paint,
return;
}
if (width >= 0) {
- GrVec strokeSize;;
+ GrVec strokeSize;
if (width > 0) {
strokeSize.set(width, width);
combinedMatrix.mapVectors(&strokeSize, 1);
@@ -982,11 +982,10 @@ void GrContext::drawOval(const GrPaint& paint,
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 @@ void GrContext::drawOval(const GrPaint& paint,
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 @@ void GrContext::drawPath(const GrPaint& paint, const SkPath& path, bool doHairLi
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 @@ GrDrawTarget* GrContext::prepareToDraw(const GrPaint* paint, BufferedDraw buffer
* 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,