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 #include "SkPaint.h" | 9 #include "SkPaint.h" |
10 #include "SkAnnotation.h" | 10 #include "SkAnnotation.h" |
(...skipping 1534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1545 | 1545 |
1546 #define assert_byte(x) SkASSERT(0 == ((x) >> 8)) | 1546 #define assert_byte(x) SkASSERT(0 == ((x) >> 8)) |
1547 | 1547 |
1548 // Beyond this size, LCD doesn't appreciably improve quality, but it always | 1548 // Beyond this size, LCD doesn't appreciably improve quality, but it always |
1549 // cost more RAM and draws slower, so we set a cap. | 1549 // cost more RAM and draws slower, so we set a cap. |
1550 #ifndef SK_MAX_SIZE_FOR_LCDTEXT | 1550 #ifndef SK_MAX_SIZE_FOR_LCDTEXT |
1551 #define SK_MAX_SIZE_FOR_LCDTEXT 48 | 1551 #define SK_MAX_SIZE_FOR_LCDTEXT 48 |
1552 #endif | 1552 #endif |
1553 | 1553 |
1554 static bool tooBigForLCD(const SkScalerContext::Rec& rec) { | 1554 static bool tooBigForLCD(const SkScalerContext::Rec& rec) { |
1555 SkScalar area = SkScalarMul(rec.fPost2x2[0][0], rec.fPost2x2[1][1]) - | 1555 SkScalar area = rec.fPost2x2[0][0] * rec.fPost2x2[1][1] - |
1556 SkScalarMul(rec.fPost2x2[1][0], rec.fPost2x2[0][1]); | 1556 rec.fPost2x2[1][0] * rec.fPost2x2[0][1]; |
1557 SkScalar size = SkScalarMul(area, rec.fTextSize); | 1557 SkScalar size = SkScalarSqrt(SkScalarAbs(area)) * rec.fTextSize; |
1558 return SkScalarAbs(size) > SkIntToScalar(SK_MAX_SIZE_FOR_LCDTEXT); | 1558 return size > SkIntToScalar(SK_MAX_SIZE_FOR_LCDTEXT); |
1559 } | 1559 } |
1560 | 1560 |
1561 /* | 1561 /* |
1562 * Return the scalar with only limited fractional precision. Used to consolidat
e matrices | 1562 * Return the scalar with only limited fractional precision. Used to consolidat
e matrices |
1563 * that vary only slightly when we create our key into the font cache, since th
e font scaler | 1563 * that vary only slightly when we create our key into the font cache, since th
e font scaler |
1564 * typically returns the same looking resuts for tiny changes in the matrix. | 1564 * typically returns the same looking resuts for tiny changes in the matrix. |
1565 */ | 1565 */ |
1566 static SkScalar sk_relax(SkScalar x) { | 1566 static SkScalar sk_relax(SkScalar x) { |
1567 int n = sk_float_round2int(x * 1024); | 1567 int n = sk_float_round2int(x * 1024); |
1568 return n / 1024.0f; | 1568 return n / 1024.0f; |
(...skipping 1088 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2657 } | 2657 } |
2658 #ifdef SK_BUILD_FOR_ANDROID | 2658 #ifdef SK_BUILD_FOR_ANDROID |
2659 if (dirty & kPaintOptionsAndroid_DirtyBit) { | 2659 if (dirty & kPaintOptionsAndroid_DirtyBit) { |
2660 SkPaintOptionsAndroid options; | 2660 SkPaintOptionsAndroid options; |
2661 options.unflatten(buffer); | 2661 options.unflatten(buffer); |
2662 paint->setPaintOptionsAndroid(options); | 2662 paint->setPaintOptionsAndroid(options); |
2663 } | 2663 } |
2664 #endif | 2664 #endif |
2665 SkASSERT(dirty == paint->fDirtyBits); | 2665 SkASSERT(dirty == paint->fDirtyBits); |
2666 } | 2666 } |
OLD | NEW |