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 1220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1231 matrix.postTranslate(pos[i].fX - prevPos.fX, pos[i].fY - prevPos.fY); | 1231 matrix.postTranslate(pos[i].fX - prevPos.fX, pos[i].fY - prevPos.fY); |
1232 if (iterPath) { | 1232 if (iterPath) { |
1233 path->addPath(*iterPath, matrix); | 1233 path->addPath(*iterPath, matrix); |
1234 } | 1234 } |
1235 prevPos = pos[i]; | 1235 prevPos = pos[i]; |
1236 i++; | 1236 i++; |
1237 } | 1237 } |
1238 } | 1238 } |
1239 | 1239 |
1240 SkRect SkPaint::getFontBounds() const { | 1240 SkRect SkPaint::getFontBounds() const { |
| 1241 // This approach can be a little over 1% too narrow when using GDI, |
| 1242 // so we compensate by scaling the x-axis another 2%. |
| 1243 SkScalar xScale = fTextScaleX * 1.02f; |
| 1244 |
1241 SkMatrix m; | 1245 SkMatrix m; |
1242 m.setScale(fTextSize * fTextScaleX, fTextSize); | 1246 m.setScale(fTextSize * xScale, fTextSize); |
1243 m.postSkew(fTextSkewX, 0); | 1247 m.postSkew(fTextSkewX, 0); |
1244 | 1248 |
1245 SkTypeface* typeface = this->getTypeface(); | 1249 SkTypeface* typeface = this->getTypeface(); |
1246 if (NULL == typeface) { | 1250 if (NULL == typeface) { |
1247 typeface = SkTypeface::GetDefaultTypeface(); | 1251 typeface = SkTypeface::GetDefaultTypeface(); |
1248 } | 1252 } |
1249 | 1253 |
1250 SkRect bounds; | 1254 SkRect bounds; |
1251 m.mapRect(&bounds, typeface->getBounds()); | 1255 m.mapRect(&bounds, typeface->getBounds()); |
1252 return bounds; | 1256 return bounds; |
(...skipping 1131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2384 } | 2388 } |
2385 | 2389 |
2386 uint32_t SkPaint::getHash() const { | 2390 uint32_t SkPaint::getHash() const { |
2387 // We're going to hash 10 pointers and 7 32-bit values, finishing up with fB
itfields, | 2391 // We're going to hash 10 pointers and 7 32-bit values, finishing up with fB
itfields, |
2388 // so fBitfields should be 10 pointers and 6 32-bit values from the start. | 2392 // so fBitfields should be 10 pointers and 6 32-bit values from the start. |
2389 SK_COMPILE_ASSERT(offsetof(SkPaint, fBitfields) == 10 * sizeof(void*) + 6 *
sizeof(uint32_t), | 2393 SK_COMPILE_ASSERT(offsetof(SkPaint, fBitfields) == 10 * sizeof(void*) + 6 *
sizeof(uint32_t), |
2390 SkPaint_notPackedTightly); | 2394 SkPaint_notPackedTightly); |
2391 return SkChecksum::Murmur3(reinterpret_cast<const uint32_t*>(this), | 2395 return SkChecksum::Murmur3(reinterpret_cast<const uint32_t*>(this), |
2392 offsetof(SkPaint, fBitfields) + sizeof(fBitfields
)); | 2396 offsetof(SkPaint, fBitfields) + sizeof(fBitfields
)); |
2393 } | 2397 } |
OLD | NEW |