Changeset 194607 in webkit
- Timestamp:
- Jan 5, 2016, 2:09:20 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r194605 r194607 1 2016-01-05 Simon Fraser <simon.fraser@apple.com> 2 3 Adjust tile coverage with margin tiles, and tidy up the indicator 4 https://bugs.webkit.org/show_bug.cgi?id=152742 5 6 Reviewed by Beth Dakin. 7 8 New baselines. simple-document-with-margin-tiles.html needs to wait for over 0.5s 9 for the FrameView::enableSpeculativeTilingIfNeeded() timer to fire before 10 dumping coverage (ouch). 11 12 * tiled-drawing/scrolling/fast-scroll-iframe-latched-iframe-expected.txt: 13 * tiled-drawing/scrolling/fast-scroll-iframe-latched-iframe-with-handler-expected.txt: 14 * tiled-drawing/scrolling/fast-scroll-iframe-latched-mainframe-expected.txt: 15 * tiled-drawing/scrolling/fast-scroll-iframe-latched-mainframe-with-handler-expected.txt: 16 * tiled-drawing/simple-document-with-margin-tiles.html: 17 1 18 2016-01-05 Brady Eidson <beidson@apple.com> 2 19 -
trunk/LayoutTests/tiled-drawing/scrolling/fast-scroll-iframe-latched-iframe-expected.txt
r187905 r194607 22 22 (contentsOpaque 1) 23 23 (visible rect 0.00, 0.00 785.00 x 600.00) 24 (coverage rect 0.00, 0.00 1570.00 x 1800.00)24 (coverage rect 0.00, 0.00 785.00 x 1800.00) 25 25 (intersects coverage rect 1) 26 26 (contentsScale 1.00) -
trunk/LayoutTests/tiled-drawing/scrolling/fast-scroll-iframe-latched-iframe-with-handler-expected.txt
r187905 r194607 22 22 (contentsOpaque 1) 23 23 (visible rect 0.00, 0.00 785.00 x 600.00) 24 (coverage rect 0.00, 0.00 1570.00 x 1800.00)24 (coverage rect 0.00, 0.00 785.00 x 1800.00) 25 25 (intersects coverage rect 1) 26 26 (contentsScale 1.00) -
trunk/LayoutTests/tiled-drawing/scrolling/fast-scroll-iframe-latched-mainframe-expected.txt
r187905 r194607 22 22 (contentsOpaque 1) 23 23 (visible rect 0.00, 70.00 785.00 x 600.00) 24 (coverage rect 0.00, 0.00 1570.00 x 1800.00)24 (coverage rect 0.00, 0.00 785.00 x 1800.00) 25 25 (intersects coverage rect 1) 26 26 (contentsScale 1.00) -
trunk/LayoutTests/tiled-drawing/scrolling/fast-scroll-iframe-latched-mainframe-with-handler-expected.txt
r187905 r194607 22 22 (contentsOpaque 1) 23 23 (visible rect 0.00, 70.00 785.00 x 600.00) 24 (coverage rect 0.00, 0.00 1570.00 x 1800.00)24 (coverage rect 0.00, 0.00 785.00 x 1800.00) 25 25 (intersects coverage rect 1) 26 26 (contentsScale 1.00) -
trunk/LayoutTests/tiled-drawing/simple-document-with-margin-tiles-expected.txt
r187905 r194607 11 11 (contentsOpaque 1) 12 12 (visible rect 0.00, 0.00 785.00 x 585.00) 13 (coverage rect - 512.00, -512.00 1809.00 x 1609.00)13 (coverage rect -392.50, -512.00 1570.00 x 1755.00) 14 14 (intersects coverage rect 1) 15 15 (contentsScale 1.00) -
trunk/LayoutTests/tiled-drawing/simple-document-with-margin-tiles.html
r187905 r194607 14 14 </style> 15 15 <script> 16 if (window.testRunner) 16 if (window.testRunner) { 17 17 testRunner.dumpAsText(); 18 testRunner.waitUntilDone(); 19 } 18 20 19 21 function doTest() 20 22 { 21 if (window.internals) {23 if (window.internals) 22 24 window.internals.settings.setBackgroundShouldExtendBeyondPage(true); 23 document.getElementById('layers').innerText = internals.layerTreeAsText(document, 24 internals.LAYER_TREE_INCLUDES_VISIBLE_RECTS | internals.LAYER_TREE_INCLUDES_TILE_CACHES); 25 } 25 26 // FrameView::enableSpeculativeTilingIfNeeded() uses a 0.5s timer to enable speculative tiling. 27 window.setTimeout(function() { 28 if (window.internals) { 29 document.getElementById('layers').innerText = internals.layerTreeAsText(document, 30 internals.LAYER_TREE_INCLUDES_VISIBLE_RECTS | internals.LAYER_TREE_INCLUDES_TILE_CACHES); 31 } 32 33 if (window.testRunner) 34 testRunner.notifyDone(); 35 }, 550); 26 36 } 27 37 window.addEventListener('load', doTest, false); -
trunk/Source/WebCore/ChangeLog
r194596 r194607 1 2016-01-05 Simon Fraser <simon.fraser@apple.com> 2 3 Adjust tile coverage with margin tiles, and tidy up the indicator 4 https://bugs.webkit.org/show_bug.cgi?id=152742 5 6 Reviewed by Beth Dakin. 7 8 The tile coverage rect was unfeasibly large when margin tiles are present, and 9 could be bigger than the layer itself, making the indicator look odd. 10 11 Fix by improving the logic in TileController::adjustTileCoverageRect(): this 12 now first extends the visible rect for scrolling, and then constrains it 13 within the bounds with margin padding. It also unites with the passed-in 14 coverageRect, ensuring that we don't lose information about overhang for 15 margin tile coverage. 16 17 Second, update the tiled scrolling indicator when the visible rect changes, 18 and coalesce the map updates on a timer. 19 20 * platform/graphics/TiledBacking.h: 21 * platform/graphics/ca/GraphicsLayerCA.cpp: 22 (WebCore::GraphicsLayerCA::adjustCoverageRect): 23 * platform/graphics/ca/TileController.cpp: 24 (WebCore::TileController::setVisibleRect): 25 (WebCore::TileController::setTiledScrollingIndicatorPosition): 26 (WebCore::expandRectWithinRect): 27 (WebCore::TileController::adjustTileCoverageRect): 28 (WebCore::TileController::updateTileCoverageMap): 29 (WebCore::TileController::computeTileCoverageRect): Deleted. 30 * platform/graphics/ca/TileController.h: 31 * platform/graphics/ca/TileCoverageMap.cpp: 32 (WebCore::TileCoverageMap::TileCoverageMap): 33 (WebCore::TileCoverageMap::setNeedsUpdate): 34 (WebCore::TileCoverageMap::updateTimerFired): 35 * platform/graphics/ca/TileCoverageMap.h: 36 1 37 2016-01-05 Antti Koivisto <antti@apple.com> 2 38 -
trunk/Source/WebCore/platform/graphics/TiledBacking.h
r190998 r194607 111 111 virtual TileCoverage tileCoverage() const = 0; 112 112 113 virtual FloatRect computeTileCoverageRect(const FloatSize& newSize, const FloatRect& previousVisibleRect, const FloatRect& currentVisibleRect, float contentsScale) const = 0;113 virtual void adjustTileCoverageRect(FloatRect& coverageRect, const FloatSize& newSize, const FloatRect& previousVisibleRect, const FloatRect& currentVisibleRect, float contentsScale) const = 0; 114 114 115 115 virtual IntSize tileSize() const = 0; -
trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp
r193382 r194607 33 33 #include "GraphicsLayerFactory.h" 34 34 #include "Image.h" 35 #include "Logging.h" 35 36 #include "PlatformCAFilters.h" 36 37 #include "PlatformCALayer.h" … … 1244 1245 switch (type()) { 1245 1246 case Type::PageTiledBacking: 1246 coverageRect = tiledBacking()->computeTileCoverageRect(size(), oldVisibleRect, rects.visibleRect, pageScaleFactor() * deviceScaleFactor());1247 tiledBacking()->adjustTileCoverageRect(coverageRect, size(), oldVisibleRect, rects.visibleRect, pageScaleFactor() * deviceScaleFactor()); 1247 1248 break; 1248 1249 case Type::Normal: -
trunk/Source/WebCore/platform/graphics/ca/TileController.cpp
r194496 r194607 28 28 29 29 #include "IntRect.h" 30 #include "Logging.h" 30 31 #include "PlatformCALayer.h" 31 32 #include "Region.h" 33 #include "TextStream.h" 32 34 #include "TileCoverageMap.h" 33 35 #include "TileGrid.h" … … 186 188 void TileController::setVisibleRect(const FloatRect& rect) 187 189 { 190 if (rect == m_visibleRect) 191 return; 192 188 193 m_visibleRect = rect; 194 updateTileCoverageMap(); 189 195 } 190 196 … … 226 232 if (!m_coverageMap) 227 233 return; 234 228 235 m_coverageMap->setPosition(position); 229 m_coverageMap->update();236 updateTileCoverageMap(); 230 237 } 231 238 … … 315 322 } 316 323 317 FloatRect TileController::computeTileCoverageRect(const FloatSize& newSize, const FloatRect& previousVisibleRect, const FloatRect& visibleRect, float contentsScale) const 324 #if !PLATFORM(IOS) 325 // Return 'rect' padded evenly on all sides to achieve 'newSize', but make the padding uneven to contain within constrainingRect. 326 static FloatRect expandRectWithinRect(const FloatRect& rect, const FloatSize& newSize, const FloatRect& constrainingRect) 327 { 328 ASSERT(newSize.width() >= rect.width() && newSize.height() >= rect.height()); 329 330 FloatSize extraSize = newSize - rect.size(); 331 332 FloatRect expandedRect = rect; 333 expandedRect.inflateX(extraSize.width() / 2); 334 expandedRect.inflateY(extraSize.height() / 2); 335 336 if (expandedRect.x() < constrainingRect.x()) 337 expandedRect.setX(constrainingRect.x()); 338 else if (expandedRect.maxX() > constrainingRect.maxX()) 339 expandedRect.setX(constrainingRect.maxX() - expandedRect.width()); 340 341 if (expandedRect.y() < constrainingRect.y()) 342 expandedRect.setY(constrainingRect.y()); 343 else if (expandedRect.maxY() > constrainingRect.maxY()) 344 expandedRect.setY(constrainingRect.maxY() - expandedRect.height()); 345 346 return intersection(expandedRect, constrainingRect); 347 } 348 #endif 349 350 void TileController::adjustTileCoverageRect(FloatRect& coverageRect, const FloatSize& newSize, const FloatRect& previousVisibleRect, const FloatRect& visibleRect, float contentsScale) const 318 351 { 319 352 // 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. 320 if (!m_isInWindow) 321 return visibleRect; 353 if (!m_isInWindow) { 354 coverageRect = visibleRect; 355 return; 356 } 322 357 323 358 #if PLATFORM(IOS) … … 325 360 UNUSED_PARAM(previousVisibleRect); 326 361 327 if (m_tileCoverage == CoverageForVisibleArea || MemoryPressureHandler::singleton().isUnderMemoryPressure()) 328 return visibleRect; 362 if (m_tileCoverage == CoverageForVisibleArea || MemoryPressureHandler::singleton().isUnderMemoryPressure()) { 363 coverageRect = visibleRect; 364 return; 365 } 329 366 330 367 double horizontalMargin = tileSize().width() / contentsScale; … … 352 389 353 390 if (!m_velocity.horizontalVelocity && !m_velocity.verticalVelocity) { 354 if (m_velocity.scaleChangeRate > 0) 355 return visibleRect; 391 if (m_velocity.scaleChangeRate > 0) { 392 coverageRect = visibleRect; 393 return; 394 } 356 395 futureRect.setWidth(futureRect.width() + horizontalMargin); 357 396 futureRect.setHeight(futureRect.height() + verticalMargin); … … 372 411 futureRect.setY(0); 373 412 374 return futureRect; 413 coverageRect.unite(futureRect); 414 return; 375 415 #else 376 416 UNUSED_PARAM(contentsScale); 377 417 378 418 // FIXME: look at how far the document can scroll in each dimension. 379 float coverageHorizontalSize = visibleRect.width(); 380 float coverageVerticalSize = visibleRect.height(); 419 FloatSize coverageSize = visibleRect.size(); 381 420 382 421 bool largeVisibleRectChange = !previousVisibleRect.isEmpty() && !visibleRect.intersects(previousVisibleRect); … … 385 424 // These values were chosen because it's more common to have tall pages and to scroll vertically, 386 425 // so we keep more tiles above and below the current area. 426 float widthScale = 1; 427 float heightScale = 1; 387 428 388 429 if (m_tileCoverage & CoverageForHorizontalScrolling && !largeVisibleRectChange) 389 coverageHorizontalSize *= 2;430 widthScale = 2; 390 431 391 432 if (m_tileCoverage & CoverageForVerticalScrolling && !largeVisibleRectChange) 392 coverageVerticalSize *= 3; 393 394 coverageVerticalSize += topMarginHeight() + bottomMarginHeight(); 395 coverageHorizontalSize += leftMarginWidth() + rightMarginWidth(); 396 397 // Can't use m_tileCacheLayer->bounds() here, because the size of the underlying platform layer 398 // hasn't been updated for the current commit. 433 heightScale = 3; 434 435 coverageSize.scale(widthScale, heightScale); 436 399 437 FloatRect coverageBounds = boundsForSize(newSize); 400 float coverageLeft = visibleRect.x() - (coverageHorizontalSize - visibleRect.width()) / 2; 401 coverageLeft = std::min(coverageLeft, coverageBounds.maxX() - coverageHorizontalSize); 402 coverageLeft = std::max(coverageLeft, coverageBounds.x()); 403 404 float coverageTop = visibleRect.y() - (coverageVerticalSize - visibleRect.height()) / 2; 405 coverageTop = std::min(coverageTop, coverageBounds.maxY() - coverageVerticalSize); 406 coverageTop = std::max(coverageTop, coverageBounds.y()); 407 408 return FloatRect(coverageLeft, coverageTop, coverageHorizontalSize, coverageVerticalSize); 438 439 FloatRect coverage = expandRectWithinRect(visibleRect, coverageSize, coverageBounds); 440 LOG_WITH_STREAM(Scrolling, stream << "TileController::computeTileCoverageRect newSize=" << newSize << " mode " << m_tileCoverage << " expanded to " << coverageSize << " bounds with margin " << coverageBounds << " coverage " << coverage); 441 coverageRect.unite(coverage); 409 442 #endif 410 443 } … … 501 534 { 502 535 if (m_coverageMap) 503 m_coverageMap-> update();536 m_coverageMap->setNeedsUpdate(); 504 537 } 505 538 -
trunk/Source/WebCore/platform/graphics/ca/TileController.h
r190998 r194607 107 107 virtual int rightMarginWidth() const override; 108 108 virtual TileCoverage tileCoverage() const override { return m_tileCoverage; } 109 virtual FloatRect computeTileCoverageRect(const FloatSize& newSize, const FloatRect& previousVisibleRect, const FloatRect& currentVisibleRect, float contentsScale) const override;109 virtual void adjustTileCoverageRect(FloatRect& coverageRect, const FloatSize& newSize, const FloatRect& previousVisibleRect, const FloatRect& currentVisibleRect, float contentsScale) const override; 110 110 virtual bool unparentsOffscreenTiles() const override { return m_unparentsOffscreenTiles; } 111 111 virtual bool scrollingPerformanceLoggingEnabled() const override { return m_scrollingPerformanceLoggingEnabled; } -
trunk/Source/WebCore/platform/graphics/ca/TileCoverageMap.cpp
r190628 r194607 35 35 TileCoverageMap::TileCoverageMap(const TileController& controller) 36 36 : m_controller(controller) 37 , m_updateTimer(*this, &TileCoverageMap::updateTimerFired) 37 38 , m_layer(*controller.rootLayer().createCompatibleLayer(PlatformCALayer::LayerTypeSimpleLayer, this)) 38 39 , m_visibleRectIndicatorLayer(*controller.rootLayer().createCompatibleLayer(PlatformCALayer::LayerTypeLayer, nullptr)) … … 47 48 m_layer.get().setContentsScale(m_controller.deviceScaleFactor()); 48 49 50 m_visibleRectIndicatorLayer.get().setName("visible rect indicator"); 49 51 m_visibleRectIndicatorLayer.get().setBorderWidth(2); 50 52 m_visibleRectIndicatorLayer.get().setAnchorPoint(FloatPoint3D()); 51 53 m_visibleRectIndicatorLayer.get().setBorderColor(Color(255, 0, 0)); 52 54 55 m_coverageRectIndicatorLayer.get().setName("coverage indicator"); 53 56 m_coverageRectIndicatorLayer.get().setBorderWidth(2); 54 57 m_coverageRectIndicatorLayer.get().setAnchorPoint(FloatPoint3D()); … … 64 67 { 65 68 m_layer.get().setOwner(nullptr); 69 } 70 71 void TileCoverageMap::setNeedsUpdate() 72 { 73 if (!m_updateTimer.isActive()) 74 m_updateTimer.startOneShot(0); 75 } 76 77 void TileCoverageMap::updateTimerFired() 78 { 79 update(); 66 80 } 67 81 -
trunk/Source/WebCore/platform/graphics/ca/TileCoverageMap.h
r183354 r194607 31 31 #include "PlatformCALayer.h" 32 32 #include "PlatformCALayerClient.h" 33 #include "Timer.h" 33 34 #include <wtf/Noncopyable.h> 34 35 #include <wtf/RetainPtr.h> … … 54 55 void setDeviceScaleFactor(float); 55 56 57 void setNeedsUpdate(); 58 56 59 private: 57 60 // PlatformCALayerClient … … 62 65 virtual float platformCALayerDeviceScaleFactor() const override; 63 66 67 void updateTimerFired(); 68 64 69 const TileController& m_controller; 70 71 Timer m_updateTimer; 65 72 66 73 Ref<PlatformCALayer> m_layer;
Note:
See TracChangeset
for help on using the changeset viewer.