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 | |
748 SkScalar gdiTextSize = SkScalarRoundToScalar(realTextSize * 64.0f) / 64.0f; | 744 SkScalar gdiTextSize = SkScalarRoundToScalar(realTextSize * 64.0f) / 64.0f; |
749 #endif | |
750 if (gdiTextSize == 0) { | 745 if (gdiTextSize == 0) { |
751 gdiTextSize = SK_Scalar1; | 746 gdiTextSize = SK_Scalar1; |
752 } | 747 } |
753 | 748 |
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 | |
762 bool bitmapRequested = SkToBool(fRec.fFlags & SkScalerContext::kEmbeddedBitm
apText_Flag); | 749 bool bitmapRequested = SkToBool(fRec.fFlags & SkScalerContext::kEmbeddedBitm
apText_Flag); |
763 bool hasBitmap = false; | 750 bool hasBitmap = false; |
764 bool axisAlignedBitmap = false; | 751 bool axisAlignedBitmap = false; |
765 if (bitmapRequested) { | 752 if (bitmapRequested) { |
766 hasBitmap = hasBitmapStrike(typeface, SkScalarTruncToInt(gdiTextSize)); | 753 hasBitmap = hasBitmapStrike(typeface, SkScalarTruncToInt(gdiTextSize)); |
767 axisAlignedBitmap = isAxisAligned(fRec); | 754 axisAlignedBitmap = isAxisAligned(fRec); |
768 } | 755 } |
769 | 756 |
770 // If the user requested aliased, do so with aliased compatible metrics. | 757 // If the user requested aliased, do so with aliased compatible metrics. |
771 if (SkMask::kBW_Format == fRec.fMaskFormat) { | 758 if (SkMask::kBW_Format == fRec.fMaskFormat) { |
772 #endif | |
773 fTextSizeRender = gdiTextSize; | 759 fTextSizeRender = gdiTextSize; |
774 fRenderingMode = DWRITE_RENDERING_MODE_ALIASED; | 760 fRenderingMode = DWRITE_RENDERING_MODE_ALIASED; |
775 fTextureType = DWRITE_TEXTURE_ALIASED_1x1; | 761 fTextureType = DWRITE_TEXTURE_ALIASED_1x1; |
776 fTextSizeMeasure = gdiTextSize; | 762 fTextSizeMeasure = gdiTextSize; |
777 fMeasuringMode = DWRITE_MEASURING_MODE_GDI_CLASSIC; | 763 fMeasuringMode = DWRITE_MEASURING_MODE_GDI_CLASSIC; |
778 #ifndef SK_IGNORE_DWRITE_BITMAP_FIX | 764 |
779 // If we can use a bitmap, use gdi classic rendering and measurement. | 765 // If we can use a bitmap, use gdi classic rendering and measurement. |
780 // This will not always provide a bitmap, but matches expected behavior. | 766 // This will not always provide a bitmap, but matches expected behavior. |
781 } else if (hasBitmap && axisAlignedBitmap) { | 767 } else if (hasBitmap && axisAlignedBitmap) { |
782 fTextSizeRender = gdiTextSize; | 768 fTextSizeRender = gdiTextSize; |
783 fRenderingMode = DWRITE_RENDERING_MODE_CLEARTYPE_GDI_CLASSIC; | 769 fRenderingMode = DWRITE_RENDERING_MODE_CLEARTYPE_GDI_CLASSIC; |
784 fTextureType = DWRITE_TEXTURE_CLEARTYPE_3x1; | 770 fTextureType = DWRITE_TEXTURE_CLEARTYPE_3x1; |
785 fTextSizeMeasure = gdiTextSize; | 771 fTextSizeMeasure = gdiTextSize; |
786 fMeasuringMode = DWRITE_MEASURING_MODE_GDI_CLASSIC; | 772 fMeasuringMode = DWRITE_MEASURING_MODE_GDI_CLASSIC; |
787 #endif | 773 |
788 // If rotated but the horizontal text could have used a bitmap, | 774 // If rotated but the horizontal text could have used a bitmap, |
789 // render high quality rotated glyphs but measure using bitmap metrics. | 775 // render high quality rotated glyphs but measure using bitmap metrics. |
790 } else if (hasBitmap) { | 776 } else if (hasBitmap) { |
791 fTextSizeRender = gdiTextSize; | 777 fTextSizeRender = gdiTextSize; |
792 fRenderingMode = DWRITE_RENDERING_MODE_CLEARTYPE_NATURAL_SYMMETRIC; | 778 fRenderingMode = DWRITE_RENDERING_MODE_CLEARTYPE_NATURAL_SYMMETRIC; |
793 fTextureType = DWRITE_TEXTURE_CLEARTYPE_3x1; | 779 fTextureType = DWRITE_TEXTURE_CLEARTYPE_3x1; |
794 fTextSizeMeasure = gdiTextSize; | 780 fTextSizeMeasure = gdiTextSize; |
795 fMeasuringMode = DWRITE_MEASURING_MODE_GDI_CLASSIC; | 781 fMeasuringMode = DWRITE_MEASURING_MODE_GDI_CLASSIC; |
796 | 782 |
797 // The normal case is to use natural symmetric rendering and linear metrics. | 783 // 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... |
2033 } | 2019 } |
2034 | 2020 |
2035 #include "SkFontMgr_indirect.h" | 2021 #include "SkFontMgr_indirect.h" |
2036 SkFontMgr* SkFontMgr_New_DirectWriteRenderer(SkRemotableFontMgr* proxy) { | 2022 SkFontMgr* SkFontMgr_New_DirectWriteRenderer(SkRemotableFontMgr* proxy) { |
2037 SkAutoTUnref<SkFontMgr> impl(SkFontMgr_New_DirectWrite()); | 2023 SkAutoTUnref<SkFontMgr> impl(SkFontMgr_New_DirectWrite()); |
2038 if (impl.get() == NULL) { | 2024 if (impl.get() == NULL) { |
2039 return NULL; | 2025 return NULL; |
2040 } | 2026 } |
2041 return SkNEW_ARGS(SkFontMgr_Indirect, (impl.get(), proxy)); | 2027 return SkNEW_ARGS(SkFontMgr_Indirect, (impl.get(), proxy)); |
2042 } | 2028 } |
OLD | NEW |