Title: [154413] trunk/Source/WebCore
- Revision
- 154413
- Author
- [email protected]
- Date
- 2013-08-21 14:04:57 -0700 (Wed, 21 Aug 2013)
Log Message
revalidateTiles and ensureTilesForRect can share a lot of code
https://bugs.webkit.org/show_bug.cgi?id=119282
Reviewed by Simon Fraser.
No new tests, just a refactoring.
The bodies of ensureTilesForRect and revalidateTiles are nearly equivalent.
* platform/graphics/ca/mac/TileController.h:
Add an enum, NewTileType, to note whether the tiles created by ensureTilesForRect will
be primary coverage tiles or secondary out-of-view tiles.
* platform/graphics/ca/mac/TileController.mm:
(WebCore::TileController::prepopulateRect):
Move the code to see if we already have the requisite tiles in the
primary coverage rect, as well as our call to updateTileCoverageMap,
out into prepopulateRect, to generalize ensureTilesForRect.
(WebCore::TileController::revalidateTiles):
Make use of ensureTilesForRect. The platformCALayerDidCreateTiles call will happen there, now.
(WebCore::TileController::ensureTilesForRect):
Make ensureTilesForRect return the rect that it created tiles for, and only put
tiles in a cohort if we're creating secondary tiles.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (154412 => 154413)
--- trunk/Source/WebCore/ChangeLog 2013-08-21 21:03:49 UTC (rev 154412)
+++ trunk/Source/WebCore/ChangeLog 2013-08-21 21:04:57 UTC (rev 154413)
@@ -1,5 +1,33 @@
2013-08-21 Tim Horton <[email protected]>
+ revalidateTiles and ensureTilesForRect can share a lot of code
+ https://bugs.webkit.org/show_bug.cgi?id=119282
+
+ Reviewed by Simon Fraser.
+
+ No new tests, just a refactoring.
+
+ The bodies of ensureTilesForRect and revalidateTiles are nearly equivalent.
+
+ * platform/graphics/ca/mac/TileController.h:
+ Add an enum, NewTileType, to note whether the tiles created by ensureTilesForRect will
+ be primary coverage tiles or secondary out-of-view tiles.
+
+ * platform/graphics/ca/mac/TileController.mm:
+ (WebCore::TileController::prepopulateRect):
+ Move the code to see if we already have the requisite tiles in the
+ primary coverage rect, as well as our call to updateTileCoverageMap,
+ out into prepopulateRect, to generalize ensureTilesForRect.
+
+ (WebCore::TileController::revalidateTiles):
+ Make use of ensureTilesForRect. The platformCALayerDidCreateTiles call will happen there, now.
+
+ (WebCore::TileController::ensureTilesForRect):
+ Make ensureTilesForRect return the rect that it created tiles for, and only put
+ tiles in a cohort if we're creating secondary tiles.
+
+2013-08-21 Tim Horton <[email protected]>
+
isReplacementObscured is wrong when the indicator is clipped by an iframe
https://bugs.webkit.org/show_bug.cgi?id=120031
<rdar://problem/14606819>
Modified: trunk/Source/WebCore/platform/graphics/ca/mac/TileController.h (154412 => 154413)
--- trunk/Source/WebCore/platform/graphics/ca/mac/TileController.h 2013-08-21 21:03:49 UTC (rev 154412)
+++ trunk/Source/WebCore/platform/graphics/ca/mac/TileController.h 2013-08-21 21:04:57 UTC (rev 154413)
@@ -146,7 +146,8 @@
typedef unsigned TileValidationPolicyFlags;
void revalidateTiles(TileValidationPolicyFlags foregroundValidationPolicy = 0, TileValidationPolicyFlags backgroundValidationPolicy = 0);
- void ensureTilesForRect(const FloatRect&);
+ enum class NewTileType { PrimaryTiles, SecondaryTiles };
+ IntRect ensureTilesForRect(const FloatRect&, NewTileType);
void updateTileCoverageMap();
void removeAllTiles();
Modified: trunk/Source/WebCore/platform/graphics/ca/mac/TileController.mm (154412 => 154413)
--- trunk/Source/WebCore/platform/graphics/ca/mac/TileController.mm 2013-08-21 21:03:49 UTC (rev 154412)
+++ trunk/Source/WebCore/platform/graphics/ca/mac/TileController.mm 2013-08-21 21:04:57 UTC (rev 154413)
@@ -350,7 +350,17 @@
void TileController::prepopulateRect(const FloatRect& rect)
{
- ensureTilesForRect(rect);
+ FloatRect scaledRect(rect);
+ scaledRect.scale(m_scale);
+ IntRect rectInTileCoords(enclosingIntRect(scaledRect));
+
+ if (m_primaryTileCoverageRect.contains(rectInTileCoords))
+ return;
+
+ ensureTilesForRect(rect, NewTileType::SecondaryTiles);
+
+ if (m_tiledScrollingIndicatorLayer)
+ updateTileCoverageMap();
}
void TileController::setIsInWindow(bool isInWindow)
@@ -661,50 +671,10 @@
if (!m_aggressivelyRetainsTiles)
scheduleCohortRemoval();
}
-
- TileIndex topLeft;
- TileIndex bottomRight;
- getTileIndexRangeForRect(coverageRectInTileCoords, topLeft, bottomRight);
-
- Vector<FloatRect> dirtyRects;
// Ensure primary tile coverage tiles.
- m_primaryTileCoverageRect = IntRect();
+ m_primaryTileCoverageRect = ensureTilesForRect(tileCoverageRect, NewTileType::PrimaryTiles);
- for (int y = topLeft.y(); y <= bottomRight.y(); ++y) {
- for (int x = topLeft.x(); x <= bottomRight.x(); ++x) {
- TileIndex tileIndex(x, y);
-
- IntRect tileRect = rectForTileIndex(tileIndex);
- m_primaryTileCoverageRect.unite(tileRect);
-
- bool shouldChangeTileLayerFrame = false;
-
- TileInfo& tileInfo = m_tiles.add(tileIndex, TileInfo()).iterator->value;
- if (!tileInfo.layer)
- tileInfo.layer = createTileLayer(tileRect);
- else {
- // We already have a layer for this tile. Ensure that its size is correct.
- FloatSize tileLayerSize([tileInfo.layer.get() frame].size);
- shouldChangeTileLayerFrame = tileLayerSize != FloatSize(tileRect.size());
-
- if (shouldChangeTileLayerFrame)
- [tileInfo.layer.get() setFrame:tileRect];
- }
-
- bool shouldParentTileLayer = (!m_unparentsOffscreenTiles || m_isInWindow) && ![tileInfo.layer.get() superlayer];
-
- if (shouldParentTileLayer)
- [m_tileContainerLayer.get() addSublayer:tileInfo.layer.get()];
-
- if ((shouldParentTileLayer && [tileInfo.layer.get() needsDisplay]) || shouldChangeTileLayerFrame) {
- FloatRect scaledTileRect = tileRect;
- scaledTileRect.scale(1 / m_scale);
- dirtyRects.append(scaledTileRect);
- }
- }
- }
-
if (validationPolicy & PruneSecondaryTiles) {
removeAllSecondaryTiles();
m_cohortList.clear();
@@ -745,12 +715,6 @@
m_visibleRectAtLastRevalidate = visibleRect;
m_boundsAtLastRevalidate = bounds;
-
- if (dirtyRects.isEmpty())
- return;
-
- // This will ensure we flush compositing state and do layout in this run loop iteration.
- platformLayer->owner()->platformCALayerDidCreateTiles(dirtyRects);
}
TileController::TileCohort TileController::nextTileCohort() const
@@ -804,22 +768,19 @@
updateTileCoverageMap();
}
-void TileController::ensureTilesForRect(const FloatRect& rect)
+IntRect TileController::ensureTilesForRect(const FloatRect& rect, NewTileType newTileType)
{
if (m_unparentsOffscreenTiles && !m_isInWindow)
- return;
+ return IntRect();
PlatformCALayer* platformLayer = PlatformCALayer::platformCALayer(m_tileCacheLayer);
if (!platformLayer)
- return;
+ return IntRect();
FloatRect scaledRect(rect);
scaledRect.scale(m_scale);
IntRect rectInTileCoords(enclosingIntRect(scaledRect));
- if (m_primaryTileCoverageRect.contains(rectInTileCoords))
- return;
-
TileIndex topLeft;
TileIndex bottomRight;
getTileIndexRangeForRect(rectInTileCoords, topLeft, bottomRight);
@@ -828,6 +789,8 @@
TileCohort currCohort = nextTileCohort();
unsigned tilesInCohort = 0;
+ IntRect coverageRect;
+
for (int y = topLeft.y(); y <= bottomRight.y(); ++y) {
for (int x = topLeft.x(); x <= bottomRight.x(); ++x) {
TileIndex tileIndex(x, y);
@@ -835,25 +798,27 @@
IntRect tileRect = rectForTileIndex(tileIndex);
TileInfo& tileInfo = m_tiles.add(tileIndex, TileInfo()).iterator->value;
+ coverageRect.unite(tileRect);
+
bool shouldChangeTileLayerFrame = false;
if (!tileInfo.layer)
tileInfo.layer = createTileLayer(tileRect);
else {
// We already have a layer for this tile. Ensure that its size is correct.
- CGSize tileLayerSize = [tileInfo.layer.get() frame].size;
- shouldChangeTileLayerFrame = tileLayerSize.width < tileRect.width() || tileLayerSize.height < tileRect.height();
+ FloatSize tileLayerSize([tileInfo.layer.get() frame].size);
+ shouldChangeTileLayerFrame = tileLayerSize != FloatSize(tileRect.size());
if (shouldChangeTileLayerFrame)
[tileInfo.layer.get() setFrame:tileRect];
}
- if (!tileRect.intersects(m_primaryTileCoverageRect)) {
+ if (newTileType == NewTileType::SecondaryTiles && !tileRect.intersects(m_primaryTileCoverageRect)) {
tileInfo.cohort = currCohort;
++tilesInCohort;
}
- bool shouldParentTileLayer = ![tileInfo.layer.get() superlayer];
+ bool shouldParentTileLayer = (!m_unparentsOffscreenTiles || m_isInWindow) && ![tileInfo.layer.get() superlayer];
if (shouldParentTileLayer)
[m_tileContainerLayer.get() addSublayer:tileInfo.layer.get()];
@@ -869,12 +834,11 @@
if (tilesInCohort)
startedNewCohort(currCohort);
- if (m_tiledScrollingIndicatorLayer)
- updateTileCoverageMap();
-
// This will ensure we flush compositing state and do layout in this run loop iteration.
if (!dirtyRects.isEmpty())
platformLayer->owner()->platformCALayerDidCreateTiles(dirtyRects);
+
+ return coverageRect;
}
void TileController::updateTileCoverageMap()
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes