Bug 96940 - A layout test to verify scaled composited layers have crisp text
Summary: A layout test to verify scaled composited layers have crisp text
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Dana Jansens
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-09-17 12:20 PDT by Dana Jansens
Modified: 2012-10-24 11:10 PDT (History)
7 users (show)

See Also:


Attachments
Patch (2.11 KB, patch)
2012-09-17 12:21 PDT, Dana Jansens
no flags Details | Formatted Diff | Diff
Patch (2.15 KB, patch)
2012-09-17 13:01 PDT, Dana Jansens
no flags Details | Formatted Diff | Diff
Patch (38.51 KB, patch)
2012-10-22 16:05 PDT, Dana Jansens
no flags Details | Formatted Diff | Diff
Patch (5.10 KB, patch)
2012-10-22 17:34 PDT, Dana Jansens
no flags Details | Formatted Diff | Diff
Patch (5.40 KB, patch)
2012-10-22 17:45 PDT, Dana Jansens
no flags Details | Formatted Diff | Diff
Patch (5.47 KB, patch)
2012-10-23 17:13 PDT, Dana Jansens
no flags Details | Formatted Diff | Diff
Patch (6.41 KB, patch)
2012-10-24 09:59 PDT, Dana Jansens
no flags Details | Formatted Diff | Diff
Patch for landing (6.52 KB, patch)
2012-10-24 10:32 PDT, Dana Jansens
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dana Jansens 2012-09-17 12:20:35 PDT
A layout test to verify scaled composited layers have crisp text
Comment 1 Dana Jansens 2012-09-17 12:21:17 PDT
Created attachment 164437 [details]
Patch
Comment 2 James Robinson 2012-09-17 12:39:47 PDT
So the expectation here is that we'd raster at the higher scale instead of applying the transform in the compositor?  What behavior would you expect if the scale and translate were applied as one big matrix?
Comment 3 Dana Jansens 2012-09-17 12:43:50 PDT
The expectation is that the contents of the composited layer contain the CSS transform, in exactly the same way as happens for device scale factor.

If we had a scale and transform, I would expect the text to be crisp because the backing texture of the layer is scaled, and the compositor would apply the scale+transform during rendering to put crisp text on the screen at the appropriate place.
Comment 4 Dana Jansens 2012-09-17 12:44:39 PDT
(In reply to comment #3)
> The expectation is that the contents of the composited layer contain the CSS transform, in exactly the same way as happens for device scale factor.
> 
> If we had a scale and transform, I would expect the text to be crisp because the backing texture of the layer is scaled, and the compositor would apply the scale+transform during rendering to put crisp text on the screen at the appropriate place.

s/transform/translate/ in that second paragraph.
Comment 5 Dana Jansens 2012-09-17 13:01:13 PDT
Created attachment 164444 [details]
Patch

this version of the test uses a translate instead of left/top. we can use this instead if you like.
Comment 6 James Robinson 2012-09-17 13:07:17 PDT
That's not the point.  The question here is fundamentally about what scale to raster with when there's a compositor-applied transform.  For deviceScale you're right that we should raster at the post-scaled value so we end up 1:1 to screen.  For other transforms, it's much less clear what the right thing is.  Rastering at the highest scale we see and then trying to downsample in the compositor does produce the highest quality, but uses a lot of time and memory.  It sounds like you want to do a peephole optimization for the case where the compositing trigger and scale are on the same element but not address the more general case of a scale on an ancestor.  That seems fine, but I'd like you to precisely define what the parameters for this will be.

The other case to think about is when a scale is being animated (which is really common) - what scale do you want to raster at?
Comment 7 Dana Jansens 2012-09-17 13:13:46 PDT
(In reply to comment #6)
> That's not the point.  The question here is fundamentally about what scale to raster with when there's a compositor-applied transform.  For deviceScale you're right that we should raster at the post-scaled value so we end up 1:1 to screen.  For other transforms, it's much less clear what the right thing is.  Rastering at the highest scale we see and then trying to downsample in the compositor does produce the highest quality, but uses a lot of time and memory.  It sounds like you want to do a peephole optimization for the case where the compositing trigger and scale are on the same element but not address the more general case of a scale on an ancestor.  That seems fine, but I'd like you to precisely define what the parameters for this will be.

Oh! I kinda assumed transform() included the parent but right, it does not.

It seems to me that it's a bug if we draw things fuzzy because of a webkit-transform on some ancestor (ie composited layer vs non), and that we should match what the output would look like if it was rendered in the NCCH instead.

> The other case to think about is when a scale is being animated (which is really common) - what scale do you want to raster at?

Right, Nat's concerned about causing a lot of painting, so I am proposing that we don't change the layer's contentsScale until animation completes, so we can avoid invalidations during the animation.
Comment 8 Adrienne Walker 2012-09-17 13:16:36 PDT
Is there any way to just make this a ref test? One has a composited layer with a scale, the other has a scale but goes into the root?
Comment 9 Simon Fraser (smfr) 2012-09-17 17:43:59 PDT
This sounds like a test for bug 27684. Why add a test before the bug is fixed?
Comment 10 Dana Jansens 2012-09-17 17:53:20 PDT
The fix for chromium's compositor is happening here: https://codereview.chromium.org/10915313
Comment 11 Simon Fraser (smfr) 2012-09-17 18:18:11 PDT
Can't we fix it in cross-platform code?
Comment 12 James Robinson 2012-09-17 18:26:17 PDT
That's tricky - the cross-platform code gets a GraphicsContext passed in from the platform-dependent code via GraphicsLayerClient.  This context has to be sized + scaled correctly by the compositor implementation.

The question then becomes is the compositor implementation or cross-platform code in a better place to decide the scale+size for a given layer.  My inclination is it's the mostly compositor implementation, since only it can make intelligent choices about resource use vs. time vs. quality tradeoffs.  Cross-platform code can't really have any idea of what the impact of rastering at a higher resolution will be on a given backend or if it'll have any effect as all.

That said part of the work could definitely be done in cross-platform code depending on how the exact solution works.  For instance, if we want to make any scaling decisions based on animation progress I think doing it in cross-platform code makes sense.
Comment 13 Simon Fraser (smfr) 2012-09-18 10:02:39 PDT
(In reply to comment #12)
> That's tricky - the cross-platform code gets a GraphicsContext passed in from the platform-dependent code via GraphicsLayerClient.  This context has to be sized + scaled correctly by the compositor implementation.

This is what GraphicsLayer::setContentsScale() is for.

> The question then becomes is the compositor implementation or cross-platform code in a better place to decide the scale+size for a given layer.  My inclination is it's the mostly compositor implementation, since only it can make intelligent choices about resource use vs. time vs. quality tradeoffs. 

True, but I think the cross-platform code is the best place to compute the ideal scale.
Comment 14 Dana Jansens 2012-10-22 16:05:31 PDT
Created attachment 170012 [details]
Patch

Two tests, one with and one without a surface
Comment 15 Adrienne Walker 2012-10-22 17:05:37 PDT
The font rasterization in that expected image looks really strange to my eyes.  Is that really the correct result?

Also, consider using a ref test, to check that font rasterization looks the same whether or not you create a render surface or not, and whether or not you create a layer or not.
Comment 16 WebKit Review Bot 2012-10-22 17:07:20 PDT
Comment on attachment 170012 [details]
Patch

Attachment 170012 [details] did not pass chromium-ews (chromium-xvfb):
Output: http://queues.webkit.org/results/14500297

New failing tests:
platform/chromium/virtual/softwarecompositing/text-on-scaled-layer.html
platform/chromium/virtual/softwarecompositing/text-on-scaled-surface.html
Comment 17 Dana Jansens 2012-10-22 17:22:52 PDT
(In reply to comment #15)
> The font rasterization in that expected image looks really strange to my eyes.  Is that really the correct result?

Probably not, this is from running it on precise. It's not fuzzy, so it's right in that regard.

> Also, consider using a ref test, to check that font rasterization looks the same whether or not you create a render surface or not, and whether or not you create a layer or not.

I'll have to learn about ref tests at last it seems. :)
Comment 18 Dana Jansens 2012-10-22 17:34:04 PDT
Created attachment 170035 [details]
Patch

Reftests instead of pixel results
Comment 19 Dana Jansens 2012-10-22 17:45:59 PDT
Created attachment 170039 [details]
Patch

Add softwarecompositing test expectations
Comment 20 Adrienne Walker 2012-10-22 18:11:00 PDT
I'm confused why these are expected-mismatch and not expected.  Isn't the goal here to assert that the text with and without surfaces/layers is identical?
Comment 21 Dana Jansens 2012-10-23 08:27:30 PDT
Oh, I misread, thanks.
Comment 22 Dana Jansens 2012-10-23 17:13:50 PDT
Created attachment 170272 [details]
Patch

Proper ref tests that pass on my local machine
Comment 23 Build Bot 2012-10-23 22:45:01 PDT
Comment on attachment 170272 [details]
Patch

Attachment 170272 [details] did not pass mac-ews (mac):
Output: http://queues.webkit.org/results/14569065

New failing tests:
media/video-zoom.html
compositing/text-on-scaled-layer.html
Comment 24 Dana Jansens 2012-10-24 09:59:46 PDT
Created attachment 170418 [details]
Patch

Add test expectations for mac
Comment 25 Adrienne Walker 2012-10-24 10:01:58 PDT
Comment on attachment 170418 [details]
Patch

R=me.
Comment 26 Dana Jansens 2012-10-24 10:32:47 PDT
Created attachment 170426 [details]
Patch for landing
Comment 27 WebKit Review Bot 2012-10-24 11:10:44 PDT
Comment on attachment 170426 [details]
Patch for landing

Clearing flags on attachment: 170426

Committed r132376: <http://trac.webkit.org/changeset/132376>
Comment 28 WebKit Review Bot 2012-10-24 11:10:49 PDT
All reviewed patches have been landed.  Closing bug.