OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 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 #ifndef SkMatrixPriv_DEFINE | 8 #ifndef SkMatrixPriv_DEFINE |
9 #define SkMatrixPriv_DEFINE | 9 #define SkMatrixPriv_DEFINE |
10 | 10 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
58 } | 58 } |
59 // Insert other special-cases here (e.g. scale+translate) | 59 // Insert other special-cases here (e.g. scale+translate) |
60 | 60 |
61 // general case | 61 // general case |
62 SkMatrix::MapXYProc proc = mx.getMapXYProc(); | 62 SkMatrix::MapXYProc proc = mx.getMapXYProc(); |
63 for (int i = 0; i < count; ++i) { | 63 for (int i = 0; i < count; ++i) { |
64 proc(mx, pts->fX, pts->fY, pts); | 64 proc(mx, pts->fX, pts->fY, pts); |
65 pts = (SkPoint*)((intptr_t)pts + stride); | 65 pts = (SkPoint*)((intptr_t)pts + stride); |
66 } | 66 } |
67 } | 67 } |
68 | |
robertphillips
2016/08/23 19:50:19
Would the mx, rect, quad parameter order be more p
bsalomon
2016/08/23 20:15:40
I'd be in favor of any order that had the two inpu
| |
69 static void SetMappedRectFan(const SkMatrix& mx, SkPoint quad[4], const SkRe ct& rect) { | |
70 SkMatrix::TypeMask tm = mx.getType(); | |
71 SkScalar l = rect.fLeft; | |
72 SkScalar t = rect.fTop; | |
73 SkScalar r = rect.fRight; | |
74 SkScalar b = rect.fBottom; | |
75 if (tm <= (SkMatrix::kScale_Mask | SkMatrix::kTranslate_Mask)) { | |
76 const SkScalar tx = mx.getTranslateX(); | |
77 const SkScalar ty = mx.getTranslateY(); | |
78 if (tm <= SkMatrix::kTranslate_Mask) { | |
79 l += tx; | |
80 t += ty; | |
81 r += tx; | |
82 b += ty; | |
83 } else { | |
84 const SkScalar sx = mx.getScaleX(); | |
85 const SkScalar sy = mx.getScaleY(); | |
86 l = sx * l + tx; | |
87 t = sy * t + ty; | |
88 r = sx * r + tx; | |
89 b = sy * b + ty; | |
90 } | |
91 quad[0].set(l, t); | |
92 quad[1].set(l, b); | |
93 quad[2].set(r, b); | |
94 quad[3].set(r, t); | |
95 } else { | |
96 quad[0].setRectFan(l, t, r, b); | |
97 mx.mapPoints(quad, quad, 4); | |
98 } | |
99 } | |
68 }; | 100 }; |
69 | 101 |
70 #endif | 102 #endif |
OLD | NEW |