| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
| 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 "SkTypes.h" | 8 #include "SkTypes.h" |
| 9 #undef GetGlyphIndices | 9 #undef GetGlyphIndices |
| 10 | 10 |
| (...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 734 | 734 |
| 735 // GA is the matrix A with rotation removed. | 735 // GA is the matrix A with rotation removed. |
| 736 SkMatrix GA(G); | 736 SkMatrix GA(G); |
| 737 GA.preConcat(A); | 737 GA.preConcat(A); |
| 738 | 738 |
| 739 // realTextSize is the actual device size we want (as opposed to the size th
e user requested). | 739 // realTextSize is the actual device size we want (as opposed to the size th
e user requested). |
| 740 // gdiTextSize is the size we request when GDI compatible. | 740 // gdiTextSize is the size we request when GDI compatible. |
| 741 // If the scale is negative, this means the matrix will do the flip anyway. | 741 // If the scale is negative, this means the matrix will do the flip anyway. |
| 742 SkScalar realTextSize = SkScalarAbs(GA.get(SkMatrix::kMScaleY)); | 742 SkScalar realTextSize = SkScalarAbs(GA.get(SkMatrix::kMScaleY)); |
| 743 // Due to floating point math, the lower bits are suspect. Round carefully. | 743 // Due to floating point math, the lower bits are suspect. Round carefully. |
| 744 #ifdef SK_IGNORE_DWRITE_BITMAP_FIX |
| 745 SkScalar roundedTextSize = SkScalarRoundToScalar(realTextSize * 64.0f) / 64.
0f; |
| 746 SkScalar gdiTextSize = SkScalarFloorToScalar(roundedTextSize); |
| 747 #else |
| 744 SkScalar gdiTextSize = SkScalarRoundToScalar(realTextSize * 64.0f) / 64.0f; | 748 SkScalar gdiTextSize = SkScalarRoundToScalar(realTextSize * 64.0f) / 64.0f; |
| 749 #endif |
| 745 if (gdiTextSize == 0) { | 750 if (gdiTextSize == 0) { |
| 746 gdiTextSize = SK_Scalar1; | 751 gdiTextSize = SK_Scalar1; |
| 747 } | 752 } |
| 748 | 753 |
| 754 #ifdef SK_IGNORE_DWRITE_BITMAP_FIX |
| 755 bool hasBitmap = fRec.fFlags & SkScalerContext::kEmbeddedBitmapText_Flag && |
| 756 hasBitmapStrike(typeface, SkScalarTruncToInt(gdiTextSize)); |
| 757 bool axisAligned = isAxisAligned(fRec); |
| 758 bool isBiLevel = SkMask::kBW_Format == fRec.fMaskFormat || (hasBitmap && axi
sAligned); |
| 759 |
| 760 if (isBiLevel) { |
| 761 #else |
| 749 bool bitmapRequested = SkToBool(fRec.fFlags & SkScalerContext::kEmbeddedBitm
apText_Flag); | 762 bool bitmapRequested = SkToBool(fRec.fFlags & SkScalerContext::kEmbeddedBitm
apText_Flag); |
| 750 bool hasBitmap = false; | 763 bool hasBitmap = false; |
| 751 bool axisAlignedBitmap = false; | 764 bool axisAlignedBitmap = false; |
| 752 if (bitmapRequested) { | 765 if (bitmapRequested) { |
| 753 hasBitmap = hasBitmapStrike(typeface, SkScalarTruncToInt(gdiTextSize)); | 766 hasBitmap = hasBitmapStrike(typeface, SkScalarTruncToInt(gdiTextSize)); |
| 754 axisAlignedBitmap = isAxisAligned(fRec); | 767 axisAlignedBitmap = isAxisAligned(fRec); |
| 755 } | 768 } |
| 756 | 769 |
| 757 // If the user requested aliased, do so with aliased compatible metrics. | 770 // If the user requested aliased, do so with aliased compatible metrics. |
| 758 if (SkMask::kBW_Format == fRec.fMaskFormat) { | 771 if (SkMask::kBW_Format == fRec.fMaskFormat) { |
| 772 #endif |
| 759 fTextSizeRender = gdiTextSize; | 773 fTextSizeRender = gdiTextSize; |
| 760 fRenderingMode = DWRITE_RENDERING_MODE_ALIASED; | 774 fRenderingMode = DWRITE_RENDERING_MODE_ALIASED; |
| 761 fTextureType = DWRITE_TEXTURE_ALIASED_1x1; | 775 fTextureType = DWRITE_TEXTURE_ALIASED_1x1; |
| 762 fTextSizeMeasure = gdiTextSize; | 776 fTextSizeMeasure = gdiTextSize; |
| 763 fMeasuringMode = DWRITE_MEASURING_MODE_GDI_CLASSIC; | 777 fMeasuringMode = DWRITE_MEASURING_MODE_GDI_CLASSIC; |
| 764 | 778 #ifndef SK_IGNORE_DWRITE_BITMAP_FIX |
| 765 // If we can use a bitmap, use gdi classic rendering and measurement. | 779 // If we can use a bitmap, use gdi classic rendering and measurement. |
| 766 // This will not always provide a bitmap, but matches expected behavior. | 780 // This will not always provide a bitmap, but matches expected behavior. |
| 767 } else if (hasBitmap && axisAlignedBitmap) { | 781 } else if (hasBitmap && axisAlignedBitmap) { |
| 768 fTextSizeRender = gdiTextSize; | 782 fTextSizeRender = gdiTextSize; |
| 769 fRenderingMode = DWRITE_RENDERING_MODE_CLEARTYPE_GDI_CLASSIC; | 783 fRenderingMode = DWRITE_RENDERING_MODE_CLEARTYPE_GDI_CLASSIC; |
| 770 fTextureType = DWRITE_TEXTURE_CLEARTYPE_3x1; | 784 fTextureType = DWRITE_TEXTURE_CLEARTYPE_3x1; |
| 771 fTextSizeMeasure = gdiTextSize; | 785 fTextSizeMeasure = gdiTextSize; |
| 772 fMeasuringMode = DWRITE_MEASURING_MODE_GDI_CLASSIC; | 786 fMeasuringMode = DWRITE_MEASURING_MODE_GDI_CLASSIC; |
| 773 | 787 #endif |
| 774 // If rotated but the horizontal text could have used a bitmap, | 788 // If rotated but the horizontal text could have used a bitmap, |
| 775 // render high quality rotated glyphs but measure using bitmap metrics. | 789 // render high quality rotated glyphs but measure using bitmap metrics. |
| 776 } else if (hasBitmap) { | 790 } else if (hasBitmap) { |
| 777 fTextSizeRender = gdiTextSize; | 791 fTextSizeRender = gdiTextSize; |
| 778 fRenderingMode = DWRITE_RENDERING_MODE_CLEARTYPE_NATURAL_SYMMETRIC; | 792 fRenderingMode = DWRITE_RENDERING_MODE_CLEARTYPE_NATURAL_SYMMETRIC; |
| 779 fTextureType = DWRITE_TEXTURE_CLEARTYPE_3x1; | 793 fTextureType = DWRITE_TEXTURE_CLEARTYPE_3x1; |
| 780 fTextSizeMeasure = gdiTextSize; | 794 fTextSizeMeasure = gdiTextSize; |
| 781 fMeasuringMode = DWRITE_MEASURING_MODE_GDI_CLASSIC; | 795 fMeasuringMode = DWRITE_MEASURING_MODE_GDI_CLASSIC; |
| 782 | 796 |
| 783 // The normal case is to use natural symmetric rendering and linear metrics. | 797 // The normal case is to use natural symmetric rendering and linear metrics. |
| (...skipping 1235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2019 } | 2033 } |
| 2020 | 2034 |
| 2021 #include "SkFontMgr_indirect.h" | 2035 #include "SkFontMgr_indirect.h" |
| 2022 SkFontMgr* SkFontMgr_New_DirectWriteRenderer(SkRemotableFontMgr* proxy) { | 2036 SkFontMgr* SkFontMgr_New_DirectWriteRenderer(SkRemotableFontMgr* proxy) { |
| 2023 SkAutoTUnref<SkFontMgr> impl(SkFontMgr_New_DirectWrite()); | 2037 SkAutoTUnref<SkFontMgr> impl(SkFontMgr_New_DirectWrite()); |
| 2024 if (impl.get() == NULL) { | 2038 if (impl.get() == NULL) { |
| 2025 return NULL; | 2039 return NULL; |
| 2026 } | 2040 } |
| 2027 return SkNEW_ARGS(SkFontMgr_Indirect, (impl.get(), proxy)); | 2041 return SkNEW_ARGS(SkFontMgr_Indirect, (impl.get(), proxy)); |
| 2028 } | 2042 } |
| OLD | NEW |