Index: src/gpu/GrContext.cpp |
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp |
index 66588c46bce32c1f161e52ce532e3ca2d8ecf6a9..1c0bae1927499a5df0ed0bacdccbfe788021b381 100644 |
--- a/src/gpu/GrContext.cpp |
+++ b/src/gpu/GrContext.cpp |
@@ -25,8 +25,10 @@ |
#include "GrResourceCache.h" |
#include "GrSoftwarePathRenderer.h" |
#include "GrStencilBuffer.h" |
+#include "GrStrokeInfo.h" |
#include "GrTextStrike.h" |
#include "GrTracing.h" |
+#include "SkDashPathPriv.h" |
#include "SkGr.h" |
#include "SkRTConf.h" |
#include "SkRRect.h" |
@@ -775,15 +777,22 @@ static inline bool rect_contains_inclusive(const SkRect& rect, const SkPoint& po |
void GrContext::drawRect(const GrPaint& paint, |
const SkRect& rect, |
- const SkStrokeRec* stroke, |
+ const GrStrokeInfo* strokeInfo, |
bsalomon
2014/06/05 19:22:54
Why does this take a StrokeRec* and others a Strok
egdaniel
2014/06/05 20:18:17
There are a few locations throughout the code that
|
const SkMatrix* matrix) { |
robertphillips
2014/06/05 18:28:00
NULL != ?
egdaniel
2014/06/05 19:07:23
Yes to this and all the other ones
egdaniel
2014/06/05 19:07:23
yes to this and all the other ones
|
+ if (strokeInfo && strokeInfo->isDashed()) { |
+ SkPath path; |
+ path.addRect(rect); |
+ this->drawPath(paint, path, *strokeInfo); |
+ return; |
+ } |
+ |
AutoRestoreEffects are; |
AutoCheckFlush acf(this); |
GrDrawTarget* target = this->prepareToDraw(&paint, BUFFERED_DRAW, &are, &acf); |
GR_CREATE_TRACE_MARKER("GrContext::drawRect", target); |
robertphillips
2014/06/05 18:28:01
NULL ==
|
- SkScalar width = stroke == NULL ? -1 : stroke->getWidth(); |
+ SkScalar width = !strokeInfo ? -1 : strokeInfo->getStrokeRec().getWidth(); |
SkMatrix combinedMatrix = target->drawState()->getViewMatrix(); |
if (NULL != matrix) { |
combinedMatrix.preConcat(*matrix); |
@@ -830,6 +839,9 @@ void GrContext::drawRect(const GrPaint& paint, |
!target->getDrawState().getRenderTarget()->isMultisampled(); |
bool doAA = needAA && apply_aa_to_rect(target, rect, width, combinedMatrix, &devBoundRect, |
&useVertexCoverage); |
+ |
robertphillips
2014/06/05 18:28:00
strokeRec ?
egdaniel
2014/06/05 19:07:23
sure
|
+ const SkStrokeRec& stroke = strokeInfo->getStrokeRec(); |
+ |
if (doAA) { |
GrDrawState::AutoViewMatrixRestore avmr; |
if (!avmr.setIdentity(target->drawState())) { |
@@ -1006,21 +1018,30 @@ void GrContext::drawVertices(const GrPaint& paint, |
void GrContext::drawRRect(const GrPaint& paint, |
const SkRRect& rrect, |
- const SkStrokeRec& stroke) { |
+ const GrStrokeInfo& strokeInfo) { |
if (rrect.isEmpty()) { |
return; |
} |
+ if (strokeInfo.isDashed()) { |
+ SkPath path; |
+ path.addRRect(rrect); |
+ this->drawPath(paint, path, strokeInfo); |
+ return; |
+ } |
+ |
AutoRestoreEffects are; |
AutoCheckFlush acf(this); |
GrDrawTarget* target = this->prepareToDraw(&paint, BUFFERED_DRAW, &are, &acf); |
GR_CREATE_TRACE_MARKER("GrContext::drawRRect", target); |
robertphillips
2014/06/05 18:28:01
strokeRec ?
|
+ const SkStrokeRec& stroke = strokeInfo.getStrokeRec(); |
+ |
if (!fOvalRenderer->drawRRect(target, this, paint.isAntiAlias(), rrect, stroke)) { |
SkPath path; |
path.addRRect(rrect); |
- this->internalDrawPath(target, paint.isAntiAlias(), path, stroke); |
+ this->internalDrawPath(target, paint.isAntiAlias(), path, strokeInfo); |
} |
} |
@@ -1045,7 +1066,7 @@ void GrContext::drawDRRect(const GrPaint& paint, |
path.addRRect(outer); |
path.setFillType(SkPath::kEvenOdd_FillType); |
- SkStrokeRec fillRec(SkStrokeRec::kFill_InitStyle); |
+ GrStrokeInfo fillRec(SkStrokeRec::kFill_InitStyle); |
this->internalDrawPath(target, paint.isAntiAlias(), path, fillRec); |
} |
} |
@@ -1054,21 +1075,31 @@ void GrContext::drawDRRect(const GrPaint& paint, |
void GrContext::drawOval(const GrPaint& paint, |
const SkRect& oval, |
- const SkStrokeRec& stroke) { |
+ const GrStrokeInfo& strokeInfo) { |
if (oval.isEmpty()) { |
return; |
} |
+ if (strokeInfo.isDashed()) { |
+ SkPath path; |
+ path.addOval(oval); |
+ this->drawPath(paint, path, strokeInfo); |
+ return; |
+ } |
+ |
AutoRestoreEffects are; |
AutoCheckFlush acf(this); |
GrDrawTarget* target = this->prepareToDraw(&paint, BUFFERED_DRAW, &are, &acf); |
GR_CREATE_TRACE_MARKER("GrContext::drawOval", target); |
robertphillips
2014/06/05 18:28:00
strokeRec ?
|
+ const SkStrokeRec& stroke = strokeInfo.getStrokeRec(); |
+ |
+ |
if (!fOvalRenderer->drawOval(target, this, paint.isAntiAlias(), oval, stroke)) { |
SkPath path; |
path.addOval(oval); |
- this->internalDrawPath(target, paint.isAntiAlias(), path, stroke); |
+ this->internalDrawPath(target, paint.isAntiAlias(), path, strokeInfo); |
} |
} |
@@ -1127,7 +1158,7 @@ static bool is_nested_rects(GrDrawTarget* target, |
return true; |
} |
-void GrContext::drawPath(const GrPaint& paint, const SkPath& path, const SkStrokeRec& stroke) { |
+void GrContext::drawPath(const GrPaint& paint, const SkPath& path, const GrStrokeInfo& strokeInfo) { |
if (path.isEmpty()) { |
if (path.isInverseFillType()) { |
@@ -1136,6 +1167,21 @@ void GrContext::drawPath(const GrPaint& paint, const SkPath& path, const SkStrok |
return; |
} |
+ if (strokeInfo.isDashed()) { |
+ const SkPathEffect::DashInfo& info = strokeInfo.getDashInfo(); |
+ SkTLazy<SkPath> effectPath; |
robertphillips
2014/06/05 18:28:00
Do we need cullRect here ? Can we just pass NULL t
egdaniel
2014/06/05 19:07:23
So I was matching the format used by the filterPat
|
+ const SkRect* cullRect = NULL; |
+ GrStrokeInfo newStrokeInfo(strokeInfo, false); |
+ SkStrokeRec* stroke = newStrokeInfo.getStrokeRecPtr(); |
+ if (SkDashPath::FilterDashPath(effectPath.init(), path, stroke, cullRect, info)) { |
+ this->drawPath(paint, *effectPath.get(), newStrokeInfo); |
+ return; |
+ } |
+ |
+ this->drawPath(paint, path, newStrokeInfo); |
+ return; |
+ } |
+ |
// Note that internalDrawPath may sw-rasterize the path into a scratch texture. |
// Scratch textures can be recycled after they are returned to the texture |
// cache. This presents a potential hazard for buffered drawing. However, |
@@ -1148,6 +1194,8 @@ void GrContext::drawPath(const GrPaint& paint, const SkPath& path, const SkStrok |
GR_CREATE_TRACE_MARKER("GrContext::drawPath", target); |
robertphillips
2014/06/05 18:28:00
strokeRec ?
|
+ const SkStrokeRec& stroke = strokeInfo.getStrokeRec(); |
+ |
bool useCoverageAA = paint.isAntiAlias() && !drawState->getRenderTarget()->isMultisampled(); |
if (useCoverageAA && stroke.getWidth() < 0 && !path.isConvex()) { |
@@ -1175,12 +1223,12 @@ void GrContext::drawPath(const GrPaint& paint, const SkPath& path, const SkStrok |
if (!isOval || path.isInverseFillType() |
|| !fOvalRenderer->drawOval(target, this, paint.isAntiAlias(), ovalRect, stroke)) { |
- this->internalDrawPath(target, paint.isAntiAlias(), path, stroke); |
+ this->internalDrawPath(target, paint.isAntiAlias(), path, strokeInfo); |
} |
} |
void GrContext::internalDrawPath(GrDrawTarget* target, bool useAA, const SkPath& path, |
- const SkStrokeRec& origStroke) { |
+ const GrStrokeInfo& strokeInfo) { |
SkASSERT(!path.isEmpty()); |
GR_CREATE_TRACE_MARKER("GrContext::internalDrawPath", target); |
@@ -1201,7 +1249,7 @@ void GrContext::internalDrawPath(GrDrawTarget* target, bool useAA, const SkPath& |
const SkPath* pathPtr = &path; |
SkTLazy<SkPath> tmpPath; |
- SkTCopyOnFirstWrite<SkStrokeRec> stroke(origStroke); |
+ SkTCopyOnFirstWrite<SkStrokeRec> stroke(strokeInfo.getStrokeRec()); |
// Try a 1st time without stroking the path and without allowing the SW renderer |
GrPathRenderer* pr = this->getPathRenderer(*pathPtr, *stroke, target, false, type); |