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 #ifndef SkTextMapStateProc_DEFINED | 8 #ifndef SkTextMapStateProc_DEFINED |
9 #define SkTextMapStateProc_DEFINED | 9 #define SkTextMapStateProc_DEFINED |
10 | 10 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
48 kXY, | 48 kXY, |
49 kOnlyScaleX, | 49 kOnlyScaleX, |
50 kOnlyTransX, | 50 kOnlyTransX, |
51 kX | 51 kX |
52 } fMapCase; | 52 } fMapCase; |
53 const SkMatrix::MapXYProc fProc; | 53 const SkMatrix::MapXYProc fProc; |
54 SkPoint fOffset; // In kOnly* mode, this includes the matrix translation co mponent. | 54 SkPoint fOffset; // In kOnly* mode, this includes the matrix translation co mponent. |
55 SkScalar fScaleX; // This is only used by kOnly... cases. | 55 SkScalar fScaleX; // This is only used by kOnly... cases. |
56 }; | 56 }; |
57 | 57 |
58 static inline SkScalar SkClampScalarToFixed(SkScalar a) { | |
59 return SkScalarPin(a, SkIntToScalar(-16384), SkIntToScalar(16384)); | |
mtklein
2015/03/04 21:45:30
What fixed format are we clamping to? Signed 1.14
bungeman-skia
2015/03/04 21:57:35
This is SkFixed we're clamping to. SkFixed is symm
mtklein
2015/03/04 22:11:00
Oh, duh, we're clamping SkScalars, not SkFixed. O
reed1
2015/03/05 18:27:35
Lets modify its name to make it more obvious that
| |
60 } | |
61 | |
58 inline void SkTextMapStateProc::operator()(const SkScalar pos[], SkPoint* loc) c onst { | 62 inline void SkTextMapStateProc::operator()(const SkScalar pos[], SkPoint* loc) c onst { |
59 switch(fMapCase) { | 63 switch(fMapCase) { |
60 case kXY: | 64 case kXY: |
61 fProc(fMatrix, pos[0] + fOffset.x(), pos[1] + fOffset.y(), loc); | 65 fProc(fMatrix, pos[0] + fOffset.x(), pos[1] + fOffset.y(), loc); |
62 break; | 66 break; |
63 case kOnlyScaleX: | 67 case kOnlyScaleX: |
64 loc->set(SkScalarMul(fScaleX, *pos) + fOffset.x(), fOffset.y()); | 68 loc->set(SkScalarMul(fScaleX, *pos) + fOffset.x(), fOffset.y()); |
65 break; | 69 break; |
66 case kOnlyTransX: | 70 case kOnlyTransX: |
67 loc->set(*pos + fOffset.x(), fOffset.y()); | 71 loc->set(*pos + fOffset.x(), fOffset.y()); |
68 break; | 72 break; |
69 default: | 73 default: |
70 SkASSERT(false); | 74 SkASSERT(false); |
71 case kX: | 75 case kX: |
72 fProc(fMatrix, *pos + fOffset.x(), fOffset.y(), loc); | 76 fProc(fMatrix, *pos + fOffset.x(), fOffset.y(), loc); |
73 break; | 77 break; |
74 } | 78 } |
79 loc->set(SkClampScalarToFixed(loc->x()), SkClampScalarToFixed(loc->y())); | |
75 } | 80 } |
76 | 81 |
77 #endif | 82 #endif |
78 | 83 |
OLD | NEW |