Title: [107645] trunk/Source/WebCore
Revision
107645
Author
[email protected]
Date
2012-02-13 17:07:14 -0800 (Mon, 13 Feb 2012)

Log Message

[chromium] Use HashMap<..., OwnPtr<Tile>> for compositor tilemap
https://bugs.webkit.org/show_bug.cgi?id=74154

Reviewed by James Robinson.

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 (107644 => 107645)


--- trunk/Source/WebCore/ChangeLog	2012-02-14 00:59:20 UTC (rev 107644)
+++ trunk/Source/WebCore/ChangeLog	2012-02-14 01:07:14 UTC (rev 107645)
@@ -1,3 +1,26 @@
+2012-02-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.
+
+        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):
+
 2012-02-13  Kentaro Hara  <[email protected]>
 
         Add [CustomToJSObject] to interfaces which have custom toJS() and toV8()

Modified: trunk/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp (107644 => 107645)


--- trunk/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp	2012-02-14 00:59:20 UTC (rev 107644)
+++ trunk/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp	2012-02-14 01:07:14 UTC (rev 107645)
@@ -53,10 +53,9 @@
 class UpdatableTile : public CCLayerTilingData::Tile {
     WTF_MAKE_NONCOPYABLE(UpdatableTile);
 public:
-    explicit UpdatableTile(PassOwnPtr<LayerTextureUpdater::Texture> texture)
-        : m_partialUpdate(false)
-        , m_texture(texture)
+    static PassOwnPtr<UpdatableTile> create(PassOwnPtr<LayerTextureUpdater::Texture> texture)
     {
+        return adoptPtr(new UpdatableTile(texture));
     }
 
     LayerTextureUpdater::Texture* texture() { return m_texture.get(); }
@@ -74,6 +73,12 @@
     IntRect m_opaqueRect;
     bool m_partialUpdate;
 private:
+    explicit UpdatableTile(PassOwnPtr<LayerTextureUpdater::Texture> texture)
+        : m_partialUpdate(false)
+        , m_texture(texture)
+    {
+    }
+
     OwnPtr<LayerTextureUpdater::Texture> m_texture;
 };
 
@@ -292,11 +297,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_dirtyRect = m_tiler->tileRect(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_dirtyRect = m_tiler->tileRect(addedTile);
+    return addedTile;
 }
 
 void TiledLayerChromium::setNeedsDisplayRect(const FloatRect& dirtyRect)

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTilingData.cpp (107644 => 107645)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTilingData.cpp	2012-02-14 00:59:20 UTC (rev 107644)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTilingData.cpp	2012-02-14 01:07:14 UTC (rev 107645)
@@ -74,23 +74,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 (107644 => 107645)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTilingData.h	2012-02-14 00:59:20 UTC (rev 107644)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTilingData.h	2012-02-14 01:07:14 UTC (rev 107645)
@@ -34,7 +34,6 @@
 #include <wtf/HashMap.h>
 #include <wtf/HashTraits.h>
 #include <wtf/PassOwnPtr.h>
-#include <wtf/RefCounted.h>
 
 namespace WebCore {
 
@@ -61,7 +60,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) { }
@@ -84,13 +83,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 (107644 => 107645)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCTiledLayerImpl.cpp	2012-02-14 00:59:20 UTC (rev 107644)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCTiledLayerImpl.cpp	2012-02-14 01:07:14 UTC (rev 107645)
@@ -47,7 +47,7 @@
 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; }
@@ -56,6 +56,8 @@
     void setOpaqueRect(const IntRect& opaqueRect) { m_opaqueRect = opaqueRect; }
 
 private:
+    DrawableTile() : m_textureId(0) { }
+
     Platform3DObject m_textureId;
     IntRect m_opaqueRect;
 };
@@ -103,9 +105,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::quadTransform() const
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to