Changeset 266982 in webkit
- Timestamp:
- Sep 12, 2020 4:01:36 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ChangeLog
r266833 r266982 1 2020-09-12 Myles C. Maxfield <mmaxfield@apple.com> 2 3 [Apple Win] Add a CTFont member to FontPlatformData 4 https://bugs.webkit.org/show_bug.cgi?id=216432 5 6 Reviewed by Darin Adler. 7 8 Include ***CoreText.cpp files on the Apple Win port. 9 10 * Source/cmake/OptionsAppleWin.cmake: 11 1 12 2020-09-10 Adrian Perez de Castro <aperez@igalia.com> 2 13 -
trunk/Source/WebCore/ChangeLog
r266981 r266982 1 2020-09-12 Myles C. Maxfield <mmaxfield@apple.com> 2 3 [Apple Win] Add a CTFont member to FontPlatformData 4 https://bugs.webkit.org/show_bug.cgi?id=216432 5 6 Reviewed by Darin Adler. 7 8 This is the second step on the path to replacing the Apple Win port's use of CGFont with CTFont. 9 This patch adds m_ctFont to FontPlatformData, and makes FontPlatformData's constructors create 10 this object from their existing arguments. It also enables the USE(CORE_TEXT) flag on the Apple 11 Win port, but manually disables each of the USE(CORE_TEXT) sites on Windows, so there isn't any 12 behavior change just yet. The new member, m_ctFont, is therefore still unused in this patch. The 13 next steps will be replacing our current Apple Win font functions with their USE(CORE_TEXT) 14 counterparts, one-by-one. (Replacing them one-by-one is better than doing them all at once in a 15 giant mondo-patch.) 16 17 No new tests because there is no behavior change yet. 18 19 * PlatformAppleWin.cmake: 20 * platform/graphics/Font.cpp: 21 * platform/graphics/FontCascade.cpp: 22 * platform/graphics/FontPlatformData.cpp: 23 * platform/graphics/FontPlatformData.h: The #defines are temporarily getting worse before they'll 24 be getting better. When this project is done, there will be fewer #defines, and this file will be 25 cleaner than it was when I started. 26 (WebCore::FontPlatformData::cgFont const): 27 (WebCore::FontPlatformData::ctFont const): 28 * platform/graphics/coretext/FontCascadeCoreText.cpp: 29 * platform/graphics/coretext/FontCoreText.cpp: 30 * platform/graphics/coretext/FontPlatformDataCoreText.cpp: 31 * platform/graphics/coretext/GlyphPageCoreText.cpp: 32 * platform/graphics/win/FontPlatformDataCGWin.cpp: 33 (WebCore::FontPlatformData::platformDataInit): 34 (WebCore::FontPlatformData::FontPlatformData): 35 (WebCore::FontPlatformData::hash const): 36 (WebCore::FontPlatformData::platformIsEqual const): 37 1 38 2020-09-12 Myles C. Maxfield <mmaxfield@apple.com> 2 39 -
trunk/Source/WebCore/PlatformAppleWin.cmake
r264786 r266982 151 151 platform/graphics/cg/UTIRegistry.cpp 152 152 153 platform/graphics/coretext/FontCascadeCoreText.cpp 154 platform/graphics/coretext/FontCoreText.cpp 155 platform/graphics/coretext/FontPlatformDataCoreText.cpp 156 platform/graphics/coretext/GlyphPageCoreText.cpp 157 153 158 platform/graphics/opentype/OpenTypeCG.cpp 154 159 -
trunk/Source/WebCore/platform/graphics/Font.cpp
r266936 r266982 475 475 } 476 476 477 #if !USE(CORE_TEXT) 477 #if !USE(CORE_TEXT) || PLATFORM(WIN) 478 478 479 479 bool Font::isProbablyOnlyUsedToRenderIcons() const … … 512 512 } 513 513 514 #if !USE(CORE_TEXT) 514 #if !USE(CORE_TEXT) || PLATFORM(WIN) 515 515 void Font::applyTransforms(GlyphBuffer&, unsigned, unsigned, bool, bool, const AtomString&, StringView, TextDirection) const 516 516 { -
trunk/Source/WebCore/platform/graphics/FontCascade.cpp
r266936 r266982 596 596 } 597 597 598 #if !USE(CORE_TEXT) 598 #if !USE(CORE_TEXT) || PLATFORM(WIN) 599 599 bool FontCascade::isSubpixelAntialiasingAvailable() 600 600 { -
trunk/Source/WebCore/platform/graphics/FontPlatformData.cpp
r266936 r266982 32 32 #endif 33 33 34 #if PLATFORM(WIN) && USE(CORE_TEXT) 35 #include <pal/spi/win/CoreTextSPIWin.h> 36 #endif 37 34 38 namespace WebCore { 35 39 … … 52 56 { 53 57 } 54 55 #if USE(CG) && PLATFORM(WIN)56 FontPlatformData::FontPlatformData(CGFontRef cgFont, float size, bool syntheticBold, bool syntheticOblique, FontOrientation orientation, FontWidthVariant widthVariant, TextRenderingMode textRenderingMode)57 : FontPlatformData(size, syntheticBold, syntheticOblique, orientation, widthVariant, textRenderingMode)58 {59 m_cgFont = cgFont;60 ASSERT(m_cgFont);61 }62 #endif63 58 64 59 #if !USE(FREETYPE) … … 85 80 #endif 86 81 87 #if !USE(CORE_TEXT) 82 #if !USE(CORE_TEXT) || PLATFORM(WIN) 88 83 89 84 String FontPlatformData::familyName() const -
trunk/Source/WebCore/platform/graphics/FontPlatformData.h
r266936 r266982 87 87 #endif 88 88 89 #if PLATFORM(WIN) 90 FontPlatformData(GDIObject<HFONT>, float size, bool syntheticBold, bool syntheticOblique, bool useGDI); 91 #if USE(CG) 92 FontPlatformData(GDIObject<HFONT>, CGFontRef, float size, bool syntheticBold, bool syntheticOblique, bool useGDI); 93 FontPlatformData(CGFontRef, float size, bool syntheticBold, bool syntheticOblique, FontOrientation, FontWidthVariant, TextRenderingMode); 94 #endif 95 #if USE(DIRECT2D) 96 FontPlatformData(GDIObject<HFONT>&&, COMPtr<IDWriteFont>&&, float size, bool syntheticBold, bool syntheticOblique, bool useGDI); 97 #endif 98 #if USE(CAIRO) 99 FontPlatformData(GDIObject<HFONT>, cairo_font_face_t*, float size, bool bold, bool italic); 100 #endif 101 #endif 102 103 #if USE(FREETYPE) 104 FontPlatformData(cairo_font_face_t*, RefPtr<FcPattern>&&, float size, bool fixedWidth, bool syntheticBold, bool syntheticOblique, FontOrientation); 105 #endif 106 89 107 static FontPlatformData cloneWithOrientation(const FontPlatformData&, FontOrientation); 90 108 static FontPlatformData cloneWithSyntheticOblique(const FontPlatformData&, bool); 91 109 static FontPlatformData cloneWithSize(const FontPlatformData&, float); 92 110 93 #if USE(CG) && PLATFORM(WIN)94 FontPlatformData(CGFontRef, float size, bool syntheticBold, bool syntheticOblique, FontOrientation, FontWidthVariant, TextRenderingMode);95 #endif96 97 #if PLATFORM(WIN)98 FontPlatformData(GDIObject<HFONT>, float size, bool syntheticBold, bool syntheticOblique, bool useGDI);99 #endif100 101 #if PLATFORM(WIN) && USE(CG)102 FontPlatformData(GDIObject<HFONT>, CGFontRef, float size, bool syntheticBold, bool syntheticOblique, bool useGDI);103 #endif104 105 #if PLATFORM(WIN) && USE(DIRECT2D)106 FontPlatformData(GDIObject<HFONT>&&, COMPtr<IDWriteFont>&&, float size, bool syntheticBold, bool syntheticOblique, bool useGDI);107 #endif108 109 #if PLATFORM(WIN) && USE(CAIRO)110 FontPlatformData(GDIObject<HFONT>, cairo_font_face_t*, float size, bool bold, bool italic);111 #endif112 113 #if USE(FREETYPE)114 FontPlatformData(cairo_font_face_t*, RefPtr<FcPattern>&&, float size, bool fixedWidth, bool syntheticBold, bool syntheticOblique, FontOrientation);115 #endif116 117 111 #if PLATFORM(WIN) 118 112 HFONT hfont() const { return m_font ? m_font->get() : 0; } 119 113 bool useGDI() const { return m_useGDI; } 120 #endif 121 122 #if USE(CORE_TEXT) 114 #if USE(CG) 115 CGFontRef cgFont() const { return m_cgFont.get(); } 116 #endif 117 #if USE(CORE_TEXT) 118 CTFontRef ctFont() const { return m_ctFont.get(); } 119 #endif 120 #elif USE(CORE_TEXT) 123 121 CTFontRef font() const { return m_font.get(); } 124 122 WEBCORE_EXPORT CTFontRef registeredFont() const; // Returns nullptr iff the font is not registered, such as web fonts (otherwise returns font()). … … 136 134 137 135 bool hasVariations() const { return m_hasVariations; } 138 139 #if USE(CG) && PLATFORM(WIN)140 CGFontRef cgFont() const { return m_cgFont.get(); }141 #endif142 136 143 137 #if USE(DIRECT2D) … … 200 194 } 201 195 202 #if PLATFORM(COCOA) || PLATFORM(WIN) || USE(FREETYPE)203 196 RefPtr<SharedBuffer> openTypeTable(uint32_t table) const; 204 #endif 205 206 #if !LOG_DISABLED 197 207 198 String description() const; 208 #endif209 199 210 200 private: … … 223 213 #endif 224 214 225 #if USE(CORE_TEXT) 215 #if PLATFORM(WIN) 216 RefPtr<SharedGDIObject<HFONT>> m_font; // FIXME: Delete this in favor of m_ctFont or m_dwFont or m_scaledFont. 217 #if USE(CG) 218 RetainPtr<CGFontRef> m_cgFont; // FIXME: Delete this in favor of m_ctFont. 219 #endif 220 #if USE(CORE_TEXT) 221 RetainPtr<CTFontRef> m_ctFont; 222 #endif 223 #elif USE(CORE_TEXT) 226 224 // FIXME: Get rid of one of these. These two fonts are subtly different, and it is not obvious which one to use where. 227 225 RetainPtr<CTFontRef> m_font; 228 226 mutable RetainPtr<CTFontRef> m_ctFont; 229 #elif PLATFORM(WIN)230 RefPtr<SharedGDIObject<HFONT>> m_font;231 #endif232 233 #if USE(CG) && PLATFORM(WIN)234 RetainPtr<CGFontRef> m_cgFont;235 227 #endif 236 228 … … 248 240 #endif 249 241 250 // The values below are common to all ports251 // FIXME: If they're common to all ports, they should move to Font252 242 float m_size { 0 }; 253 243 -
trunk/Source/WebCore/platform/graphics/coretext/FontCascadeCoreText.cpp
r266977 r266982 42 42 namespace WebCore { 43 43 44 #if !PLATFORM(WIN) 45 44 46 // Confusingly, even when CGFontRenderingGetFontSmoothingDisabled() returns true, CGContextSetShouldSmoothFonts() still impacts text 45 47 // rendering, which is why this function uses the "subpixel antialiasing" rather than "smoothing" terminology. … … 310 312 } 311 313 312 } 314 #endif 315 316 } -
trunk/Source/WebCore/platform/graphics/coretext/FontCoreText.cpp
r266977 r266982 52 52 namespace WebCore { 53 53 54 #if !PLATFORM(WIN) 55 54 56 static inline bool caseInsensitiveCompare(CFStringRef a, CFStringRef b) 55 57 { … … 769 771 } 770 772 773 #endif 774 771 775 } // namespace WebCore -
trunk/Source/WebCore/platform/graphics/coretext/FontPlatformDataCoreText.cpp
r266977 r266982 35 35 36 36 namespace WebCore { 37 38 #if !PLATFORM(WIN) 37 39 38 40 FontPlatformData::FontPlatformData(CTFontRef font, float size, bool syntheticBold, bool syntheticOblique, FontOrientation orientation, FontWidthVariant widthVariant, TextRenderingMode textRenderingMode) … … 181 183 } 182 184 185 #endif 186 183 187 } // namespace WebCore -
trunk/Source/WebCore/platform/graphics/coretext/GlyphPageCoreText.cpp
r266977 r266982 42 42 namespace WebCore { 43 43 44 #if !PLATFORM(WIN) 45 44 46 static bool shouldFillWithVerticalGlyphs(const UChar* buffer, unsigned bufferLength, const Font& font) 45 47 { … … 79 81 } 80 82 83 #endif 84 81 85 } // namespace WebCore -
trunk/Source/WebCore/platform/graphics/win/FontPlatformDataCGWin.cpp
r238298 r266982 29 29 #include "SharedGDIObject.h" 30 30 #include <pal/spi/cg/CoreGraphicsSPI.h> 31 #include <pal/spi/win/CoreTextSPIWin.h> 31 32 #include <wtf/HashMap.h> 32 33 #include <wtf/RetainPtr.h> … … 115 116 GetObject(font, sizeof(logfont), &logfont); 116 117 m_cgFont = adoptCF(CGFontCreateWithPlatformFont(&logfont)); 118 m_ctFont = adoptCF(CTFontCreateWithGraphicsFont(m_cgFont.get(), size, nullptr, nullptr)); 117 119 if (!m_useGDI) 118 120 m_isSystemFont = !wcscmp(faceName, L"Lucida Grande"); … … 125 127 , m_font(SharedGDIObject<HFONT>::create(WTFMove(hfont))) 126 128 , m_cgFont(font) 129 , m_ctFont(adoptCF(CTFontCreateWithGraphicsFont(m_cgFont.get(), size, nullptr, nullptr))) 127 130 , m_useGDI(useGDI) 128 131 { 129 132 } 130 133 134 FontPlatformData::FontPlatformData(CGFontRef cgFont, float size, bool syntheticBold, bool syntheticOblique, FontOrientation orientation, FontWidthVariant widthVariant, TextRenderingMode textRenderingMode) 135 : FontPlatformData(size, syntheticBold, syntheticOblique, orientation, widthVariant, textRenderingMode) 136 { 137 m_cgFont = cgFont; 138 ASSERT(m_cgFont); 139 m_ctFont = adoptCF(CTFontCreateWithGraphicsFont(m_cgFont.get(), size, nullptr, nullptr)); 140 } 141 131 142 unsigned FontPlatformData::hash() const 132 143 { 133 return m_font ? m_font->hash() : 0; 144 unsigned fontHash = m_font ? m_font->hash() : 0; 145 CFHashCode cgFontHash = WTF::safeCFHash(m_cgFont.get()); 146 CFHashCode ctFontHash = WTF::safeCFHash(m_ctFont.get()); 147 uintptr_t hashCodes[] = { fontHash, cgFontHash, ctFontHash, m_useGDI }; 148 return StringHasher::hashMemory<sizeof(hashCodes)>(hashCodes); 134 149 } 135 150 … … 137 152 { 138 153 return m_font == other.m_font 139 && m_cgFont == other.m_cgFont 154 && WTF::safeCFEqual(m_cgFont.get(), other.m_cgFont.get()) 155 && WTF::safeCFEqual(m_ctFont.get(), other.m_ctFont.get()) 140 156 && m_useGDI == other.m_useGDI; 141 157 } -
trunk/Source/cmake/OptionsAppleWin.cmake
r259606 r266982 49 49 SET_AND_EXPOSE_TO_BUILD(USE_CA ON) 50 50 SET_AND_EXPOSE_TO_BUILD(USE_CG ON) 51 SET_AND_EXPOSE_TO_BUILD(USE_CORE_TEXT ON) 51 52 52 53 set(CMAKE_REQUIRED_INCLUDES ${WEBKIT_LIBRARIES_INCLUDE_DIR})
Note: See TracChangeset
for help on using the changeset viewer.