- Revision
- 102726
- Author
- [email protected]
- Date
- 2011-12-13 17:52:40 -0800 (Tue, 13 Dec 2011)
Log Message
[chromium] Use HashMap<..., OwnPtr<Tile>> for compositor tilemap
https://bugs.webkit.org/show_bug.cgi?id=74154
Reviewed by James Robinson.
After r102410 landed, it's now possible to properly use an OwnPtr to
store tiles rather than hackily use a RefPtr.
Covered by the compositing/ layout tests.
* platform/graphics/chromium/TiledLayerChromium.cpp:
(WebCore::UpdatableTile::create):
(WebCore::UpdatableTile::UpdatableTile):
(WebCore::TiledLayerChromium::createTile):
* platform/graphics/chromium/cc/CCLayerTilingData.cpp:
(WebCore::CCLayerTilingData::addTile):
(WebCore::CCLayerTilingData::takeTile):
(WebCore::CCLayerTilingData::tileAt):
* platform/graphics/chromium/cc/CCLayerTilingData.h:
* platform/graphics/chromium/cc/CCTiledLayerImpl.cpp:
(WebCore::DrawableTile::create):
(WebCore::DrawableTile::DrawableTile):
(WebCore::CCTiledLayerImpl::createTile):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (102725 => 102726)
--- trunk/Source/WebCore/ChangeLog 2011-12-14 01:52:00 UTC (rev 102725)
+++ trunk/Source/WebCore/ChangeLog 2011-12-14 01:52:40 UTC (rev 102726)
@@ -1,3 +1,29 @@
+2011-12-13 Adrienne Walker <[email protected]>
+
+ [chromium] Use HashMap<..., OwnPtr<Tile>> for compositor tilemap
+ https://bugs.webkit.org/show_bug.cgi?id=74154
+
+ Reviewed by James Robinson.
+
+ After r102410 landed, it's now possible to properly use an OwnPtr to
+ store tiles rather than hackily use a RefPtr.
+
+ Covered by the compositing/ layout tests.
+
+ * platform/graphics/chromium/TiledLayerChromium.cpp:
+ (WebCore::UpdatableTile::create):
+ (WebCore::UpdatableTile::UpdatableTile):
+ (WebCore::TiledLayerChromium::createTile):
+ * platform/graphics/chromium/cc/CCLayerTilingData.cpp:
+ (WebCore::CCLayerTilingData::addTile):
+ (WebCore::CCLayerTilingData::takeTile):
+ (WebCore::CCLayerTilingData::tileAt):
+ * platform/graphics/chromium/cc/CCLayerTilingData.h:
+ * platform/graphics/chromium/cc/CCTiledLayerImpl.cpp:
+ (WebCore::DrawableTile::create):
+ (WebCore::DrawableTile::DrawableTile):
+ (WebCore::CCTiledLayerImpl::createTile):
+
2011-12-13 Dmitry Lomov <[email protected]>
https://bugs.webkit.org/show_bug.cgi?id=73691
Modified: trunk/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp (102725 => 102726)
--- trunk/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp 2011-12-14 01:52:00 UTC (rev 102725)
+++ trunk/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp 2011-12-14 01:52:40 UTC (rev 102726)
@@ -52,7 +52,10 @@
class UpdatableTile : public CCLayerTilingData::Tile {
WTF_MAKE_NONCOPYABLE(UpdatableTile);
public:
- explicit UpdatableTile(PassOwnPtr<LayerTextureUpdater::Texture> texture) : m_texture(texture) { }
+ static PassOwnPtr<UpdatableTile> create(PassOwnPtr<LayerTextureUpdater::Texture> texture)
+ {
+ return adoptPtr(new UpdatableTile(texture));
+ }
LayerTextureUpdater::Texture* texture() { return m_texture.get(); }
ManagedTexture* managedTexture() { return m_texture->texture(); }
@@ -65,6 +68,8 @@
// Content-space rectangle that needs to be updated.
IntRect m_updateRect;
private:
+ explicit UpdatableTile(PassOwnPtr<LayerTextureUpdater::Texture> texture) : m_texture(texture) { }
+
OwnPtr<LayerTextureUpdater::Texture> m_texture;
};
@@ -278,11 +283,12 @@
UpdatableTile* TiledLayerChromium::createTile(int i, int j)
{
- RefPtr<UpdatableTile> tile = adoptRef(new UpdatableTile(textureUpdater()->createTexture(textureManager())));
- m_tiler->addTile(tile, i, j);
- tile->m_dirtyLayerRect = m_tiler->tileLayerRect(tile.get());
+ OwnPtr<UpdatableTile> tile(UpdatableTile::create(textureUpdater()->createTexture(textureManager())));
+ UpdatableTile* addedTile = tile.get();
+ m_tiler->addTile(tile.release(), i, j);
- return tile.get();
+ addedTile->m_dirtyLayerRect = m_tiler->tileLayerRect(addedTile);
+ return addedTile;
}
void TiledLayerChromium::setNeedsDisplayRect(const FloatRect& dirtyRect)
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTilingData.cpp (102725 => 102726)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTilingData.cpp 2011-12-14 01:52:00 UTC (rev 102725)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTilingData.cpp 2011-12-14 01:52:40 UTC (rev 102726)
@@ -65,23 +65,21 @@
return *this;
}
-void CCLayerTilingData::addTile(PassRefPtr<Tile> tile, int i, int j)
+void CCLayerTilingData::addTile(PassOwnPtr<Tile> tile, int i, int j)
{
ASSERT(!tileAt(i, j));
tile->moveTo(i, j);
m_tiles.add(make_pair(i, j), tile);
}
-PassRefPtr<CCLayerTilingData::Tile> CCLayerTilingData::takeTile(int i, int j)
+PassOwnPtr<CCLayerTilingData::Tile> CCLayerTilingData::takeTile(int i, int j)
{
return m_tiles.take(make_pair(i, j));
}
CCLayerTilingData::Tile* CCLayerTilingData::tileAt(int i, int j) const
{
- Tile* tile = m_tiles.get(make_pair(i, j)).get();
- ASSERT(!tile || tile->refCount() == 1);
- return tile;
+ return m_tiles.get(make_pair(i, j));
}
void CCLayerTilingData::reset()
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTilingData.h (102725 => 102726)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTilingData.h 2011-12-14 01:52:00 UTC (rev 102725)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTilingData.h 2011-12-14 01:52:40 UTC (rev 102726)
@@ -34,7 +34,6 @@
#include <wtf/HashMap.h>
#include <wtf/HashTraits.h>
#include <wtf/PassOwnPtr.h>
-#include <wtf/RefCounted.h>
namespace WebCore {
@@ -62,7 +61,7 @@
const CCLayerTilingData& operator=(const CCLayerTilingData&);
- class Tile: public RefCounted<Tile> {
+ class Tile {
WTF_MAKE_NONCOPYABLE(Tile);
public:
Tile() : m_i(-1), m_j(-1) { }
@@ -85,13 +84,10 @@
static void constructDeletedValue(TileMapKey& slot) { slot = std::make_pair(-2, -2); }
static bool isDeletedValue(TileMapKey value) { return value.first == -2 && value.second == -2; }
};
- // FIXME: The mapped value in TileMap should really be an OwnPtr, as the
- // refcount of a Tile should never be more than 1. However, HashMap
- // doesn't easily support OwnPtr as a value.
- typedef HashMap<TileMapKey, RefPtr<Tile>, DefaultHash<TileMapKey>::Hash, TileMapKeyTraits> TileMap;
+ typedef HashMap<TileMapKey, OwnPtr<Tile>, DefaultHash<TileMapKey>::Hash, TileMapKeyTraits> TileMap;
- void addTile(PassRefPtr<Tile>, int, int);
- PassRefPtr<Tile> takeTile(int, int);
+ void addTile(PassOwnPtr<Tile>, int, int);
+ PassOwnPtr<Tile> takeTile(int, int);
Tile* tileAt(int, int) const;
const TileMap& tiles() const { return m_tiles; }
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCTiledLayerImpl.cpp (102725 => 102726)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCTiledLayerImpl.cpp 2011-12-14 01:52:00 UTC (rev 102725)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCTiledLayerImpl.cpp 2011-12-14 01:52:40 UTC (rev 102726)
@@ -42,11 +42,13 @@
class DrawableTile : public CCLayerTilingData::Tile {
WTF_MAKE_NONCOPYABLE(DrawableTile);
public:
- DrawableTile() : m_textureId(0) { }
+ static PassOwnPtr<DrawableTile> create() { return adoptPtr(new DrawableTile()); }
Platform3DObject textureId() const { return m_textureId; }
void setTextureId(Platform3DObject textureId) { m_textureId = textureId; }
private:
+ DrawableTile() : m_textureId(0) { }
+
Platform3DObject m_textureId;
};
@@ -92,9 +94,10 @@
DrawableTile* CCTiledLayerImpl::createTile(int i, int j)
{
- RefPtr<DrawableTile> tile = adoptRef(new DrawableTile());
- m_tiler->addTile(tile, i, j);
- return tile.get();
+ OwnPtr<DrawableTile> tile(DrawableTile::create());
+ DrawableTile* addedTile = tile.get();
+ m_tiler->addTile(tile.release(), i, j);
+ return addedTile;
}
TransformationMatrix CCTiledLayerImpl::tilingTransform() const