| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 | 9 |
| 10 #ifndef SkAutoKern_DEFINED | 10 #ifndef SkAutoKern_DEFINED |
| 11 #define SkAutoKern_DEFINED | 11 #define SkAutoKern_DEFINED |
| 12 | 12 |
| 13 #include "SkGlyph.h" | 13 #include "SkGlyph.h" |
| 14 | 14 |
| 15 #define SkAutoKern_AdjustF(prev, next) (((next) - (prev) + 32) >> 6 << 16) | 15 #define SkAutoKern_Adjust(prev, next) SkIntToScalar(((next) - (prev) + 32) >>
6) |
| 16 #define SkAutoKern_AdjustS(prev, next) SkIntToScalar(((next) - (prev) + 32) >
> 6) | |
| 17 | 16 |
| 18 /* this is a helper class to perform auto-kerning | 17 /* this is a helper class to perform auto-kerning |
| 19 * the adjust() method returns a SkFixed corresponding | 18 * the adjust() method returns a SkScalar corresponding |
| 20 * to a +1/0/-1 pixel adjustment | 19 * to a +1/0/-1 pixel adjustment |
| 21 */ | 20 */ |
| 22 | 21 |
| 23 class SkAutoKern { | 22 class SkAutoKern { |
| 24 public: | 23 public: |
| 25 SkAutoKern() : fPrevRsbDelta(0) {} | 24 SkAutoKern() : fPrevRsbDelta(0) {} |
| 26 | 25 |
| 27 SkFixed adjust(const SkGlyph& glyph) | 26 SkScalar adjust(const SkGlyph& glyph) |
| 28 { | 27 { |
| 29 // if (SkAbs32(glyph.fLsbDelta) > 47 || SkAbs32(glyph.fRsbDelta) > 47) | 28 // if (SkAbs32(glyph.fLsbDelta) > 47 || SkAbs32(glyph.fRsbDelta) > 47) |
| 30 // printf("------- %d> L %d R %d\n", glyph.f_GlyphID, glyph.fLsbDelta
, glyph.fRsbDelta); | 29 // printf("------- %d> L %d R %d\n", glyph.f_GlyphID, glyph.fLsbDelta
, glyph.fRsbDelta); |
| 31 | 30 |
| 32 #if 0 | 31 #if 0 |
| 33 int distort = fPrevRsbDelta - glyph.fLsbDelta; | 32 int distort = fPrevRsbDelta - glyph.fLsbDelta; |
| 34 | 33 |
| 35 fPrevRsbDelta = glyph.fRsbDelta; | 34 fPrevRsbDelta = glyph.fRsbDelta; |
| 36 | 35 |
| 37 if (distort >= 32) | 36 if (distort >= 32) |
| 38 return -SK_Fixed1; | 37 return -SK_Scalar1; |
| 39 else if (distort < -32) | 38 else if (distort < -32) |
| 40 return +SK_Fixed1; | 39 return +SK_Scalar1; |
| 41 else | 40 else |
| 42 return 0; | 41 return 0; |
| 43 #else | 42 #else |
| 44 SkFixed adjust = SkAutoKern_AdjustF(fPrevRsbDelta, glyph.fLsbDelta); | 43 SkScalar adjust = SkAutoKern_Adjust(fPrevRsbDelta, glyph.fLsbDelta); |
| 45 fPrevRsbDelta = glyph.fRsbDelta; | 44 fPrevRsbDelta = glyph.fRsbDelta; |
| 46 return adjust; | 45 return adjust; |
| 47 #endif | 46 #endif |
| 48 } | 47 } |
| 49 private: | 48 private: |
| 50 int fPrevRsbDelta; | 49 int fPrevRsbDelta; |
| 51 }; | 50 }; |
| 52 | 51 |
| 53 #endif | 52 #endif |
| OLD | NEW |