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 1463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1474 #define assert_byte(x) SkASSERT(0 == ((x) >> 8)) | 1474 #define assert_byte(x) SkASSERT(0 == ((x) >> 8)) |
1475 | 1475 |
1476 // Beyond this size, LCD doesn't appreciably improve quality, but it always | 1476 // Beyond this size, LCD doesn't appreciably improve quality, but it always |
1477 // cost more RAM and draws slower, so we set a cap. | 1477 // cost more RAM and draws slower, so we set a cap. |
1478 #ifndef SK_MAX_SIZE_FOR_LCDTEXT | 1478 #ifndef SK_MAX_SIZE_FOR_LCDTEXT |
1479 #define SK_MAX_SIZE_FOR_LCDTEXT 48 | 1479 #define SK_MAX_SIZE_FOR_LCDTEXT 48 |
1480 #endif | 1480 #endif |
1481 | 1481 |
1482 const SkScalar gMaxSize2ForLCDText = SK_MAX_SIZE_FOR_LCDTEXT * SK_MAX_SIZE_FOR_L
CDTEXT; | 1482 const SkScalar gMaxSize2ForLCDText = SK_MAX_SIZE_FOR_LCDTEXT * SK_MAX_SIZE_FOR_L
CDTEXT; |
1483 | 1483 |
1484 static bool tooBigForLCD(const SkScalerContext::Rec& rec, bool checkPost2x2) { | 1484 static bool too_big_for_lcd(const SkScalerContext::Rec& rec, bool checkPost2x2)
{ |
1485 SkScalar size = rec.fTextSize; | |
1486 if (checkPost2x2) { | 1485 if (checkPost2x2) { |
1487 SkScalar area = rec.fPost2x2[0][0] * rec.fPost2x2[1][1] - | 1486 SkScalar area = rec.fPost2x2[0][0] * rec.fPost2x2[1][1] - |
1488 rec.fPost2x2[1][0] * rec.fPost2x2[0][1]; | 1487 rec.fPost2x2[1][0] * rec.fPost2x2[0][1]; |
1489 size *= SkScalarAbs(area); | 1488 area *= rec.fTextSize * rec.fTextSize; |
| 1489 return area > gMaxSize2ForLCDText; |
| 1490 } else { |
| 1491 return rec.fTextSize > SK_MAX_SIZE_FOR_LCDTEXT; |
1490 } | 1492 } |
1491 return size > gMaxSize2ForLCDText; | |
1492 } | 1493 } |
1493 | 1494 |
1494 /* | 1495 /* |
1495 * Return the scalar with only limited fractional precision. Used to consolidat
e matrices | 1496 * Return the scalar with only limited fractional precision. Used to consolidat
e matrices |
1496 * that vary only slightly when we create our key into the font cache, since th
e font scaler | 1497 * that vary only slightly when we create our key into the font cache, since th
e font scaler |
1497 * typically returns the same looking resuts for tiny changes in the matrix. | 1498 * typically returns the same looking resuts for tiny changes in the matrix. |
1498 */ | 1499 */ |
1499 static SkScalar sk_relax(SkScalar x) { | 1500 static SkScalar sk_relax(SkScalar x) { |
1500 int n = sk_float_round2int(x * 1024); | 1501 int n = sk_float_round2int(x * 1024); |
1501 return n / 1024.0f; | 1502 return n / 1024.0f; |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1577 } | 1578 } |
1578 } else { | 1579 } else { |
1579 rec->fFrameWidth = 0; | 1580 rec->fFrameWidth = 0; |
1580 rec->fMiterLimit = 0; | 1581 rec->fMiterLimit = 0; |
1581 rec->fStrokeJoin = 0; | 1582 rec->fStrokeJoin = 0; |
1582 } | 1583 } |
1583 | 1584 |
1584 rec->fMaskFormat = SkToU8(computeMaskFormat(paint)); | 1585 rec->fMaskFormat = SkToU8(computeMaskFormat(paint)); |
1585 | 1586 |
1586 if (SkMask::kLCD16_Format == rec->fMaskFormat || SkMask::kLCD32_Format == re
c->fMaskFormat) { | 1587 if (SkMask::kLCD16_Format == rec->fMaskFormat || SkMask::kLCD32_Format == re
c->fMaskFormat) { |
1587 if (tooBigForLCD(*rec, checkPost2x2)) { | 1588 if (too_big_for_lcd(*rec, checkPost2x2)) { |
1588 rec->fMaskFormat = SkMask::kA8_Format; | 1589 rec->fMaskFormat = SkMask::kA8_Format; |
1589 flags |= SkScalerContext::kGenA8FromLCD_Flag; | 1590 flags |= SkScalerContext::kGenA8FromLCD_Flag; |
1590 } else { | 1591 } else { |
1591 SkPixelGeometry geometry = deviceProperties | 1592 SkPixelGeometry geometry = deviceProperties |
1592 ? deviceProperties->fPixelGeometry | 1593 ? deviceProperties->fPixelGeometry |
1593 : SkSurfacePropsDefaultPixelGeometry(); | 1594 : SkSurfacePropsDefaultPixelGeometry(); |
1594 switch (geometry) { | 1595 switch (geometry) { |
1595 case kUnknown_SkPixelGeometry: | 1596 case kUnknown_SkPixelGeometry: |
1596 // eeek, can't support LCD | 1597 // eeek, can't support LCD |
1597 rec->fMaskFormat = SkMask::kA8_Format; | 1598 rec->fMaskFormat = SkMask::kA8_Format; |
(...skipping 977 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2575 return 0 == this->getAlpha(); | 2576 return 0 == this->getAlpha(); |
2576 case SkXfermode::kDst_Mode: | 2577 case SkXfermode::kDst_Mode: |
2577 return true; | 2578 return true; |
2578 default: | 2579 default: |
2579 break; | 2580 break; |
2580 } | 2581 } |
2581 } | 2582 } |
2582 return false; | 2583 return false; |
2583 } | 2584 } |
2584 | 2585 |
OLD | NEW |