Created
February 29, 2012 15:38
-
-
Save kenchris/1941757 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/Source/WebCore/platform/graphics/TiledBackingStore.cpp b/Source/WebCore/platform/graphics/TiledBackingStore.cpp | |
index 8f7052c..4d0fdf9 100644 | |
--- a/Source/WebCore/platform/graphics/TiledBackingStore.cpp | |
+++ b/Source/WebCore/platform/graphics/TiledBackingStore.cpp | |
@@ -82,11 +82,11 @@ void TiledBackingStore::coverWithTilesIfNeeded(const FloatPoint& panningTrajecto | |
void TiledBackingStore::invalidate(const IntRect& contentsDirtyRect) | |
{ | |
- IntRect dirtyRect(mapFromContents(contentsDirtyRect)); | |
- | |
+ IntRect dirtyRect(intersection(mapFromContents(contentsDirtyRect), m_previousKeepRect)); | |
+ | |
Tile::Coordinate topLeft = tileCoordinateForPoint(dirtyRect.location()); | |
Tile::Coordinate bottomRight = tileCoordinateForPoint(innerBottomRight(dirtyRect)); | |
- | |
+ | |
for (unsigned yCoordinate = topLeft.y(); yCoordinate <= bottomRight.y(); ++yCoordinate) { | |
for (unsigned xCoordinate = topLeft.x(); xCoordinate <= bottomRight.x(); ++xCoordinate) { | |
RefPtr<Tile> currentTile = tileAt(Tile::Coordinate(xCoordinate, yCoordinate)); | |
@@ -213,7 +213,7 @@ float TiledBackingStore::coverageRatio(const WebCore::IntRect& contentsRect) con | |
for (unsigned yCoordinate = topLeft.y(); yCoordinate <= bottomRight.y(); ++yCoordinate) { | |
for (unsigned xCoordinate = topLeft.x(); xCoordinate <= bottomRight.x(); ++xCoordinate) { | |
Tile::Coordinate currentCoordinate(xCoordinate, yCoordinate); | |
- RefPtr<Tile> currentTile = tileAt(Tile::Coordinate(xCoordinate, yCoordinate)); | |
+ RefPtr<Tile> currentTile = tileAt(currentCoordinate); | |
if (currentTile && currentTile->isReadyToPaint()) { | |
IntRect coverRect = intersection(dirtyRect, currentTile->rect()); | |
coverArea += coverRect.width() * coverRect.height(); | |
@@ -233,28 +233,29 @@ void TiledBackingStore::createTiles() | |
if (m_contentsFrozen) | |
return; | |
+ // Update our backing store geometry. | |
+ const IntRect previousRect = m_rect; | |
+ m_rect = mapFromContents(m_client->tiledBackingStoreContentsRect()); | |
+ | |
const IntRect visibleRect = visibleContentsRect(); | |
m_previousVisibleRect = visibleRect; | |
if (visibleRect.isEmpty()) | |
return; | |
- // Resize tiles on edges in case the contents size has changed. | |
- bool didResizeTiles = false; | |
- const IntSize contentsSize = contentsRect().size(); | |
- | |
- if (contentsSize != m_previousContentsSize) { | |
- m_previousContentsSize = contentsSize; | |
- didResizeTiles = resizeEdgeTiles(); | |
- } | |
- | |
IntRect keepRect; | |
IntRect coverRect; | |
computeCoverAndKeepRect(visibleRect, coverRect, keepRect); | |
dropTilesOutsideRect(keepRect); | |
- // Search for the tile position closest to the viewport center that does not yet contain a tile. | |
+ // after having dropped tiles outside the keep rect. | |
+ bool didResizeTiles = false; | |
+ if (previousRect != m_rect) | |
+ didResizeTiles = resizeEdgeTiles(); | |
+ | |
+ // Search for the tile position closest to the viewport center that does not yet contain a tile. | |
// Which position is considered the closest depends on the tileDistance function. | |
double shortestDistance = std::numeric_limits<double>::infinity(); | |
Vector<Tile::Coordinate> tilesToCreate; | |
@@ -299,7 +300,7 @@ void TiledBackingStore::createTiles() | |
void TiledBackingStore::adjustForContentsRect(IntRect& rect) const | |
{ | |
- IntRect bounds = contentsRect(); | |
+ IntRect bounds = m_rect; | |
IntSize candidateSize = rect.size(); | |
// We will try to keep the cover and keep rect the same size at all time, which | |
@@ -374,7 +375,6 @@ void TiledBackingStore::computeCoverAndKeepRect(const IntRect& visibleRect, IntR | |
bool TiledBackingStore::resizeEdgeTiles() | |
{ | |
bool wasResized = false; | |
- | |
Vector<Tile::Coordinate> tilesToRemove; | |
TileMap::iterator end = m_tiles.end(); | |
for (TileMap::iterator it = m_tiles.begin(); it != end; ++it) { | |
@@ -396,19 +396,19 @@ bool TiledBackingStore::resizeEdgeTiles() | |
void TiledBackingStore::dropTilesOutsideRect(const IntRect& keepRect) | |
{ | |
- FloatRect keepRectF = keepRect; | |
+ Tile::Coordinate topLeft = tileCoordinateForPoint(m_previousKeepRect.location()); | |
+ Tile::Coordinate bottomRight = tileCoordinateForPoint(innerBottomRight(m_previousKeepRect)); | |
- Vector<Tile::Coordinate> toRemove; | |
- TileMap::iterator end = m_tiles.end(); | |
- for (TileMap::iterator it = m_tiles.begin(); it != end; ++it) { | |
- Tile::Coordinate coordinate = it->second->coordinate(); | |
- FloatRect tileRect = it->second->rect(); | |
- if (!tileRect.intersects(keepRectF)) | |
- toRemove.append(coordinate); | |
+ for (unsigned yCoordinate = topLeft.y(); yCoordinate <= bottomRight.y(); ++yCoordinate) { | |
+ for (unsigned xCoordinate = topLeft.x(); xCoordinate <= bottomRight.x(); ++xCoordinate) { | |
+ Tile::Coordinate currentCoordinate(xCoordinate, yCoordinate); | |
+ RefPtr<Tile> currentTile = tileAt(currentCoordinate); | |
+ if (currentTile && !currentTile->rect().intersects(keepRect)) | |
+ removeTile(currentCoordinate); | |
+ } | |
} | |
- unsigned removeCount = toRemove.size(); | |
- for (unsigned n = 0; n < removeCount; ++n) | |
- removeTile(toRemove[n]); | |
+ | |
+ m_previousKeepRect = keepRect; | |
} | |
void TiledBackingStore::removeAllNonVisibleTiles() | |
@@ -447,22 +447,17 @@ IntRect TiledBackingStore::mapFromContents(const IntRect& rect) const | |
rect.height() * m_contentsScale)); | |
} | |
-IntRect TiledBackingStore::contentsRect() const | |
-{ | |
- return mapFromContents(m_client->tiledBackingStoreContentsRect()); | |
-} | |
- | |
IntRect TiledBackingStore::tileRectForCoordinate(const Tile::Coordinate& coordinate) const | |
{ | |
IntRect rect(coordinate.x() * m_tileSize.width(), | |
- coordinate.y() * m_tileSize.height(), | |
- m_tileSize.width(), | |
- m_tileSize.height()); | |
+ coordinate.y() * m_tileSize.height(), | |
+ m_tileSize.width(), | |
+ m_tileSize.height()); | |
- rect.intersect(contentsRect()); | |
+ rect.intersect(m_rect); | |
return rect; | |
} | |
- | |
+ | |
Tile::Coordinate TiledBackingStore::tileCoordinateForPoint(const IntPoint& point) const | |
{ | |
int x = point.x() / m_tileSize.width(); | |
@@ -470,7 +465,6 @@ Tile::Coordinate TiledBackingStore::tileCoordinateForPoint(const IntPoint& point | |
return Tile::Coordinate(std::max(x, 0), std::max(y, 0)); | |
} | |
- | |
void TiledBackingStore::startTileBufferUpdateTimer() | |
{ | |
if (m_tileBufferUpdateTimer->isActive() || !m_client->tiledBackingStoreUpdatesAllowed() || m_contentsFrozen) | |
@@ -520,7 +514,7 @@ void TiledBackingStore::setSupportsAlpha(bool a) | |
if (a == supportsAlpha()) | |
return; | |
m_supportsAlpha = a; | |
- invalidate(contentsRect()); | |
+ invalidate(m_rect); | |
} | |
} | |
diff --git a/Source/WebCore/platform/graphics/TiledBackingStore.h b/Source/WebCore/platform/graphics/TiledBackingStore.h | |
index a9d1ebd..7e7cb3c 100644 | |
--- a/Source/WebCore/platform/graphics/TiledBackingStore.h | |
+++ b/Source/WebCore/platform/graphics/TiledBackingStore.h | |
@@ -99,7 +99,6 @@ private: | |
void setTile(const Tile::Coordinate& coordinate, PassRefPtr<Tile> tile); | |
void removeTile(const Tile::Coordinate& coordinate); | |
- IntRect contentsRect() const; | |
IntRect visibleContentsRect() const; | |
float coverageRatio(const IntRect&) const; | |
@@ -123,7 +122,9 @@ private: | |
FloatPoint m_visibleRectTrajectoryVector; | |
IntRect m_previousVisibleRect; | |
- IntSize m_previousContentsSize; | |
+ IntRect m_previousKeepRect; | |
+ | |
+ IntRect m_rect; | |
float m_contentsScale; | |
float m_pendingScale; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment