Changeset 245837 in webkit
- Timestamp:
- May 28, 2019, 6:07:03 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 7 added
- 9 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/tiled-drawing/scrolling/overflow (added)
-
LayoutTests/tiled-drawing/scrolling/overflow/overflow-scrolled-down-tile-coverage-expected.txt (added)
-
LayoutTests/tiled-drawing/scrolling/overflow/overflow-scrolled-down-tile-coverage.html (added)
-
LayoutTests/tiled-drawing/scrolling/overflow/overflow-scrolled-up-tile-coverage-expected.txt (added)
-
LayoutTests/tiled-drawing/scrolling/overflow/overflow-scrolled-up-tile-coverage.html (added)
-
LayoutTests/tiled-drawing/scrolling/overflow/overflow-tile-coverage-expected.txt (added)
-
LayoutTests/tiled-drawing/scrolling/overflow/overflow-tile-coverage.html (added)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/platform/graphics/TiledBacking.h (modified) (1 diff)
-
Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp (modified) (1 diff)
-
Source/WebCore/platform/graphics/ca/PlatformCALayer.h (modified) (1 diff)
-
Source/WebCore/platform/graphics/ca/TileController.cpp (modified) (4 diffs)
-
Source/WebCore/platform/graphics/ca/TileController.h (modified) (5 diffs)
-
Source/WebCore/rendering/RenderLayer.h (modified) (2 diffs)
-
Source/WebCore/rendering/RenderLayerBacking.cpp (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r245829 r245837 1 2019-05-28 Simon Fraser <simon.fraser@apple.com> 2 3 Use scroll-velocity-based tile coverage for overflow:scroll 4 https://bugs.webkit.org/show_bug.cgi?id=198294 5 rdar://problem/48942184 6 7 Reviewed by Tim Horton. 8 9 * tiled-drawing/scrolling/overflow/overflow-scrolled-down-tile-coverage-expected.txt: Added. 10 * tiled-drawing/scrolling/overflow/overflow-scrolled-down-tile-coverage.html: Added. 11 * tiled-drawing/scrolling/overflow/overflow-scrolled-up-tile-coverage-expected.txt: Added. 12 * tiled-drawing/scrolling/overflow/overflow-scrolled-up-tile-coverage.html: Added. 13 * tiled-drawing/scrolling/overflow/overflow-tile-coverage-expected.txt: Added. 14 * tiled-drawing/scrolling/overflow/overflow-tile-coverage.html: Added. 15 1 16 2019-05-28 Youenn Fablet <youenn@apple.com> 2 17 -
trunk/Source/WebCore/ChangeLog
r245825 r245837 1 2019-05-28 Simon Fraser <simon.fraser@apple.com> 2 3 Use scroll-velocity-based tile coverage for overflow:scroll 4 https://bugs.webkit.org/show_bug.cgi?id=198294 5 rdar://problem/48942184 6 7 Reviewed by Tim Horton. 8 9 Start using a velocity-based tile coverage computation on layers with Type::ScrolledContents, 10 which is the content layers for overflow:scroll when they get big enough to get tiled. 11 12 Move legacy macOS coverage code into adjustTileCoverageForDesktopPageScrolling() because 13 I don't want to change its behavior in this patch. Use TileController::adjustTileCoverageRectForScrolling() 14 for iOS and macOS overflow scrolling. Since only iOS page scrolling gets velocity data from the UI 15 process, compute velocity in TileController using the visible rect top-left. 16 17 For overflow scroll, we have to plumb horizontal and vertical coverage in from 18 RenderLayerBacking. 19 20 Tests: tiled-drawing/scrolling/overflow/overflow-scrolled-down-tile-coverage.html 21 tiled-drawing/scrolling/overflow/overflow-scrolled-up-tile-coverage.html 22 tiled-drawing/scrolling/overflow/overflow-tile-coverage.html 23 24 * platform/graphics/TiledBacking.h: 25 * platform/graphics/ca/GraphicsLayerCA.cpp: 26 (WebCore::GraphicsLayerCA::adjustCoverageRect const): 27 * platform/graphics/ca/PlatformCALayer.h: 28 * platform/graphics/ca/TileController.cpp: 29 (WebCore::TileController::setVelocity): 30 (WebCore::TileController::adjustTileCoverageRect): 31 (WebCore::TileController::adjustTileCoverageForDesktopPageScrolling const): 32 (WebCore::TileController::adjustTileCoverageWithScrollingVelocity const): 33 (WebCore::TileController::adjustTileCoverageRectForScrolling): 34 (WebCore::expandRectWithinRect): Deleted. 35 (WebCore::TileController::adjustTileCoverageRect const): Deleted. 36 (WebCore::TileController::adjustTileCoverageRectForScrolling const): Deleted. 37 * platform/graphics/ca/TileController.h: 38 * rendering/RenderLayer.h: 39 * rendering/RenderLayerBacking.cpp: 40 (WebCore::computePageTiledBackingCoverage): 41 (WebCore::computeOverflowTiledBackingCoverage): 42 (WebCore::RenderLayerBacking::adjustTiledBackingCoverage): 43 (WebCore::RenderLayerBacking::updateGeometry): 44 1 45 2019-05-28 Shawn Roberts <sroberts@apple.com> 2 46 -
trunk/Source/WebCore/platform/graphics/TiledBacking.h
r245794 r245837 96 96 virtual TileCoverage tileCoverage() const = 0; 97 97 98 virtual FloatRect adjustTileCoverageRect(const FloatRect& coverageRect, const FloatRect& previousVisibleRect, const FloatRect& currentVisibleRect, bool sizeChanged) const= 0;99 virtual FloatRect adjustTileCoverageRectForScrolling(const FloatRect& coverageRect, const FloatSize& newSize, const FloatRect& previousVisibleRect, const FloatRect& currentVisibleRect, float contentsScale) const= 0;98 virtual FloatRect adjustTileCoverageRect(const FloatRect& coverageRect, const FloatRect& previousVisibleRect, const FloatRect& currentVisibleRect, bool sizeChanged) = 0; 99 virtual FloatRect adjustTileCoverageRectForScrolling(const FloatRect& coverageRect, const FloatSize& newSize, const FloatRect& previousVisibleRect, const FloatRect& currentVisibleRect, float contentsScale) = 0; 100 100 101 101 virtual void willStartLiveResize() = 0; -
trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp
r245794 r245837 1448 1448 coverageRect = tiledBacking()->adjustTileCoverageRectForScrolling(coverageRect, size(), oldVisibleRect, rects.visibleRect, pageScaleFactor() * deviceScaleFactor()); 1449 1449 break; 1450 case Type::ScrolledContents: 1451 if (m_layer->usesTiledBackingLayer()) 1452 coverageRect = tiledBacking()->adjustTileCoverageRectForScrolling(coverageRect, size(), oldVisibleRect, rects.visibleRect, pageScaleFactor() * deviceScaleFactor()); 1453 break; 1450 1454 case Type::Normal: 1451 case Type::ScrolledContents: 1452 if (m_layer->layerType() == PlatformCALayer::LayerTypeTiledBackingLayer) 1455 if (m_layer->usesTiledBackingLayer()) 1453 1456 coverageRect = tiledBacking()->adjustTileCoverageRect(coverageRect, oldVisibleRect, rects.visibleRect, size() != m_sizeAtLastCoverageRectUpdate); 1454 1457 break; -
trunk/Source/WebCore/platform/graphics/ca/PlatformCALayer.h
r243962 r245837 100 100 bool usesTiledBackingLayer() const { return layerType() == LayerTypePageTiledBackingLayer || layerType() == LayerTypeTiledBackingLayer; } 101 101 102 bool isPageTiledBackingLayer() const { return layerType() == LayerTypePageTiledBackingLayer; } 103 102 104 PlatformCALayerClient* owner() const { return m_owner; } 103 105 virtual void setOwner(PlatformCALayerClient* owner) { m_owner = owner; } -
trunk/Source/WebCore/platform/graphics/ca/TileController.cpp
r245794 r245837 241 241 { 242 242 bool changeAffectsTileCoverage = m_velocity.velocityOrScaleIsChanging() || velocity.velocityOrScaleIsChanging(); 243 243 244 m_velocity = velocity; 244 245 m_haveExternalVelocityData = true; 246 245 247 if (changeAffectsTileCoverage) 246 248 setNeedsRevalidateTiles(); … … 361 363 } 362 364 363 #if !PLATFORM(IOS_FAMILY) 364 // Return 'rect' padded evenly on all sides to achieve 'newSize', but make the padding uneven to contain within constrainingRect. 365 static FloatRect expandRectWithinRect(const FloatRect& rect, const FloatSize& newSize, const FloatRect& constrainingRect) 366 { 367 ASSERT(newSize.width() >= rect.width() && newSize.height() >= rect.height()); 368 369 FloatSize extraSize = newSize - rect.size(); 370 371 FloatRect expandedRect = rect; 372 expandedRect.inflateX(extraSize.width() / 2); 373 expandedRect.inflateY(extraSize.height() / 2); 374 375 if (expandedRect.x() < constrainingRect.x()) 376 expandedRect.setX(constrainingRect.x()); 377 else if (expandedRect.maxX() > constrainingRect.maxX()) 378 expandedRect.setX(constrainingRect.maxX() - expandedRect.width()); 379 380 if (expandedRect.y() < constrainingRect.y()) 381 expandedRect.setY(constrainingRect.y()); 382 else if (expandedRect.maxY() > constrainingRect.maxY()) 383 expandedRect.setY(constrainingRect.maxY() - expandedRect.height()); 384 385 return intersection(expandedRect, constrainingRect); 386 } 387 #endif 388 389 FloatRect TileController::adjustTileCoverageRect(const FloatRect& coverageRect, const FloatRect& previousVisibleRect, const FloatRect& currentVisibleRect, bool sizeChanged) const 365 FloatRect TileController::adjustTileCoverageRect(const FloatRect& coverageRect, const FloatRect& previousVisibleRect, const FloatRect& currentVisibleRect, bool sizeChanged) 390 366 { 391 367 // If the old visible rect is empty, we have no information about how the visible area is changing … … 450 426 } 451 427 452 FloatRect TileController::adjustTileCoverageRectForScrolling(const FloatRect& coverageRect, const FloatSize& newSize, const FloatRect& previousVisibleRect, const FloatRect& visibleRect, float contentsScale) const 453 { 454 // 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. 455 if (!m_isInWindow) 456 return visibleRect; 457 458 #if PLATFORM(IOS_FAMILY) 459 // FIXME: unify the iOS and Mac code. 460 UNUSED_PARAM(previousVisibleRect); 461 428 #if !PLATFORM(IOS_FAMILY) 429 // Coverage expansion for less memory-constrained devices. 430 // Kept separate to preserve historical behavior; should be merged with adjustTileCoverageWithScrollingVelocity eventually. 431 FloatRect TileController::adjustTileCoverageForDesktopPageScrolling(const FloatRect& coverageRect, const FloatSize& newSize, const FloatRect& previousVisibleRect, const FloatRect& visibleRect) const 432 { 433 // FIXME: look at how far the document can scroll in each dimension. 434 FloatSize coverageSize = visibleRect.size(); 435 436 bool largeVisibleRectChange = !previousVisibleRect.isEmpty() && !visibleRect.intersects(previousVisibleRect); 437 438 // Inflate the coverage rect so that it covers 2x of the visible width and 3x of the visible height. 439 // These values were chosen because it's more common to have tall pages and to scroll vertically, 440 // so we keep more tiles above and below the current area. 441 float widthScale = 1; 442 float heightScale = 1; 443 444 if (m_tileCoverage & CoverageForHorizontalScrolling && !largeVisibleRectChange) 445 widthScale = 2; 446 447 if (m_tileCoverage & CoverageForVerticalScrolling && !largeVisibleRectChange) 448 heightScale = 3; 449 450 coverageSize.scale(widthScale, heightScale); 451 452 FloatRect coverageBounds = boundsForSize(newSize); 453 454 // Return 'rect' padded evenly on all sides to achieve 'newSize', but make the padding uneven to contain within constrainingRect. 455 auto expandRectWithinRect = [](const FloatRect& rect, const FloatSize& newSize, const FloatRect& constrainingRect) { 456 ASSERT(newSize.width() >= rect.width() && newSize.height() >= rect.height()); 457 458 FloatSize extraSize = newSize - rect.size(); 459 460 FloatRect expandedRect = rect; 461 expandedRect.inflateX(extraSize.width() / 2); 462 expandedRect.inflateY(extraSize.height() / 2); 463 464 if (expandedRect.x() < constrainingRect.x()) 465 expandedRect.setX(constrainingRect.x()); 466 else if (expandedRect.maxX() > constrainingRect.maxX()) 467 expandedRect.setX(constrainingRect.maxX() - expandedRect.width()); 468 469 if (expandedRect.y() < constrainingRect.y()) 470 expandedRect.setY(constrainingRect.y()); 471 else if (expandedRect.maxY() > constrainingRect.maxY()) 472 expandedRect.setY(constrainingRect.maxY() - expandedRect.height()); 473 474 return intersection(expandedRect, constrainingRect); 475 }; 476 477 FloatRect coverage = expandRectWithinRect(visibleRect, coverageSize, coverageBounds); 478 LOG_WITH_STREAM(Tiling, stream << "TileController::adjustTileCoverageForDesktopPageScrolling newSize=" << newSize << " mode " << m_tileCoverage << " expanded to " << coverageSize << " bounds with margin " << coverageBounds << " coverage " << coverage); 479 return unionRect(coverageRect, coverage); 480 } 481 #endif 482 483 FloatRect TileController::adjustTileCoverageWithScrollingVelocity(const FloatRect& coverageRect, const FloatSize& newSize, const FloatRect& visibleRect, float contentsScale) const 484 { 462 485 if (m_tileCoverage == CoverageForVisibleArea || MemoryPressureHandler::singleton().isUnderMemoryPressure()) 463 486 return visibleRect; … … 509 532 futureRect.setY(0); 510 533 511 LOG_WITH_STREAM(Tiling, stream << "TileController " << this << " computeTileCoverageRect- coverage " << coverageRect << " expanded to " << unionRect(coverageRect, futureRect) << " velocity " << m_velocity);534 LOG_WITH_STREAM(Tiling, stream << "TileController " << this << " adjustTileCoverageForScrolling - coverage " << coverageRect << " expanded to " << unionRect(coverageRect, futureRect) << " velocity " << m_velocity); 512 535 513 536 return unionRect(coverageRect, futureRect); 537 } 538 539 FloatRect TileController::adjustTileCoverageRectForScrolling(const FloatRect& coverageRect, const FloatSize& newSize, const FloatRect& previousVisibleRect, const FloatRect& visibleRect, float contentsScale) 540 { 541 // 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. 542 if (!m_isInWindow) 543 return visibleRect; 544 545 #if !PLATFORM(IOS_FAMILY) 546 if (m_tileCacheLayer->isPageTiledBackingLayer()) 547 return adjustTileCoverageForDesktopPageScrolling(coverageRect, newSize, previousVisibleRect, visibleRect); 514 548 #else 515 UNUSED_PARAM(contentsScale); 516 517 // FIXME: look at how far the document can scroll in each dimension. 518 FloatSize coverageSize = visibleRect.size(); 519 520 bool largeVisibleRectChange = !previousVisibleRect.isEmpty() && !visibleRect.intersects(previousVisibleRect); 521 522 // Inflate the coverage rect so that it covers 2x of the visible width and 3x of the visible height. 523 // These values were chosen because it's more common to have tall pages and to scroll vertically, 524 // so we keep more tiles above and below the current area. 525 float widthScale = 1; 526 float heightScale = 1; 527 528 if (m_tileCoverage & CoverageForHorizontalScrolling && !largeVisibleRectChange) 529 widthScale = 2; 530 531 if (m_tileCoverage & CoverageForVerticalScrolling && !largeVisibleRectChange) 532 heightScale = 3; 549 UNUSED_PARAM(previousVisibleRect); 550 #endif 551 552 auto computeVelocityIfNecessary = [&](FloatPoint scrollOffset) { 553 if (m_haveExternalVelocityData) 554 return; 555 556 if (!m_historicalVelocityData) 557 m_historicalVelocityData = std::make_unique<HistoricalVelocityData>(); 558 559 m_velocity = m_historicalVelocityData->velocityForNewData(scrollOffset, contentsScale, MonotonicTime::now()); 560 }; 533 561 534 coverageSize.scale(widthScale, heightScale); 535 536 FloatRect coverageBounds = boundsForSize(newSize); 537 538 FloatRect coverage = expandRectWithinRect(visibleRect, coverageSize, coverageBounds); 539 LOG_WITH_STREAM(Tiling, stream << "TileController::computeTileCoverageRect newSize=" << newSize << " mode " << m_tileCoverage << " expanded to " << coverageSize << " bounds with margin " << coverageBounds << " coverage " << coverage); 540 return unionRect(coverageRect, coverage); 541 #endif 562 computeVelocityIfNecessary(visibleRect.location()); 563 564 return adjustTileCoverageWithScrollingVelocity(coverageRect, newSize, visibleRect, contentsScale); 542 565 } 543 566 -
trunk/Source/WebCore/platform/graphics/ca/TileController.h
r245794 r245837 123 123 TileCoverage tileCoverage() const final { return m_tileCoverage; } 124 124 125 FloatRect adjustTileCoverageRect(const FloatRect& coverageRect, const FloatRect& previousVisibleRect, const FloatRect& currentVisibleRect, bool sizeChanged) constfinal;126 FloatRect adjustTileCoverageRectForScrolling(const FloatRect& coverageRect, const FloatSize& newSize, const FloatRect& previousVisibleRect, const FloatRect& currentVisibleRect, float contentsScale) constfinal;125 FloatRect adjustTileCoverageRect(const FloatRect& coverageRect, const FloatRect& previousVisibleRect, const FloatRect& currentVisibleRect, bool sizeChanged) final; 126 FloatRect adjustTileCoverageRectForScrolling(const FloatRect& coverageRect, const FloatSize& newSize, const FloatRect& previousVisibleRect, const FloatRect& currentVisibleRect, float contentsScale) final; 127 127 128 128 bool scrollingPerformanceLoggingEnabled() const final { return m_scrollingPerformanceLoggingEnabled; } … … 191 191 void notePendingTileSizeChange(); 192 192 void tileSizeChangeTimerFired(); 193 193 194 #if !PLATFORM(IOS_FAMILY) 195 FloatRect adjustTileCoverageForDesktopPageScrolling(const FloatRect& coverageRect, const FloatSize& newSize, const FloatRect& previousVisibleRect, const FloatRect& visibleRect) const; 196 #endif 197 198 FloatRect adjustTileCoverageWithScrollingVelocity(const FloatRect& coverageRect, const FloatSize& newSize, const FloatRect& visibleRect, float contentsScale) const; 199 194 200 IntRect boundsForSize(const FloatSize&) const; 195 201 … … 205 211 std::unique_ptr<TileGrid> m_tileGrid; 206 212 std::unique_ptr<TileGrid> m_zoomedOutTileGrid; 213 214 std::unique_ptr<HistoricalVelocityData> m_historicalVelocityData; // Used when we track velocity internally. 207 215 208 216 FloatRect m_visibleRect; // Only used for scroll performance logging. … … 215 223 216 224 TileCoverage m_tileCoverage { CoverageForVisibleArea }; 217 225 218 226 VelocityData m_velocity; 219 227 … … 237 245 bool m_inLiveResize { false }; 238 246 bool m_tileSizeLocked { false }; 247 bool m_haveExternalVelocityData { false }; 239 248 bool m_isTileSizeUpdateDelayDisabledForTesting { false }; 240 249 -
trunk/Source/WebCore/rendering/RenderLayer.h
r245490 r245837 451 451 452 452 bool scrollsOverflow() const; 453 bool hasScrollableHorizontalOverflow() const; 454 bool hasScrollableVerticalOverflow() const; 453 455 bool hasScrollbars() const { return m_hBar || m_vBar; } 454 456 void setHasHorizontalScrollbar(bool); … … 1067 1069 bool hasHorizontalOverflow() const; 1068 1070 bool hasVerticalOverflow() const; 1069 bool hasScrollableHorizontalOverflow() const;1070 bool hasScrollableVerticalOverflow() const;1071 1071 1072 1072 bool showsOverflowControls() const; -
trunk/Source/WebCore/rendering/RenderLayerBacking.cpp
r245786 r245837 356 356 } 357 357 358 static TiledBacking::TileCoverage computePageTiledBackingCoverage(RenderLayerBacking* backing) 359 { 360 // FIXME: When we use TiledBacking for overflow, this should look at RenderView scrollability. 361 auto& frameView = backing->owningLayer().renderer().view().frameView(); 362 358 static TiledBacking::TileCoverage computePageTiledBackingCoverage(const RenderLayer& layer) 359 { 363 360 // If the page is non-visible, don't incur the cost of keeping extra tiles for scrolling. 364 if (! backing->owningLayer().page().isVisible())361 if (!layer.page().isVisible()) 365 362 return TiledBacking::CoverageForVisibleArea; 363 364 auto& frameView = layer.renderer().view().frameView(); 366 365 367 366 TiledBacking::TileCoverage tileCoverage = TiledBacking::CoverageForVisibleArea; … … 378 377 } 379 378 379 static TiledBacking::TileCoverage computeOverflowTiledBackingCoverage(const RenderLayer& layer) 380 { 381 // If the page is non-visible, don't incur the cost of keeping extra tiles for scrolling. 382 if (!layer.page().isVisible()) 383 return TiledBacking::CoverageForVisibleArea; 384 385 auto& frameView = layer.renderer().view().frameView(); 386 387 TiledBacking::TileCoverage tileCoverage = TiledBacking::CoverageForVisibleArea; 388 bool useMinimalTilesDuringLiveResize = frameView.inLiveResize(); 389 if (!useMinimalTilesDuringLiveResize) { 390 if (layer.hasScrollableHorizontalOverflow()) 391 tileCoverage |= TiledBacking::CoverageForHorizontalScrolling; 392 393 if (layer.hasScrollableVerticalOverflow()) 394 tileCoverage |= TiledBacking::CoverageForVerticalScrolling; 395 } 396 return tileCoverage; 397 } 398 380 399 void RenderLayerBacking::adjustTiledBackingCoverage() 381 400 { 382 if (!m_isFrameLayerWithTiledBacking) 383 return; 384 385 TiledBacking::TileCoverage tileCoverage = computePageTiledBackingCoverage(this); 386 tiledBacking()->setTileCoverage(tileCoverage); 401 if (m_isFrameLayerWithTiledBacking) { 402 auto tileCoverage = computePageTiledBackingCoverage(m_owningLayer); 403 tiledBacking()->setTileCoverage(tileCoverage); 404 } 405 406 if (m_owningLayer.hasCompositedScrollableOverflow() && m_scrolledContentsLayer) { 407 if (auto* tiledBacking = m_scrolledContentsLayer->tiledBacking()) { 408 auto tileCoverage = computeOverflowTiledBackingCoverage(m_owningLayer); 409 tiledBacking->setTileCoverage(tileCoverage); 410 } 411 } 387 412 } 388 413 … … 1259 1284 m_foregroundLayer->setOffsetFromRenderer(m_scrolledContentsLayer->offsetFromRenderer() - toLayoutSize(m_scrolledContentsLayer->scrollOffset())); 1260 1285 } 1286 1287 adjustTiledBackingCoverage(); 1261 1288 } 1262 1289
Note:
See TracChangeset
for help on using the changeset viewer.