Diff
Modified: trunk/LayoutTests/ChangeLog (254505 => 254506)
--- trunk/LayoutTests/ChangeLog 2020-01-14 14:37:51 UTC (rev 254505)
+++ trunk/LayoutTests/ChangeLog 2020-01-14 14:40:12 UTC (rev 254506)
@@ -1,3 +1,21 @@
+2020-01-14 Carlos Alberto Lopez Perez <clo...@igalia.com>
+
+ [Freetype] Support for the -webkit-font-smoothing CSS property
+ https://bugs.webkit.org/show_bug.cgi?id=54763
+
+ Reviewed by Simon Fraser.
+
+ Add a regression test. This test is specific for platform gtk because
+ it depends on the custom fonts.conf file that its used for GTK layout
+ tests.
+
+ * platform/gtk/TestExpectations:
+ * platform/gtk/fast/css/font-smoothing-expected.png:
+ * platform/gtk/fonts/webkit-font-smoothing-expected.html: Added.
+ * platform/gtk/fonts/webkit-font-smoothing.html: Added.
+ * platform/wpe/TestExpectations:
+ * platform/wpe/fast/css/font-smoothing-expected.png: Added.
+
2020-01-14 youenn fablet <you...@apple.com>
Add support for MediaStream audio track rendering in GPUProcess
Modified: trunk/LayoutTests/platform/gtk/TestExpectations (254505 => 254506)
--- trunk/LayoutTests/platform/gtk/TestExpectations 2020-01-14 14:37:51 UTC (rev 254505)
+++ trunk/LayoutTests/platform/gtk/TestExpectations 2020-01-14 14:40:12 UTC (rev 254506)
@@ -814,8 +814,6 @@
webkit.org/b/142269 fast/attachment/attachment-dom.html [ Failure ]
webkit.org/b/142270 fast/canvas/canvas-ellipse-zero-lineto.html [ Failure ]
-webkit.org/b/142819 fast/text/baseline-inline-block.html [ ImageOnlyFailure ]
-
# This feature is only enabled on Mac and iOS right now
contentfiltering [ Skip ]
http/tests/contentfiltering [ Skip ]
@@ -1206,6 +1204,9 @@
webkit.org/b/206002 http/wpt/css/css-highlight-api/highlight-text-replace.html [ ImageOnlyFailure ]
webkit.org/b/206002 http/wpt/css/css-highlight-api/highlight-text.html [ ImageOnlyFailure ]
+webkit.org/b/205186 compositing/contents-format/subpixel-antialiased-text.html [ ImageOnlyFailure ]
+webkit.org/b/205187 fast/text/font-antialiasing-save-restore.html [ ImageOnlyFailure ]
+
#////////////////////////////////////////////////////////////////////////////////////////
# End of Expected failures.
#
Modified: trunk/LayoutTests/platform/gtk/fast/css/font-smoothing-expected.png
(Binary files differ)
Added: trunk/LayoutTests/platform/gtk/fonts/webkit-font-smoothing-expected.html (0 => 254506)
--- trunk/LayoutTests/platform/gtk/fonts/webkit-font-smoothing-expected.html (rev 0)
+++ trunk/LayoutTests/platform/gtk/fonts/webkit-font-smoothing-expected.html 2020-01-14 14:40:12 UTC (rev 254506)
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <style>
+ p {
+ font-size: 16pt;
+ font-family: Liberation Sans;
+ }
+ </style>
+</head>
+<body>
+ <p>This test is not expected to work outside of WebKitTestRunner.</p>
+ <p>It depends on the custom fonts.conf file that its loaded by the test tooling.</p>
+ <p>Test results:</p>
+ <p style="font-family: NonAntiAliasedSans;">This should NOT be antialiased.</p>
+ <p style="font-family: SubpixelDisabledSans;">This should be antialiased.<p>
+</body>
+</html>
Added: trunk/LayoutTests/platform/gtk/fonts/webkit-font-smoothing.html (0 => 254506)
--- trunk/LayoutTests/platform/gtk/fonts/webkit-font-smoothing.html (rev 0)
+++ trunk/LayoutTests/platform/gtk/fonts/webkit-font-smoothing.html 2020-01-14 14:40:12 UTC (rev 254506)
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <style>
+ p {
+ font-size: 16pt;
+ font-family: Liberation Sans;
+ }
+ </style>
+</head>
+<body>
+ <p>This test is not expected to work outside of WebKitTestRunner.</p>
+ <p>It depends on the custom fonts.conf file that its loaded by the test tooling.</p>
+ <p>Test results:</p>
+ <p style="-webkit-font-smoothing: none">This should NOT be antialiased.</p>
+ <p style="-webkit-font-smoothing: antialiased">This should be antialiased.</p>
+</body>
+</html>
Modified: trunk/LayoutTests/platform/wpe/TestExpectations (254505 => 254506)
--- trunk/LayoutTests/platform/wpe/TestExpectations 2020-01-14 14:37:51 UTC (rev 254505)
+++ trunk/LayoutTests/platform/wpe/TestExpectations 2020-01-14 14:40:12 UTC (rev 254506)
@@ -505,6 +505,9 @@
webkit.org/b/200165 imported/w3c/web-platform-tests/websockets/cookies/007.html [ Failure ]
webkit.org/b/200165 imported/w3c/web-platform-tests/websockets/cookies/004.html [ Failure ]
+webkit.org/b/205186 compositing/contents-format/subpixel-antialiased-text.html [ ImageOnlyFailure ]
+webkit.org/b/205187 fast/text/font-antialiasing-save-restore.html [ ImageOnlyFailure ]
+
#////////////////////////////////////////////////////////////////////////////////////////
# 3. UNRESOLVED TESTS
#////////////////////////////////////////////////////////////////////////////////////////
Added: trunk/LayoutTests/platform/wpe/fast/css/font-smoothing-expected.png
(Binary files differ)
Index: trunk/LayoutTests/platform/wpe/fast/css/font-smoothing-expected.png
===================================================================
--- trunk/LayoutTests/platform/wpe/fast/css/font-smoothing-expected.png 2020-01-14 14:37:51 UTC (rev 254505)
+++ trunk/LayoutTests/platform/wpe/fast/css/font-smoothing-expected.png 2020-01-14 14:40:12 UTC (rev 254506)
Property changes on: trunk/LayoutTests/platform/wpe/fast/css/font-smoothing-expected.png
___________________________________________________________________
Added: svn:mime-type
+image/png
\ No newline at end of property
Modified: trunk/Source/WebCore/ChangeLog (254505 => 254506)
--- trunk/Source/WebCore/ChangeLog 2020-01-14 14:37:51 UTC (rev 254505)
+++ trunk/Source/WebCore/ChangeLog 2020-01-14 14:40:12 UTC (rev 254506)
@@ -1,3 +1,40 @@
+2020-01-14 Carlos Alberto Lopez Perez <clo...@igalia.com>
+
+ [Freetype] Support for the -webkit-font-smoothing CSS property
+ https://bugs.webkit.org/show_bug.cgi?id=54763
+
+ Reviewed by Simon Fraser.
+
+ Pass the smoothing preference defined on the CSS style, so its
+ taken into account when drawing the font. If the CSS doesn't
+ specify any preference then it behaves like before this patch
+ (it tries to automatically antialias the font, if supported).
+
+ This patch sets the antialiasing value at drawing time without
+ affecting the font, like the Mac/iOS ports do. This approach is
+ maybe less efficient than taking into account the antialiasing
+ value when the font platform data its created, but its a better
+ fit for the current cross-platform code.
+ I did some benchmarks (see the bug above if you are curious) and
+ I was unable to prove this method is less efficient than setting
+ the antialising value when the font platform data is created.
+
+ Test: platform/gtk/fonts/webkit-font-smoothing.html
+
+ * platform/graphics/cairo/CairoOperations.cpp:
+ (WebCore::Cairo::drawGlyphsToContext):
+ (WebCore::Cairo::drawGlyphsShadow):
+ (WebCore::Cairo::drawGlyphs):
+ * platform/graphics/cairo/CairoOperations.h:
+ * platform/graphics/cairo/CairoUtilities.cpp:
+ * platform/graphics/cairo/CairoUtilities.h:
+ * platform/graphics/cairo/FontCairo.cpp:
+ (WebCore::FontCascade::drawGlyphs):
+ * platform/graphics/cairo/GraphicsContextImplCairo.cpp:
+ (WebCore::GraphicsContextImplCairo::drawGlyphs):
+ * platform/graphics/nicosia/cairo/NicosiaCairoOperationRecorder.cpp:
+ (Nicosia::CairoOperationRecorder::drawGlyphs):
+
2020-01-14 youenn fablet <you...@apple.com>
Add support for MediaStream audio track rendering in GPUProcess
Modified: trunk/Source/WebCore/platform/graphics/cairo/CairoOperations.cpp (254505 => 254506)
--- trunk/Source/WebCore/platform/graphics/cairo/CairoOperations.cpp 2020-01-14 14:37:51 UTC (rev 254505)
+++ trunk/Source/WebCore/platform/graphics/cairo/CairoOperations.cpp 2020-01-14 14:40:12 UTC (rev 254506)
@@ -35,6 +35,7 @@
#if USE(CAIRO)
+#include "CairoUniquePtr.h"
#include "CairoUtilities.h"
#include "DrawErrorUnderline.h"
#include "FloatConversion.h"
@@ -306,7 +307,7 @@
#endif
}
-static void drawGlyphsToContext(cairo_t* context, cairo_scaled_font_t* scaledFont, double syntheticBoldOffset, const Vector<cairo_glyph_t>& glyphs)
+static void drawGlyphsToContext(cairo_t* context, cairo_scaled_font_t* scaledFont, double syntheticBoldOffset, const Vector<cairo_glyph_t>& glyphs, FontSmoothingMode fontSmoothingMode)
{
cairo_matrix_t originalTransform;
if (syntheticBoldOffset)
@@ -313,6 +314,26 @@
cairo_get_matrix(context, &originalTransform);
cairo_set_scaled_font(context, scaledFont);
+
+ // The scaled font defaults to FontSmoothingMode::AutoSmoothing. Only override antialiasing settings if its not auto.
+ if (fontSmoothingMode != FontSmoothingMode::AutoSmoothing) {
+ CairoUniquePtr<cairo_font_options_t> fontOptionsSmoothing(cairo_font_options_copy(getDefaultCairoFontOptions()));
+ switch (fontSmoothingMode) {
+ case FontSmoothingMode::Antialiased:
+ cairo_font_options_set_antialias(fontOptionsSmoothing.get(), CAIRO_ANTIALIAS_GRAY);
+ break;
+ case FontSmoothingMode::SubpixelAntialiased:
+ cairo_font_options_set_antialias(fontOptionsSmoothing.get(), CAIRO_ANTIALIAS_SUBPIXEL);
+ break;
+ case FontSmoothingMode::NoSmoothing:
+ cairo_font_options_set_antialias(fontOptionsSmoothing.get(), CAIRO_ANTIALIAS_NONE);
+ break;
+ default:
+ ASSERT_NOT_REACHED();
+ }
+ cairo_set_font_options(context, fontOptionsSmoothing.get());
+ }
+
cairo_show_glyphs(context, glyphs.data(), glyphs.size());
if (syntheticBoldOffset) {
@@ -323,7 +344,7 @@
}
}
-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)
+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)
{
ShadowBlur shadow({ shadowState.blur, shadowState.blur }, shadowState.offset, shadowState.color, shadowState.ignoreTransforms);
if (!(textDrawingMode & TextModeFill) || shadow.type() == ShadowBlur::NoShadow)
@@ -336,7 +357,7 @@
cairo_translate(context, shadowOffset.width(), shadowOffset.height());
setSourceRGBAFromColor(context, shadowColor);
- drawGlyphsToContext(context, scaledFont, syntheticBoldOffset, glyphs);
+ drawGlyphsToContext(context, scaledFont, syntheticBoldOffset, glyphs, fontSmoothingMode);
cairo_restore(context);
return;
@@ -347,9 +368,9 @@
FloatRect fontExtentsRect(point.x() + extents.x_bearing, point.y() + extents.y_bearing, extents.width, extents.height);
shadow.drawShadowLayer(State::getCTM(platformContext), State::getClipBounds(platformContext), fontExtentsRect,
- [scaledFont, syntheticBoldOffset, &glyphs](GraphicsContext& shadowContext)
+ [scaledFont, syntheticBoldOffset, &glyphs, fontSmoothingMode](GraphicsContext& shadowContext)
{
- drawGlyphsToContext(shadowContext.platformContext()->cr(), scaledFont, syntheticBoldOffset, glyphs);
+ drawGlyphsToContext(shadowContext.platformContext()->cr(), scaledFont, syntheticBoldOffset, glyphs, fontSmoothingMode);
},
[&platformContext, &shadowState](ImageBuffer& layerImage, const FloatPoint& layerOrigin, const FloatSize& layerSize)
{
@@ -836,9 +857,9 @@
cairo_restore(cr);
}
-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)
+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)
{
- drawGlyphsShadow(platformContext, shadowState, textDrawingMode, shadowOffset, shadowColor, point, scaledFont, syntheticBoldOffset, glyphs);
+ drawGlyphsShadow(platformContext, shadowState, textDrawingMode, shadowOffset, shadowColor, point, scaledFont, syntheticBoldOffset, glyphs, fontSmoothingMode);
cairo_t* cr = platformContext.cr();
cairo_save(cr);
@@ -845,7 +866,7 @@
if (textDrawingMode & TextModeFill) {
prepareForFilling(cr, fillSource, AdjustPatternForGlobalAlpha);
- drawGlyphsToContext(cr, scaledFont, syntheticBoldOffset, glyphs);
+ drawGlyphsToContext(cr, scaledFont, syntheticBoldOffset, glyphs, fontSmoothingMode);
}
// Prevent running into a long computation within cairo. If the stroke width is
Modified: trunk/Source/WebCore/platform/graphics/cairo/CairoOperations.h (254505 => 254506)
--- trunk/Source/WebCore/platform/graphics/cairo/CairoOperations.h 2020-01-14 14:37:51 UTC (rev 254505)
+++ trunk/Source/WebCore/platform/graphics/cairo/CairoOperations.h 2020-01-14 14:40:12 UTC (rev 254506)
@@ -136,7 +136,7 @@
void strokePath(PlatformContextCairo&, const Path&, const StrokeSource&, const ShadowState&);
void clearRect(PlatformContextCairo&, const FloatRect&);
-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&);
+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);
void drawNativeImage(PlatformContextCairo&, cairo_surface_t*, const FloatRect&, const FloatRect&, const ImagePaintingOptions&, float, const ShadowState&);
void drawPattern(PlatformContextCairo&, cairo_surface_t*, const IntSize&, const FloatRect&, const FloatRect&, const AffineTransform&, const FloatPoint&, const ImagePaintingOptions&);
Modified: trunk/Source/WebCore/platform/graphics/cairo/CairoUtilities.cpp (254505 => 254506)
--- trunk/Source/WebCore/platform/graphics/cairo/CairoUtilities.cpp 2020-01-14 14:37:51 UTC (rev 254505)
+++ trunk/Source/WebCore/platform/graphics/cairo/CairoUtilities.cpp 2020-01-14 14:40:12 UTC (rev 254506)
@@ -56,7 +56,7 @@
namespace WebCore {
-#if USE(FREETYPE) && !PLATFORM(GTK)
+#if USE(CAIRO) && !PLATFORM(GTK)
const cairo_font_options_t* getDefaultCairoFontOptions()
{
static NeverDestroyed<cairo_font_options_t*> options = cairo_font_options_create();
Modified: trunk/Source/WebCore/platform/graphics/cairo/CairoUtilities.h (254505 => 254506)
--- trunk/Source/WebCore/platform/graphics/cairo/CairoUtilities.h 2020-01-14 14:37:51 UTC (rev 254505)
+++ trunk/Source/WebCore/platform/graphics/cairo/CairoUtilities.h 2020-01-14 14:40:12 UTC (rev 254506)
@@ -70,7 +70,9 @@
cairo_scaled_font_t* m_scaledFont { nullptr };
FT_Face m_ftFace { nullptr };
};
+#endif
+#if USE(CAIRO)
const cairo_font_options_t* getDefaultCairoFontOptions();
#endif
Modified: trunk/Source/WebCore/platform/graphics/cairo/FontCairo.cpp (254505 => 254506)
--- trunk/Source/WebCore/platform/graphics/cairo/FontCairo.cpp 2020-01-14 14:37:51 UTC (rev 254505)
+++ trunk/Source/WebCore/platform/graphics/cairo/FontCairo.cpp 2020-01-14 14:40:12 UTC (rev 254506)
@@ -49,7 +49,7 @@
namespace WebCore {
void FontCascade::drawGlyphs(GraphicsContext& context, const Font& font, const GlyphBuffer& glyphBuffer,
- unsigned from, unsigned numGlyphs, const FloatPoint& point, FontSmoothingMode)
+ unsigned from, unsigned numGlyphs, const FloatPoint& point, FontSmoothingMode fontSmoothingMode)
{
if (!font.platformData().size())
return;
@@ -76,7 +76,8 @@
auto& state = context.state();
Cairo::drawGlyphs(*context.platformContext(), Cairo::FillSource(state), Cairo::StrokeSource(state),
Cairo::ShadowState(state), point, scaledFont, syntheticBoldOffset, glyphs, xOffset,
- state.textDrawingMode, state.strokeThickness, state.shadowOffset, state.shadowColor);
+ state.textDrawingMode, state.strokeThickness, state.shadowOffset, state.shadowColor,
+ fontSmoothingMode);
}
Path Font::platformPathForGlyph(Glyph glyph) const
Modified: trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextImplCairo.cpp (254505 => 254506)
--- trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextImplCairo.cpp 2020-01-14 14:37:51 UTC (rev 254505)
+++ trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextImplCairo.cpp 2020-01-14 14:40:12 UTC (rev 254506)
@@ -233,7 +233,6 @@
void GraphicsContextImplCairo::drawGlyphs(const Font& font, const GlyphBuffer& glyphBuffer, unsigned from, unsigned numGlyphs, const FloatPoint& point, FontSmoothingMode fontSmoothing)
{
- UNUSED_PARAM(fontSmoothing);
if (!font.platformData().size())
return;
@@ -258,7 +257,8 @@
auto& state = graphicsContext().state();
Cairo::drawGlyphs(m_platformContext, Cairo::FillSource(state), Cairo::StrokeSource(state),
Cairo::ShadowState(state), point, scaledFont, syntheticBoldOffset, glyphs, xOffset,
- state.textDrawingMode, state.strokeThickness, state.shadowOffset, state.shadowColor);
+ state.textDrawingMode, state.strokeThickness, state.shadowOffset, state.shadowColor,
+ fontSmoothing);
}
ImageDrawResult GraphicsContextImplCairo::drawImage(Image& image, const FloatRect& destination, const FloatRect& source, const ImagePaintingOptions& imagePaintingOptions)
Modified: trunk/Source/WebCore/platform/graphics/nicosia/cairo/NicosiaCairoOperationRecorder.cpp (254505 => 254506)
--- trunk/Source/WebCore/platform/graphics/nicosia/cairo/NicosiaCairoOperationRecorder.cpp 2020-01-14 14:37:51 UTC (rev 254505)
+++ trunk/Source/WebCore/platform/graphics/nicosia/cairo/NicosiaCairoOperationRecorder.cpp 2020-01-14 14:40:12 UTC (rev 254506)
@@ -493,13 +493,13 @@
void CairoOperationRecorder::drawGlyphs(const Font& font, const GlyphBuffer& glyphBuffer, unsigned from, unsigned numGlyphs, const FloatPoint& point, FontSmoothingMode fontSmoothing)
{
- 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> {
+ 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> {
virtual ~DrawGlyphs() = default;
void execute(PaintingOperationReplay& replayer) override
{
Cairo::drawGlyphs(contextForReplay(replayer), arg<0>(), arg<1>(), arg<2>(), arg<3>(), arg<4>().get(),
- arg<5>(), arg<6>(), arg<7>(), arg<8>(), arg<9>(), arg<10>(), arg<11>());
+ arg<5>(), arg<6>(), arg<7>(), arg<8>(), arg<9>(), arg<10>(), arg<11>(), arg<12>());
}
void dump(TextStream& ts) override
@@ -508,7 +508,6 @@
}
};
- UNUSED_PARAM(fontSmoothing);
if (!font.platformData().size())
return;
@@ -531,7 +530,7 @@
Cairo::ShadowState(state), point,
RefPtr<cairo_scaled_font_t>(font.platformData().scaledFont()),
font.syntheticBoldOffset(), WTFMove(glyphs), xOffset, state.textDrawingMode,
- state.strokeThickness, state.shadowOffset, state.shadowColor));
+ state.strokeThickness, state.shadowOffset, state.shadowColor, fontSmoothing));
}
ImageDrawResult CairoOperationRecorder::drawImage(Image& image, const FloatRect& destination, const FloatRect& source, const ImagePaintingOptions& imagePaintingOptions)