Changeset 106397 in webkit
- Timestamp:
- Jan 31, 2012 2:46:39 PM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r106393 r106397 1 2012-01-31 Anders Carlsson <andersca@apple.com> 2 3 Put tiles in a HashMap 4 https://bugs.webkit.org/show_bug.cgi?id=77480 5 6 Reviewed by Antti Koivisto. 7 8 Put tiles in a hash map keyed off the tile index. 9 10 * platform/graphics/ca/mac/TileCache.h: 11 Shuffle member variables around so the order makes more sense. 12 Add the tile map. 13 14 * platform/graphics/ca/mac/TileCache.mm: 15 (WebCore::TileCache::TileCache): 16 Update member initializers. 17 18 (WebCore::TileCache::setNeedsDisplayInRect): 19 Call tileLayerAtIndex instead of tileLayerAtPosition. 20 21 (WebCore::TileCache::setAcceleratesDrawing): 22 (WebCore::TileCache::setTileDebugBorderWidth): 23 (WebCore::TileCache::setTileDebugBorderColor): 24 Iterate over the hash map instead of the sublayers. 25 26 (WebCore::TileCache::resizeTileGrid): 27 Add the created layers to the map. 28 29 (WebCore::TileCache::tileLayerAtIndex): 30 Rename from tileLayerAtPoint to better reflect that this member function 31 returns a tile layer at the given index and not the given point. 32 1 33 2012-01-31 Antti Koivisto <antti@apple.com> 2 34 -
trunk/Source/WebCore/platform/graphics/ca/mac/TileCache.h
r106385 r106397 27 27 #define TileCache_h 28 28 29 #include "IntPointHash.h" 29 30 #include "IntSize.h" 31 #include <wtf/HashMap.h> 30 32 #include <wtf/Noncopyable.h> 31 33 #include <wtf/PassOwnPtr.h> … … 67 69 68 70 private: 71 typedef IntPoint TileIndex; 72 69 73 TileCache(WebTileCacheLayer*, const IntSize& tileSize); 70 74 … … 77 81 void resizeTileGrid(const IntSize& numTiles); 78 82 79 WebTileLayer* tileLayerAt Position(const IntPoint&) const;83 WebTileLayer* tileLayerAtIndex(const TileIndex&) const; 80 84 RetainPtr<WebTileLayer> createTileLayer(); 81 85 … … 83 87 84 88 WebTileCacheLayer* m_tileCacheLayer; 89 RetainPtr<CALayer> m_tileContainerLayer; 85 90 const IntSize m_tileSize; 86 87 RetainPtr<CALayer> m_tileContainerLayer;88 89 RetainPtr<CGColorRef> m_tileDebugBorderColor;90 float m_tileDebugBorderWidth;91 91 92 92 // Number of tiles in each dimension. 93 93 IntSize m_numTilesInGrid; 94 94 95 typedef HashMap<TileIndex, RetainPtr<WebTileLayer> > TileMap; 96 TileMap m_tiles; 97 95 98 bool m_acceleratesDrawing; 99 100 RetainPtr<CGColorRef> m_tileDebugBorderColor; 101 float m_tileDebugBorderWidth; 96 102 }; 97 103 -
trunk/Source/WebCore/platform/graphics/ca/mac/TileCache.mm
r106385 r106397 51 51 TileCache::TileCache(WebTileCacheLayer* tileCacheLayer, const IntSize& tileSize) 52 52 : m_tileCacheLayer(tileCacheLayer) 53 , m_tileContainerLayer(adoptCF([[CALayer alloc] init])) 53 54 , m_tileSize(tileSize) 54 , m_ tileContainerLayer(adoptCF([[CALayer alloc] init]))55 , m_acceleratesDrawing(false) 55 56 , m_tileDebugBorderWidth(0) 56 , m_acceleratesDrawing(false)57 57 { 58 58 [CATransaction begin]; … … 88 88 for (int y = topLeft.y(); y <= bottomRight.y(); ++y) { 89 89 for (int x = topLeft.x(); x <= bottomRight.x(); ++x) { 90 WebTileLayer* tileLayer = tileLayerAt Position(IntPoint(x, y));90 WebTileLayer* tileLayer = tileLayerAtIndex(IntPoint(x, y)); 91 91 92 92 CGRect tileRect = [m_tileCacheLayer convertRect:rect toLayer:tileLayer]; … … 159 159 m_acceleratesDrawing = acceleratesDrawing; 160 160 161 for ( WebTileLayer* tileLayer in [m_tileContainerLayer.get() sublayers])162 [ tileLayersetAcceleratesDrawing:m_acceleratesDrawing];161 for (TileMap::const_iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it) 162 [it->second.get() setAcceleratesDrawing:m_acceleratesDrawing]; 163 163 #else 164 164 UNUSED_PARAM(acceleratesDrawing); … … 177 177 178 178 m_tileDebugBorderWidth = borderWidth; 179 for ( WebTileLayer* tileLayer in [m_tileContainerLayer.get() sublayers])180 [ tileLayersetBorderWidth:m_tileDebugBorderWidth];179 for (TileMap::const_iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it) 180 [it->second.get() setBorderWidth:m_tileDebugBorderWidth]; 181 181 } 182 182 … … 187 187 188 188 m_tileDebugBorderColor = borderColor; 189 for ( WebTileLayer* tileLayer in [m_tileContainerLayer.get() sublayers])190 [ tileLayersetBorderColor:m_tileDebugBorderColor.get()];189 for (TileMap::const_iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it) 190 [it->second.get() setBorderColor:m_tileDebugBorderColor.get()]; 191 191 } 192 192 … … 246 246 247 247 if (x < m_numTilesInGrid.width() && y < m_numTilesInGrid.height()) { 248 // We can reuse the tile layer at this position.249 tileLayer = tileLayerAt Position(IntPoint(x, y));248 // We can reuse the tile layer at this index. 249 tileLayer = tileLayerAtIndex(IntPoint(x, y)); 250 250 } else { 251 251 tileLayer = createTileLayer(); 252 m_tiles.set(IntPoint(x, y), tileLayer.get()); 252 253 } 253 254 … … 264 265 } 265 266 266 WebTileLayer* TileCache::tileLayerAt Position(const IntPoint& point) const267 { 268 ASSERT( point.x() >= 0);269 ASSERT( point.x() <= m_numTilesInGrid.width());270 ASSERT( point.y() >= 0);271 ASSERT( point.y() <= m_numTilesInGrid.height());272 273 return [[m_tileContainerLayer.get() sublayers] objectAtIndex:point.y() * m_numTilesInGrid.width() + point.x()];267 WebTileLayer* TileCache::tileLayerAtIndex(const TileIndex& index) const 268 { 269 ASSERT(index.x() >= 0); 270 ASSERT(index.x() <= m_numTilesInGrid.width()); 271 ASSERT(index.y() >= 0); 272 ASSERT(index.y() <= m_numTilesInGrid.height()); 273 274 return m_tiles.get(index).get(); 274 275 } 275 276
Note: See TracChangeset
for help on using the changeset viewer.