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 "GrBatch.h" | 10 #include "GrBatch.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 | 44 |
45 if (!strokeInfo.isDashed() || 2 != strokeInfo.getDashCount()) { | 45 if (!strokeInfo.isDashed() || 2 != strokeInfo.getDashCount()) { |
46 return false; | 46 return false; |
47 } | 47 } |
48 | 48 |
49 const SkScalar* intervals = strokeInfo.getDashIntervals(); | 49 const SkScalar* intervals = strokeInfo.getDashIntervals(); |
50 if (0 == intervals[0] && 0 == intervals[1]) { | 50 if (0 == intervals[0] && 0 == intervals[1]) { |
51 return false; | 51 return false; |
52 } | 52 } |
53 | 53 |
54 SkPaint::Cap cap = strokeInfo.getStrokeRec().getCap(); | 54 SkPaint::Cap cap = strokeInfo.getCap(); |
55 // Current we do don't handle Round or Square cap dashes | 55 // Current we do don't handle Round or Square cap dashes |
56 if (SkPaint::kRound_Cap == cap && intervals[0] != 0.f) { | 56 if (SkPaint::kRound_Cap == cap && intervals[0] != 0.f) { |
57 return false; | 57 return false; |
58 } | 58 } |
59 | 59 |
60 return true; | 60 return true; |
61 } | 61 } |
62 | 62 |
63 namespace { | 63 namespace { |
64 struct DashLineVertex { | 64 struct DashLineVertex { |
(...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
677 | 677 |
678 BatchTracker fBatch; | 678 BatchTracker fBatch; |
679 SkSTArray<1, Geometry, true> fGeoData; | 679 SkSTArray<1, Geometry, true> fGeoData; |
680 }; | 680 }; |
681 | 681 |
682 static GrBatch* create_batch(GrColor color, const SkMatrix& viewMatrix, const Sk
Point pts[2], | 682 static GrBatch* create_batch(GrColor color, const SkMatrix& viewMatrix, const Sk
Point pts[2], |
683 bool useAA, const GrStrokeInfo& strokeInfo, bool ms
aaRT) { | 683 bool useAA, const GrStrokeInfo& strokeInfo, bool ms
aaRT) { |
684 const SkScalar* intervals = strokeInfo.getDashIntervals(); | 684 const SkScalar* intervals = strokeInfo.getDashIntervals(); |
685 SkScalar phase = strokeInfo.getDashPhase(); | 685 SkScalar phase = strokeInfo.getDashPhase(); |
686 | 686 |
687 SkPaint::Cap cap = strokeInfo.getStrokeRec().getCap(); | 687 SkPaint::Cap cap = strokeInfo.getCap(); |
688 | 688 |
689 DashBatch::Geometry geometry; | 689 DashBatch::Geometry geometry; |
690 geometry.fSrcStrokeWidth = strokeInfo.getStrokeRec().getWidth(); | 690 geometry.fSrcStrokeWidth = strokeInfo.getWidth(); |
691 | 691 |
692 // the phase should be normalized to be [0, sum of all intervals) | 692 // the phase should be normalized to be [0, sum of all intervals) |
693 SkASSERT(phase >= 0 && phase < intervals[0] + intervals[1]); | 693 SkASSERT(phase >= 0 && phase < intervals[0] + intervals[1]); |
694 | 694 |
695 // Rotate the src pts so they are aligned horizontally with pts[0].fX < pts[
1].fX | 695 // Rotate the src pts so they are aligned horizontally with pts[0].fX < pts[
1].fX |
696 if (pts[0].fY != pts[1].fY || pts[0].fX > pts[1].fX) { | 696 if (pts[0].fY != pts[1].fY || pts[0].fX > pts[1].fX) { |
697 SkMatrix rotMatrix; | 697 SkMatrix rotMatrix; |
698 align_to_x_axis(pts, &rotMatrix, geometry.fPtsRot); | 698 align_to_x_axis(pts, &rotMatrix, geometry.fPtsRot); |
699 if(!rotMatrix.invert(&geometry.fSrcRotInv)) { | 699 if(!rotMatrix.invert(&geometry.fSrcRotInv)) { |
700 SkDebugf("Failed to create invertible rotation matrix!\n"); | 700 SkDebugf("Failed to create invertible rotation matrix!\n"); |
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1303 info.fIntervals = intervals; | 1303 info.fIntervals = intervals; |
1304 info.fCount = 2; | 1304 info.fCount = 2; |
1305 info.fPhase = phase; | 1305 info.fPhase = phase; |
1306 SkDEBUGCODE(bool success = ) strokeInfo.setDashInfo(info); | 1306 SkDEBUGCODE(bool success = ) strokeInfo.setDashInfo(info); |
1307 SkASSERT(success); | 1307 SkASSERT(success); |
1308 | 1308 |
1309 return create_batch(color, viewMatrix, pts, useAA, strokeInfo, msaaRT); | 1309 return create_batch(color, viewMatrix, pts, useAA, strokeInfo, msaaRT); |
1310 } | 1310 } |
1311 | 1311 |
1312 #endif | 1312 #endif |
OLD | NEW |