Changeset 183354 in webkit


Ignore:
Timestamp:
Apr 26, 2015, 10:24:40 AM (11 years ago)
Author:
Simon Fraser
Message:

Expand compositing coverage rect when scrolling and animating
https://bugs.webkit.org/show_bug.cgi?id=144214
rdar://problem/20695926

Reviewed by Darin Adler.

Source/WebCore:

r183300 added a secondary rect that gets mapped through graphics layers during
layer flushing, which represents a rect, in layer coordinates, that represents
the portion of this layer that's visible in the viewport.

This patch extends that rect based on scrolling and animating, with the extended
coverage rect being mapped into descendants (where it's used to determine whether
they should detach their backing store). This required moving the responsibility for
extending the coverage rect from TileController (where it was used to compute
tiled extent), to GraphicsLayerCA. Thus, GraphicsLayerCA now owns the concept
of coverage rect, and pushes it onto TileControllers.

Test: compositing/tiling/transform-origin-tiled.html

  • platform/graphics/TiledBacking.h: Coverage rect is now pushed onto

TiledBacking from outside; new functions reflect that.

  • platform/graphics/ca/GraphicsLayerCA.cpp:

(WebCore::GraphicsLayerCA::flushCompositingStateForThisLayerOnly): No need to pass
old visible rect to commitLayerChangesBeforeSublayers.
(WebCore::accumulatesTransform):
(WebCore::GraphicsLayerCA::recursiveVisibleRectChangeRequiresFlush): Now calls computeVisibleAndCoverageRect(),
then adjustCoverageRect() which adjusts for scrolling and animations.
(WebCore::GraphicsLayerCA::computeVisibleAndCoverageRect): Fetch the coverage rect from the
TransformState, but we can only use this if mapping it through various transforms didn't clamp
it (which can happen with severe rotations in perspective).
(WebCore::GraphicsLayerCA::adjustCoverageRect): If this layer represents the page tiled backing,
ask the TileController to do coverage adjustment (code which should move into here eventually).
For other tiled layers, do motion-based adjustment. This should really be done for all layers
(an animating non-tiled layer may contain a tiled layer).
(WebCore::GraphicsLayerCA::setVisibleAndCoverageRects): The VisibleRectChanged wasn't needed
any more; layers only react to changed in coverage rect now.
(WebCore::GraphicsLayerCA::recursiveCommitChanges): If adjustCoverageRect() changed the
coverage rect, here we push the new rect back into the TransformState so it will affect
descendants.
(WebCore::GraphicsLayerCA::commitLayerChangesBeforeSublayers):
(WebCore::GraphicsLayerCA::updateCoverage): Coverage and backing store attachment go
hand-in-hand now.
(WebCore::GraphicsLayerCA::changeLayerTypeTo):
(WebCore::GraphicsLayerCA::computeVisibleRect): Deleted.
(WebCore::GraphicsLayerCA::updateBackingStoreAttachment): Deleted.
(WebCore::GraphicsLayerCA::updateVisibleRect): Deleted.

  • platform/graphics/ca/GraphicsLayerCA.h:
  • platform/graphics/ca/TileController.cpp:

(WebCore::TileController::setVisibleRect): Visible rect is only used for scroll performance
logging now.
(WebCore::TileController::setCoverageRect):
(WebCore::TileController::tilesWouldChangeForCoverageRect):
(WebCore::TileController::revalidateTiles):
(WebCore::TileController::boundsForSize): This is required because when computeTileCoverageRect()
is called at the top of committing the owning layer, we haven't yet pushed a new size to the
underlying platform layer (which TileController::bounds() consults).
(WebCore::TileController::bounds):
(WebCore::TileController::computeTileCoverageRect): Have to push the new size in, since the
underlying layer hasn't been updated yet.
(WebCore::TileController::didRevalidateTiles):
(WebCore::TileController::tilesWouldChangeForVisibleRect): Deleted.

  • platform/graphics/ca/TileController.h:
  • platform/graphics/ca/TileCoverageMap.cpp:

(WebCore::TileCoverageMap::TileCoverageMap): Add a layer to the tile map that shows
a dark blue outline for the coverage rect.
(WebCore::TileCoverageMap::update): Fix some minor issues with map position when top
content inset is non-zero.

  • platform/graphics/ca/TileCoverageMap.h:
  • platform/graphics/ca/TileGrid.cpp: Everything is in terms of coverage rect now.

(WebCore::TileGrid::tilesWouldChangeForCoverageRect):
(WebCore::TileGrid::revalidateTiles):
(WebCore::TileGrid::tilesWouldChangeForVisibleRect): Deleted.

  • platform/graphics/ca/TileGrid.h:
  • platform/graphics/transforms/TransformState.cpp:

(WebCore::TransformState::operator=):
(WebCore::TransformState::mappedQuad): Pass direction into mapQuad().
(WebCore::TransformState::mappedSecondaryQuad): Ditto.
(WebCore::TransformState::setLastPlanarSecondaryQuad): This function allows a caller
to pass in a secondary quad, and get it mapped into the coordinate space of the last
"flattening" state (since the TransformState may have in-flight XY offset, or transform).
This mapping is achieved by re-using mapQuad(), but in the inverse direction.
(WebCore::TransformState::mapQuad): Make direction a parameter.
(WebCore::TransformState::flattenWithTransform): This code omitted to map the secondary
quad. Failure was detected by tests.

  • platform/graphics/transforms/TransformState.h:

(WebCore::TransformState::isMappingSecondaryQuad):
(WebCore::TransformState::direction):
(WebCore::TransformState::inverseDirection):
(WebCore::TransformState::lastPlanarSecondaryQuad): Deleted.

LayoutTests:

New baselines for tests dumping layer output, with coverage rect being affected
by this changeset. One new test for tiling a layer inside overflow:hidden with transform-origin.

  • compositing/contents-scale/animating-expected.txt:
  • compositing/contents-scale/rounded-contents-scale-expected.txt:
  • compositing/contents-scale/scaled-ancestor-expected.txt:
  • compositing/contents-scale/simple-scale-expected.txt:
  • compositing/tiling/transform-origin-tiled.html: Added.
  • platform/mac-wk2/compositing/tiling/rotated-tiled-clamped-expected.txt:
  • platform/mac-wk2/compositing/tiling/rotated-tiled-preserve3d-clamped-expected.txt:
  • platform/mac-wk2/compositing/tiling/tile-cache-zoomed-expected.txt:
  • platform/mac-wk2/compositing/visible-rect/iframe-no-layers-expected.txt:
  • platform/mac-wk2/tiled-drawing/scrolling/fast-scroll-div-latched-div-expected.txt:
  • platform/mac-wk2/tiled-drawing/scrolling/fast-scroll-div-latched-div-with-handler-expected.txt:
  • platform/mac-wk2/tiled-drawing/scrolling/fast-scroll-div-latched-mainframe-expected.txt:
  • platform/mac-wk2/tiled-drawing/scrolling/fast-scroll-div-latched-mainframe-with-handler-expected.txt:
  • platform/mac-wk2/tiled-drawing/scrolling/fast-scroll-iframe-latched-iframe-expected.txt:
  • platform/mac-wk2/tiled-drawing/scrolling/fast-scroll-iframe-latched-iframe-with-handler-expected.txt:
  • platform/mac-wk2/tiled-drawing/scrolling/fast-scroll-iframe-latched-mainframe-expected.txt:
  • platform/mac-wk2/tiled-drawing/scrolling/fast-scroll-iframe-latched-mainframe-with-handler-expected.txt:
  • platform/mac-wk2/tiled-drawing/scrolling/fast-scroll-select-latched-mainframe-expected.txt:
  • platform/mac-wk2/tiled-drawing/scrolling/fast-scroll-select-latched-mainframe-with-handler-expected.txt:
  • platform/mac-wk2/tiled-drawing/scrolling/fast-scroll-select-latched-select-expected.txt:
  • platform/mac-wk2/tiled-drawing/scrolling/fast-scroll-select-latched-select-with-handler-expected.txt:
  • platform/mac-wk2/tiled-drawing/scrolling/fixed/four-bars-zoomed-expected.txt:
  • platform/mac-wk2/tiled-drawing/simple-document-with-margin-tiles-expected.txt:
  • platform/mac-wk2/tiled-drawing/tile-size-slow-zoomed-expected.txt:
  • platform/mac-wk2/tiled-drawing/tiled-drawing-scroll-position-page-cache-restoration-expected.txt:
  • platform/mac-wk2/tiled-drawing/tiled-drawing-zoom-expected.txt:
  • platform/mac-wk2/tiled-drawing/tiled-drawing-zoom-scrolled-expected.txt:
  • platform/mac/compositing/tiling/rotated-tiled-clamped-expected.txt:
  • platform/mac/compositing/tiling/rotated-tiled-preserve3d-clamped-expected.txt:
  • platform/mac/compositing/tiling/tile-cache-zoomed-expected.txt:
  • platform/mac/compositing/visible-rect/2d-transformed-expected.txt:
  • platform/mac/compositing/visible-rect/3d-transformed-expected.txt:
  • platform/mac/compositing/visible-rect/clipped-by-viewport-expected.txt:
  • platform/mac/compositing/visible-rect/clipped-visible-rect-expected.txt:
  • platform/mac/compositing/visible-rect/iframe-and-layers-expected.txt:
  • platform/mac/compositing/visible-rect/iframe-no-layers-expected.txt:
  • platform/mac/compositing/visible-rect/scrolled-expected.txt:
Location:
trunk
Files:
1 added
49 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r183351 r183354  
     12015-04-25  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Expand compositing coverage rect when scrolling and animating
     4        https://bugs.webkit.org/show_bug.cgi?id=144214
     5        rdar://problem/20695926
     6
     7        Reviewed by Darin Adler.
     8       
     9        New baselines for tests dumping layer output, with coverage rect being affected
     10        by this changeset. One new test for tiling a layer inside overflow:hidden with transform-origin.
     11
     12        * compositing/contents-scale/animating-expected.txt:
     13        * compositing/contents-scale/rounded-contents-scale-expected.txt:
     14        * compositing/contents-scale/scaled-ancestor-expected.txt:
     15        * compositing/contents-scale/simple-scale-expected.txt:
     16        * compositing/tiling/transform-origin-tiled.html: Added.
     17        * platform/mac-wk2/compositing/tiling/rotated-tiled-clamped-expected.txt:
     18        * platform/mac-wk2/compositing/tiling/rotated-tiled-preserve3d-clamped-expected.txt:
     19        * platform/mac-wk2/compositing/tiling/tile-cache-zoomed-expected.txt:
     20        * platform/mac-wk2/compositing/visible-rect/iframe-no-layers-expected.txt:
     21        * platform/mac-wk2/tiled-drawing/scrolling/fast-scroll-div-latched-div-expected.txt:
     22        * platform/mac-wk2/tiled-drawing/scrolling/fast-scroll-div-latched-div-with-handler-expected.txt:
     23        * platform/mac-wk2/tiled-drawing/scrolling/fast-scroll-div-latched-mainframe-expected.txt:
     24        * platform/mac-wk2/tiled-drawing/scrolling/fast-scroll-div-latched-mainframe-with-handler-expected.txt:
     25        * platform/mac-wk2/tiled-drawing/scrolling/fast-scroll-iframe-latched-iframe-expected.txt:
     26        * platform/mac-wk2/tiled-drawing/scrolling/fast-scroll-iframe-latched-iframe-with-handler-expected.txt:
     27        * platform/mac-wk2/tiled-drawing/scrolling/fast-scroll-iframe-latched-mainframe-expected.txt:
     28        * platform/mac-wk2/tiled-drawing/scrolling/fast-scroll-iframe-latched-mainframe-with-handler-expected.txt:
     29        * platform/mac-wk2/tiled-drawing/scrolling/fast-scroll-select-latched-mainframe-expected.txt:
     30        * platform/mac-wk2/tiled-drawing/scrolling/fast-scroll-select-latched-mainframe-with-handler-expected.txt:
     31        * platform/mac-wk2/tiled-drawing/scrolling/fast-scroll-select-latched-select-expected.txt:
     32        * platform/mac-wk2/tiled-drawing/scrolling/fast-scroll-select-latched-select-with-handler-expected.txt:
     33        * platform/mac-wk2/tiled-drawing/scrolling/fixed/four-bars-zoomed-expected.txt:
     34        * platform/mac-wk2/tiled-drawing/simple-document-with-margin-tiles-expected.txt:
     35        * platform/mac-wk2/tiled-drawing/tile-size-slow-zoomed-expected.txt:
     36        * platform/mac-wk2/tiled-drawing/tiled-drawing-scroll-position-page-cache-restoration-expected.txt:
     37        * platform/mac-wk2/tiled-drawing/tiled-drawing-zoom-expected.txt:
     38        * platform/mac-wk2/tiled-drawing/tiled-drawing-zoom-scrolled-expected.txt:
     39        * platform/mac/compositing/tiling/rotated-tiled-clamped-expected.txt:
     40        * platform/mac/compositing/tiling/rotated-tiled-preserve3d-clamped-expected.txt:
     41        * platform/mac/compositing/tiling/tile-cache-zoomed-expected.txt:
     42        * platform/mac/compositing/visible-rect/2d-transformed-expected.txt:
     43        * platform/mac/compositing/visible-rect/3d-transformed-expected.txt:
     44        * platform/mac/compositing/visible-rect/clipped-by-viewport-expected.txt:
     45        * platform/mac/compositing/visible-rect/clipped-visible-rect-expected.txt:
     46        * platform/mac/compositing/visible-rect/iframe-and-layers-expected.txt:
     47        * platform/mac/compositing/visible-rect/iframe-no-layers-expected.txt:
     48        * platform/mac/compositing/visible-rect/scrolled-expected.txt:
     49
    1502015-04-25  Alexey Proskuryakov  <ap@apple.com>
    251
  • trunk/LayoutTests/compositing/contents-scale/animating-expected.txt

    r183300 r183354  
    2424          (transform [1.50 0.00 0.00 0.00] [0.00 1.50 0.00 0.00] [0.00 0.00 1.00 0.00] [0.00 0.00 0.00 1.00])
    2525          (visible rect 0.00, 0.00 100.00 x 100.00)
    26           (coverage rect 0.00, 0.00 800.00 x 600.00)
     26          (coverage rect -12.00, -6.67 533.33 x 400.00)
    2727          (intersects coverage rect 1)
    2828          (contentsScale 1.00)
  • trunk/LayoutTests/compositing/contents-scale/rounded-contents-scale-expected.txt

    r183300 r183354  
    3030              (transform [1.00 0.00 0.00 0.00] [0.00 1.00 0.00 0.00] [0.00 0.00 1.00 0.00] [0.00 0.00 -200.00 1.00])
    3131              (visible rect 0.00, 0.00 102.00 x 102.00)
    32               (coverage rect -8.00, -8.00 800.00 x 600.00)
     32              (coverage rect -11.20, -11.20 1120.00 x 840.00)
    3333              (intersects coverage rect 1)
    3434              (contentsScale 1.00)
     
    4141              (transform [1.00 0.00 0.00 0.00] [0.00 1.00 0.00 0.00] [0.00 0.00 1.00 0.00] [0.00 0.00 -100.00 1.00])
    4242              (visible rect 0.00, 0.00 102.00 x 102.00)
    43               (coverage rect -8.00, -8.00 800.00 x 600.00)
     43              (coverage rect -9.60, -91.60 960.00 x 720.00)
    4444              (intersects coverage rect 1)
    4545              (contentsScale 1.00)
     
    5151              (drawsContent 1)
    5252              (visible rect 0.00, 0.00 102.00 x 102.00)
    53               (coverage rect -8.00, -8.00 800.00 x 600.00)
     53              (coverage rect -8.00, -172.00 800.00 x 600.00)
    5454              (intersects coverage rect 1)
    5555              (contentsScale 1.00)
     
    6262              (transform [1.00 0.00 0.00 0.00] [0.00 1.00 0.00 0.00] [0.00 0.00 1.00 0.00] [0.00 0.00 50.00 1.00])
    6363              (visible rect 0.00, 0.00 102.00 x 102.00)
    64               (coverage rect -8.00, -8.00 800.00 x 600.00)
     64              (coverage rect -7.20, -253.20 720.00 x 540.00)
    6565              (intersects coverage rect 1)
    6666              (contentsScale 1.00)
     
    7373              (transform [1.00 0.00 0.00 0.00] [0.00 1.00 0.00 0.00] [0.00 0.00 1.00 0.00] [0.00 0.00 100.00 1.00])
    7474              (visible rect 0.00, 0.00 102.00 x 102.00)
    75               (coverage rect -8.00, -8.00 800.00 x 600.00)
     75              (coverage rect -6.40, -334.40 640.00 x 480.00)
    7676              (intersects coverage rect 1)
    7777              (contentsScale 1.00)
     
    8484              (transform [1.00 0.00 0.00 0.00] [0.00 1.00 0.00 0.00] [0.00 0.00 1.00 0.00] [0.00 0.00 150.00 1.00])
    8585              (visible rect 0.00, 0.00 102.00 x 4.40)
    86               (coverage rect -8.00, -8.00 800.00 x 600.00)
     86              (coverage rect -5.60, -415.60 560.00 x 420.00)
    8787              (intersects coverage rect 1)
    8888              (contentsScale 1.00)
  • trunk/LayoutTests/compositing/contents-scale/scaled-ancestor-expected.txt

    r183300 r183354  
    2323          (transform [2.00 0.00 0.00 0.00] [0.00 2.00 0.00 0.00] [0.00 0.00 1.00 0.00] [0.00 0.00 0.00 1.00])
    2424          (visible rect 0.00, 0.00 102.00 x 102.00)
    25           (coverage rect 0.00, 0.00 800.00 x 600.00)
     25          (coverage rect -4.00, -4.00 400.00 x 300.00)
    2626          (intersects coverage rect 1)
    2727          (contentsScale 1.00)
     
    3333              (drawsContent 1)
    3434              (visible rect 0.00, 0.00 100.00 x 100.00)
    35               (coverage rect -11.00, -11.00 800.00 x 600.00)
     35              (coverage rect -15.00, -15.00 400.00 x 300.00)
    3636              (intersects coverage rect 1)
    3737              (contentsScale 1.00)
  • trunk/LayoutTests/compositing/contents-scale/simple-scale-expected.txt

    r183300 r183354  
    2424          (transform [2.00 0.00 0.00 0.00] [0.00 2.00 0.00 0.00] [0.00 0.00 1.00 0.00] [0.00 0.00 0.00 1.00])
    2525          (visible rect 0.00, 0.00 100.00 x 100.00)
    26           (coverage rect 0.00, 0.00 800.00 x 600.00)
     26          (coverage rect -9.00, -5.00 400.00 x 300.00)
    2727          (intersects coverage rect 1)
    2828          (contentsScale 1.00)
  • trunk/LayoutTests/compositing/tiling/transform-origin-tiled-expected.txt

    r183353 r183354  
    4242                  (contentsOpaque 1)
    4343                  (drawsContent 1)
    44                   (transform [0.17 0.00 -0.98 0.00] [0.00 1.00 0.00 0.00] [0.98 0.00 0.17 0.00] [0.00 0.00 0.00 1.00])
    45                   (visible rect 0.00, 0.00 2800.00 x 300.00)
    46                   (coverage rect 0.00, 0.00 500.00 x 300.00)
     44                  (visible rect 1250.00, 0.00 500.00 x 300.00)
     45                  (coverage rect 1250.00, 0.00 500.00 x 300.00)
    4746                  (intersects coverage rect 1)
    4847                  (contentsScale 1.00)
    49                   (tile cache coverage 0, 0 2800 x 300)
     48                  (tile cache coverage 1024, 0 1024 x 300)
    5049                  (tile size 512 x 512)
    51                   (top left tile 0, 0 tiles grid 6 x 1)
     50                  (top left tile 2, 0 tiles grid 2 x 1)
    5251                )
    5352              )
  • trunk/LayoutTests/platform/mac-wk2/compositing/tiling/rotated-tiled-clamped-expected.txt

    r183300 r183354  
    4444                  (transform [0.17 0.00 -0.98 0.00] [0.00 1.00 0.00 0.00] [0.98 0.00 0.17 0.00] [0.00 0.00 0.00 1.00])
    4545                  (visible rect 0.00, 0.00 2800.00 x 300.00)
    46                   (coverage rect 0.00, 0.00 500.00 x 300.00)
     46                  (coverage rect 0.00, 0.00 2800.00 x 300.00)
    4747                  (intersects coverage rect 1)
    4848                  (contentsScale 1.00)
  • trunk/LayoutTests/platform/mac-wk2/compositing/tiling/rotated-tiled-preserve3d-clamped-expected.txt

    r183300 r183354  
    5151                      (transform [0.17 0.00 -0.98 0.00] [0.00 1.00 0.00 0.00] [0.98 0.00 0.17 0.00] [0.00 0.00 0.00 1.00])
    5252                      (visible rect 0.00, 0.00 2800.00 x 300.00)
    53                       (coverage rect -1562500.00, -1562500.00 1563571.88 x 1562694.63)
     53                      (coverage rect 0.00, 0.00 2800.00 x 300.00)
    5454                      (intersects coverage rect 1)
    5555                      (contentsScale 1.00)
  • trunk/LayoutTests/platform/mac-wk2/compositing/tiling/tile-cache-zoomed-expected.txt

    r183300 r183354  
    1313      (transform [1.60 0.00 0.00 0.00] [0.00 1.60 0.00 0.00] [0.00 0.00 1.00 0.00] [0.00 0.00 0.00 1.00])
    1414      (visible rect 0.00, 0.00 490.63 x 365.63)
    15       (coverage rect 0.00, 0.00 785.00 x 585.00)
     15      (coverage rect 0.00, 0.00 490.63 x 365.63)
    1616      (intersects coverage rect 1)
    1717      (contentsScale 1.60)
     
    2626          (transform [1.00 0.00 0.00 0.00] [0.00 1.00 0.00 0.00] [0.00 0.00 1.00 0.00] [0.00 0.00 1.00 1.00])
    2727          (visible rect 0.00, 0.00 482.63 x 357.63)
    28           (coverage rect 0.00, 0.00 785.00 x 585.00)
     28          (coverage rect -8.00, -8.00 490.63 x 365.63)
    2929          (intersects coverage rect 1)
    3030          (contentsScale 1.60)
  • trunk/LayoutTests/platform/mac-wk2/compositing/visible-rect/iframe-no-layers-expected.txt

    r183300 r183354  
    2323          (transform [1.00 0.00 0.00 0.00] [0.00 1.00 0.00 0.00] [0.00 0.00 1.00 0.00] [0.00 0.00 1.00 1.00])
    2424          (visible rect 2.00, 92.00 98.00 x 135.00)
    25           (coverage rect 10.00, 100.00 285.00 x 135.00)
     25          (coverage rect 2.00, 92.00 285.00 x 135.00)
    2626          (intersects coverage rect 1)
    2727          (contentsScale 1.00)
  • trunk/LayoutTests/platform/mac-wk2/tiled-drawing/scrolling/fast-scroll-div-latched-div-expected.txt

    r183301 r183354  
    7070      (contentsOpaque 1)
    7171      (visible rect 0.00, 0.00 785.00 x 585.00)
    72       (coverage rect 0.00, 0.00 785.00 x 585.00)
     72      (coverage rect 0.00, 0.00 1570.00 x 1755.00)
    7373      (intersects coverage rect 1)
    7474      (contentsScale 1.00)
  • trunk/LayoutTests/platform/mac-wk2/tiled-drawing/scrolling/fast-scroll-div-latched-div-with-handler-expected.txt

    r183301 r183354  
    7171      (contentsOpaque 1)
    7272      (visible rect 0.00, 0.00 785.00 x 585.00)
    73       (coverage rect 0.00, 0.00 785.00 x 585.00)
     73      (coverage rect 0.00, 0.00 1570.00 x 1755.00)
    7474      (intersects coverage rect 1)
    7575      (contentsScale 1.00)
  • trunk/LayoutTests/platform/mac-wk2/tiled-drawing/scrolling/fast-scroll-div-latched-mainframe-expected.txt

    r183301 r183354  
    6969      (contentsOpaque 1)
    7070      (visible rect 0.00, 70.00 785.00 x 585.00)
    71       (coverage rect 0.00, 70.00 785.00 x 585.00)
     71      (coverage rect 0.00, 0.00 1570.00 x 1755.00)
    7272      (intersects coverage rect 1)
    7373      (contentsScale 1.00)
  • trunk/LayoutTests/platform/mac-wk2/tiled-drawing/scrolling/fast-scroll-div-latched-mainframe-with-handler-expected.txt

    r183301 r183354  
    7070      (contentsOpaque 1)
    7171      (visible rect 0.00, 70.00 785.00 x 585.00)
    72       (coverage rect 0.00, 70.00 785.00 x 585.00)
     72      (coverage rect 0.00, 0.00 1570.00 x 1755.00)
    7373      (intersects coverage rect 1)
    7474      (contentsScale 1.00)
  • trunk/LayoutTests/platform/mac-wk2/tiled-drawing/scrolling/fast-scroll-iframe-latched-iframe-expected.txt

    r183301 r183354  
    2626      (contentsOpaque 1)
    2727      (visible rect 0.00, 0.00 785.00 x 600.00)
    28       (coverage rect 0.00, 0.00 785.00 x 600.00)
     28      (coverage rect 0.00, 0.00 1570.00 x 1800.00)
    2929      (intersects coverage rect 1)
    3030      (contentsScale 1.00)
  • trunk/LayoutTests/platform/mac-wk2/tiled-drawing/scrolling/fast-scroll-iframe-latched-iframe-with-handler-expected.txt

    r183301 r183354  
    2727      (contentsOpaque 1)
    2828      (visible rect 0.00, 0.00 785.00 x 600.00)
    29       (coverage rect 0.00, 0.00 785.00 x 600.00)
     29      (coverage rect 0.00, 0.00 1570.00 x 1800.00)
    3030      (intersects coverage rect 1)
    3131      (contentsScale 1.00)
  • trunk/LayoutTests/platform/mac-wk2/tiled-drawing/scrolling/fast-scroll-iframe-latched-mainframe-expected.txt

    r183301 r183354  
    2525      (contentsOpaque 1)
    2626      (visible rect 0.00, 70.00 785.00 x 600.00)
    27       (coverage rect 0.00, 70.00 785.00 x 600.00)
     27      (coverage rect 0.00, 0.00 1570.00 x 1800.00)
    2828      (intersects coverage rect 1)
    2929      (contentsScale 1.00)
  • trunk/LayoutTests/platform/mac-wk2/tiled-drawing/scrolling/fast-scroll-iframe-latched-mainframe-with-handler-expected.txt

    r183301 r183354  
    2626      (contentsOpaque 1)
    2727      (visible rect 0.00, 70.00 785.00 x 600.00)
    28       (coverage rect 0.00, 70.00 785.00 x 600.00)
     28      (coverage rect 0.00, 0.00 1570.00 x 1800.00)
    2929      (intersects coverage rect 1)
    3030      (contentsScale 1.00)
  • trunk/LayoutTests/platform/mac-wk2/tiled-drawing/scrolling/fast-scroll-select-latched-mainframe-expected.txt

    r183301 r183354  
    2727      (contentsOpaque 1)
    2828      (visible rect 0.00, 70.00 785.00 x 585.00)
    29       (coverage rect 0.00, 70.00 785.00 x 585.00)
     29      (coverage rect 0.00, 0.00 1570.00 x 1755.00)
    3030      (intersects coverage rect 1)
    3131      (contentsScale 1.00)
  • trunk/LayoutTests/platform/mac-wk2/tiled-drawing/scrolling/fast-scroll-select-latched-mainframe-with-handler-expected.txt

    r183301 r183354  
    2828      (contentsOpaque 1)
    2929      (visible rect 0.00, 70.00 785.00 x 585.00)
    30       (coverage rect 0.00, 70.00 785.00 x 585.00)
     30      (coverage rect 0.00, 0.00 1570.00 x 1755.00)
    3131      (intersects coverage rect 1)
    3232      (contentsScale 1.00)
  • trunk/LayoutTests/platform/mac-wk2/tiled-drawing/scrolling/fast-scroll-select-latched-select-expected.txt

    r183301 r183354  
    2828      (contentsOpaque 1)
    2929      (visible rect 0.00, 0.00 785.00 x 585.00)
    30       (coverage rect 0.00, 0.00 785.00 x 585.00)
     30      (coverage rect 0.00, 0.00 1570.00 x 1755.00)
    3131      (intersects coverage rect 1)
    3232      (contentsScale 1.00)
  • trunk/LayoutTests/platform/mac-wk2/tiled-drawing/scrolling/fast-scroll-select-latched-select-with-handler-expected.txt

    r183301 r183354  
    2929      (contentsOpaque 1)
    3030      (visible rect 0.00, 0.00 785.00 x 585.00)
    31       (coverage rect 0.00, 0.00 785.00 x 585.00)
     31      (coverage rect 0.00, 0.00 1570.00 x 1755.00)
    3232      (intersects coverage rect 1)
    3333      (contentsScale 1.00)
  • trunk/LayoutTests/platform/mac-wk2/tiled-drawing/scrolling/fixed/four-bars-zoomed-expected.txt

    r183301 r183354  
    4141      (transform [2.30 0.00 0.00 0.00] [0.00 2.30 0.00 0.00] [0.00 0.00 1.00 0.00] [0.00 0.00 0.00 1.00])
    4242      (visible rect 0.00, 0.00 341.30 x 254.35)
    43       (coverage rect 0.00, 0.00 785.00 x 585.00)
     43      (coverage rect 0.00, 0.00 341.30 x 254.35)
    4444      (intersects coverage rect 1)
    4545      (contentsScale 2.30)
     
    5353          (drawsContent 1)
    5454          (visible rect 4.00, 4.00 341.30 x 78.00)
    55           (coverage rect 4.00, 4.00 785.00 x 585.00)
     55          (coverage rect 4.00, 4.00 341.30 x 254.35)
    5656          (intersects coverage rect 1)
    5757          (contentsScale 2.30)
     
    6262          (drawsContent 1)
    6363          (visible rect 0.00, 0.00 182.00 x 58.35)
    64           (coverage rect -6.00, -196.00 785.00 x 585.00)
     64          (coverage rect -6.00, -196.00 341.30 x 254.35)
    6565          (intersects coverage rect 1)
    6666          (contentsScale 2.30)
     
    7171          (drawsContent 1)
    7272          (visible rect 0.00, 0.00 0.00 x 0.00)
    73           (coverage rect -597.00, -196.00 785.00 x 585.00)
    74           (intersects coverage rect 1)
     73          (coverage rect -597.00, -196.00 341.30 x 254.35)
     74          (intersects coverage rect 0)
    7575          (contentsScale 2.30)
    7676        )
     
    8080          (drawsContent 1)
    8181          (visible rect 0.00, 0.00 0.00 x 0.00)
    82           (coverage rect 4.00, -497.00 785.00 x 585.00)
    83           (intersects coverage rect 1)
     82          (coverage rect 4.00, -497.00 341.30 x 254.35)
     83          (intersects coverage rect 0)
    8484          (contentsScale 2.30)
    8585        )
  • trunk/LayoutTests/platform/mac-wk2/tiled-drawing/simple-document-with-margin-tiles-expected.txt

    r183301 r183354  
    1111      (contentsOpaque 1)
    1212      (visible rect 0.00, 0.00 785.00 x 585.00)
    13       (coverage rect 0.00, 0.00 785.00 x 585.00)
     13      (coverage rect -512.00, -512.00 1809.00 x 1609.00)
    1414      (intersects coverage rect 1)
    1515      (contentsScale 1.00)
  • trunk/LayoutTests/platform/mac-wk2/tiled-drawing/tile-size-slow-zoomed-expected.txt

    r183301 r183354  
    1313      (transform [1.70 0.00 0.00 0.00] [0.00 1.70 0.00 0.00] [0.00 0.00 1.00 0.00] [0.00 0.00 0.00 1.00])
    1414      (visible rect 0.00, 0.00 461.76 x 344.12)
    15       (coverage rect 0.00, 0.00 785.00 x 585.00)
     15      (coverage rect 0.00, 0.00 461.76 x 344.12)
    1616      (intersects coverage rect 1)
    1717      (contentsScale 1.70)
  • trunk/LayoutTests/platform/mac-wk2/tiled-drawing/tiled-drawing-scroll-position-page-cache-restoration-expected.txt

    r183301 r183354  
    1313      (contentsOpaque 1)
    1414      (visible rect 1000.00, 1000.00 785.00 x 585.00)
    15       (coverage rect 1000.00, 1000.00 785.00 x 585.00)
     15      (coverage rect 607.50, 415.00 1570.00 x 1755.00)
    1616      (intersects coverage rect 1)
    1717      (contentsScale 1.00)
  • trunk/LayoutTests/platform/mac-wk2/tiled-drawing/tiled-drawing-zoom-expected.txt

    r183301 r183354  
    1313      (transform [2.30 0.00 0.00 0.00] [0.00 2.30 0.00 0.00] [0.00 0.00 1.00 0.00] [0.00 0.00 0.00 1.00])
    1414      (visible rect 0.00, 0.00 341.30 x 254.35)
    15       (coverage rect 0.00, 0.00 785.00 x 585.00)
     15      (coverage rect 0.00, 0.00 341.30 x 254.35)
    1616      (intersects coverage rect 1)
    1717      (contentsScale 2.30)
  • trunk/LayoutTests/platform/mac-wk2/tiled-drawing/tiled-drawing-zoom-scrolled-expected.txt

    r183301 r183354  
    1313      (transform [2.30 0.00 0.00 0.00] [0.00 2.30 0.00 0.00] [0.00 0.00 1.00 0.00] [0.00 0.00 0.00 1.00])
    1414      (visible rect 800.00, 1000.00 341.30 x 254.35)
    15       (coverage rect 1840.00, 2300.00 785.00 x 585.00)
    16       (intersects coverage rect 0)
     15      (coverage rect 800.00, 1000.00 341.30 x 254.35)
     16      (intersects coverage rect 1)
    1717      (contentsScale 2.30)
    1818      (tile cache coverage 667, 890 540 x 445)
  • trunk/LayoutTests/platform/mac/compositing/tiling/rotated-tiled-clamped-expected.txt

    r183300 r183354  
    4141                  (transform [0.17 0.00 -0.98 0.00] [0.00 1.00 0.00 0.00] [0.98 0.00 0.17 0.00] [0.00 0.00 0.00 1.00])
    4242                  (visible rect 0.00, 0.00 2800.00 x 300.00)
    43                   (coverage rect 0.00, 0.00 500.00 x 300.00)
     43                  (coverage rect 0.00, 0.00 2800.00 x 300.00)
    4444                  (intersects coverage rect 1)
    4545                  (contentsScale 1.00)
  • trunk/LayoutTests/platform/mac/compositing/tiling/rotated-tiled-preserve3d-clamped-expected.txt

    r183300 r183354  
    4848                      (transform [0.17 0.00 -0.98 0.00] [0.00 1.00 0.00 0.00] [0.98 0.00 0.17 0.00] [0.00 0.00 0.00 1.00])
    4949                      (visible rect 0.00, 0.00 2800.00 x 300.00)
    50                       (coverage rect -1562500.00, -1562500.00 1563571.88 x 1562694.63)
     50                      (coverage rect 0.00, 0.00 2800.00 x 300.00)
    5151                      (intersects coverage rect 1)
    5252                      (contentsScale 1.00)
  • trunk/LayoutTests/platform/mac/compositing/tiling/tile-cache-zoomed-expected.txt

    r183300 r183354  
    1313      (transform [1.60 0.00 0.00 0.00] [0.00 1.60 0.00 0.00] [0.00 0.00 1.00 0.00] [0.00 0.00 0.00 1.00])
    1414      (visible rect 0.00, 0.00 490.63 x 365.63)
    15       (coverage rect 0.00, 0.00 785.00 x 585.00)
     15      (coverage rect 0.00, 0.00 490.63 x 365.63)
    1616      (intersects coverage rect 1)
    1717      (contentsScale 1.60)
     
    2323          (transform [1.00 0.00 0.00 0.00] [0.00 1.00 0.00 0.00] [0.00 0.00 1.00 0.00] [0.00 0.00 1.00 1.00])
    2424          (visible rect 0.00, 0.00 482.63 x 357.63)
    25           (coverage rect 0.00, 0.00 785.00 x 585.00)
     25          (coverage rect -8.00, -8.00 490.63 x 365.63)
    2626          (intersects coverage rect 1)
    2727          (contentsScale 1.60)
  • trunk/LayoutTests/platform/mac/compositing/visible-rect/2d-transformed-expected.txt

    r183300 r183354  
    4545                  (transform [0.71 0.71 0.00 0.00] [-0.71 0.71 0.00 0.00] [0.00 0.00 1.00 0.00] [150.00 0.00 0.00 1.00])
    4646                  (visible rect 0.00, 0.00 200.00 x 200.00)
    47                   (coverage rect 0.00, 0.00 500.00 x 200.00)
     47                  (coverage rect -147.49, -147.49 494.97 x 494.97)
    4848                  (intersects coverage rect 1)
    4949                  (contentsScale 1.00)
  • trunk/LayoutTests/platform/mac/compositing/visible-rect/3d-transformed-expected.txt

    r183300 r183354  
    3838                  (transform [1.00 0.00 0.00 0.00] [0.00 0.71 0.71 0.00] [0.00 -0.71 0.71 0.00] [0.00 0.00 0.00 1.00])
    3939                  (visible rect 0.00, 0.00 220.62 x 218.46)
    40                   (coverage rect 0.00, 0.00 200.00 x 200.00)
     40                  (coverage rect -6.51, -51.46 227.13 x 269.92)
    4141                  (intersects coverage rect 1)
    4242                  (contentsScale 1.00)
     
    6969                  (transform [0.71 0.00 0.71 0.00] [0.00 1.00 0.00 0.00] [-0.71 0.00 0.71 0.00] [0.00 0.00 0.00 1.00])
    7070                  (visible rect 0.00, 0.00 218.46 x 220.62)
    71                   (coverage rect 0.00, 0.00 200.00 x 200.00)
     71                  (coverage rect -51.46, -6.51 269.92 x 227.13)
    7272                  (intersects coverage rect 1)
    7373                  (contentsScale 1.00)
  • trunk/LayoutTests/platform/mac/compositing/visible-rect/clipped-by-viewport-expected.txt

    r183300 r183354  
    2121          (transform [1.00 0.00 0.00 0.00] [0.00 1.00 0.00 0.00] [0.00 0.00 1.00 0.00] [0.00 0.00 1.00 1.00])
    2222          (visible rect 100.00, 120.00 100.00 x 80.00)
    23           (coverage rect 0.00, 0.00 800.00 x 600.00)
     23          (coverage rect 100.00, 120.00 800.00 x 600.00)
    2424          (intersects coverage rect 1)
    2525          (contentsScale 1.00)
     
    3131          (transform [1.00 0.00 0.00 0.00] [0.00 1.00 0.00 0.00] [0.00 0.00 1.00 0.00] [0.00 0.00 1.00 1.00])
    3232          (visible rect 100.00, 0.00 100.00 x 200.00)
    33           (coverage rect 0.00, 0.00 800.00 x 600.00)
     33          (coverage rect 100.00, -200.00 800.00 x 600.00)
    3434          (intersects coverage rect 1)
    3535          (contentsScale 1.00)
  • trunk/LayoutTests/platform/mac/compositing/visible-rect/clipped-visible-rect-expected.txt

    r183300 r183354  
    3737                  (transform [1.00 0.00 0.00 0.00] [0.00 1.00 0.00 0.00] [0.00 0.00 1.00 0.00] [0.00 0.00 1.00 1.00])
    3838                  (visible rect 100.00, 0.00 100.00 x 200.00)
    39                   (coverage rect 0.00, 0.00 500.00 x 200.00)
     39                  (coverage rect 100.00, 0.00 500.00 x 200.00)
    4040                  (intersects coverage rect 1)
    4141                  (contentsScale 1.00)
     
    4747                  (transform [1.00 0.00 0.00 0.00] [0.00 1.00 0.00 0.00] [0.00 0.00 1.00 0.00] [0.00 0.00 1.00 1.00])
    4848                  (visible rect 0.00, 0.00 200.00 x 200.00)
    49                   (coverage rect 0.00, 0.00 500.00 x 200.00)
     49                  (coverage rect -150.00, 0.00 500.00 x 200.00)
    5050                  (intersects coverage rect 1)
    5151                  (contentsScale 1.00)
     
    5757                  (transform [1.00 0.00 0.00 0.00] [0.00 1.00 0.00 0.00] [0.00 0.00 1.00 0.00] [0.00 0.00 1.00 1.00])
    5858                  (visible rect 0.00, 0.00 100.00 x 200.00)
    59                   (coverage rect 0.00, 0.00 500.00 x 200.00)
     59                  (coverage rect -400.00, 0.00 500.00 x 200.00)
    6060                  (intersects coverage rect 1)
    6161                  (contentsScale 1.00)
  • trunk/LayoutTests/platform/mac/compositing/visible-rect/iframe-and-layers-expected.txt

    r183300 r183354  
    6969                                  (transform [1.00 0.00 0.00 0.00] [0.00 1.00 0.00 0.00] [0.00 0.00 1.00 0.00] [0.00 0.00 1.00 1.00])
    7070                                  (visible rect 0.00, 0.00 100.00 x 127.00)
    71                                   (coverage rect 0.00, 0.00 285.00 x 135.00)
     71                                  (coverage rect -8.00, -8.00 285.00 x 135.00)
    7272                                  (intersects coverage rect 1)
    7373                                  (contentsScale 1.00)
     
    9191          (transform [1.00 0.00 0.00 0.00] [0.00 1.00 0.00 0.00] [0.00 0.00 1.00 0.00] [0.00 0.00 1.00 1.00])
    9292          (visible rect 0.00, 0.00 200.00 x 200.00)
    93           (coverage rect 0.00, 0.00 785.00 x 585.00)
     93          (coverage rect -8.00, -226.00 785.00 x 585.00)
    9494          (intersects coverage rect 1)
    9595          (contentsScale 1.00)
  • trunk/LayoutTests/platform/mac/compositing/visible-rect/iframe-no-layers-expected.txt

    r183300 r183354  
    2222          (transform [1.00 0.00 0.00 0.00] [0.00 1.00 0.00 0.00] [0.00 0.00 1.00 0.00] [0.00 0.00 1.00 1.00])
    2323          (visible rect 2.00, 92.00 98.00 x 135.00)
    24           (coverage rect 10.00, 100.00 285.00 x 135.00)
     24          (coverage rect 2.00, 92.00 285.00 x 135.00)
    2525          (intersects coverage rect 1)
    2626          (contentsScale 1.00)
  • trunk/LayoutTests/platform/mac/compositing/visible-rect/scrolled-expected.txt

    r183300 r183354  
    2121          (transform [1.00 0.00 0.00 0.00] [0.00 1.00 0.00 0.00] [0.00 0.00 1.00 0.00] [0.00 0.00 1.00 1.00])
    2222          (visible rect 17.00, 200.00 183.00 x 300.00)
    23           (coverage rect 25.00, 200.00 785.00 x 585.00)
     23          (coverage rect 17.00, 200.00 785.00 x 585.00)
    2424          (intersects coverage rect 1)
    2525          (contentsScale 1.00)
  • trunk/Source/WebCore/ChangeLog

    r183350 r183354  
     12015-04-25  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Expand compositing coverage rect when scrolling and animating
     4        https://bugs.webkit.org/show_bug.cgi?id=144214
     5        rdar://problem/20695926
     6
     7        Reviewed by Darin Adler.
     8       
     9        r183300 added a secondary rect that gets mapped through graphics layers during
     10        layer flushing, which represents a rect, in layer coordinates, that represents
     11        the portion of this layer that's visible in the viewport.
     12       
     13        This patch extends that rect based on scrolling and animating, with the extended
     14        coverage rect being mapped into descendants (where it's used to determine whether
     15        they should detach their backing store). This required moving the responsibility for
     16        extending the coverage rect from TileController (where it was used to compute
     17        tiled extent), to GraphicsLayerCA. Thus, GraphicsLayerCA now owns the concept
     18        of coverage rect, and pushes it onto TileControllers.
     19
     20        Test: compositing/tiling/transform-origin-tiled.html
     21
     22        * platform/graphics/TiledBacking.h: Coverage rect is now pushed onto
     23        TiledBacking from outside; new functions reflect that.
     24        * platform/graphics/ca/GraphicsLayerCA.cpp:
     25        (WebCore::GraphicsLayerCA::flushCompositingStateForThisLayerOnly): No need to pass
     26        old visible rect to commitLayerChangesBeforeSublayers.
     27        (WebCore::accumulatesTransform):
     28        (WebCore::GraphicsLayerCA::recursiveVisibleRectChangeRequiresFlush): Now calls computeVisibleAndCoverageRect(),
     29        then adjustCoverageRect() which adjusts for scrolling and animations.
     30        (WebCore::GraphicsLayerCA::computeVisibleAndCoverageRect): Fetch the coverage rect from the
     31        TransformState, but we can only use this if mapping it through various transforms didn't clamp
     32        it (which can happen with severe rotations in perspective).
     33        (WebCore::GraphicsLayerCA::adjustCoverageRect): If this layer represents the page tiled backing,
     34        ask the TileController to do coverage adjustment (code which should move into here eventually).
     35        For other tiled layers, do motion-based adjustment. This should really be done for all layers
     36        (an animating non-tiled layer may contain a tiled layer).
     37        (WebCore::GraphicsLayerCA::setVisibleAndCoverageRects): The VisibleRectChanged wasn't needed
     38        any more; layers only react to changed in coverage rect now.
     39        (WebCore::GraphicsLayerCA::recursiveCommitChanges): If adjustCoverageRect() changed the
     40        coverage rect, here we push the new rect back into the TransformState so it will affect
     41        descendants.
     42        (WebCore::GraphicsLayerCA::commitLayerChangesBeforeSublayers):
     43        (WebCore::GraphicsLayerCA::updateCoverage): Coverage and backing store attachment go
     44        hand-in-hand now.
     45        (WebCore::GraphicsLayerCA::changeLayerTypeTo):
     46        (WebCore::GraphicsLayerCA::computeVisibleRect): Deleted.
     47        (WebCore::GraphicsLayerCA::updateBackingStoreAttachment): Deleted.
     48        (WebCore::GraphicsLayerCA::updateVisibleRect): Deleted.
     49        * platform/graphics/ca/GraphicsLayerCA.h:
     50        * platform/graphics/ca/TileController.cpp:
     51        (WebCore::TileController::setVisibleRect): Visible rect is only used for scroll performance
     52        logging now.
     53        (WebCore::TileController::setCoverageRect):
     54        (WebCore::TileController::tilesWouldChangeForCoverageRect):
     55        (WebCore::TileController::revalidateTiles):
     56        (WebCore::TileController::boundsForSize): This is required because when computeTileCoverageRect()
     57        is called at the top of committing the owning layer, we haven't yet pushed a new size to the
     58        underlying platform layer (which TileController::bounds() consults).
     59        (WebCore::TileController::bounds):
     60        (WebCore::TileController::computeTileCoverageRect): Have to push the new size in, since the
     61        underlying layer hasn't been updated yet.
     62        (WebCore::TileController::didRevalidateTiles):
     63        (WebCore::TileController::tilesWouldChangeForVisibleRect): Deleted.
     64        * platform/graphics/ca/TileController.h:
     65        * platform/graphics/ca/TileCoverageMap.cpp:
     66        (WebCore::TileCoverageMap::TileCoverageMap): Add a layer to the tile map that shows
     67        a dark blue outline for the coverage rect.
     68        (WebCore::TileCoverageMap::update): Fix some minor issues with map position when top
     69        content inset is non-zero.
     70        * platform/graphics/ca/TileCoverageMap.h:
     71        * platform/graphics/ca/TileGrid.cpp: Everything is in terms of coverage rect now.
     72        (WebCore::TileGrid::tilesWouldChangeForCoverageRect):
     73        (WebCore::TileGrid::revalidateTiles):
     74        (WebCore::TileGrid::tilesWouldChangeForVisibleRect): Deleted.
     75        * platform/graphics/ca/TileGrid.h:
     76        * platform/graphics/transforms/TransformState.cpp:
     77        (WebCore::TransformState::operator=):
     78        (WebCore::TransformState::mappedQuad): Pass direction into mapQuad().
     79        (WebCore::TransformState::mappedSecondaryQuad): Ditto.
     80        (WebCore::TransformState::setLastPlanarSecondaryQuad): This function allows a caller
     81        to pass in a secondary quad, and get it mapped into the coordinate space of the last
     82        "flattening" state (since the TransformState may have in-flight XY offset, or transform).
     83        This mapping is achieved by re-using mapQuad(), but in the inverse direction.
     84        (WebCore::TransformState::mapQuad): Make direction a parameter.
     85        (WebCore::TransformState::flattenWithTransform): This code omitted to map the secondary
     86        quad. Failure was detected by tests.
     87        * platform/graphics/transforms/TransformState.h:
     88        (WebCore::TransformState::isMappingSecondaryQuad):
     89        (WebCore::TransformState::direction):
     90        (WebCore::TransformState::inverseDirection):
     91        (WebCore::TransformState::lastPlanarSecondaryQuad): Deleted.
     92
    1932015-04-25  Dan Bernstein  <mitz@apple.com>
    294
  • trunk/Source/WebCore/platform/graphics/TiledBacking.h

    r183224 r183354  
    6767    virtual void setVisibleRect(const FloatRect&) = 0;
    6868    virtual FloatRect visibleRect() const = 0;
    69     virtual bool tilesWouldChangeForVisibleRect(const FloatRect&) const = 0;
     69
     70    virtual void setCoverageRect(const FloatRect&) = 0;
     71    virtual FloatRect coverageRect() const = 0;
     72    virtual bool tilesWouldChangeForCoverageRect(const FloatRect&) const = 0;
    7073
    7174    virtual void setTiledScrollingIndicatorPosition(const FloatPoint&) = 0;
     
    8891    virtual void setTileCoverage(TileCoverage) = 0;
    8992    virtual TileCoverage tileCoverage() const = 0;
     93
     94    virtual FloatRect computeTileCoverageRect(const FloatSize& newSize, const FloatRect& previousVisibleRect, const FloatRect& currentVisibleRect) const = 0;
    9095
    9196    virtual IntSize tileSize() const = 0;
  • trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp

    r183302 r183354  
    10891089
    10901090    FloatPoint offset = computePositionRelativeToBase(pageScaleFactor);
    1091     commitLayerChangesBeforeSublayers(commitState, pageScaleFactor, offset, m_visibleRect);
     1091    commitLayerChangesBeforeSublayers(commitState, pageScaleFactor, offset);
    10921092    commitLayerChangesAfterSublayers(commitState);
    10931093
     
    10961096}
    10971097
     1098static inline bool accumulatesTransform(const GraphicsLayerCA& layer)
     1099{
     1100    return layer.preserves3D() || (layer.parent() && layer.parent()->preserves3D());
     1101}
     1102
    10981103bool GraphicsLayerCA::recursiveVisibleRectChangeRequiresFlush(const TransformState& state) const
    10991104{
     
    11021107    // This may be called at times when layout has not been updated, so we want to avoid calling out to the client
    11031108    // for animating transforms.
    1104     FloatRect newVisibleRect = computeVisibleRect(localState, 0);
    1105     if (m_layer->layerType() == PlatformCALayer::LayerTypeTiledBackingLayer)
    1106         newVisibleRect = adjustTiledLayerVisibleRect(tiledBacking(), m_visibleRect, newVisibleRect, m_sizeAtLastVisibleRectUpdate, m_size);
    1107 
    1108     if (newVisibleRect != m_visibleRect) {
     1109    VisibleAndCoverageRects rects = computeVisibleAndCoverageRect(localState, accumulatesTransform(*this), 0);
     1110    adjustCoverageRect(rects, m_visibleRect);
     1111
     1112    if (rects.coverageRect != m_coverageRect) {
    11091113        if (TiledBacking* tiledBacking = this->tiledBacking()) {
    1110             if (tiledBacking->tilesWouldChangeForVisibleRect(newVisibleRect))
     1114            if (tiledBacking->tilesWouldChangeForCoverageRect(rects.coverageRect))
    11111115                return true;
    11121116        }
     
    11751179}
    11761180
    1177 FloatRect GraphicsLayerCA::computeVisibleRect(TransformState& state, ComputeVisibleRectFlags flags) const
    1178 {
    1179     bool preserve3D = preserves3D() || (parent() ? parent()->preserves3D() : false);
    1180     TransformState::TransformAccumulation accumulation = preserve3D ? TransformState::AccumulateTransform : TransformState::FlattenTransform;
    1181 
     1181GraphicsLayerCA::VisibleAndCoverageRects GraphicsLayerCA::computeVisibleAndCoverageRect(TransformState& state, bool preserves3D, ComputeVisibleRectFlags flags) const
     1182{
    11821183    FloatPoint position = m_position;
    11831184    client().customPositionForVisibleRectComputation(this, position);
     
    11911192
    11921193    bool applyWasClamped;
     1194    TransformState::TransformAccumulation accumulation = preserves3D ? TransformState::AccumulateTransform : TransformState::FlattenTransform;
    11931195    state.applyTransform(layerTransform, accumulation, &applyWasClamped);
    11941196
     
    12121214        state.flatten();
    12131215        state.setQuad(clipRectForSelf);
    1214         if (state.lastPlanarSecondaryQuad()) {
     1216        if (state.isMappingSecondaryQuad()) {
    12151217            FloatQuad secondaryQuad(clipRectForSelf);
    12161218            state.setSecondaryQuad(&secondaryQuad);
     
    12181220    }
    12191221
    1220     return clipRectForSelf;
    1221 }
    1222 
    1223 void GraphicsLayerCA::setVisibleAndCoverageRects(const FloatRect& visibleRect, const FloatRect& coverageRect)
    1224 {
    1225     bool visibleRectChanged = visibleRect != m_visibleRect;
    1226     bool coverageRectChanged = coverageRect != m_coverageRect;
     1222    FloatRect coverageRect = clipRectForSelf;
     1223    std::unique_ptr<FloatQuad> quad = state.mappedSecondaryQuad(&mapWasClamped);
     1224    if (quad && !mapWasClamped && !applyWasClamped)
     1225        coverageRect = quad->boundingBox();
     1226
     1227    return VisibleAndCoverageRects(clipRectForSelf, coverageRect);
     1228}
     1229
     1230bool GraphicsLayerCA::adjustCoverageRect(VisibleAndCoverageRects& rects, const FloatRect& oldVisibleRect) const
     1231{
     1232    FloatRect coverageRect = rects.coverageRect;
     1233
     1234    // FIXME: TileController's computeTileCoverageRect() code should move here, and we should unify these different
     1235    // ways of computing coverage.
     1236    switch (type()) {
     1237    case Type::PageTiledBacking:
     1238        coverageRect = tiledBacking()->computeTileCoverageRect(size(), oldVisibleRect, rects.visibleRect);
     1239        break;
     1240    case Type::Normal:
     1241        if (m_layer->layerType() == PlatformCALayer::LayerTypeTiledBackingLayer)
     1242            coverageRect.unite(adjustTiledLayerVisibleRect(tiledBacking(), oldVisibleRect, rects.visibleRect, m_sizeAtLastCoverageRectUpdate, m_size));
     1243        break;
     1244    default:
     1245        break;
     1246    }
     1247   
     1248    if (rects.coverageRect == coverageRect)
     1249        return false;
     1250
     1251    rects.coverageRect = coverageRect;
     1252    return true;
     1253}
     1254
     1255void GraphicsLayerCA::setVisibleAndCoverageRects(const VisibleAndCoverageRects& rects)
     1256{
     1257    bool visibleRectChanged = rects.visibleRect != m_visibleRect;
     1258    bool coverageRectChanged = rects.coverageRect != m_coverageRect;
    12271259    if (!visibleRectChanged && !coverageRectChanged)
    12281260        return;
    12291261
    12301262    if (visibleRectChanged) {
    1231         m_uncommittedChanges |= VisibleRectChanged;
    1232         m_visibleRect = visibleRect;
     1263        m_uncommittedChanges |= CoverageRectChanged;
     1264        m_visibleRect = rects.visibleRect;
    12331265       
    12341266        if (GraphicsLayerCA* maskLayer = downcast<GraphicsLayerCA>(m_maskLayer)) {
    12351267            // FIXME: this assumes that the mask layer has the same geometry as this layer (which is currently always true).
    1236             maskLayer->m_uncommittedChanges |= VisibleRectChanged;
    1237             maskLayer->m_visibleRect = visibleRect;
     1268            maskLayer->m_uncommittedChanges |= CoverageRectChanged;
     1269            maskLayer->m_visibleRect = rects.visibleRect;
    12381270        }
    12391271    }
     
    12411273    if (coverageRectChanged) {
    12421274        m_uncommittedChanges |= CoverageRectChanged;
    1243         m_coverageRect = coverageRect;
     1275        m_coverageRect = rects.coverageRect;
    12441276
    12451277        // FIXME: we need to take reflections into account when determining whether this layer intersects the coverage rect.
     
    12481280        if (GraphicsLayerCA* maskLayer = downcast<GraphicsLayerCA>(m_maskLayer)) {
    12491281            maskLayer->m_uncommittedChanges |= CoverageRectChanged;
    1250             maskLayer->m_coverageRect = coverageRect;
     1282            maskLayer->m_coverageRect = rects.coverageRect;
    12511283        }
    12521284    }
     
    12601292    CommitState childCommitState = commitState;
    12611293    bool affectedByTransformAnimation = commitState.ancestorHasTransformAnimation;
    1262    
    1263     FloatRect visibleRect = computeVisibleRect(localState);
    1264     FloatRect coverageRect = visibleRect;
    1265     if (std::unique_ptr<FloatQuad> quad = localState.mappedSecondaryQuad())
    1266         coverageRect = quad->boundingBox();
    1267 
    1268     FloatRect oldVisibleRect = m_visibleRect;
    1269     setVisibleAndCoverageRects(visibleRect, coverageRect);
     1294
     1295    bool accumulateTransform = accumulatesTransform(*this);
     1296    VisibleAndCoverageRects rects = computeVisibleAndCoverageRect(localState, accumulateTransform);
     1297    if (adjustCoverageRect(rects, m_visibleRect)) {
     1298        if (state.isMappingSecondaryQuad()) {
     1299            FloatQuad secondaryQuad(rects.coverageRect);
     1300            localState.setLastPlanarSecondaryQuad(&secondaryQuad);
     1301        }
     1302    }
     1303    setVisibleAndCoverageRects(rects);
    12701304
    12711305#ifdef VISIBLE_TILE_WASH
     
    13041338        baseRelativePosition += m_position;
    13051339   
    1306     commitLayerChangesBeforeSublayers(childCommitState, pageScaleFactor, baseRelativePosition, oldVisibleRect);
     1340    commitLayerChangesBeforeSublayers(childCommitState, pageScaleFactor, baseRelativePosition);
    13071341
    13081342    if (isRunningTransformAnimation()) {
     
    13121346
    13131347    if (GraphicsLayerCA* maskLayer = downcast<GraphicsLayerCA>(m_maskLayer))
    1314         maskLayer->commitLayerChangesBeforeSublayers(childCommitState, pageScaleFactor, baseRelativePosition, oldVisibleRect);
     1348        maskLayer->commitLayerChangesBeforeSublayers(childCommitState, pageScaleFactor, baseRelativePosition);
    13151349
    13161350    const Vector<GraphicsLayer*>& childLayers = children();
     
    13871421}
    13881422
    1389 void GraphicsLayerCA::commitLayerChangesBeforeSublayers(CommitState& commitState, float pageScaleFactor, const FloatPoint& positionRelativeToBase, const FloatRect& oldVisibleRect)
     1423void GraphicsLayerCA::commitLayerChangesBeforeSublayers(CommitState& commitState, float pageScaleFactor, const FloatPoint& positionRelativeToBase)
    13901424{
    13911425    TemporaryChange<bool> committingChangesChange(m_isCommittingChanges, true);
     
    14871521        updateContentsScale(pageScaleFactor);
    14881522
    1489     if (m_uncommittedChanges & VisibleRectChanged)
    1490         updateVisibleRect(oldVisibleRect);
    1491    
    14921523    if (m_uncommittedChanges & CoverageRectChanged)
    1493         updateBackingStoreAttachment();
    1494 
    1495     if (m_uncommittedChanges & TilingAreaChanged) // Needs to happen after VisibleRectChanged, ContentsScaleChanged
     1524        updateCoverage();
     1525
     1526    if (m_uncommittedChanges & TilingAreaChanged) // Needs to happen after CoverageRectChanged, ContentsScaleChanged
    14961527        updateTiles();
    14971528
     
    19661997}
    19671998
    1968 void GraphicsLayerCA::updateBackingStoreAttachment()
    1969 {
     1999void GraphicsLayerCA::updateCoverage()
     2000{
     2001    // FIXME: Need to set coverage on clone layers too.
     2002    if (TiledBacking* backing = tiledBacking()) {
     2003        backing->setVisibleRect(m_visibleRect);
     2004        backing->setCoverageRect(m_coverageRect);
     2005    }
     2006
    19702007    m_layer->setBackingStoreAttached(m_intersectsCoverageRect);
    19712008    if (m_layerClones) {
     
    19742011            it->value->setBackingStoreAttached(m_intersectsCoverageRect);
    19752012    }
     2013
     2014    m_sizeAtLastCoverageRectUpdate = m_size;
    19762015}
    19772016
     
    20892128    expandedRect.intersect(tiledBacking->boundsWithoutMargin());
    20902129    return expandedRect;
    2091 }
    2092 
    2093 void GraphicsLayerCA::updateVisibleRect(const FloatRect& oldVisibleRect)
    2094 {
    2095     if (!m_layer->usesTiledBackingLayer())
    2096         return;
    2097 
    2098     FloatRect tileArea = m_visibleRect;
    2099     if (m_layer->layerType() == PlatformCALayer::LayerTypeTiledBackingLayer)
    2100         tileArea = adjustTiledLayerVisibleRect(tiledBacking(), oldVisibleRect, tileArea, m_sizeAtLastVisibleRectUpdate, m_size);
    2101 
    2102     tiledBacking()->setVisibleRect(tileArea);
    2103 
    2104     m_sizeAtLastVisibleRectUpdate = m_size;
    21052130}
    21062131
     
    33133338   
    33143339    if (m_usingTiledBacking)
    3315         m_uncommittedChanges |= VisibleRectChanged;
     3340        m_uncommittedChanges |= CoverageRectChanged;
    33163341
    33173342#ifndef NDEBUG
  • trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h

    r183300 r183354  
    247247    }
    248248
    249     void commitLayerChangesBeforeSublayers(CommitState&, float pageScaleFactor, const FloatPoint& positionRelativeToBase, const FloatRect& oldVisibleRect);
     249    void commitLayerChangesBeforeSublayers(CommitState&, float pageScaleFactor, const FloatPoint& positionRelativeToBase);
    250250    void commitLayerChangesAfterSublayers(CommitState&);
    251251
     
    276276    enum ComputeVisibleRectFlag { RespectAnimatingTransforms = 1 << 0 };
    277277    typedef unsigned ComputeVisibleRectFlags;
    278     FloatRect computeVisibleRect(TransformState&, ComputeVisibleRectFlags = RespectAnimatingTransforms) const;
     278   
     279    struct VisibleAndCoverageRects {
     280        FloatRect visibleRect;
     281        FloatRect coverageRect;
     282       
     283        VisibleAndCoverageRects(const FloatRect& visRect, const FloatRect& covRect)
     284            : visibleRect(visRect)
     285            , coverageRect(covRect)
     286        {
     287        }
     288    };
     289   
     290    VisibleAndCoverageRects computeVisibleAndCoverageRect(TransformState&, bool accumulateTransform, ComputeVisibleRectFlags = RespectAnimatingTransforms) const;
     291    bool adjustCoverageRect(VisibleAndCoverageRects&, const FloatRect& oldVisibleRect) const;
    279292
    280293    const FloatRect& visibleRect() const { return m_visibleRect; }
    281294    const FloatRect& coverageRect() const { return m_coverageRect; }
    282295
    283     void setVisibleAndCoverageRects(const FloatRect& visibleRect, const FloatRect& coverageRect);
     296    void setVisibleAndCoverageRects(const VisibleAndCoverageRects&);
    284297   
    285298    static FloatRect adjustTiledLayerVisibleRect(TiledBacking*, const FloatRect& oldVisibleRect, const FloatRect& newVisibleRect, const FloatSize& oldSize, const FloatSize& newSize);
     
    364377    void updateStructuralLayer();
    365378    void updateDrawsContent();
    366     void updateBackingStoreAttachment();
     379    void updateCoverage();
    367380    void updateBackgroundColor();
    368381
     
    379392    void updateAcceleratesDrawing();
    380393    void updateDebugBorder();
    381     void updateVisibleRect(const FloatRect& oldVisibleRect);
    382394    void updateTiles();
    383395    void updateContentsScale(float pageScaleFactor);
     
    451463        ContentsScaleChanged =          1LLU << 24,
    452464        ContentsVisibilityChanged =     1LLU << 25,
    453         VisibleRectChanged =            1LLU << 26,
    454         CoverageRectChanged =           1LLU << 27,
    455         FiltersChanged =                1LLU << 28,
    456         BackdropFiltersChanged =        1LLU << 29,
    457         TilingAreaChanged =             1LLU << 30,
    458         TilesAdded =                    1LLU << 31,
    459         DebugIndicatorsChanged =        1LLU << 32,
    460         CustomAppearanceChanged =       1LLU << 33,
    461         BlendModeChanged =              1LLU << 34,
    462         ShapeChanged =                  1LLU << 35,
    463         WindRuleChanged =               1LLU << 36,
     465        CoverageRectChanged =           1LLU << 26,
     466        FiltersChanged =                1LLU << 27,
     467        BackdropFiltersChanged =        1LLU << 28,
     468        TilingAreaChanged =             1LLU << 29,
     469        TilesAdded =                    1LLU << 30,
     470        DebugIndicatorsChanged =        1LLU << 31,
     471        CustomAppearanceChanged =       1LLU << 32,
     472        BlendModeChanged =              1LLU << 33,
     473        ShapeChanged =                  1LLU << 34,
     474        WindRuleChanged =               1LLU << 35,
    464475    };
    465476    typedef uint64_t LayerChangeFlags;
     
    493504#endif
    494505    FloatRect m_visibleRect;
    495     FloatSize m_sizeAtLastVisibleRectUpdate;
     506    FloatSize m_sizeAtLastCoverageRectUpdate;
    496507
    497508    FloatRect m_coverageRect; // Area for which we should maintain backing store, in the coordinate space of this layer.
  • trunk/Source/WebCore/platform/graphics/ca/TileController.cpp

    r183224 r183354  
    183183}
    184184
    185 void TileController::setVisibleRect(const FloatRect& visibleRect)
     185void TileController::setVisibleRect(const FloatRect& rect)
     186{
     187    m_visibleRect = rect;
     188}
     189
     190void TileController::setCoverageRect(const FloatRect& rect)
    186191{
    187192    ASSERT(owningGraphicsLayer()->isCommittingChanges());
    188     if (m_visibleRect == visibleRect)
    189         return;
    190 
    191     m_visibleRect = visibleRect;
     193    if (m_coverageRect == rect)
     194        return;
     195
     196    m_coverageRect = rect;
    192197    setNeedsRevalidateTiles();
    193198}
    194199
    195 bool TileController::tilesWouldChangeForVisibleRect(const FloatRect& newVisibleRect) const
     200bool TileController::tilesWouldChangeForCoverageRect(const FloatRect& rect) const
    196201{
    197202    if (bounds().isEmpty())
    198203        return false;
    199     return tileGrid().tilesWouldChangeForVisibleRect(newVisibleRect, m_visibleRect);
     204
     205    return tileGrid().tilesWouldChangeForCoverageRect(rect);
    200206}
    201207
     
    257263    ASSERT(owningGraphicsLayer()->isCommittingChanges());
    258264    tileGrid().revalidateTiles(0);
    259     m_visibleRectAtLastRevalidate = m_visibleRect;
    260265}
    261266
     
    283288}
    284289
     290IntRect TileController::boundsForSize(const FloatSize& size) const
     291{
     292    IntPoint boundsOriginIncludingMargin(-leftMarginWidth(), -topMarginHeight());
     293    IntSize boundsSizeIncludingMargin = expandedIntSize(size);
     294    boundsSizeIncludingMargin.expand(leftMarginWidth() + rightMarginWidth(), topMarginHeight() + bottomMarginHeight());
     295
     296    return IntRect(boundsOriginIncludingMargin, boundsSizeIncludingMargin);
     297}
     298
    285299IntRect TileController::bounds() const
    286300{
    287     IntPoint boundsOriginIncludingMargin(-leftMarginWidth(), -topMarginHeight());
    288     IntSize boundsSizeIncludingMargin = expandedIntSize(m_tileCacheLayer->bounds().size());
    289     boundsSizeIncludingMargin.expand(leftMarginWidth() + rightMarginWidth(), topMarginHeight() + bottomMarginHeight());
    290 
    291     return IntRect(boundsOriginIncludingMargin, boundsSizeIncludingMargin);
     301    return boundsForSize(m_tileCacheLayer->bounds().size());
    292302}
    293303
     
    304314}
    305315
    306 FloatRect TileController::computeTileCoverageRect(const FloatRect& previousVisibleRect, const FloatRect& visibleRect) const
     316FloatRect TileController::computeTileCoverageRect(const FloatSize& newSize, const FloatRect& previousVisibleRect, const FloatRect& visibleRect) const
    307317{
    308318    // If the page is not in a window (for example if it's in a background tab), we limit the tile coverage rect to the visible rect.
     
    347357    }
    348358
    349     IntSize contentSize = bounds().size();
     359    // Can't use m_tileCacheLayer->bounds() here, because the size of the underlying platform layer
     360    // hasn't been updated for the current commit.
     361    IntSize contentSize = expandedIntSize(newSize);
    350362    if (futureRect.maxX() > contentSize.width())
    351363        futureRect.setX(contentSize.width() - futureRect.width());
     
    378390    coverageHorizontalSize += leftMarginWidth() + rightMarginWidth();
    379391
    380     FloatRect coverageBounds = bounds();
     392    // Can't use m_tileCacheLayer->bounds() here, because the size of the underlying platform layer
     393    // hasn't been updated for the current commit.
     394    FloatRect coverageBounds = boundsForSize(newSize);
    381395    float coverageLeft = visibleRect.x() - (coverageHorizontalSize - visibleRect.width()) / 2;
    382396    coverageLeft = std::min(coverageLeft, coverageBounds.maxX() - coverageHorizontalSize);
     
    428442void TileController::didRevalidateTiles()
    429443{
    430     m_visibleRectAtLastRevalidate = visibleRect();
    431444    m_boundsAtLastRevalidate = bounds();
    432445
  • trunk/Source/WebCore/platform/graphics/ca/TileController.h

    r183173 r183354  
    8080
    8181    virtual FloatRect visibleRect() const override { return m_visibleRect; }
     82    virtual FloatRect coverageRect() const override { return m_coverageRect; }
    8283
    8384    unsigned blankPixelCount() const;
     
    106107    virtual int rightMarginWidth() const override;
    107108    virtual TileCoverage tileCoverage() const override { return m_tileCoverage; }
     109    virtual FloatRect computeTileCoverageRect(const FloatSize& newSize, const FloatRect& previousVisibleRect, const FloatRect& currentVisibleRect) const override;
    108110    virtual bool unparentsOffscreenTiles() const override { return m_unparentsOffscreenTiles; }
    109111    virtual bool scrollingPerformanceLoggingEnabled() const override { return m_scrollingPerformanceLoggingEnabled; }
    110112
    111     FloatRect computeTileCoverageRect(const FloatRect& previousVisibleRect, const FloatRect& currentVisibleRect) const;
    112 
    113113    IntRect boundsAtLastRevalidate() const { return m_boundsAtLastRevalidate; }
    114114    IntRect boundsAtLastRevalidateWithoutMargin() const;
    115     FloatRect visibleRectAtLastRevalidate() const { return m_visibleRectAtLastRevalidate; }
    116115    void didRevalidateTiles();
    117116
     
    137136    // TiledBacking member functions.
    138137    virtual void setVisibleRect(const FloatRect&) override;
    139     virtual bool tilesWouldChangeForVisibleRect(const FloatRect&) const override;
     138    virtual void setCoverageRect(const FloatRect&) override;
     139    virtual bool tilesWouldChangeForCoverageRect(const FloatRect&) const override;
    140140    virtual void setTiledScrollingIndicatorPosition(const FloatPoint&) override;
    141141    virtual void setTopContentInset(float) override;
     
    159159    virtual float zoomedOutContentsScale() const override;
    160160
    161 
    162161    void tileRevalidationTimerFired();
    163 
    164162    void setNeedsRevalidateTiles();
     163   
     164    IntRect boundsForSize(const FloatSize&) const;
    165165
    166166    PlatformCALayerClient* owningGraphicsLayer() const { return m_tileCacheLayer->owner(); }
     
    174174
    175175    IntSize m_tileSize;
    176     FloatRect m_visibleRect;
    177     FloatRect m_visibleRectAtLastRevalidate;
     176    FloatRect m_visibleRect; // Only used for scroll performance logging.
     177    FloatRect m_coverageRect;
    178178    IntRect m_boundsAtLastRevalidate;
    179179
  • trunk/Source/WebCore/platform/graphics/ca/TileCoverageMap.cpp

    r175583 r183354  
    3737    , m_layer(*controller.rootLayer().createCompatibleLayer(PlatformCALayer::LayerTypeSimpleLayer, this))
    3838    , m_visibleRectIndicatorLayer(*controller.rootLayer().createCompatibleLayer(PlatformCALayer::LayerTypeLayer, nullptr))
     39    , m_coverageRectIndicatorLayer(*controller.rootLayer().createCompatibleLayer(PlatformCALayer::LayerTypeLayer, nullptr))
    3940    , m_position(FloatPoint(0, controller.topContentInset()))
    4041{
     
    4546    m_layer.get().setPosition(FloatPoint(2, 2));
    4647    m_layer.get().setContentsScale(m_controller.deviceScaleFactor());
     48
    4749    m_visibleRectIndicatorLayer.get().setBorderWidth(2);
    4850    m_visibleRectIndicatorLayer.get().setAnchorPoint(FloatPoint3D());
    4951    m_visibleRectIndicatorLayer.get().setBorderColor(Color(255, 0, 0));
     52   
     53    m_coverageRectIndicatorLayer.get().setBorderWidth(2);
     54    m_coverageRectIndicatorLayer.get().setAnchorPoint(FloatPoint3D());
     55    m_coverageRectIndicatorLayer.get().setBorderColor(Color(0, 0, 128));
    5056
     57    m_layer.get().appendSublayer(m_coverageRectIndicatorLayer);
    5158    m_layer.get().appendSublayer(m_visibleRectIndicatorLayer);
    5259
     
    6370    FloatRect containerBounds = m_controller.bounds();
    6471    FloatRect visibleRect = m_controller.visibleRect();
     72    FloatRect coverageRect = m_controller.coverageRect();
    6573    visibleRect.contract(4, 4); // Layer is positioned 2px from top and left edges.
    6674
     
    6977    if (!containerBounds.isEmpty()) {
    7078        widthScale = std::min<float>(visibleRect.width() / containerBounds.width(), 0.1);
    71         scale = std::min(widthScale, visibleRect.height() / containerBounds.height());
     79        float visibleHeight = visibleRect.height() - std::min(m_controller.topContentInset(), visibleRect.y());
     80        scale = std::min(widthScale, visibleHeight / containerBounds.height());
    7281    }
    7382
    7483    float indicatorScale = scale * m_controller.tileGrid().scale();
     84
    7585    FloatRect mapBounds = containerBounds;
    7686    mapBounds.scale(indicatorScale, indicatorScale);
     
    8494    m_visibleRectIndicatorLayer->setPosition(visibleRect.location());
    8595    m_visibleRectIndicatorLayer->setBounds(FloatRect(FloatPoint(), visibleRect.size()));
     96
     97    coverageRect.scale(indicatorScale, indicatorScale);
     98    coverageRect.expand(2, 2);
     99    m_coverageRectIndicatorLayer->setPosition(coverageRect.location());
     100    m_coverageRectIndicatorLayer->setBounds(FloatRect(FloatPoint(), coverageRect.size()));
    86101
    87102    Color visibleRectIndicatorColor;
  • trunk/Source/WebCore/platform/graphics/ca/TileCoverageMap.h

    r177786 r183354  
    6666    Ref<PlatformCALayer> m_layer;
    6767    Ref<PlatformCALayer> m_visibleRectIndicatorLayer;
     68    Ref<PlatformCALayer> m_coverageRectIndicatorLayer;
    6869
    6970    FloatPoint m_position;
  • trunk/Source/WebCore/platform/graphics/ca/TileGrid.cpp

    r183175 r183354  
    186186}
    187187
    188 bool TileGrid::tilesWouldChangeForVisibleRect(const FloatRect& newVisibleRect, const FloatRect& oldVisibleRect) const
    189 {
    190     FloatRect visibleRect = newVisibleRect;
    191 
    192     if (visibleRect.isEmpty())
     188bool TileGrid::tilesWouldChangeForCoverageRect(const FloatRect& coverageRect) const
     189{
     190    if (coverageRect.isEmpty())
    193191        return false;
    194        
    195     FloatRect currentTileCoverageRect = m_controller.computeTileCoverageRect(oldVisibleRect, newVisibleRect);
    196     FloatRect scaledRect(currentTileCoverageRect);
     192
     193    FloatRect scaledRect(coverageRect);
    197194    scaledRect.scale(m_scale);
    198195    IntRect currentCoverageRectInTileCoords(enclosingIntRect(scaledRect));
     
    202199    getTileIndexRangeForRect(currentCoverageRectInTileCoords, topLeft, bottomRight);
    203200
    204     IntRect coverageRect = rectForTileIndex(topLeft);
    205     coverageRect.unite(rectForTileIndex(bottomRight));
    206     return coverageRect != m_primaryTileCoverageRect;
     201    IntRect tileCoverageRect = rectForTileIndex(topLeft);
     202    tileCoverageRect.unite(rectForTileIndex(bottomRight));
     203    return tileCoverageRect != m_primaryTileCoverageRect;
    207204}
    208205
     
    307304void TileGrid::revalidateTiles(TileValidationPolicy validationPolicy)
    308305{
    309     FloatRect visibleRect = m_controller.visibleRect();
     306    FloatRect coverageRect = m_controller.coverageRect();
    310307    IntRect bounds = m_controller.bounds();
    311308
    312     if (visibleRect.isEmpty() || bounds.isEmpty())
     309    if (coverageRect.isEmpty() || bounds.isEmpty())
    313310        return;
    314311
    315     FloatRect tileCoverageRect = m_controller.computeTileCoverageRect(m_controller.visibleRectAtLastRevalidate(), visibleRect);
    316     FloatRect scaledRect(tileCoverageRect);
     312    FloatRect scaledRect(coverageRect);
    317313    scaledRect.scale(m_scale);
    318314    IntRect coverageRectInTileCoords(enclosingIntRect(scaledRect));
     
    379375
    380376    // Ensure primary tile coverage tiles.
    381     m_primaryTileCoverageRect = ensureTilesForRect(tileCoverageRect, CoverageType::PrimaryTiles);
     377    m_primaryTileCoverageRect = ensureTilesForRect(coverageRect, CoverageType::PrimaryTiles);
    382378
    383379    if (validationPolicy & PruneSecondaryTiles) {
  • trunk/Source/WebCore/platform/graphics/ca/TileGrid.h

    r183175 r183354  
    7474    void revalidateTiles(TileValidationPolicy);
    7575
    76     bool tilesWouldChangeForVisibleRect(const FloatRect& newVisibleRect, const FloatRect& oldVisibleRect) const;
     76    bool tilesWouldChangeForCoverageRect(const FloatRect&) const;
    7777
    7878    IntRect tileCoverageRect() const;
  • trunk/Source/WebCore/platform/graphics/transforms/TransformState.cpp

    r183274 r183354  
    4242        else
    4343            m_lastPlanarSecondaryQuad = nullptr;
    44        
    4544    }
    4645    m_accumulatingTransform = other.m_accumulatingTransform;
     
    181180
    182181    FloatQuad quad = m_lastPlanarQuad;
    183     mapQuad(quad, wasClamped);
     182    mapQuad(quad, m_direction, wasClamped);
    184183    return quad;
    185184}
     
    194193
    195194    FloatQuad quad = *m_lastPlanarSecondaryQuad;
    196     mapQuad(quad, wasClamped);
     195    mapQuad(quad, m_direction, wasClamped);
    197196    return std::make_unique<FloatQuad>(quad);
    198197}
    199198
    200 void TransformState::mapQuad(FloatQuad& quad, bool* wasClamped) const
    201 {
    202     quad.move((m_direction == ApplyTransformDirection) ? m_accumulatedOffset : -m_accumulatedOffset);
     199void TransformState::setLastPlanarSecondaryQuad(const FloatQuad* quad)
     200{
     201    if (!quad) {
     202        m_lastPlanarSecondaryQuad = nullptr;
     203        return;
     204    }
     205   
     206    // Map the quad back through any transform or offset back into the last flattening coordinate space.
     207    FloatQuad backMappedQuad(*quad);
     208    mapQuad(backMappedQuad, inverseDirection());
     209    m_lastPlanarSecondaryQuad = std::make_unique<FloatQuad>(backMappedQuad);
     210}
     211
     212void TransformState::mapQuad(FloatQuad& quad, TransformDirection direction, bool* wasClamped) const
     213{
     214    quad.move((direction == ApplyTransformDirection) ? m_accumulatedOffset : -m_accumulatedOffset);
    203215    if (!m_accumulatedTransform)
    204216        return;
    205217
    206     if (m_direction == ApplyTransformDirection)
     218    if (direction == ApplyTransformDirection)
    207219        quad = m_accumulatedTransform->mapQuad(quad);
    208220
     
    215227        if (m_mapPoint)
    216228            m_lastPlanarPoint = t.mapPoint(m_lastPlanarPoint);
    217         if (m_mapQuad)
     229        if (m_mapQuad) {
    218230            m_lastPlanarQuad = t.mapQuad(m_lastPlanarQuad);
     231            if (m_lastPlanarSecondaryQuad)
     232                *m_lastPlanarSecondaryQuad = t.mapQuad(*m_lastPlanarSecondaryQuad);
     233        }
     234
    219235    } else {
    220236        TransformationMatrix inverseTransform = t.inverse();
    221237        if (m_mapPoint)
    222238            m_lastPlanarPoint = inverseTransform.projectPoint(m_lastPlanarPoint);
    223         if (m_mapQuad)
     239        if (m_mapQuad) {
    224240            m_lastPlanarQuad = inverseTransform.projectQuad(m_lastPlanarQuad, wasClamped);
     241            if (m_lastPlanarSecondaryQuad)
     242                *m_lastPlanarSecondaryQuad = inverseTransform.projectQuad(*m_lastPlanarSecondaryQuad, wasClamped);
     243        }
    225244    }
    226245
  • trunk/Source/WebCore/platform/graphics/transforms/TransformState.h

    r183274 r183354  
    8080    }
    8181
     82    // FIXME: webkit.org/b/144226 use Optional<FloatQuad>.
    8283    void setSecondaryQuad(const FloatQuad* quad)
    8384    {
     
    8990            m_lastPlanarSecondaryQuad = nullptr;
    9091    }
     92
     93    // FIXME: webkit.org/b/144226 use Optional<FloatQuad>.
     94    void setLastPlanarSecondaryQuad(const FloatQuad*);
    9195
    9296    void move(LayoutUnit x, LayoutUnit y, TransformAccumulation accumulate = FlattenTransform)
     
    104108    FloatQuad lastPlanarQuad() const { return m_lastPlanarQuad; }
    105109    FloatQuad* lastPlanarSecondaryQuad() const { return m_lastPlanarSecondaryQuad.get(); }
     110    bool isMappingSecondaryQuad() const { return m_lastPlanarSecondaryQuad.get(); }
    106111
    107112    // Return the point or quad mapped through the current transform
     
    116121    void applyAccumulatedOffset();
    117122   
    118     void mapQuad(FloatQuad&, bool* clamped) const;
     123    TransformDirection direction() const { return m_direction; }
     124    TransformDirection inverseDirection() const;
     125
     126    void mapQuad(FloatQuad&, TransformDirection, bool* clamped = nullptr) const;
    119127   
    120128    FloatPoint m_lastPlanarPoint;
     
    131139};
    132140
     141inline TransformState::TransformDirection TransformState::inverseDirection() const
     142{
     143    return m_direction == ApplyTransformDirection ? UnapplyInverseTransformDirection : ApplyTransformDirection;
     144}
     145
    133146} // namespace WebCore
    134147
Note: See TracChangeset for help on using the changeset viewer.