Changeset 167041 in webkit
- Timestamp:
- Apr 9, 2014, 3:29:15 PM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r167040 r167041 1 2014-04-09 Antti Koivisto <antti@apple.com> 2 3 TileGrid should be PlatformCALayerClient instead of TileController 4 https://bugs.webkit.org/show_bug.cgi?id=131456 5 6 Reviewed by Tim Horton. 7 8 The client interface is for the tiles in the grid. 9 10 * platform/graphics/ca/mac/TileController.h: 11 * platform/graphics/ca/mac/TileController.mm: 12 (WebCore::TileController::setContentsScale): 13 (WebCore::TileController::createTileLayer): 14 (WebCore::TileController::platformCALayerPaintContents): Deleted. 15 (WebCore::TileController::platformCALayerDeviceScaleFactor): Deleted. 16 (WebCore::TileController::platformCALayerShowDebugBorders): Deleted. 17 (WebCore::TileController::platformCALayerShowRepaintCounter): Deleted. 18 (WebCore::TileController::platformCALayerIncrementRepaintCount): Deleted. 19 * platform/graphics/ca/mac/TileGrid.h: 20 21 Move repaint counter to TileGrid too. 22 23 * platform/graphics/ca/mac/TileGrid.mm: 24 (WebCore::TileGrid::removeTiles): 25 (WebCore::TileGrid::removeAllSecondaryTiles): 26 (WebCore::TileGrid::removeTilesInCohort): 27 28 Cleaned up tile removal. 29 30 (WebCore::TileGrid::revalidateTiles): 31 (WebCore::TileGrid::ensureTilesForRect): 32 (WebCore::TileGrid::platformCALayerPaintContents): 33 (WebCore::TileGrid::platformCALayerDeviceScaleFactor): 34 (WebCore::TileGrid::platformCALayerShowDebugBorders): 35 (WebCore::TileGrid::platformCALayerShowRepaintCounter): 36 (WebCore::TileGrid::platformCALayerContentsOpaque): 37 (WebCore::TileGrid::platformCALayerIncrementRepaintCount): 38 (WebCore::queueTileForRemoval): Deleted. 39 1 40 2014-04-09 Alexey Proskuryakov <ap@apple.com> 2 41 -
trunk/Source/WebCore/platform/graphics/ca/mac/TileController.h
r166997 r167041 49 49 typedef Vector<RetainPtr<PlatformLayer>> PlatformLayerList; 50 50 51 class TileController final : public TiledBacking, public PlatformCALayerClient { 52 WTF_MAKE_NONCOPYABLE(TileController); 53 51 class TileController final : public TiledBacking { 52 WTF_MAKE_NONCOPYABLE(TileController); WTF_MAKE_FAST_ALLOCATED; 54 53 public: 55 54 static PassOwnPtr<TileController> create(PlatformCALayer*); … … 105 104 virtual TileCoverage tileCoverage() const override { return m_tileCoverage; } 106 105 virtual bool unparentsOffscreenTiles() const override { return m_unparentsOffscreenTiles; } 106 virtual bool scrollingPerformanceLoggingEnabled() const override { return m_scrollingPerformanceLoggingEnabled; } 107 107 108 108 IntRect boundsWithoutMargin() const; … … 118 118 bool shouldTemporarilyRetainTileCohorts() const; 119 119 120 typedef HashMap<PlatformCALayer*, int> RepaintCountMap;121 RepaintCountMap& repaintCountMap() { return m_tileRepaintCounts; }122 123 120 void updateTileCoverageMap(); 124 121 125 RefPtr<PlatformCALayer> createTileLayer(const IntRect& );122 RefPtr<PlatformCALayer> createTileLayer(const IntRect&, TileGrid&); 126 123 127 124 const TileGrid& tileGrid() const { return *m_tileGrid; } … … 145 142 virtual IntRect tileGridExtent() const override; 146 143 virtual void setScrollingPerformanceLoggingEnabled(bool flag) override { m_scrollingPerformanceLoggingEnabled = flag; } 147 virtual bool scrollingPerformanceLoggingEnabled() const override { return m_scrollingPerformanceLoggingEnabled; }148 144 virtual void setUnparentsOffscreenTiles(bool flag) override { m_unparentsOffscreenTiles = flag; } 149 145 virtual double retainedTileBackingStoreMemory() const override; … … 152 148 virtual void setScrollingModeIndication(ScrollingModeIndication) override; 153 149 virtual void setTileMargins(int marginTop, int marginBottom, int marginLeft, int marginRight) override; 154 155 // PlatformCALayerClient156 virtual void platformCALayerPaintContents(PlatformCALayer*, GraphicsContext&, const FloatRect&) override;157 virtual bool platformCALayerShowDebugBorders() const override;158 virtual bool platformCALayerShowRepaintCounter(PlatformCALayer*) const override;159 virtual int platformCALayerIncrementRepaintCount(PlatformCALayer*) override;160 virtual bool platformCALayerContentsOpaque() const override { return m_tilesAreOpaque; }161 virtual bool platformCALayerDrawsContent() const override { return true; }162 virtual float platformCALayerDeviceScaleFactor() const override;163 150 164 151 void scheduleTileRevalidation(double interval); … … 181 168 182 169 Timer<TileController> m_tileRevalidationTimer; 183 184 RepaintCountMap m_tileRepaintCounts;185 170 186 171 float m_contentsScale; -
trunk/Source/WebCore/platform/graphics/ca/mac/TileController.mm
r166997 r167041 27 27 #import "TileController.h" 28 28 29 #import "GraphicsContext.h"30 29 #import "IntRect.h" 31 30 #import "PlatformCALayer.h" … … 36 35 #import "LayerPool.h" 37 36 #endif 38 #import "WebLayer.h"39 37 #import <wtf/MainThread.h> 40 38 #import <utility> … … 104 102 } 105 103 106 void TileController::platformCALayerPaintContents(PlatformCALayer* platformCALayer, GraphicsContext& context, const FloatRect&)107 {108 #if PLATFORM(IOS)109 if (pthread_main_np())110 WebThreadLock();111 #endif112 113 {114 GraphicsContextStateSaver stateSaver(context);115 116 FloatPoint3D layerOrigin = platformCALayer->position();117 context.translate(-layerOrigin.x(), -layerOrigin.y());118 context.scale(FloatSize(tileGrid().scale(), tileGrid().scale()));119 120 RepaintRectList dirtyRects = collectRectsToPaint(context.platformContext(), platformCALayer);121 drawLayerContents(context.platformContext(), m_tileCacheLayer, dirtyRects);122 }123 124 int repaintCount = platformCALayerIncrementRepaintCount(platformCALayer);125 if (owningGraphicsLayer()->platformCALayerShowRepaintCounter(0))126 drawRepaintIndicator(context.platformContext(), platformCALayer, repaintCount, cachedCGColor(m_tileDebugBorderColor, ColorSpaceDeviceRGB));127 128 if (scrollingPerformanceLoggingEnabled()) {129 FloatRect visiblePart(platformCALayer->position().x(), platformCALayer->position().y(), platformCALayer->bounds().size().width(), platformCALayer->bounds().size().height());130 visiblePart.intersect(visibleRect());131 132 if (repaintCount == 1 && !visiblePart.isEmpty())133 WTFLogAlways("SCROLLING: Filled visible fresh tile. Time: %f Unfilled Pixels: %u\n", WTF::monotonicallyIncreasingTime(), blankPixelCount());134 }135 }136 137 float TileController::platformCALayerDeviceScaleFactor() const138 {139 return owningGraphicsLayer()->platformCALayerDeviceScaleFactor();140 }141 142 bool TileController::platformCALayerShowDebugBorders() const143 {144 return owningGraphicsLayer()->platformCALayerShowDebugBorders();145 }146 147 bool TileController::platformCALayerShowRepaintCounter(PlatformCALayer*) const148 {149 return owningGraphicsLayer()->platformCALayerShowRepaintCounter(0);150 }151 152 104 void TileController::setContentsScale(float scale) 153 105 { … … 156 108 ASSERT(owningGraphicsLayer()->isCommittingChanges()); 157 109 158 float deviceScaleFactor = platformCALayerDeviceScaleFactor();110 float deviceScaleFactor = owningGraphicsLayer()->platformCALayerDeviceScaleFactor(); 159 111 160 112 // The scale we get is the product of the page scale factor and device scale factor. … … 479 431 } 480 432 481 RefPtr<PlatformCALayer> TileController::createTileLayer(const IntRect& tileRect )433 RefPtr<PlatformCALayer> TileController::createTileLayer(const IntRect& tileRect, TileGrid& grid) 482 434 { 483 435 #if PLATFORM(IOS) … … 487 439 #endif 488 440 489 if (layer) { 490 m_tileRepaintCounts.remove(layer.get()); 491 layer->setOwner(this); 492 } else 493 layer = m_tileCacheLayer->createCompatibleLayer(PlatformCALayer::LayerTypeTiledBackingTileLayer, this); 441 if (layer) 442 layer->setOwner(&grid); 443 else 444 layer = m_tileCacheLayer->createCompatibleLayer(PlatformCALayer::LayerTypeTiledBackingTileLayer, &grid); 494 445 495 446 layer->setAnchorPoint(FloatPoint3D()); … … 515 466 } 516 467 517 int TileController::platformCALayerIncrementRepaintCount(PlatformCALayer* platformCALayer)518 {519 int repaintCount = 0;520 521 if (m_tileRepaintCounts.contains(platformCALayer))522 repaintCount = m_tileRepaintCounts.get(platformCALayer);523 524 m_tileRepaintCounts.set(platformCALayer, ++repaintCount);525 526 return repaintCount;527 }528 529 468 Vector<RefPtr<PlatformCALayer>> TileController::containerLayers() 530 469 { -
trunk/Source/WebCore/platform/graphics/ca/mac/TileGrid.h
r166997 r167041 29 29 #include "IntPointHash.h" 30 30 #include "IntRect.h" 31 #include "PlatformCALayerClient.h" 31 32 #include "Timer.h" 32 33 #include <wtf/Deque.h> … … 37 38 namespace WebCore { 38 39 40 class GraphicsContext; 39 41 class PlatformCALayer; 40 42 class TileController; 41 43 42 class TileGrid {43 WTF_MAKE_NONCOPYABLE(TileGrid); 44 class TileGrid : public PlatformCALayerClient { 45 WTF_MAKE_NONCOPYABLE(TileGrid); WTF_MAKE_FAST_ALLOCATED; 44 46 public: 45 47 TileGrid(TileController&); … … 110 112 TileCohort oldestTileCohort() const; 111 113 114 void removeTiles(Vector<TileGrid::TileIndex>& toRemove); 115 116 // PlatformCALayerClient 117 virtual void platformCALayerPaintContents(PlatformCALayer*, GraphicsContext&, const FloatRect&) override; 118 virtual bool platformCALayerShowDebugBorders() const override; 119 virtual bool platformCALayerShowRepaintCounter(PlatformCALayer*) const override; 120 virtual int platformCALayerIncrementRepaintCount(PlatformCALayer*) override; 121 virtual bool platformCALayerContentsOpaque() const override; 122 virtual bool platformCALayerDrawsContent() const override { return true; } 123 virtual float platformCALayerDeviceScaleFactor() const override; 124 112 125 TileController& m_controller; 113 126 Ref<PlatformCALayer> m_containerLayer; … … 133 146 134 147 Timer<TileGrid> m_cohortRemovalTimer; 148 149 typedef HashMap<PlatformCALayer*, int> RepaintCountMap; 150 RepaintCountMap m_tileRepaintCounts; 135 151 }; 136 152 -
trunk/Source/WebCore/platform/graphics/ca/mac/TileGrid.mm
r166997 r167041 27 27 #import "TileGrid.h" 28 28 29 #import "GraphicsContext.h" 29 30 #import "LayerPool.h" 30 31 #import "PlatformCALayer.h" 31 32 #import "TileController.h" 33 #import "WebLayer.h" 32 34 #import <wtf/MainThread.h> 33 35 … … 281 283 } 282 284 283 static inline void queueTileForRemoval(const TileGrid::TileIndex& tileIndex, const TileGrid::TileInfo& tileInfo, Vector<TileGrid::TileIndex>& tilesToRemove, TileController::RepaintCountMap& repaintCounts) 284 { 285 tileInfo.layer->removeFromSuperlayer(); 286 repaintCounts.remove(tileInfo.layer.get()); 287 tilesToRemove.append(tileIndex); 288 } 289 290 void TileGrid::removeAllSecondaryTiles() 291 { 292 Vector<TileIndex> tilesToRemove; 293 294 for (TileMap::iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it) { 295 const TileInfo& tileInfo = it->value; 296 if (tileInfo.cohort == VisibleTileCohort) 297 continue; 298 299 queueTileForRemoval(it->key, it->value, tilesToRemove, m_controller.repaintCountMap()); 300 } 301 302 for (size_t i = 0; i < tilesToRemove.size(); ++i) { 303 TileInfo tileInfo = m_tiles.take(tilesToRemove[i]); 285 void TileGrid::removeTiles(Vector<TileGrid::TileIndex>& toRemove) 286 { 287 for (size_t i = 0; i < toRemove.size(); ++i) { 288 TileInfo tileInfo = m_tiles.take(toRemove[i]); 289 tileInfo.layer->removeFromSuperlayer(); 290 m_tileRepaintCounts.remove(tileInfo.layer.get()); 304 291 #if !PLATFORM(IOS) 305 292 LayerPool::sharedPool()->addLayer(tileInfo.layer); … … 308 295 } 309 296 297 void TileGrid::removeAllSecondaryTiles() 298 { 299 Vector<TileIndex> tilesToRemove; 300 301 for (auto& entry : m_tiles) { 302 const TileInfo& tileInfo = entry.value; 303 if (tileInfo.cohort == VisibleTileCohort) 304 continue; 305 tilesToRemove.append(entry.key); 306 } 307 308 removeTiles(tilesToRemove); 309 } 310 310 311 void TileGrid::removeTilesInCohort(TileCohort cohort) 311 312 { … … 313 314 Vector<TileIndex> tilesToRemove; 314 315 315 for ( TileMap::iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it) {316 const TileInfo& tileInfo = it->value;316 for (auto& entry : m_tiles) { 317 const TileInfo& tileInfo = entry.value; 317 318 if (tileInfo.cohort != cohort) 318 319 continue; 319 320 queueTileForRemoval(it->key, it->value, tilesToRemove, m_controller.repaintCountMap()); 321 } 322 323 for (size_t i = 0; i < tilesToRemove.size(); ++i) { 324 TileInfo tileInfo = m_tiles.take(tilesToRemove[i]); 325 #if !PLATFORM(IOS) 326 LayerPool::sharedPool()->addLayer(tileInfo.layer); 327 #endif 328 } 320 tilesToRemove.append(entry.key); 321 } 322 323 removeTiles(tilesToRemove); 329 324 } 330 325 … … 430 425 431 426 Vector<TileIndex> tilesToRemove; 432 for (TileMap::iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it) { 433 const TileIndex& index = it->key; 434 if (index.y() < topLeftForBounds.y() 435 || index.y() > bottomRightForBounds.y() 436 || index.x() < topLeftForBounds.x() 437 || index.x() > bottomRightForBounds.x()) 438 queueTileForRemoval(index, it->value, tilesToRemove, m_controller.repaintCountMap()); 427 for (auto& index : m_tiles.keys()) { 428 if (index.y() < topLeftForBounds.y() || index.y() > bottomRightForBounds.y() || index.x() < topLeftForBounds.x() || index.x() > bottomRightForBounds.x()) 429 tilesToRemove.append(index); 439 430 } 440 431 … … 533 524 bool shouldChangeTileLayerFrame = false; 534 525 535 if (!tileInfo.layer) 536 tileInfo.layer = m_controller.createTileLayer(tileRect); 537 else { 526 if (!tileInfo.layer) { 527 tileInfo.layer = m_controller.createTileLayer(tileRect, *this); 528 ASSERT(!m_tileRepaintCounts.contains(tileInfo.layer.get())); 529 } else { 538 530 // We already have a layer for this tile. Ensure that its size is correct. 539 531 FloatSize tileLayerSize(tileInfo.layer->bounds().size()); … … 645 637 } 646 638 639 void TileGrid::platformCALayerPaintContents(PlatformCALayer* platformCALayer, GraphicsContext& context, const FloatRect&) 640 { 641 #if PLATFORM(IOS) 642 if (pthread_main_np()) 643 WebThreadLock(); 644 #endif 645 646 { 647 GraphicsContextStateSaver stateSaver(context); 648 649 FloatPoint3D layerOrigin = platformCALayer->position(); 650 context.translate(-layerOrigin.x(), -layerOrigin.y()); 651 context.scale(FloatSize(m_scale, m_scale)); 652 653 RepaintRectList dirtyRects = collectRectsToPaint(context.platformContext(), platformCALayer); 654 drawLayerContents(context.platformContext(), &m_controller.rootLayer(), dirtyRects); 655 } 656 657 int repaintCount = platformCALayerIncrementRepaintCount(platformCALayer); 658 if (m_controller.rootLayer().owner()->platformCALayerShowRepaintCounter(0)) 659 drawRepaintIndicator(context.platformContext(), platformCALayer, repaintCount, cachedCGColor(m_controller.tileDebugBorderColor(), ColorSpaceDeviceRGB)); 660 661 if (m_controller.scrollingPerformanceLoggingEnabled()) { 662 FloatRect visiblePart(platformCALayer->position().x(), platformCALayer->position().y(), platformCALayer->bounds().size().width(), platformCALayer->bounds().size().height()); 663 visiblePart.intersect(m_controller.visibleRect()); 664 665 if (repaintCount == 1 && !visiblePart.isEmpty()) 666 WTFLogAlways("SCROLLING: Filled visible fresh tile. Time: %f Unfilled Pixels: %u\n", WTF::monotonicallyIncreasingTime(), blankPixelCount()); 667 } 668 } 669 670 float TileGrid::platformCALayerDeviceScaleFactor() const 671 { 672 return m_controller.rootLayer().owner()->platformCALayerDeviceScaleFactor(); 673 } 674 675 bool TileGrid::platformCALayerShowDebugBorders() const 676 { 677 return m_controller.rootLayer().owner()->platformCALayerShowDebugBorders(); 678 } 679 680 bool TileGrid::platformCALayerShowRepaintCounter(PlatformCALayer*) const 681 { 682 return m_controller.rootLayer().owner()->platformCALayerShowRepaintCounter(0); 683 } 684 685 bool TileGrid::platformCALayerContentsOpaque() const 686 { 687 return m_controller.tilesAreOpaque(); 688 } 689 690 int TileGrid::platformCALayerIncrementRepaintCount(PlatformCALayer* platformCALayer) 691 { 692 int repaintCount = 0; 693 694 if (m_tileRepaintCounts.contains(platformCALayer)) 695 repaintCount = m_tileRepaintCounts.get(platformCALayer); 696 697 m_tileRepaintCounts.set(platformCALayer, ++repaintCount); 698 699 return repaintCount; 700 } 701 647 702 #if PLATFORM(IOS) 648 703 void TileGrid::removeUnparentedTilesNow()
Note:
See TracChangeset
for help on using the changeset viewer.