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 18 matching lines...) Expand all Loading... |
29 #include "SkStream.h" | 29 #include "SkStream.h" |
30 #include "SkString.h" | 30 #include "SkString.h" |
31 #include "SkTScopedComPtr.h" | 31 #include "SkTScopedComPtr.h" |
32 #include "SkThread.h" | 32 #include "SkThread.h" |
33 #include "SkTypeface_win.h" | 33 #include "SkTypeface_win.h" |
34 #include "SkTypefaceCache.h" | 34 #include "SkTypefaceCache.h" |
35 #include "SkUtils.h" | 35 #include "SkUtils.h" |
36 | 36 |
37 #include <dwrite.h> | 37 #include <dwrite.h> |
38 | 38 |
39 SK_DECLARE_STATIC_MUTEX(gFTMutex); | |
40 | |
41 static bool isLCD(const SkScalerContext::Rec& rec) { | 39 static bool isLCD(const SkScalerContext::Rec& rec) { |
42 return SkMask::kLCD16_Format == rec.fMaskFormat || | 40 return SkMask::kLCD16_Format == rec.fMaskFormat || |
43 SkMask::kLCD32_Format == rec.fMaskFormat; | 41 SkMask::kLCD32_Format == rec.fMaskFormat; |
44 } | 42 } |
45 | 43 |
46 /** Prefer to use this type to prevent template proliferation. */ | 44 /** Prefer to use this type to prevent template proliferation. */ |
47 typedef SkAutoSTMalloc<16, WCHAR> SkSMallocWCHAR; | 45 typedef SkAutoSTMalloc<16, WCHAR> SkSMallocWCHAR; |
48 | 46 |
49 static HRESULT cstring_to_wchar(const char* skname, SkSMallocWCHAR* name) { | 47 static HRESULT cstring_to_wchar(const char* skname, SkSMallocWCHAR* name) { |
50 int wlen = MultiByteToWideChar(CP_UTF8, 0, skname, -1, NULL, 0); | 48 int wlen = MultiByteToWideChar(CP_UTF8, 0, skname, -1, NULL, 0); |
(...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
712 | 710 |
713 return wcscmp(dwFaceFontFamilyNameChar.get(), dwFontFamilyNameChar.get()) ==
0 && | 711 return wcscmp(dwFaceFontFamilyNameChar.get(), dwFontFamilyNameChar.get()) ==
0 && |
714 wcscmp(dwFaceFontNameChar.get(), dwFontNameChar.get()) == 0; | 712 wcscmp(dwFaceFontNameChar.get(), dwFontNameChar.get()) == 0; |
715 } | 713 } |
716 | 714 |
717 SkScalerContext_DW::SkScalerContext_DW(DWriteFontTypeface* typeface, | 715 SkScalerContext_DW::SkScalerContext_DW(DWriteFontTypeface* typeface, |
718 const SkDescriptor* desc) | 716 const SkDescriptor* desc) |
719 : SkScalerContext(typeface, desc) | 717 : SkScalerContext(typeface, desc) |
720 , fTypeface(SkRef(typeface)) | 718 , fTypeface(SkRef(typeface)) |
721 , fGlyphCount(-1) { | 719 , fGlyphCount(-1) { |
722 SkAutoMutexAcquire ac(gFTMutex); | |
723 | 720 |
724 fXform.m11 = SkScalarToFloat(fRec.fPost2x2[0][0]); | 721 fXform.m11 = SkScalarToFloat(fRec.fPost2x2[0][0]); |
725 fXform.m12 = SkScalarToFloat(fRec.fPost2x2[1][0]); | 722 fXform.m12 = SkScalarToFloat(fRec.fPost2x2[1][0]); |
726 fXform.m21 = SkScalarToFloat(fRec.fPost2x2[0][1]); | 723 fXform.m21 = SkScalarToFloat(fRec.fPost2x2[0][1]); |
727 fXform.m22 = SkScalarToFloat(fRec.fPost2x2[1][1]); | 724 fXform.m22 = SkScalarToFloat(fRec.fPost2x2[1][1]); |
728 fXform.dx = 0; | 725 fXform.dx = 0; |
729 fXform.dy = 0; | 726 fXform.dy = 0; |
730 | 727 |
731 fOffscreen.init(fTypeface->fDWriteFontFace.get(), fXform, SkScalarToFloat(fR
ec.fTextSize)); | 728 fOffscreen.init(fTypeface->fDWriteFontFace.get(), fXform, SkScalarToFloat(fR
ec.fTextSize)); |
732 } | 729 } |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
968 U8CPU r = sk_apply_lut_if<APPLY_PREBLEND>(*(src++), tableR); | 965 U8CPU r = sk_apply_lut_if<APPLY_PREBLEND>(*(src++), tableR); |
969 U8CPU g = sk_apply_lut_if<APPLY_PREBLEND>(*(src++), tableG); | 966 U8CPU g = sk_apply_lut_if<APPLY_PREBLEND>(*(src++), tableG); |
970 U8CPU b = sk_apply_lut_if<APPLY_PREBLEND>(*(src++), tableB); | 967 U8CPU b = sk_apply_lut_if<APPLY_PREBLEND>(*(src++), tableB); |
971 dst[i] = SkPackARGB32(0xFF, r, g, b); | 968 dst[i] = SkPackARGB32(0xFF, r, g, b); |
972 } | 969 } |
973 dst = (SkPMColor*)((char*)dst + dstRB); | 970 dst = (SkPMColor*)((char*)dst + dstRB); |
974 } | 971 } |
975 } | 972 } |
976 | 973 |
977 void SkScalerContext_DW::generateImage(const SkGlyph& glyph) { | 974 void SkScalerContext_DW::generateImage(const SkGlyph& glyph) { |
978 SkAutoMutexAcquire ac(gFTMutex); | |
979 | |
980 const bool isBW = SkMask::kBW_Format == fRec.fMaskFormat; | 975 const bool isBW = SkMask::kBW_Format == fRec.fMaskFormat; |
981 const bool isAA = !isLCD(fRec); | 976 const bool isAA = !isLCD(fRec); |
982 | 977 |
983 //Create the mask. | 978 //Create the mask. |
984 const void* bits = fOffscreen.draw(glyph, isBW); | 979 const void* bits = fOffscreen.draw(glyph, isBW); |
985 if (!bits) { | 980 if (!bits) { |
986 sk_bzero(glyph.fImage, glyph.computeImageSize()); | 981 sk_bzero(glyph.fImage, glyph.computeImageSize()); |
987 return; | 982 return; |
988 } | 983 } |
989 | 984 |
(...skipping 17 matching lines...) Expand all Loading... |
1007 SkASSERT(SkMask::kLCD32_Format == glyph.fMaskFormat); | 1002 SkASSERT(SkMask::kLCD32_Format == glyph.fMaskFormat); |
1008 if (fPreBlend.isApplicable()) { | 1003 if (fPreBlend.isApplicable()) { |
1009 rgb_to_lcd32<true>(src, glyph, fPreBlend.fR, fPreBlend.fG, fPreBlend
.fB); | 1004 rgb_to_lcd32<true>(src, glyph, fPreBlend.fR, fPreBlend.fG, fPreBlend
.fB); |
1010 } else { | 1005 } else { |
1011 rgb_to_lcd32<false>(src, glyph, fPreBlend.fR, fPreBlend.fG, fPreBlen
d.fB); | 1006 rgb_to_lcd32<false>(src, glyph, fPreBlend.fR, fPreBlend.fG, fPreBlen
d.fB); |
1012 } | 1007 } |
1013 } | 1008 } |
1014 } | 1009 } |
1015 | 1010 |
1016 void SkScalerContext_DW::generatePath(const SkGlyph& glyph, SkPath* path) { | 1011 void SkScalerContext_DW::generatePath(const SkGlyph& glyph, SkPath* path) { |
1017 SkAutoMutexAcquire ac(gFTMutex); | |
1018 | |
1019 SkASSERT(&glyph && path); | 1012 SkASSERT(&glyph && path); |
1020 | 1013 |
1021 path->reset(); | 1014 path->reset(); |
1022 | 1015 |
1023 SkTScopedComPtr<IDWriteGeometrySink> geometryToPath; | 1016 SkTScopedComPtr<IDWriteGeometrySink> geometryToPath; |
1024 HRVM(SkDWriteGeometrySink::Create(path, &geometryToPath), | 1017 HRVM(SkDWriteGeometrySink::Create(path, &geometryToPath), |
1025 "Could not create geometry to path converter."); | 1018 "Could not create geometry to path converter."); |
1026 uint16_t glyphId = glyph.getGlyphID(); | 1019 uint16_t glyphId = glyph.getGlyphID(); |
1027 //TODO: convert to<->from DIUs? This would make a difference if hinting. | 1020 //TODO: convert to<->from DIUs? This would make a difference if hinting. |
1028 //It may not be needed, it appears that DirectWrite only hints at em size. | 1021 //It may not be needed, it appears that DirectWrite only hints at em size. |
(...skipping 876 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1905 SK_TRACEHR(hr, "Could not get GetUserDefaultLocaleName."); | 1898 SK_TRACEHR(hr, "Could not get GetUserDefaultLocaleName."); |
1906 } else { | 1899 } else { |
1907 localeNameLen = getUserDefaultLocaleNameProc(localeNameStorage, LOCALE_N
AME_MAX_LENGTH); | 1900 localeNameLen = getUserDefaultLocaleNameProc(localeNameStorage, LOCALE_N
AME_MAX_LENGTH); |
1908 if (localeNameLen) { | 1901 if (localeNameLen) { |
1909 localeName = localeNameStorage; | 1902 localeName = localeNameStorage; |
1910 }; | 1903 }; |
1911 } | 1904 } |
1912 | 1905 |
1913 return SkNEW_ARGS(SkFontMgr_DirectWrite, (sysFontCollection.get(), localeNam
e, localeNameLen)); | 1906 return SkNEW_ARGS(SkFontMgr_DirectWrite, (sysFontCollection.get(), localeNam
e, localeNameLen)); |
1914 } | 1907 } |
OLD | NEW |