OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "GrDashingEffect.h" | 8 #include "GrDashingEffect.h" |
9 | 9 |
10 #include "../GrAARectRenderer.h" | 10 #include "../GrAARectRenderer.h" |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 | 187 |
188 SkScalar srcPhase = info.fPhase; | 188 SkScalar srcPhase = info.fPhase; |
189 | 189 |
190 // Rotate the src pts so they are aligned horizontally with pts[0].fX < pts[
1].fX | 190 // Rotate the src pts so they are aligned horizontally with pts[0].fX < pts[
1].fX |
191 SkMatrix srcRotInv; | 191 SkMatrix srcRotInv; |
192 SkPoint ptsRot[2]; | 192 SkPoint ptsRot[2]; |
193 if (pts[0].fY != pts[1].fY || pts[0].fX > pts[1].fX) { | 193 if (pts[0].fY != pts[1].fY || pts[0].fX > pts[1].fX) { |
194 SkMatrix rotMatrix; | 194 SkMatrix rotMatrix; |
195 align_to_x_axis(pts, &rotMatrix, ptsRot); | 195 align_to_x_axis(pts, &rotMatrix, ptsRot); |
196 if(!rotMatrix.invert(&srcRotInv)) { | 196 if(!rotMatrix.invert(&srcRotInv)) { |
197 GrPrintf("Failed to create invertible rotation matrix!\n"); | 197 SkDebugf("Failed to create invertible rotation matrix!\n"); |
198 return false; | 198 return false; |
199 } | 199 } |
200 } else { | 200 } else { |
201 srcRotInv.reset(); | 201 srcRotInv.reset(); |
202 memcpy(ptsRot, pts, 2 * sizeof(SkPoint)); | 202 memcpy(ptsRot, pts, 2 * sizeof(SkPoint)); |
203 } | 203 } |
204 | 204 |
205 bool useAA = paint.isAntiAlias(); | 205 bool useAA = paint.isAntiAlias(); |
206 | 206 |
207 // Scale corrections of intervals and stroke from view matrix | 207 // Scale corrections of intervals and stroke from view matrix |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 } | 362 } |
363 | 363 |
364 int totalRectCnt = 0; | 364 int totalRectCnt = 0; |
365 | 365 |
366 totalRectCnt += !lineDone ? 1 : 0; | 366 totalRectCnt += !lineDone ? 1 : 0; |
367 totalRectCnt += hasStartRect ? 1 : 0; | 367 totalRectCnt += hasStartRect ? 1 : 0; |
368 totalRectCnt += hasEndRect ? 1 : 0; | 368 totalRectCnt += hasEndRect ? 1 : 0; |
369 | 369 |
370 GrDrawTarget::AutoReleaseGeometry geo(target, totalRectCnt * 4, 0); | 370 GrDrawTarget::AutoReleaseGeometry geo(target, totalRectCnt * 4, 0); |
371 if (!geo.succeeded()) { | 371 if (!geo.succeeded()) { |
372 GrPrintf("Failed to get space for vertices!\n"); | 372 SkDebugf("Failed to get space for vertices!\n"); |
373 return false; | 373 return false; |
374 } | 374 } |
375 | 375 |
376 DashLineVertex* verts = reinterpret_cast<DashLineVertex*>(geo.vertices()); | 376 DashLineVertex* verts = reinterpret_cast<DashLineVertex*>(geo.vertices()); |
377 | 377 |
378 int curVIdx = 0; | 378 int curVIdx = 0; |
379 | 379 |
380 if (SkPaint::kRound_Cap == cap && 0 != srcStrokeWidth) { | 380 if (SkPaint::kRound_Cap == cap && 0 != srcStrokeWidth) { |
381 // need to adjust this for round caps to correctly set the dashPos attri
b on vertices | 381 // need to adjust this for round caps to correctly set the dashPos attri
b on vertices |
382 startOffset -= halfDevStroke; | 382 startOffset -= halfDevStroke; |
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
841 switch (cap) { | 841 switch (cap) { |
842 case GrDashingEffect::kRound_DashCap: | 842 case GrDashingEffect::kRound_DashCap: |
843 return DashingCircleEffect::Create(edgeType, info, SkScalarHalf(stro
keWidth)); | 843 return DashingCircleEffect::Create(edgeType, info, SkScalarHalf(stro
keWidth)); |
844 case GrDashingEffect::kNonRound_DashCap: | 844 case GrDashingEffect::kNonRound_DashCap: |
845 return DashingLineEffect::Create(edgeType, info, strokeWidth); | 845 return DashingLineEffect::Create(edgeType, info, strokeWidth); |
846 default: | 846 default: |
847 SkFAIL("Unexpected dashed cap."); | 847 SkFAIL("Unexpected dashed cap."); |
848 } | 848 } |
849 return NULL; | 849 return NULL; |
850 } | 850 } |
OLD | NEW |