Bug 77464 - [chromium] LayerChromium::setNeedsDisplay does not apply contents scale correctly
Summary: [chromium] LayerChromium::setNeedsDisplay does not apply contents scale corre...
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: Nobody
URL:
Keywords:
: 78760 (view as bug list)
Depends on:
Blocks: 68075
  Show dependency treegraph
 
Reported: 2012-01-31 12:34 PST by Sami Kyostila
Modified: 2012-02-16 21:03 PST (History)
7 users (show)

See Also:


Attachments
Patch (8.88 KB, patch)
2012-01-31 12:48 PST, Sami Kyostila
no flags Details | Formatted Diff | Diff
Interactive page scaling (1.85 KB, patch)
2012-02-16 18:40 PST, Sami Kyostila
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Sami Kyostila 2012-01-31 12:34:08 PST
LayerChromium::setNeedsDisplay() internally uses contentBounds() to calculate that the layer region needing to be repainted. The problem is that setNeedsDisplayRect() expects CSS coordinates without the contents scale applied, while contentBounds() includes the contents scale factor.

The fix is to use bounds() to get the unscaled layer bounds. This leads to a second problem, however, that TiledLayerChromium::setNeedsDisplayRect() expects to receive coordinates with the contents scale applied. It uses the given rectangle to invalidate the underlying tiles, which leads to incorrect results if the rectangle is not scaled. This problem is remedied by scaling the rectangle passed into TiledLayerChromium::invalidate().
Comment 1 Sami Kyostila 2012-01-31 12:36:15 PST
Ack, that last sentence should read "scaling the rectangle before it is passed into TiledLayerChromium::invalidate()."
Comment 2 Sami Kyostila 2012-01-31 12:48:30 PST
Created attachment 124799 [details]
Patch
Comment 3 Eric Seidel (no email) 2012-02-14 16:37:31 PST
James is your best reviewer I think.

I'll make sure to grant you EditBugs/CanConfirm too.
Comment 4 James Robinson 2012-02-15 14:39:35 PST
Comment on attachment 124799 [details]
Patch

What happens for a non-full-layer invalidation of a scaled layer?  I.e. if the layer's contents are 200x200 but it's displayed at 100x100, and WebKit sends us an invalidation rect 50x50@0x0, I think that should map to an invalidation of 50x50@0x0 on the tiles, not 25x25@0x0.  Right?
Comment 5 Min Qin 2012-02-15 18:22:06 PST
*** Bug 78760 has been marked as a duplicate of this bug. ***
Comment 6 Sami Kyostila 2012-02-16 18:37:38 PST
(In reply to comment #4)
> (From update of attachment 124799 [details])
> What happens for a non-full-layer invalidation of a scaled layer?  I.e. if the layer's contents are 200x200 but it's displayed at 100x100, and WebKit sends us an invalidation rect 50x50@0x0, I think that should map to an invalidation of 50x50@0x0 on the tiles, not 25x25@0x0.  Right?

This is a bit involved because page scale is handled differently for the root layer vs. child layers.

For the root layer, invalidations (setNeedsDisplayRect) are in scaled coordinates, because GraphicsLayer::setAppliesPageScale() is enabled, and as a result LayerChromium::contentsScale() is always 1. This means that setNeedsDisplayRect(50x50@0x0) from WebKit corresponds to 100x100@0x0 in CSS pixels, but is 50x50@0x0 in tile pixels. So assuming 100x100 pixel tiles, we would paint the upper left quadrant of the single tile backing the layer.

For child layers, WebKit's invalidation rects are given in unscaled coordinates. So in your example a setNeedsDisplayRect(50x50@0x0) from WebKit actually means the 50x50@0x0 CSS rectangle inside the layer, or 25x25@0x0 in tile pixels. Therefore we would paint 25x25@0x0 in the single backing tile.

If you think this is madness then I'd tend to agree. I hope to make things a little more consistent once the dust settles.

Note that my patch does not change behavior for the root layer since contents scale is not used there.
Comment 7 Sami Kyostila 2012-02-16 18:40:44 PST
Created attachment 127492 [details]
Interactive page scaling

Here's a patch for debugging which allows you to change the page scale interactively with 'w' and 's'.
Comment 8 James Robinson 2012-02-16 20:07:28 PST
Comment on attachment 124799 [details]
Patch

OK, thanks for the more detailed explanation.
Comment 9 WebKit Review Bot 2012-02-16 21:02:59 PST
Comment on attachment 124799 [details]
Patch

Clearing flags on attachment: 124799

Committed r108025: <http://trac.webkit.org/changeset/108025>
Comment 10 WebKit Review Bot 2012-02-16 21:03:05 PST
All reviewed patches have been landed.  Closing bug.