Changeset 254506 in webkit
- Timestamp:
- Jan 14, 2020 6:40:12 AM (4 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r254505 r254506 1 2020-01-14 Carlos Alberto Lopez Perez <clopez@igalia.com> 2 3 [Freetype] Support for the -webkit-font-smoothing CSS property 4 https://bugs.webkit.org/show_bug.cgi?id=54763 5 6 Reviewed by Simon Fraser. 7 8 Add a regression test. This test is specific for platform gtk because 9 it depends on the custom fonts.conf file that its used for GTK layout 10 tests. 11 12 * platform/gtk/TestExpectations: 13 * platform/gtk/fast/css/font-smoothing-expected.png: 14 * platform/gtk/fonts/webkit-font-smoothing-expected.html: Added. 15 * platform/gtk/fonts/webkit-font-smoothing.html: Added. 16 * platform/wpe/TestExpectations: 17 * platform/wpe/fast/css/font-smoothing-expected.png: Added. 18 1 19 2020-01-14 youenn fablet <youenn@apple.com> 2 20 -
trunk/LayoutTests/platform/gtk/TestExpectations
r254486 r254506 815 815 webkit.org/b/142270 fast/canvas/canvas-ellipse-zero-lineto.html [ Failure ] 816 816 817 webkit.org/b/142819 fast/text/baseline-inline-block.html [ ImageOnlyFailure ]818 819 817 # This feature is only enabled on Mac and iOS right now 820 818 contentfiltering [ Skip ] … … 1206 1204 webkit.org/b/206002 http/wpt/css/css-highlight-api/highlight-text-replace.html [ ImageOnlyFailure ] 1207 1205 webkit.org/b/206002 http/wpt/css/css-highlight-api/highlight-text.html [ ImageOnlyFailure ] 1206 1207 webkit.org/b/205186 compositing/contents-format/subpixel-antialiased-text.html [ ImageOnlyFailure ] 1208 webkit.org/b/205187 fast/text/font-antialiasing-save-restore.html [ ImageOnlyFailure ] 1208 1209 1209 1210 #//////////////////////////////////////////////////////////////////////////////////////// -
trunk/LayoutTests/platform/wpe/TestExpectations
r254486 r254506 505 505 webkit.org/b/200165 imported/w3c/web-platform-tests/websockets/cookies/007.html [ Failure ] 506 506 webkit.org/b/200165 imported/w3c/web-platform-tests/websockets/cookies/004.html [ Failure ] 507 508 webkit.org/b/205186 compositing/contents-format/subpixel-antialiased-text.html [ ImageOnlyFailure ] 509 webkit.org/b/205187 fast/text/font-antialiasing-save-restore.html [ ImageOnlyFailure ] 507 510 508 511 #//////////////////////////////////////////////////////////////////////////////////////// -
trunk/Source/WebCore/ChangeLog
r254505 r254506 1 2020-01-14 Carlos Alberto Lopez Perez <clopez@igalia.com> 2 3 [Freetype] Support for the -webkit-font-smoothing CSS property 4 https://bugs.webkit.org/show_bug.cgi?id=54763 5 6 Reviewed by Simon Fraser. 7 8 Pass the smoothing preference defined on the CSS style, so its 9 taken into account when drawing the font. If the CSS doesn't 10 specify any preference then it behaves like before this patch 11 (it tries to automatically antialias the font, if supported). 12 13 This patch sets the antialiasing value at drawing time without 14 affecting the font, like the Mac/iOS ports do. This approach is 15 maybe less efficient than taking into account the antialiasing 16 value when the font platform data its created, but its a better 17 fit for the current cross-platform code. 18 I did some benchmarks (see the bug above if you are curious) and 19 I was unable to prove this method is less efficient than setting 20 the antialising value when the font platform data is created. 21 22 Test: platform/gtk/fonts/webkit-font-smoothing.html 23 24 * platform/graphics/cairo/CairoOperations.cpp: 25 (WebCore::Cairo::drawGlyphsToContext): 26 (WebCore::Cairo::drawGlyphsShadow): 27 (WebCore::Cairo::drawGlyphs): 28 * platform/graphics/cairo/CairoOperations.h: 29 * platform/graphics/cairo/CairoUtilities.cpp: 30 * platform/graphics/cairo/CairoUtilities.h: 31 * platform/graphics/cairo/FontCairo.cpp: 32 (WebCore::FontCascade::drawGlyphs): 33 * platform/graphics/cairo/GraphicsContextImplCairo.cpp: 34 (WebCore::GraphicsContextImplCairo::drawGlyphs): 35 * platform/graphics/nicosia/cairo/NicosiaCairoOperationRecorder.cpp: 36 (Nicosia::CairoOperationRecorder::drawGlyphs): 37 1 38 2020-01-14 youenn fablet <youenn@apple.com> 2 39 -
trunk/Source/WebCore/platform/graphics/cairo/CairoOperations.cpp
r253359 r254506 36 36 #if USE(CAIRO) 37 37 38 #include "CairoUniquePtr.h" 38 39 #include "CairoUtilities.h" 39 40 #include "DrawErrorUnderline.h" … … 307 308 } 308 309 309 static void drawGlyphsToContext(cairo_t* context, cairo_scaled_font_t* scaledFont, double syntheticBoldOffset, const Vector<cairo_glyph_t>& glyphs )310 static void drawGlyphsToContext(cairo_t* context, cairo_scaled_font_t* scaledFont, double syntheticBoldOffset, const Vector<cairo_glyph_t>& glyphs, FontSmoothingMode fontSmoothingMode) 310 311 { 311 312 cairo_matrix_t originalTransform; … … 314 315 315 316 cairo_set_scaled_font(context, scaledFont); 317 318 // The scaled font defaults to FontSmoothingMode::AutoSmoothing. Only override antialiasing settings if its not auto. 319 if (fontSmoothingMode != FontSmoothingMode::AutoSmoothing) { 320 CairoUniquePtr<cairo_font_options_t> fontOptionsSmoothing(cairo_font_options_copy(getDefaultCairoFontOptions())); 321 switch (fontSmoothingMode) { 322 case FontSmoothingMode::Antialiased: 323 cairo_font_options_set_antialias(fontOptionsSmoothing.get(), CAIRO_ANTIALIAS_GRAY); 324 break; 325 case FontSmoothingMode::SubpixelAntialiased: 326 cairo_font_options_set_antialias(fontOptionsSmoothing.get(), CAIRO_ANTIALIAS_SUBPIXEL); 327 break; 328 case FontSmoothingMode::NoSmoothing: 329 cairo_font_options_set_antialias(fontOptionsSmoothing.get(), CAIRO_ANTIALIAS_NONE); 330 break; 331 default: 332 ASSERT_NOT_REACHED(); 333 } 334 cairo_set_font_options(context, fontOptionsSmoothing.get()); 335 } 336 316 337 cairo_show_glyphs(context, glyphs.data(), glyphs.size()); 317 338 … … 324 345 } 325 346 326 static void drawGlyphsShadow(PlatformContextCairo& platformContext, const ShadowState& shadowState, TextDrawingModeFlags textDrawingMode, const FloatSize& shadowOffset, const Color& shadowColor, const FloatPoint& point, cairo_scaled_font_t* scaledFont, double syntheticBoldOffset, const Vector<cairo_glyph_t>& glyphs )347 static void drawGlyphsShadow(PlatformContextCairo& platformContext, const ShadowState& shadowState, TextDrawingModeFlags textDrawingMode, const FloatSize& shadowOffset, const Color& shadowColor, const FloatPoint& point, cairo_scaled_font_t* scaledFont, double syntheticBoldOffset, const Vector<cairo_glyph_t>& glyphs, FontSmoothingMode fontSmoothingMode) 327 348 { 328 349 ShadowBlur shadow({ shadowState.blur, shadowState.blur }, shadowState.offset, shadowState.color, shadowState.ignoreTransforms); … … 337 358 cairo_translate(context, shadowOffset.width(), shadowOffset.height()); 338 359 setSourceRGBAFromColor(context, shadowColor); 339 drawGlyphsToContext(context, scaledFont, syntheticBoldOffset, glyphs );360 drawGlyphsToContext(context, scaledFont, syntheticBoldOffset, glyphs, fontSmoothingMode); 340 361 341 362 cairo_restore(context); … … 348 369 349 370 shadow.drawShadowLayer(State::getCTM(platformContext), State::getClipBounds(platformContext), fontExtentsRect, 350 [scaledFont, syntheticBoldOffset, &glyphs ](GraphicsContext& shadowContext)371 [scaledFont, syntheticBoldOffset, &glyphs, fontSmoothingMode](GraphicsContext& shadowContext) 351 372 { 352 drawGlyphsToContext(shadowContext.platformContext()->cr(), scaledFont, syntheticBoldOffset, glyphs );373 drawGlyphsToContext(shadowContext.platformContext()->cr(), scaledFont, syntheticBoldOffset, glyphs, fontSmoothingMode); 353 374 }, 354 375 [&platformContext, &shadowState](ImageBuffer& layerImage, const FloatPoint& layerOrigin, const FloatSize& layerSize) … … 837 858 } 838 859 839 void drawGlyphs(PlatformContextCairo& platformContext, const FillSource& fillSource, const StrokeSource& strokeSource, const ShadowState& shadowState, const FloatPoint& point, cairo_scaled_font_t* scaledFont, double syntheticBoldOffset, const Vector<cairo_glyph_t>& glyphs, float xOffset, TextDrawingModeFlags textDrawingMode, float strokeThickness, const FloatSize& shadowOffset, const Color& shadowColor )840 { 841 drawGlyphsShadow(platformContext, shadowState, textDrawingMode, shadowOffset, shadowColor, point, scaledFont, syntheticBoldOffset, glyphs );860 void drawGlyphs(PlatformContextCairo& platformContext, const FillSource& fillSource, const StrokeSource& strokeSource, const ShadowState& shadowState, const FloatPoint& point, cairo_scaled_font_t* scaledFont, double syntheticBoldOffset, const Vector<cairo_glyph_t>& glyphs, float xOffset, TextDrawingModeFlags textDrawingMode, float strokeThickness, const FloatSize& shadowOffset, const Color& shadowColor, FontSmoothingMode fontSmoothingMode) 861 { 862 drawGlyphsShadow(platformContext, shadowState, textDrawingMode, shadowOffset, shadowColor, point, scaledFont, syntheticBoldOffset, glyphs, fontSmoothingMode); 842 863 843 864 cairo_t* cr = platformContext.cr(); … … 846 867 if (textDrawingMode & TextModeFill) { 847 868 prepareForFilling(cr, fillSource, AdjustPatternForGlobalAlpha); 848 drawGlyphsToContext(cr, scaledFont, syntheticBoldOffset, glyphs );869 drawGlyphsToContext(cr, scaledFont, syntheticBoldOffset, glyphs, fontSmoothingMode); 849 870 } 850 871 -
trunk/Source/WebCore/platform/graphics/cairo/CairoOperations.h
r252965 r254506 137 137 void clearRect(PlatformContextCairo&, const FloatRect&); 138 138 139 void drawGlyphs(PlatformContextCairo&, const FillSource&, const StrokeSource&, const ShadowState&, const FloatPoint&, cairo_scaled_font_t*, double, const Vector<cairo_glyph_t>&, float, TextDrawingModeFlags, float, const FloatSize&, const Color& );139 void drawGlyphs(PlatformContextCairo&, const FillSource&, const StrokeSource&, const ShadowState&, const FloatPoint&, cairo_scaled_font_t*, double, const Vector<cairo_glyph_t>&, float, TextDrawingModeFlags, float, const FloatSize&, const Color&, FontSmoothingMode); 140 140 141 141 void drawNativeImage(PlatformContextCairo&, cairo_surface_t*, const FloatRect&, const FloatRect&, const ImagePaintingOptions&, float, const ShadowState&); -
trunk/Source/WebCore/platform/graphics/cairo/CairoUtilities.cpp
r254502 r254506 57 57 namespace WebCore { 58 58 59 #if USE( FREETYPE) && !PLATFORM(GTK)59 #if USE(CAIRO) && !PLATFORM(GTK) 60 60 const cairo_font_options_t* getDefaultCairoFontOptions() 61 61 { -
trunk/Source/WebCore/platform/graphics/cairo/CairoUtilities.h
r254502 r254506 71 71 FT_Face m_ftFace { nullptr }; 72 72 }; 73 #endif 73 74 75 #if USE(CAIRO) 74 76 const cairo_font_options_t* getDefaultCairoFontOptions(); 75 77 #endif -
trunk/Source/WebCore/platform/graphics/cairo/FontCairo.cpp
r254190 r254506 50 50 51 51 void FontCascade::drawGlyphs(GraphicsContext& context, const Font& font, const GlyphBuffer& glyphBuffer, 52 unsigned from, unsigned numGlyphs, const FloatPoint& point, FontSmoothingMode )52 unsigned from, unsigned numGlyphs, const FloatPoint& point, FontSmoothingMode fontSmoothingMode) 53 53 { 54 54 if (!font.platformData().size()) … … 77 77 Cairo::drawGlyphs(*context.platformContext(), Cairo::FillSource(state), Cairo::StrokeSource(state), 78 78 Cairo::ShadowState(state), point, scaledFont, syntheticBoldOffset, glyphs, xOffset, 79 state.textDrawingMode, state.strokeThickness, state.shadowOffset, state.shadowColor); 79 state.textDrawingMode, state.strokeThickness, state.shadowOffset, state.shadowColor, 80 fontSmoothingMode); 80 81 } 81 82 -
trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextImplCairo.cpp
r254190 r254506 234 234 void GraphicsContextImplCairo::drawGlyphs(const Font& font, const GlyphBuffer& glyphBuffer, unsigned from, unsigned numGlyphs, const FloatPoint& point, FontSmoothingMode fontSmoothing) 235 235 { 236 UNUSED_PARAM(fontSmoothing);237 236 if (!font.platformData().size()) 238 237 return; … … 259 258 Cairo::drawGlyphs(m_platformContext, Cairo::FillSource(state), Cairo::StrokeSource(state), 260 259 Cairo::ShadowState(state), point, scaledFont, syntheticBoldOffset, glyphs, xOffset, 261 state.textDrawingMode, state.strokeThickness, state.shadowOffset, state.shadowColor); 260 state.textDrawingMode, state.strokeThickness, state.shadowOffset, state.shadowColor, 261 fontSmoothing); 262 262 } 263 263 -
trunk/Source/WebCore/platform/graphics/nicosia/cairo/NicosiaCairoOperationRecorder.cpp
r249217 r254506 494 494 void CairoOperationRecorder::drawGlyphs(const Font& font, const GlyphBuffer& glyphBuffer, unsigned from, unsigned numGlyphs, const FloatPoint& point, FontSmoothingMode fontSmoothing) 495 495 { 496 struct DrawGlyphs final : PaintingOperation, OperationData<Cairo::FillSource, Cairo::StrokeSource, Cairo::ShadowState, FloatPoint, RefPtr<cairo_scaled_font_t>, float, Vector<cairo_glyph_t>, float, TextDrawingModeFlags, float, FloatSize, Color > {496 struct DrawGlyphs final : PaintingOperation, OperationData<Cairo::FillSource, Cairo::StrokeSource, Cairo::ShadowState, FloatPoint, RefPtr<cairo_scaled_font_t>, float, Vector<cairo_glyph_t>, float, TextDrawingModeFlags, float, FloatSize, Color, FontSmoothingMode> { 497 497 virtual ~DrawGlyphs() = default; 498 498 … … 500 500 { 501 501 Cairo::drawGlyphs(contextForReplay(replayer), arg<0>(), arg<1>(), arg<2>(), arg<3>(), arg<4>().get(), 502 arg<5>(), arg<6>(), arg<7>(), arg<8>(), arg<9>(), arg<10>(), arg<11>() );502 arg<5>(), arg<6>(), arg<7>(), arg<8>(), arg<9>(), arg<10>(), arg<11>(), arg<12>()); 503 503 } 504 504 … … 509 509 }; 510 510 511 UNUSED_PARAM(fontSmoothing);512 511 if (!font.platformData().size()) 513 512 return; … … 532 531 RefPtr<cairo_scaled_font_t>(font.platformData().scaledFont()), 533 532 font.syntheticBoldOffset(), WTFMove(glyphs), xOffset, state.textDrawingMode, 534 state.strokeThickness, state.shadowOffset, state.shadowColor ));533 state.strokeThickness, state.shadowOffset, state.shadowColor, fontSmoothing)); 535 534 } 536 535
Note: See TracChangeset
for help on using the changeset viewer.