Add experimental code to use custom font dilation when rendering into non-opaque...
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 8 Apr 2015 04:15:01 +0000 (04:15 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 8 Apr 2015 04:15:01 +0000 (04:15 +0000)
commitecff066da3f25b894179ad18bbd2d8919f7a61b5
treec4876e58fbfdff7afec82492eecb7b00c550ccac
parent1d4b9c30c1858e69845f42b564b28a90790d5518
Add experimental code to use custom font dilation when rendering into non-opaque contexts
https://bugs.webkit.org/show_bug.cgi?id=143508

Reviewed by Sam Weinig.

Add GraphicsContext::setAntialiasedFontDilationEnabled(), and set it to true
when rendering into a compositing layer which is not opaque (at the same location
where we disable font smoothing).

If Settings::antialiasedFontDilationEnabled() is true, when rendering non-smoothed
text (and if CSS hasn't opted into antialiased mode), use custom font dilation
parameters, chosen using a light/medium/dark heuristic, to make this text
match more closely with LCD-smoothed text.

* page/Settings.cpp:
(WebCore::Settings::Settings):
(WebCore::Settings::setAntialiasedFontDilationEnabled): Set global state
in FontCascade (which can't easily get at Settings). This it not ideal,
but is temporary.
* page/Settings.h:
(WebCore::Settings::antialiasedFontDilationEnabled):
* page/Settings.in: Can't autogenerate this setting any more.
* platform/graphics/FontCascade.cpp:
(WebCore::FontCascade::setAntialiasedFontDilationEnabled): Set the global.
(WebCore::FontCascade::antialiasedFontDilationEnabled):
* platform/graphics/FontCascade.h:
* platform/graphics/GraphicsContext.cpp:
(WebCore::GraphicsContext::setAntialiasedFontDilationEnabled): Set graphics state
to say that we should do dilation of antialiased text.
* platform/graphics/GraphicsContext.h:
(WebCore::GraphicsContextState::GraphicsContextState):
(WebCore::GraphicsContext::antialiasedFontDilationEnabled):
* platform/graphics/ca/mac/PlatformCALayerMac.mm:
(PlatformCALayer::drawLayerContents): If the layer is not opaque, enable the
dilated text code path.
* platform/graphics/cocoa/FontCascadeCocoa.mm:
(WebCore::dilationSizeForTextColor): Heuristic (values chosen empirically) to
computed custom dilation based on foreground color.
(WebCore::FontCascade::drawGlyphs): Set the custom dilation parameters, and the
antialiasing state if we're not doing smoothing, and CSS hasn't opted into the
antialiased path.
* platform/spi/cg/CoreGraphicsSPI.h: New SPI.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@182516 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebCore/ChangeLog
Source/WebCore/page/Settings.cpp
Source/WebCore/page/Settings.h
Source/WebCore/page/Settings.in
Source/WebCore/platform/graphics/FontCascade.cpp
Source/WebCore/platform/graphics/FontCascade.h
Source/WebCore/platform/graphics/GraphicsContext.cpp
Source/WebCore/platform/graphics/GraphicsContext.h
Source/WebCore/platform/graphics/ca/mac/PlatformCALayerMac.mm
Source/WebCore/platform/graphics/cocoa/FontCascadeCocoa.mm
Source/WebCore/platform/spi/cg/CoreGraphicsSPI.h