Changeset 138858 in webkit
- Timestamp:
- Jan 4, 2013 3:15:40 PM (11 years ago)
- Location:
- trunk/Source
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r138855 r138858 1 2013-01-04 Tim Horton <timothy_horton@apple.com> 2 3 [wk2] Remove non-visible tiles from the layer tree 4 https://bugs.webkit.org/show_bug.cgi?id=106061 5 <rdar://problem/12761821> 6 7 Reviewed by Simon Fraser. 8 9 Unparenting tiles which aren't currently on-screen can allow underlying 10 frameworks to manage the layer's backing stores more effectively than we can. 11 12 In addition, add a setting (AggressiveTileRetentionEnabled) which keeps more 13 tiles around (we don't remove tiles in cohorts, nor when the TileCache moves 14 out of the window), which is off by default. 15 16 * WebCore.exp.in: Export Settings::setAggressiveTileRetentionEnabled. 17 * page/Settings.cpp: 18 (WebCore::Settings::Settings): Initialize m_aggressiveTileRetentionEnabled to false. 19 (WebCore::Settings::setAggressiveTileRetentionEnabled): Added. 20 * page/Settings.h: 21 (WebCore::Settings::aggressiveTileRetentionEnabled): Added. 22 * platform/graphics/TiledBacking.h: Add setter/getter to hand aggressivelyRetainsTiles through to TiledBackings. 23 * platform/graphics/ca/mac/TileCache.h: 24 (TileCache): Turn TileValidationPolicy into TileValidationPolicyFlags, and add 25 a flag for unparenting all tiles. 26 Implement aggressivelyRetainsTiles setter/getter. 27 * platform/graphics/ca/mac/TileCache.mm: 28 (WebCore::TileCache::TileCache): Initialize m_aggressivelyRetainsTiles to false. 29 (WebCore::TileCache::setIsInWindow): Revalidate tiles immediately if the TileCache has just entered the window. 30 (WebCore::TileCache::tileRevalidationTimerFired): 31 This is called if coverage rect, tile cache layer bounds, or visibility changes. We will revalidate tiles: 32 - Removing all tiles from the layer tree for background tile caches. 33 - Not pruning old tiles if the aggressiveTileRetentionEnabled setting is on. 34 (WebCore::TileCache::revalidateTiles): 35 Adopt TileValidationPolicyFlags instead of the old enum, and use separate flags for foreground/background caches. 36 Unparent tiles when they move out of the tile coverage rect. 37 Only schedule the tile cohort removal timer if we're not aggressively keeping tiles around. 38 Ensure that tiles are re-added to the TileCache layer tree if they already exist. 39 Unparent all tiles if TileValidationPolicyFlags says to (from tileRevalidationTimerFired's background flags). 40 Only add new tiles to the TileCache's layer tree if we're currently in the window. 41 Don't prune secondary tiles if the visible rect changes; this will already occur because when the visibleRect 42 changes, we arrive via tileRevalidationTimerFired, which asks for PruneSecondaryTiles anyway (except if we're 43 aggressively retaining tiles). This prevents tiles from being deleted unexpectedly during rubber-banding or when zoomed (this part of the patch is thanks to Simon). 44 (WebCore::TileCache::ensureTilesForRect): 45 Don't ensure any tiles if the TileCache is offscreen. 46 Ensure that tiles are re-added to the TileCache layer tree if they already exist. 47 (WebCore::TileCache::drawTileMapContents): 48 Draw a thick purple border around tiles that have been unparented. 49 1 50 2013-01-04 Adam Barth <abarth@webkit.org> 2 51 -
trunk/Source/WebCore/WebCore.exp.in
r138632 r138858 986 986 __ZN7WebCore8Settings32setNeedsAdobeFrameReloadingQuirkEb 987 987 __ZN7WebCore8Settings32setScreenFontSubstitutionEnabledEb 988 __ZN7WebCore8Settings33setAggressiveTileRetentionEnabledEb 988 989 __ZN7WebCore8Settings37setScrollingPerformanceLoggingEnabledEb 989 990 __ZN7WebCore8Settings45setShouldRespectPriorityInCSSAttributeSettersEb -
trunk/Source/WebCore/page/Settings.cpp
r137185 r138858 187 187 #endif 188 188 , m_scrollingPerformanceLoggingEnabled(false) 189 , m_aggressiveTileRetentionEnabled(false) 189 190 , m_setImageLoadingSettingsTimer(this, &Settings::imageLoadingSettingsTimerFired) 190 191 { … … 642 643 m_page->mainFrame()->view()->setScrollingPerformanceLoggingEnabled(enabled); 643 644 } 645 646 void Settings::setAggressiveTileRetentionEnabled(bool enabled) 647 { 648 m_aggressiveTileRetentionEnabled = enabled; 649 } 644 650 645 651 void Settings::setMockScrollbarsEnabled(bool flag) -
trunk/Source/WebCore/page/Settings.h
r137185 r138858 293 293 void setScrollingPerformanceLoggingEnabled(bool); 294 294 bool scrollingPerformanceLoggingEnabled() { return m_scrollingPerformanceLoggingEnabled; } 295 296 void setAggressiveTileRetentionEnabled(bool); 297 bool aggressiveTileRetentionEnabled() { return m_aggressiveTileRetentionEnabled; } 295 298 296 299 #if USE(JSC) … … 367 370 #endif 368 371 bool m_scrollingPerformanceLoggingEnabled : 1; 372 bool m_aggressiveTileRetentionEnabled : 1; 369 373 370 374 Timer<Settings> m_setImageLoadingSettingsTimer; -
trunk/Source/WebCore/platform/graphics/TiledBacking.h
r137387 r138858 71 71 virtual bool scrollingPerformanceLoggingEnabled() const = 0; 72 72 73 virtual void setAggressivelyRetainsTiles(bool) = 0; 74 virtual bool aggressivelyRetainsTiles() const = 0; 75 73 76 // Exposed for testing 74 77 virtual IntRect tileCoverageRect() const = 0; -
trunk/Source/WebCore/platform/graphics/ca/mac/TileCache.h
r137387 r138858 1 1 /* 2 * Copyright (C) 2011 Apple Inc. All rights reserved.2 * Copyright (C) 2011, 2012, 2013 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 116 116 virtual void setScrollingPerformanceLoggingEnabled(bool flag) OVERRIDE { m_scrollingPerformanceLoggingEnabled = flag; } 117 117 virtual bool scrollingPerformanceLoggingEnabled() const OVERRIDE { return m_scrollingPerformanceLoggingEnabled; } 118 virtual void setAggressivelyRetainsTiles(bool flag) OVERRIDE { m_aggressivelyRetainsTiles = flag; } 119 virtual bool aggressivelyRetainsTiles() const OVERRIDE { return m_aggressivelyRetainsTiles; } 118 120 virtual IntRect tileCoverageRect() const OVERRIDE; 119 121 virtual CALayer *tiledScrollingIndicatorLayer() OVERRIDE; … … 134 136 void cohortRemovalTimerFired(Timer<TileCache>*); 135 137 136 enum TileValidationPolicy { 137 KeepSecondaryTiles, 138 PruneSecondaryTiles 139 }; 140 void revalidateTiles(TileValidationPolicy = KeepSecondaryTiles); 138 typedef unsigned TileValidationPolicyFlags; 139 140 void revalidateTiles(TileValidationPolicyFlags foregroundValidationPolicy = 0, TileValidationPolicyFlags backgroundValidationPolicy = 0); 141 141 void ensureTilesForRect(const IntRect&); 142 142 void updateTileCoverageMap(); … … 192 192 bool m_isInWindow; 193 193 bool m_scrollingPerformanceLoggingEnabled; 194 bool m_aggressivelyRetainsTiles; 194 195 bool m_acceleratesDrawing; 195 196 bool m_tilesAreOpaque; -
trunk/Source/WebCore/platform/graphics/ca/mac/TileCache.mm
r138177 r138858 1 1 /* 2 * Copyright (C) 2011 Apple Inc. All rights reserved.2 * Copyright (C) 2011, 2012, 2013 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 81 81 82 82 namespace WebCore { 83 84 enum TileValidationPolicyFlag { 85 PruneSecondaryTiles = 1 << 0, 86 UnparentAllTiles = 1 << 1 87 }; 83 88 84 89 static const int defaultTileCacheWidth = 512; … … 101 106 , m_isInWindow(false) 102 107 , m_scrollingPerformanceLoggingEnabled(false) 108 , m_aggressivelyRetainsTiles(false) 103 109 , m_acceleratesDrawing(false) 104 110 , m_tilesAreOpaque(false) … … 243 249 [m_tileContainerLayer.get() setTransform:CATransform3DMakeScale(1 / m_scale, 1 / m_scale, 1)]; 244 250 245 revalidateTiles(PruneSecondaryTiles );251 revalidateTiles(PruneSecondaryTiles, PruneSecondaryTiles); 246 252 247 253 for (TileMap::const_iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it) { … … 311 317 m_isInWindow = isInWindow; 312 318 313 if (!m_isInWindow) { 314 const double tileRevalidationTimeout = 4; 315 scheduleTileRevalidation(tileRevalidationTimeout); 316 } 319 const double tileRevalidationTimeout = 4; 320 scheduleTileRevalidation(m_isInWindow ? 0 : tileRevalidationTimeout); 317 321 } 318 322 … … 441 445 void TileCache::tileRevalidationTimerFired(Timer<TileCache>*) 442 446 { 443 revalidateTiles(PruneSecondaryTiles); 447 TileValidationPolicyFlags foregroundValidationPolicy = m_aggressivelyRetainsTiles ? 0 : PruneSecondaryTiles; 448 TileValidationPolicyFlags backgroundValidationPolicy = foregroundValidationPolicy | UnparentAllTiles; 449 450 revalidateTiles(foregroundValidationPolicy, backgroundValidationPolicy); 444 451 } 445 452 … … 532 539 } 533 540 534 void TileCache::revalidateTiles(TileValidationPolicy validationPolicy)541 void TileCache::revalidateTiles(TileValidationPolicyFlags foregroundValidationPolicy, TileValidationPolicyFlags backgroundValidationPolicy) 535 542 { 536 543 // If the underlying PlatformLayer has been destroyed, but the WebTileCacheLayer hasn't … … 542 549 if (m_visibleRect.isEmpty() || bounds().isEmpty()) 543 550 return; 544 545 // If the visible rect size changed, drop secondary tiles to avoid lots of repainting. 546 // FIXME: when scaled, this changes due to rounding. We should use FloatRects or something. 547 // Also changes on rubber banding. 548 if (m_visibleRectAtLastRevalidate.size() != m_visibleRect.size()) 549 validationPolicy = PruneSecondaryTiles; 551 552 TileValidationPolicyFlags validationPolicy = m_isInWindow ? foregroundValidationPolicy : backgroundValidationPolicy; 550 553 551 554 IntRect tileCoverageRect = computeTileCoverageRect(m_visibleRectAtLastRevalidate); … … 584 587 tileInfo.cohort = currCohort; 585 588 ++tilesInCohort; 589 [tileInfo.layer.get() removeFromSuperlayer]; 586 590 } 587 591 } … … 591 595 startedNewCohort(currCohort); 592 596 593 scheduleCohortRemoval(); 597 if (!m_aggressivelyRetainsTiles) 598 scheduleCohortRemoval(); 594 599 } 595 600 … … 602 607 // Ensure primary tile coverage tiles. 603 608 m_primaryTileCoverageRect = IntRect(); 604 609 605 610 for (int y = topLeft.y(); y <= bottomRight.y(); ++y) { 606 611 for (int x = topLeft.x(); x <= bottomRight.x(); ++x) { … … 613 618 if (!tileInfo.layer) { 614 619 tileInfo.layer = createTileLayer(tileRect); 615 [m_tileContainerLayer.get() addSublayer:tileInfo.layer.get()]; 620 if (m_isInWindow) 621 [m_tileContainerLayer.get() addSublayer:tileInfo.layer.get()]; 616 622 } else { 623 if (m_isInWindow && ![tileInfo.layer.get() superlayer]) 624 [m_tileContainerLayer.get() addSublayer:tileInfo.layer.get()]; 625 617 626 // We already have a layer for this tile. Ensure that its size is correct. 618 627 FloatSize tileLayerSize([tileInfo.layer.get() frame].size); … … 629 638 } 630 639 631 if (validationPolicy ==PruneSecondaryTiles) {640 if (validationPolicy & PruneSecondaryTiles) { 632 641 removeAllSecondaryTiles(); 633 642 m_cohortList.clear(); 634 643 } 644 645 if (validationPolicy & UnparentAllTiles) { 646 for (TileMap::iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it) 647 [it->value.layer.get() removeFromSuperlayer]; 648 } 635 649 636 650 if (m_tiledScrollingIndicatorLayer) … … 670 684 { 671 685 const double cohortRemovalTimerSeconds = 1; 672 686 673 687 // Start the timer, or reschedule the timer from now if it's already active. 674 688 if (!m_cohortRemovalTimer.isActive()) … … 685 699 double cohortLifeTimeSeconds = 2; 686 700 double timeThreshold = monotonicallyIncreasingTime() - cohortLifeTimeSeconds; 687 701 688 702 while (!m_cohortList.isEmpty() && m_cohortList.first().creationTime < timeThreshold) { 689 703 TileCohortInfo firstCohort = m_cohortList.takeFirst(); … … 697 711 void TileCache::ensureTilesForRect(const IntRect& rect) 698 712 { 713 if (!m_isInWindow) 714 return; 715 699 716 PlatformCALayer* platformLayer = PlatformCALayer::platformCALayer(m_tileCacheLayer); 700 717 if (!platformLayer) … … 726 743 [m_tileContainerLayer.get() addSublayer:tileInfo.layer.get()]; 727 744 } else { 745 if (![tileInfo.layer.get() superlayer]) 746 [m_tileContainerLayer.get() addSublayer:tileInfo.layer.get()]; 747 728 748 // We already have a layer for this tile. Ensure that its size is correct. 729 749 CGSize tileLayerSize = [tileInfo.layer.get() frame].size; … … 934 954 935 955 CGFloat scaleFactor = layerBounds.size.width / bounds().width(); 936 937 CGContextSetRGBStrokeColor(context, 0, 0, 0, 1);938 956 939 957 CGFloat contextScale = scaleFactor / scale(); 940 958 CGContextScaleCTM(context, contextScale, contextScale); 941 942 CGContextSetLineWidth(context, 0.5 / contextScale);943 959 944 960 for (TileMap::const_iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it) { 945 961 const TileInfo& tileInfo = it->value; 946 962 WebTileLayer* tileLayer = tileInfo.layer.get(); 947 963 948 964 CGFloat red = 1; 949 965 CGFloat green = 1; … … 954 970 blue = 0; 955 971 } 956 972 957 973 TileCohort newestCohort = newestTileCohort(); 958 974 TileCohort oldestCohort = oldestTileCohort(); 959 960 if ( tileInfo.cohort != VisibleTileCohort && newestCohort > oldestCohort) {975 976 if (!m_aggressivelyRetainsTiles && tileInfo.cohort != VisibleTileCohort && newestCohort > oldestCohort) { 961 977 float cohortProportion = static_cast<float>((newestCohort - tileInfo.cohort)) / (newestCohort - oldestCohort); 962 978 CGContextSetRGBFillColor(context, red, green, blue, 1 - cohortProportion); … … 964 980 CGContextSetRGBFillColor(context, red, green, blue, 1); 965 981 982 if ([tileLayer superlayer]) { 983 CGContextSetLineWidth(context, 0.5 / contextScale); 984 CGContextSetRGBStrokeColor(context, 0, 0, 0, 1); 985 } else { 986 CGContextSetLineWidth(context, 1 / contextScale); 987 CGContextSetRGBStrokeColor(context, 0.2, 0.1, 0.9, 1); 988 } 989 966 990 CGRect frame = [tileLayer frame]; 967 991 CGContextFillRect(context, frame); -
trunk/Source/WebKit2/ChangeLog
r138845 r138858 1 2013-01-04 Tim Horton <timothy_horton@apple.com> 2 3 [wk2] Remove non-visible tiles from the layer tree 4 https://bugs.webkit.org/show_bug.cgi?id=106061 5 <rdar://problem/12761821> 6 7 Reviewed by Simon Fraser. 8 9 Add a setting to enable aggressive retention of TileCache tiles. If enabled, 10 TileCache will generally try to keep around all tiles. This setting is off by default. 11 12 * Shared/WebPreferencesStore.h: 13 * UIProcess/API/C/WKPreferences.cpp: 14 (WKPreferencesSetAggressiveTileRetentionEnabled): 15 (WKPreferencesGetAggressiveTileRetentionEnabled): 16 * UIProcess/API/C/WKPreferencesPrivate.h: 17 * WebProcess/WebPage/WebPage.cpp: 18 (WebKit::WebPage::updatePreferences): 19 * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm: 20 (WebKit::TiledCoreAnimationDrawingArea::updatePreferences): Forward the setting to the TiledBacking. 21 1 22 2013-01-04 Sam Weinig <sam@webkit.org> 2 23 -
trunk/Source/WebKit2/Shared/WebPreferencesStore.h
r136594 r138858 143 143 macro(UsesEncodingDetector, usesEncodingDetector, Bool, bool, false) \ 144 144 macro(TextAutosizingEnabled, textAutosizingEnabled, Bool, bool, false) \ 145 macro(AggressiveTileRetentionEnabled, aggressiveTileRetentionEnabled, Bool, bool, false) \ 145 146 \ 146 147 -
trunk/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp
r136594 r138858 995 995 } 996 996 997 void WKPreferencesSetAggressiveTileRetentionEnabled(WKPreferencesRef preferencesRef, bool enabled) 998 { 999 toImpl(preferencesRef)->setAggressiveTileRetentionEnabled(enabled); 1000 } 1001 1002 bool WKPreferencesGetAggressiveTileRetentionEnabled(WKPreferencesRef preferencesRef) 1003 { 1004 return toImpl(preferencesRef)->aggressiveTileRetentionEnabled(); 1005 } -
trunk/Source/WebKit2/UIProcess/API/C/WKPreferencesPrivate.h
r136594 r138858 236 236 WK_EXPORT bool WKPreferencesGetPDFPluginEnabled(WKPreferencesRef preferences); 237 237 238 // Defaults to false 239 WK_EXPORT void WKPreferencesSetAggressiveTileRetentionEnabled(WKPreferencesRef preferences, bool enabled); 240 WK_EXPORT bool WKPreferencesGetAggressiveTileRetentionEnabled(WKPreferencesRef preferences); 241 238 242 WK_EXPORT void WKPreferencesResetTestRunnerOverrides(WKPreferencesRef preferencesRef); 239 243 -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp
r138791 r138858 2325 2325 settings->setShowRepaintCounter(store.getBoolValueForKey(WebPreferencesKey::compositingRepaintCountersVisibleKey())); 2326 2326 settings->setShowTiledScrollingIndicator(store.getBoolValueForKey(WebPreferencesKey::tiledScrollingIndicatorVisibleKey())); 2327 settings->setAggressiveTileRetentionEnabled(store.getBoolValueForKey(WebPreferencesKey::aggressiveTileRetentionEnabledKey())); 2327 2328 settings->setCSSCustomFilterEnabled(store.getBoolValueForKey(WebPreferencesKey::cssCustomFilterEnabledKey())); 2328 2329 RuntimeEnabledFeatures::setCSSRegionsEnabled(store.getBoolValueForKey(WebPreferencesKey::cssRegionsEnabledKey())); -
trunk/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm
r136594 r138858 210 210 ScrollingThread::dispatch(bind(&ScrollingTree::setScrollingPerformanceLoggingEnabled, m_webPage->corePage()->scrollingCoordinator()->scrollingTree(), scrollingPerformanceLoggingEnabled)); 211 211 212 if (TiledBacking* tiledBacking = mainFrameTiledBacking()) 213 tiledBacking->setAggressivelyRetainsTiles(m_webPage->corePage()->settings()->aggressiveTileRetentionEnabled()); 214 212 215 // Soon we want pages with fixed positioned elements to be able to be scrolled by the ScrollingCoordinator. 213 216 // As a part of that work, we have to composite fixed position elements, and we have to allow those … … 447 450 if (m_pageOverlayLayer) 448 451 [m_rootLayer.get() addSublayer:m_pageOverlayLayer->platformLayer()]; 452 453 if (TiledBacking* tiledBacking = mainFrameTiledBacking()) 454 tiledBacking->setAggressivelyRetainsTiles(m_webPage->corePage()->settings()->aggressiveTileRetentionEnabled()); 449 455 450 456 updateDebugInfoLayer(m_webPage->corePage()->settings()->showTiledScrollingIndicator());
Note: See TracChangeset
for help on using the changeset viewer.