| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 SkDrawProcs_DEFINED | 8 #ifndef SkDrawProcs_DEFINED |
| 9 #define SkDrawProcs_DEFINED | 9 #define SkDrawProcs_DEFINED |
| 10 | 10 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 SkTextAlignProc(SkPaint::Align align) | 44 SkTextAlignProc(SkPaint::Align align) |
| 45 : fAlign(align) { | 45 : fAlign(align) { |
| 46 } | 46 } |
| 47 | 47 |
| 48 // Returns the glyph position, which may be rounded or not by the caller | 48 // Returns the glyph position, which may be rounded or not by the caller |
| 49 // e.g. subpixel doesn't round. | 49 // e.g. subpixel doesn't round. |
| 50 void operator()(const SkPoint& loc, const SkGlyph& glyph, SkPoint* dst) { | 50 void operator()(const SkPoint& loc, const SkGlyph& glyph, SkPoint* dst) { |
| 51 if (SkPaint::kLeft_Align == fAlign) { | 51 if (SkPaint::kLeft_Align == fAlign) { |
| 52 dst->set(loc.fX, loc.fY); | 52 dst->set(loc.fX, loc.fY); |
| 53 } else if (SkPaint::kCenter_Align == fAlign) { | 53 } else if (SkPaint::kCenter_Align == fAlign) { |
| 54 dst->set(loc.fX - SkFixedToScalar(glyph.fAdvanceX >> 1), | 54 dst->set(loc.fX - SkFloatToScalar(glyph.fAdvanceX) / 2, |
| 55 loc.fY - SkFixedToScalar(glyph.fAdvanceY >> 1)); | 55 loc.fY - SkFloatToScalar(glyph.fAdvanceY) / 2); |
| 56 } else { | 56 } else { |
| 57 SkASSERT(SkPaint::kRight_Align == fAlign); | 57 SkASSERT(SkPaint::kRight_Align == fAlign); |
| 58 dst->set(loc.fX - SkFixedToScalar(glyph.fAdvanceX), | 58 dst->set(loc.fX - SkFloatToScalar(glyph.fAdvanceX), |
| 59 loc.fY - SkFixedToScalar(glyph.fAdvanceY)); | 59 loc.fY - SkFloatToScalar(glyph.fAdvanceY)); |
| 60 } | 60 } |
| 61 } | 61 } |
| 62 private: | 62 private: |
| 63 const SkPaint::Align fAlign; | 63 const SkPaint::Align fAlign; |
| 64 }; | 64 }; |
| 65 | 65 |
| 66 #endif | 66 #endif |
| OLD | NEW |