| 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 992 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1003 bounds->set(SkIntToScalar(g.fLeft), | 1003 bounds->set(SkIntToScalar(g.fLeft), |
| 1004 SkIntToScalar(g.fTop), | 1004 SkIntToScalar(g.fTop), |
| 1005 SkIntToScalar(g.fLeft + g.fWidth), | 1005 SkIntToScalar(g.fLeft + g.fWidth), |
| 1006 SkIntToScalar(g.fTop + g.fHeight)); | 1006 SkIntToScalar(g.fTop + g.fHeight)); |
| 1007 } | 1007 } |
| 1008 | 1008 |
| 1009 // 64bits wide, with a 16bit bias. Useful when accumulating lots of 16.16 so | 1009 // 64bits wide, with a 16bit bias. Useful when accumulating lots of 16.16 so |
| 1010 // we don't overflow along the way | 1010 // we don't overflow along the way |
| 1011 typedef int64_t Sk48Dot16; | 1011 typedef int64_t Sk48Dot16; |
| 1012 | 1012 |
| 1013 #ifdef SK_SCALAR_IS_FLOAT | 1013 static inline float Sk48Dot16ToScalar(Sk48Dot16 x) { |
| 1014 static inline float Sk48Dot16ToScalar(Sk48Dot16 x) { | 1014 return (float) (x * 1.5258789e-5); // x * (1 / 65536.0f) |
| 1015 return (float) (x * 1.5258789e-5); // x * (1 / 65536.0f) | 1015 } |
| 1016 } | |
| 1017 #else | |
| 1018 static inline SkFixed Sk48Dot16ToScalar(Sk48Dot16 x) { | |
| 1019 // just return the low 32bits | |
| 1020 return static_cast<SkFixed>(x); | |
| 1021 } | |
| 1022 #endif | |
| 1023 | 1016 |
| 1024 static void join_bounds_x(const SkGlyph& g, SkRect* bounds, Sk48Dot16 dx) { | 1017 static void join_bounds_x(const SkGlyph& g, SkRect* bounds, Sk48Dot16 dx) { |
| 1025 SkScalar sx = Sk48Dot16ToScalar(dx); | 1018 SkScalar sx = Sk48Dot16ToScalar(dx); |
| 1026 bounds->join(SkIntToScalar(g.fLeft) + sx, | 1019 bounds->join(SkIntToScalar(g.fLeft) + sx, |
| 1027 SkIntToScalar(g.fTop), | 1020 SkIntToScalar(g.fTop), |
| 1028 SkIntToScalar(g.fLeft + g.fWidth) + sx, | 1021 SkIntToScalar(g.fLeft + g.fWidth) + sx, |
| 1029 SkIntToScalar(g.fTop + g.fHeight)); | 1022 SkIntToScalar(g.fTop + g.fHeight)); |
| 1030 } | 1023 } |
| 1031 | 1024 |
| 1032 static void join_bounds_y(const SkGlyph& g, SkRect* bounds, Sk48Dot16 dy) { | 1025 static void join_bounds_y(const SkGlyph& g, SkRect* bounds, Sk48Dot16 dy) { |
| (...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1549 SkScalar size = SkScalarMul(area, rec.fTextSize); | 1542 SkScalar size = SkScalarMul(area, rec.fTextSize); |
| 1550 return SkScalarAbs(size) > SkIntToScalar(SK_MAX_SIZE_FOR_LCDTEXT); | 1543 return SkScalarAbs(size) > SkIntToScalar(SK_MAX_SIZE_FOR_LCDTEXT); |
| 1551 } | 1544 } |
| 1552 | 1545 |
| 1553 /* | 1546 /* |
| 1554 * Return the scalar with only limited fractional precision. Used to consolidat
e matrices | 1547 * Return the scalar with only limited fractional precision. Used to consolidat
e matrices |
| 1555 * that vary only slightly when we create our key into the font cache, since th
e font scaler | 1548 * that vary only slightly when we create our key into the font cache, since th
e font scaler |
| 1556 * typically returns the same looking resuts for tiny changes in the matrix. | 1549 * typically returns the same looking resuts for tiny changes in the matrix. |
| 1557 */ | 1550 */ |
| 1558 static SkScalar sk_relax(SkScalar x) { | 1551 static SkScalar sk_relax(SkScalar x) { |
| 1559 #ifdef SK_SCALAR_IS_FLOAT | |
| 1560 int n = sk_float_round2int(x * 1024); | 1552 int n = sk_float_round2int(x * 1024); |
| 1561 return n / 1024.0f; | 1553 return n / 1024.0f; |
| 1562 #else | |
| 1563 // round to the nearest 10 fractional bits | |
| 1564 return (x + (1 << 5)) & ~(1024 - 1); | |
| 1565 #endif | |
| 1566 } | 1554 } |
| 1567 | 1555 |
| 1568 void SkScalerContext::MakeRec(const SkPaint& paint, | 1556 void SkScalerContext::MakeRec(const SkPaint& paint, |
| 1569 const SkDeviceProperties* deviceProperties, | 1557 const SkDeviceProperties* deviceProperties, |
| 1570 const SkMatrix* deviceMatrix, | 1558 const SkMatrix* deviceMatrix, |
| 1571 Rec* rec) { | 1559 Rec* rec) { |
| 1572 SkASSERT(deviceMatrix == NULL || !deviceMatrix->hasPerspective()); | 1560 SkASSERT(deviceMatrix == NULL || !deviceMatrix->hasPerspective()); |
| 1573 | 1561 |
| 1574 SkTypeface* typeface = paint.getTypeface(); | 1562 SkTypeface* typeface = paint.getTypeface(); |
| 1575 if (NULL == typeface) { | 1563 if (NULL == typeface) { |
| (...skipping 1015 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2591 case SkXfermode::kPlus_Mode: | 2579 case SkXfermode::kPlus_Mode: |
| 2592 return 0 == this->getAlpha(); | 2580 return 0 == this->getAlpha(); |
| 2593 case SkXfermode::kDst_Mode: | 2581 case SkXfermode::kDst_Mode: |
| 2594 return true; | 2582 return true; |
| 2595 default: | 2583 default: |
| 2596 break; | 2584 break; |
| 2597 } | 2585 } |
| 2598 } | 2586 } |
| 2599 return false; | 2587 return false; |
| 2600 } | 2588 } |
| OLD | NEW |