Index: src/gpu/effects/GrDashingEffect.cpp |
diff --git a/src/gpu/effects/GrDashingEffect.cpp b/src/gpu/effects/GrDashingEffect.cpp |
index 339e44a83c352a6a63668c26ac5b0089276b27ee..7e24d96bb83c963743b71fa1ecc944e84b70f77d 100644 |
--- a/src/gpu/effects/GrDashingEffect.cpp |
+++ b/src/gpu/effects/GrDashingEffect.cpp |
@@ -165,11 +165,9 @@ static void setup_dashed_rect_pos(const SkRect& rect, int idx, const SkMatrix& m |
} |
bool GrDashingEffect::DrawDashLine(GrGpu* gpu, GrDrawTarget* target, GrDrawState* drawState, |
- GrColor color, const SkPoint pts[2], const GrPaint& paint, |
- const GrStrokeInfo& strokeInfo) { |
- const SkMatrix& vm = drawState->getViewMatrix(); |
- |
- if (!can_fast_path_dash(pts, strokeInfo, *target, *drawState, vm)) { |
+ GrColor color, const SkMatrix& viewMatrix, const SkPoint pts[2], |
+ const GrPaint& paint, const GrStrokeInfo& strokeInfo) { |
+ if (!can_fast_path_dash(pts, strokeInfo, *target, *drawState, viewMatrix)) { |
return false; |
} |
@@ -204,7 +202,7 @@ bool GrDashingEffect::DrawDashLine(GrGpu* gpu, GrDrawTarget* target, GrDrawState |
// Scale corrections of intervals and stroke from view matrix |
SkScalar parallelScale; |
SkScalar perpScale; |
- calc_dash_scaling(¶llelScale, &perpScale, vm, ptsRot); |
+ calc_dash_scaling(¶llelScale, &perpScale, viewMatrix, ptsRot); |
bool hasCap = SkPaint::kButt_Cap != cap && 0 != srcStrokeWidth; |
@@ -222,7 +220,7 @@ bool GrDashingEffect::DrawDashLine(GrGpu* gpu, GrDrawTarget* target, GrDrawState |
SkScalar startAdj = 0; |
SkMatrix combinedMatrix = srcRotInv; |
- combinedMatrix.postConcat(vm); |
+ combinedMatrix.postConcat(viewMatrix); |
bool lineDone = false; |
SkRect startRect; |
@@ -328,7 +326,7 @@ bool GrDashingEffect::DrawDashLine(GrGpu* gpu, GrDrawTarget* target, GrDrawState |
lineDone = true; |
SkPoint devicePts[2]; |
- vm.mapPoints(devicePts, ptsRot, 2); |
+ viewMatrix.mapPoints(devicePts, ptsRot, 2); |
SkScalar lineLength = SkPoint::Distance(devicePts[0], devicePts[1]); |
if (hasCap) { |
lineLength += 2.f * halfDevStroke; |
@@ -338,13 +336,11 @@ bool GrDashingEffect::DrawDashLine(GrGpu* gpu, GrDrawTarget* target, GrDrawState |
// reset to device coordinates |
SkMatrix invert; |
- if (!vm.invert(&invert)) { |
+ if (!viewMatrix.invert(&invert)) { |
SkDebugf("Failed to invert\n"); |
return false; |
} |
- GrDrawState::AutoViewMatrixRestore avmr(drawState); |
- |
SkAutoTUnref<const GrGeometryProcessor> gp; |
bool fullDash = devIntervals[1] > 0.f || useAA; |
if (fullDash) { |
@@ -357,10 +353,13 @@ bool GrDashingEffect::DrawDashLine(GrGpu* gpu, GrDrawTarget* target, GrDrawState |
bool isRoundCap = SkPaint::kRound_Cap == cap; |
GrDashingEffect::DashCap capType = isRoundCap ? GrDashingEffect::kRound_DashCap : |
GrDashingEffect::kNonRound_DashCap; |
- gp.reset(GrDashingEffect::Create(color, edgeType, devInfo, strokeWidth, capType, invert)); |
+ gp.reset(GrDashingEffect::Create(color, SkMatrix::I(), edgeType, devInfo, strokeWidth, |
bsalomon
2014/12/29 18:35:46
For GPs that are only ever instantiated with I() s
joshualitt
2014/12/29 19:23:38
Acknowledged.
|
+ capType, invert)); |
} else { |
// Set up the vertex data for the line and start/end dashes |
- gp.reset(GrDefaultGeoProcFactory::Create(color, GrDefaultGeoProcFactory::kPosition_GPType, |
+ gp.reset(GrDefaultGeoProcFactory::Create(GrDefaultGeoProcFactory::kPosition_GPType, |
+ color, |
+ SkMatrix::I(), |
invert)); |
} |
@@ -388,7 +387,7 @@ bool GrDashingEffect::DrawDashLine(GrGpu* gpu, GrDrawTarget* target, GrDrawState |
// Draw interior part of dashed line |
if (!lineDone) { |
SkPoint devicePts[2]; |
- vm.mapPoints(devicePts, ptsRot, 2); |
+ viewMatrix.mapPoints(devicePts, ptsRot, 2); |
SkScalar lineLength = SkPoint::Distance(devicePts[0], devicePts[1]); |
if (hasCap) { |
lineLength += 2.f * halfDevStroke; |
@@ -473,6 +472,7 @@ public: |
typedef SkPathEffect::DashInfo DashInfo; |
static GrGeometryProcessor* Create(GrColor, |
+ const SkMatrix& viewMatrix, |
GrPrimitiveEdgeType edgeType, |
const DashInfo& info, |
SkScalar radius, |
@@ -507,8 +507,8 @@ public: |
const GrBatchTracker&) const SK_OVERRIDE; |
private: |
- DashingCircleEffect(GrColor, GrPrimitiveEdgeType edgeType, const DashInfo& info, |
- SkScalar radius, const SkMatrix& localMatrix); |
+ DashingCircleEffect(GrColor, const SkMatrix& viewMatrix, GrPrimitiveEdgeType edgeType, |
+ const DashInfo& info, SkScalar radius, const SkMatrix& localMatrix); |
virtual bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE; |
@@ -643,6 +643,7 @@ void GLDashingCircleEffect::GenKey(const GrGeometryProcessor& processor, |
////////////////////////////////////////////////////////////////////////////// |
GrGeometryProcessor* DashingCircleEffect::Create(GrColor color, |
+ const SkMatrix& viewMatrix, |
GrPrimitiveEdgeType edgeType, |
const DashInfo& info, |
SkScalar radius, |
@@ -651,7 +652,8 @@ GrGeometryProcessor* DashingCircleEffect::Create(GrColor color, |
return NULL; |
} |
- return SkNEW_ARGS(DashingCircleEffect, (color, edgeType, info, radius, localMatrix)); |
+ return SkNEW_ARGS(DashingCircleEffect, (color, viewMatrix, edgeType, info, radius, |
+ localMatrix)); |
} |
DashingCircleEffect::~DashingCircleEffect() {} |
@@ -671,11 +673,12 @@ GrGLGeometryProcessor* DashingCircleEffect::createGLInstance(const GrBatchTracke |
} |
DashingCircleEffect::DashingCircleEffect(GrColor color, |
+ const SkMatrix& viewMatrix, |
GrPrimitiveEdgeType edgeType, |
const DashInfo& info, |
SkScalar radius, |
const SkMatrix& localMatrix) |
- : INHERITED(color, false, localMatrix), fEdgeType(edgeType) { |
+ : INHERITED(color, viewMatrix, localMatrix), fEdgeType(edgeType) { |
this->initClassID<DashingCircleEffect>(); |
fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_GrVertexAttribType)); |
fInCoord = &this->addVertexAttrib(GrAttribute("inCoord", kVec2f_GrVertexAttribType)); |
@@ -728,7 +731,9 @@ GrGeometryProcessor* DashingCircleEffect::TestCreate(SkRandom* random, |
info.fIntervals[1] = random->nextRangeScalar(0, 10.f); |
info.fPhase = random->nextRangeScalar(0, info.fIntervals[1]); |
- return DashingCircleEffect::Create(GrRandomColor(random), edgeType, info, strokeWidth, |
+ return DashingCircleEffect::Create(GrRandomColor(random), |
+ GrProcessorUnitTest::TestMatrix(random), |
+ edgeType, info, strokeWidth, |
GrProcessorUnitTest::TestMatrix(random)); |
} |
@@ -756,6 +761,7 @@ public: |
typedef SkPathEffect::DashInfo DashInfo; |
static GrGeometryProcessor* Create(GrColor, |
+ const SkMatrix& viewMatrix, |
GrPrimitiveEdgeType edgeType, |
const DashInfo& info, |
SkScalar strokeWidth, |
@@ -788,8 +794,8 @@ public: |
const GrBatchTracker&) const SK_OVERRIDE; |
private: |
- DashingLineEffect(GrColor, GrPrimitiveEdgeType edgeType, const DashInfo& info, |
- SkScalar strokeWidth, const SkMatrix& localMatrix); |
+ DashingLineEffect(GrColor, const SkMatrix& viewMatrix, GrPrimitiveEdgeType edgeType, |
+ const DashInfo& info, SkScalar strokeWidth, const SkMatrix& localMatrix); |
virtual bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE; |
@@ -937,6 +943,7 @@ void GLDashingLineEffect::GenKey(const GrGeometryProcessor& processor, |
////////////////////////////////////////////////////////////////////////////// |
GrGeometryProcessor* DashingLineEffect::Create(GrColor color, |
+ const SkMatrix& viewMatrix, |
GrPrimitiveEdgeType edgeType, |
const DashInfo& info, |
SkScalar strokeWidth, |
@@ -945,7 +952,8 @@ GrGeometryProcessor* DashingLineEffect::Create(GrColor color, |
return NULL; |
} |
- return SkNEW_ARGS(DashingLineEffect, (color, edgeType, info, strokeWidth, localMatrix)); |
+ return SkNEW_ARGS(DashingLineEffect, (color, viewMatrix, edgeType, info, strokeWidth, |
+ localMatrix)); |
} |
DashingLineEffect::~DashingLineEffect() {} |
@@ -965,11 +973,12 @@ GrGLGeometryProcessor* DashingLineEffect::createGLInstance(const GrBatchTracker& |
} |
DashingLineEffect::DashingLineEffect(GrColor color, |
+ const SkMatrix& viewMatrix, |
GrPrimitiveEdgeType edgeType, |
const DashInfo& info, |
SkScalar strokeWidth, |
const SkMatrix& localMatrix) |
- : INHERITED(color, false, localMatrix), fEdgeType(edgeType) { |
+ : INHERITED(color, viewMatrix, localMatrix), fEdgeType(edgeType) { |
this->initClassID<DashingLineEffect>(); |
fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_GrVertexAttribType)); |
fInCoord = &this->addVertexAttrib(GrAttribute("inCoord", kVec2f_GrVertexAttribType)); |
@@ -1022,13 +1031,16 @@ GrGeometryProcessor* DashingLineEffect::TestCreate(SkRandom* random, |
info.fIntervals[1] = random->nextRangeScalar(0, 10.f); |
info.fPhase = random->nextRangeScalar(0, info.fIntervals[0] + info.fIntervals[1]); |
- return DashingLineEffect::Create(GrRandomColor(random), edgeType, info, strokeWidth, |
+ return DashingLineEffect::Create(GrRandomColor(random), |
+ GrProcessorUnitTest::TestMatrix(random), |
+ edgeType, info, strokeWidth, |
GrProcessorUnitTest::TestMatrix(random)); |
} |
////////////////////////////////////////////////////////////////////////////// |
GrGeometryProcessor* GrDashingEffect::Create(GrColor color, |
+ const SkMatrix& viewMatrix, |
GrPrimitiveEdgeType edgeType, |
const SkPathEffect::DashInfo& info, |
SkScalar strokeWidth, |
@@ -1036,10 +1048,12 @@ GrGeometryProcessor* GrDashingEffect::Create(GrColor color, |
const SkMatrix& localMatrix) { |
switch (cap) { |
case GrDashingEffect::kRound_DashCap: |
- return DashingCircleEffect::Create(color, edgeType, info, SkScalarHalf(strokeWidth), |
+ return DashingCircleEffect::Create(color, viewMatrix, edgeType, info, |
+ SkScalarHalf(strokeWidth), |
localMatrix); |
case GrDashingEffect::kNonRound_DashCap: |
- return DashingLineEffect::Create(color, edgeType, info, strokeWidth, localMatrix); |
+ return DashingLineEffect::Create(color, viewMatrix, edgeType, info, strokeWidth, |
+ localMatrix); |
default: |
SkFAIL("Unexpected dashed cap."); |
} |