Bug 104956 - [chromium] Fix PlatformContextSkia::setDrawingToImageBuffer abuse
Summary: [chromium] Fix PlatformContextSkia::setDrawingToImageBuffer abuse
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Alok Priyadarshi
URL:
Keywords:
Depends on:
Blocks: 105051
  Show dependency treegraph
 
Reported: 2012-12-13 14:40 PST by Alok Priyadarshi
Modified: 2013-01-07 14:06 PST (History)
8 users (show)

See Also:


Attachments
Patch (9.37 KB, patch)
2012-12-13 15:11 PST, Alok Priyadarshi
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alok Priyadarshi 2012-12-13 14:40:33 PST
We have been using PlatformContextSkia::setDrawingToImageBuffer to indirectly enable/disable LCD text. It was OK until only root layer had LCD text. But now to enable LCD text on composited layer, you have to call PlatformContextSkia::setDrawingToImageBuffer(false), which is wrong.

It turns out that we can use GraphicsContext::setShouldSmoothFonts() to do the same. We may also be able to deprecate PlatformContextSkia::setDrawingToImageBuffer().
Comment 1 Alok Priyadarshi 2012-12-13 15:11:24 PST
Created attachment 179350 [details]
Patch
Comment 2 James Robinson 2012-12-13 15:18:56 PST
What exactly does "setShouldSmoothFonts" mean?  Is it referring to subpixel AA, hinting, AA at all, something else?
Comment 3 Alok Priyadarshi 2012-12-13 15:20:24 PST
I was able to get rid of all setDrawingToImageBuffer calls except the ones in WebScrollbarThemePainter. It looks like it is using it to indirectly set a TransparencyWin::LayerMode in RenderThemeChromiumWin.cpp.
Comment 4 Alok Priyadarshi 2012-12-13 15:21:46 PST
(In reply to comment #2)
> What exactly does "setShouldSmoothFonts" mean?  Is it referring to subpixel AA, hinting, AA at all, something else?

From the current usage on other ports, I think it means subpixel AA.
Comment 5 James Robinson 2012-12-13 15:24:39 PST
(In reply to comment #4)
> (In reply to comment #2)
> > What exactly does "setShouldSmoothFonts" mean?  Is it referring to subpixel AA, hinting, AA at all, something else?
> 
> From the current usage on other ports, I think it means subpixel AA.

I think we want more than "I think it means".  In the past, we've definitely been burned by conflating multiple needs under a single flag.  Why not have a dedicated flag that means exactly what we want it to mean?
Comment 6 Alok Priyadarshi 2012-12-13 16:02:45 PST
The variable name is not explicit, but looking at Font::drawGlyphs in the mac port, it is pretty clear what it is being used for:

shouldAntiAlias: AA
shouldSmoothFonts: subpixel AA
shouldSubpixelQuantizeFonts: subpixel positioning

http://trac.webkit.org/browser/trunk/Source/WebCore/platform/graphics/mac/FontMac.mm#L144

I did not see those variables used in the chromium port.
Comment 7 Justin Novosad 2012-12-13 19:52:37 PST
(In reply to comment #6)
> The variable name is not explicit, but looking at Font::drawGlyphs in the mac port, it is pretty clear what it is being used for:
> 
> shouldAntiAlias: AA
> shouldSmoothFonts: subpixel AA
> shouldSubpixelQuantizeFonts: subpixel positioning
> 

If shouldSmoothFonts is in any way related to the webkit-font-smoothing CSS property, we probably want to leave it alone, since that property is now mostly used to control the boldness side-effect of subpixel AA on mac.

@bungeman?
Comment 8 Alok Priyadarshi 2012-12-13 20:59:17 PST
(In reply to comment #7)
> (In reply to comment #6)
> > The variable name is not explicit, but looking at Font::drawGlyphs in the mac port, it is pretty clear what it is being used for:
> > 
> > shouldAntiAlias: AA
> > shouldSmoothFonts: subpixel AA
> > shouldSubpixelQuantizeFonts: subpixel positioning
> > 
> 
> If shouldSmoothFonts is in any way related to the webkit-font-smoothing CSS property, we probably want to leave it alone, since that property is now mostly used to control the boldness side-effect of subpixel AA on mac.
> 
> @bungeman?

AFAICT they are not related. -webkit-font-smoothing is captured in Font::fontDescription().fontSmoothing()

See various implementations of Font::drawGlyphs().
Comment 9 bungeman 2013-01-07 10:51:54 PST
(In reply to comment #8)
> (In reply to comment #7)
> > (In reply to comment #6)
> > > The variable name is not explicit, but looking at Font::drawGlyphs in the mac port, it is pretty clear what it is being used for:
> > > 
> > > shouldAntiAlias: AA
> > > shouldSmoothFonts: subpixel AA
> > > shouldSubpixelQuantizeFonts: subpixel positioning
> > > 
> > 
> > If shouldSmoothFonts is in any way related to the webkit-font-smoothing CSS property, we probably want to leave it alone, since that property is now mostly used to control the boldness side-effect of subpixel AA on mac.
> > 
> > @bungeman?
> 
> AFAICT they are not related. -webkit-font-smoothing is captured in Font::fontDescription().fontSmoothing()
> 
> See various implementations of Font::drawGlyphs().

Summary: Use shouldAntiAlias, shouldSmoothFonts, and shouldSubpixelQuantizeFonts. While I don't know all of the details, this patch looks correct to me.

The names AntiAlias, SmoothFonts, and SubpixelQuantizeFonts are all CoreGraphics-isms. In the world of CoreGraphics they mean what Alok says they mean in comment #6. That said, this used to directly interact with -webkit-font-smoothing, as the value of -webkit-font-smoothing basically translated into one of the above on Mac. The problem was that on Mac the weight of the text changes between lcd smoothed and regular anti-aliased. What we do now is use AntiAlias and SmoothFonts to choose the rendering method, and if -webkit-font-smoothing:antialised is used set the Skia paint's hinting to 'none' (instead of 'normal'). With AntiAlias and 'normal' hinting the regular anti-alias is back-formed from the lcd so that the weight doesn't change in transitions to and from lcd smoothed.

See http://trac.webkit.org/browser/trunk/Source/WebCore/platform/graphics/skia/FontSkia.cpp#L76
Comment 10 James Robinson 2013-01-07 13:02:23 PST
Comment on attachment 179350 [details]
Patch

OK, thanks for the background.  R=me
Comment 11 WebKit Review Bot 2013-01-07 14:06:55 PST
Comment on attachment 179350 [details]
Patch

Clearing flags on attachment: 179350

Committed r138987: <http://trac.webkit.org/changeset/138987>
Comment 12 WebKit Review Bot 2013-01-07 14:06:59 PST
All reviewed patches have been landed.  Closing bug.