| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
| 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 "SkPaint.h" | 8 #include "SkPaint.h" |
| 9 #include "SkAnnotation.h" | 9 #include "SkAnnotation.h" |
| 10 #include "SkAutoKern.h" | 10 #include "SkAutoKern.h" |
| (...skipping 1082 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1093 x += advance(*g, xyIndex); | 1093 x += advance(*g, xyIndex); |
| 1094 } | 1094 } |
| 1095 } | 1095 } |
| 1096 } | 1096 } |
| 1097 SkASSERT(text == stop); | 1097 SkASSERT(text == stop); |
| 1098 | 1098 |
| 1099 *count = n; | 1099 *count = n; |
| 1100 return Sk48Dot16ToScalar(x); | 1100 return Sk48Dot16ToScalar(x); |
| 1101 } | 1101 } |
| 1102 | 1102 |
| 1103 SkScalar SkPaint::measureText(const void* textData, size_t length, | 1103 SkScalar SkPaint::measureText(const void* textData, size_t length, SkRect* bound
s) const { |
| 1104 SkRect* bounds, SkScalar zoom) const { | |
| 1105 const char* text = (const char*)textData; | 1104 const char* text = (const char*)textData; |
| 1106 SkASSERT(text != NULL || length == 0); | 1105 SkASSERT(text != NULL || length == 0); |
| 1107 | 1106 |
| 1108 SkCanonicalizePaint canon(*this); | 1107 SkCanonicalizePaint canon(*this); |
| 1109 const SkPaint& paint = canon.getPaint(); | 1108 const SkPaint& paint = canon.getPaint(); |
| 1110 SkScalar scale = canon.getScale(); | 1109 SkScalar scale = canon.getScale(); |
| 1111 | 1110 |
| 1112 SkMatrix zoomMatrix, *zoomPtr = NULL; | 1111 SkAutoGlyphCache autoCache(paint, NULL, NULL); |
| 1113 if (zoom) { | |
| 1114 zoomMatrix.setScale(zoom, zoom); | |
| 1115 zoomPtr = &zoomMatrix; | |
| 1116 } | |
| 1117 | |
| 1118 SkAutoGlyphCache autoCache(paint, NULL, zoomPtr); | |
| 1119 SkGlyphCache* cache = autoCache.getCache(); | 1112 SkGlyphCache* cache = autoCache.getCache(); |
| 1120 | 1113 |
| 1121 SkScalar width = 0; | 1114 SkScalar width = 0; |
| 1122 | 1115 |
| 1123 if (length > 0) { | 1116 if (length > 0) { |
| 1124 int tempCount; | 1117 int tempCount; |
| 1125 | 1118 |
| 1126 width = paint.measure_text(cache, text, length, &tempCount, bounds); | 1119 width = paint.measure_text(cache, text, length, &tempCount, bounds); |
| 1127 if (scale) { | 1120 if (scale) { |
| 1128 width = SkScalarMul(width, scale); | 1121 width = SkScalarMul(width, scale); |
| (...skipping 1549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2678 F_UNREF(Looper, readDrawLooper); | 2671 F_UNREF(Looper, readDrawLooper); |
| 2679 F_UNREF(ImageFilter, readImageFilter); | 2672 F_UNREF(ImageFilter, readImageFilter); |
| 2680 F(Typeface, readTypeface); | 2673 F(Typeface, readTypeface); |
| 2681 #undef F | 2674 #undef F |
| 2682 #undef F_UNREF | 2675 #undef F_UNREF |
| 2683 if (dirty & kAnnotation_DirtyBit) { | 2676 if (dirty & kAnnotation_DirtyBit) { |
| 2684 paint->setAnnotation(SkAnnotation::Create(buffer))->unref(); | 2677 paint->setAnnotation(SkAnnotation::Create(buffer))->unref(); |
| 2685 } | 2678 } |
| 2686 SkASSERT(dirty == paint->fDirtyBits); | 2679 SkASSERT(dirty == paint->fDirtyBits); |
| 2687 } | 2680 } |
| OLD | NEW |