[chromium] Simplify updateContentRect, removing rect parameter, refactor unit tests.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 22 Aug 2012 19:50:01 +0000 (19:50 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 22 Aug 2012 19:50:01 +0000 (19:50 +0000)
https://bugs.webkit.org/show_bug.cgi?id=94165

Patch by Eric Penner <epenner@google.com> on 2012-08-22
Reviewed by Adrienne Walker.

Source/WebCore:

Remove visible rect parameter from TiledLayerChromium functions. Passing a
rect that is not the visible rect wouldn't make sense, and soon we might
need further visibility information.

In refactoring the unit tests, I removed texture manager from all tests
and put it in the test class. I also made some utility functions to
simulate the commit flow and remove tons of boilerplate code. I refactored
about half the unit tests to use the utility functions.

Refactored tests.

* platform/graphics/chromium/ContentLayerChromium.cpp:
(WebCore::ContentLayerChromium::update):
(WebCore::ContentLayerChromium::needMoreUpdates):
* platform/graphics/chromium/ImageLayerChromium.cpp:
(WebCore::ImageLayerChromium::update):
* platform/graphics/chromium/TiledLayerChromium.cpp:
(WebCore):
(WebCore::TiledLayerChromium::setTexturePriorities):
(WebCore::TiledLayerChromium::resetUpdateState):
(WebCore::TiledLayerChromium::update):
(WebCore::TiledLayerChromium::needsIdlePaint):
(WebCore::TiledLayerChromium::idlePaintRect):
* platform/graphics/chromium/TiledLayerChromium.h:
(TiledLayerChromium):

Source/WebKit/chromium:

Refactored tests to remove lots of boilerplate code.

* tests/CCTiledLayerTestCommon.cpp:
* tests/CCTiledLayerTestCommon.h:
(FakeTiledLayerChromium):
* tests/TiledLayerChromiumTest.cpp:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@126340 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp
Source/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp
Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp
Source/WebCore/platform/graphics/chromium/TiledLayerChromium.h
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/tests/CCTiledLayerTestCommon.cpp
Source/WebKit/chromium/tests/CCTiledLayerTestCommon.h
Source/WebKit/chromium/tests/TiledLayerChromiumTest.cpp

index d2f27ed..6474288 100644 (file)
@@ -1,3 +1,36 @@
+2012-08-22  Eric Penner  <epenner@google.com>
+
+        [chromium] Simplify updateContentRect, removing rect parameter, refactor unit tests.
+        https://bugs.webkit.org/show_bug.cgi?id=94165
+
+        Reviewed by Adrienne Walker.
+
+        Remove visible rect parameter from TiledLayerChromium functions. Passing a
+        rect that is not the visible rect wouldn't make sense, and soon we might
+        need further visibility information.
+
+        In refactoring the unit tests, I removed texture manager from all tests
+        and put it in the test class. I also made some utility functions to 
+        simulate the commit flow and remove tons of boilerplate code. I refactored
+        about half the unit tests to use the utility functions.
+
+        Refactored tests.
+
+        * platform/graphics/chromium/ContentLayerChromium.cpp:
+        (WebCore::ContentLayerChromium::update):
+        (WebCore::ContentLayerChromium::needMoreUpdates):
+        * platform/graphics/chromium/ImageLayerChromium.cpp:
+        (WebCore::ImageLayerChromium::update):
+        * platform/graphics/chromium/TiledLayerChromium.cpp:
+        (WebCore):
+        (WebCore::TiledLayerChromium::setTexturePriorities):
+        (WebCore::TiledLayerChromium::resetUpdateState):
+        (WebCore::TiledLayerChromium::update):
+        (WebCore::TiledLayerChromium::needsIdlePaint):
+        (WebCore::TiledLayerChromium::idlePaintRect):
+        * platform/graphics/chromium/TiledLayerChromium.h:
+        (TiledLayerChromium):
+
 2012-08-22  Otto Derek Cheung  <otcheung@rim.com>
 
         [BlackBerry] Add a check to filter out cookies that tries to set the 
index 0dc960b..a8f57e2 100644 (file)
@@ -96,23 +96,13 @@ void ContentLayerChromium::setTexturePriorities(const CCPriorityCalculator& prio
 void ContentLayerChromium::update(CCTextureUpdateQueue& queue, const CCOcclusionTracker* occlusion, CCRenderingStats& stats)
 {
     createTextureUpdaterIfNeeded();
-
-    IntRect contentRect;
-
-    // Always call updateContentRect() but with an empty layer rectangle when
-    // layer doesn't draw contents.
-    if (drawsContent())
-        contentRect = visibleContentRect();
-
-    updateContentRect(queue, contentRect, occlusion, stats);
+    TiledLayerChromium::update(queue, occlusion, stats);
     m_needsDisplay = false;
 }
 
 bool ContentLayerChromium::needMoreUpdates()
 {
-    if (!drawsContent())
-        return false;
-    return needsIdlePaint(visibleContentRect());
+    return needsIdlePaint();
 }
 
 void ContentLayerChromium::createTextureUpdaterIfNeeded()
index f7e603e..f8d869f 100644 (file)
@@ -148,8 +148,7 @@ void ImageLayerChromium::update(CCTextureUpdateQueue& queue, const CCOcclusionTr
         invalidateContentRect(IntRect(IntPoint(), contentBounds()));
         m_needsDisplay = false;
     }
-
-    updateContentRect(queue, visibleContentRect(), occlusion, stats);
+    TiledLayerChromium::update(queue, occlusion, stats);
 }
 
 void ImageLayerChromium::createTextureUpdaterIfNeeded()
index cce1635..68bfa45 100644 (file)
@@ -553,11 +553,6 @@ void TiledLayerChromium::updateTileTextures(const IntRect& paintRect, int left,
     }
 }
 
-void TiledLayerChromium::setTexturePriorities(const CCPriorityCalculator& priorityCalc)
-{
-    setTexturePrioritiesInRect(priorityCalc, visibleContentRect());
-}
-
 namespace {
 // This picks a small animated layer to be anything less than one viewport. This
 // is specifically for page transitions which are viewport-sized layers. The extra
@@ -592,7 +587,7 @@ void setPriorityForTexture(const CCPriorityCalculator& priorityCalc,
 }
 }
 
-void TiledLayerChromium::setTexturePrioritiesInRect(const CCPriorityCalculator& priorityCalc, const IntRect& visibleContentRect)
+void TiledLayerChromium::setTexturePriorities(const CCPriorityCalculator& priorityCalc)
 {
     updateBounds();
     resetUpdateState();
@@ -604,7 +599,7 @@ void TiledLayerChromium::setTexturePrioritiesInRect(const CCPriorityCalculator&
     bool smallAnimatedLayer = isSmallAnimatedLayer(this);
 
     // Minimally create the tiles in the desired pre-paint rect.
-    IntRect createTilesRect = idlePaintRect(visibleContentRect);
+    IntRect createTilesRect = idlePaintRect();
     if (!createTilesRect.isEmpty()) {
         int left, top, right, bottom;
         m_tiler->contentRectToTileIndices(createTilesRect, left, top, right, bottom);
@@ -618,7 +613,7 @@ void TiledLayerChromium::setTexturePrioritiesInRect(const CCPriorityCalculator&
 
     // Also, minimally create all tiles for small animated layers and also
     // double-buffer them since we have limited their size to be reasonable.
-    IntRect doubleBufferedRect = visibleContentRect;
+    IntRect doubleBufferedRect = visibleContentRect();
     if (smallAnimatedLayer)
         doubleBufferedRect = IntRect(IntPoint::zero(), contentBounds());
 
@@ -647,7 +642,7 @@ void TiledLayerChromium::setTexturePrioritiesInRect(const CCPriorityCalculator&
                 IntRect tileRect = m_tiler->tileRect(tile);
                 tile->dirtyRect = tileRect;
                 LayerTextureUpdater::Texture* backBuffer = tile->texture();
-                setPriorityForTexture(priorityCalc, visibleContentRect, tile->dirtyRect, drawsToRoot, smallAnimatedLayer, backBuffer->texture());
+                setPriorityForTexture(priorityCalc, visibleContentRect(), tile->dirtyRect, drawsToRoot, smallAnimatedLayer, backBuffer->texture());
                 OwnPtr<CCPrioritizedTexture> frontBuffer = CCPrioritizedTexture::create(backBuffer->texture()->textureManager(),
                                                                                         backBuffer->texture()->size(),
                                                                                         backBuffer->texture()->format());
@@ -665,7 +660,7 @@ void TiledLayerChromium::setTexturePrioritiesInRect(const CCPriorityCalculator&
         if (!tile)
             continue;
         IntRect tileRect = m_tiler->tileRect(tile);
-        setPriorityForTexture(priorityCalc, visibleContentRect, tileRect, drawsToRoot, smallAnimatedLayer, tile->managedTexture());
+        setPriorityForTexture(priorityCalc, visibleContentRect(), tileRect, drawsToRoot, smallAnimatedLayer, tile->managedTexture());
     }
 }
 
@@ -680,6 +675,9 @@ Region TiledLayerChromium::visibleContentOpaqueRegion() const
 
 void TiledLayerChromium::resetUpdateState()
 {
+    m_skipsDraw = false;
+    m_failedUpdate = false;
+
     CCLayerTilingData::TileMap::const_iterator end = m_tiler->tiles().end();
     for (CCLayerTilingData::TileMap::const_iterator iter = m_tiler->tiles().begin(); iter != end; ++iter) {
         UpdatableTile* tile = static_cast<UpdatableTile*>(iter->second.get());
@@ -690,13 +688,11 @@ void TiledLayerChromium::resetUpdateState()
     }
 }
 
-void TiledLayerChromium::updateContentRect(CCTextureUpdateQueue& queue, const IntRect& contentRect, const CCOcclusionTracker* occlusion, CCRenderingStats& stats)
+void TiledLayerChromium::update(CCTextureUpdateQueue& queue, const CCOcclusionTracker* occlusion, CCRenderingStats& stats)
 {
-    m_skipsDraw = false;
-    m_failedUpdate = false;
+    ASSERT(!m_skipsDraw && !m_failedUpdate); // Did resetUpdateState get skipped?
     updateBounds();
-
-    if (m_tiler->hasEmptyBounds())
+    if (m_tiler->hasEmptyBounds() || !drawsContent())
         return;
 
     bool didPaint = false;
@@ -715,12 +711,12 @@ void TiledLayerChromium::updateContentRect(CCTextureUpdateQueue& queue, const In
         m_failedUpdate = false;
     }
 
-    if (contentRect.isEmpty())
+    if (visibleContentRect().isEmpty())
         return;
 
     // Visible painting. First occlude visible tiles and paint the non-occluded tiles.
     int left, top, right, bottom;
-    m_tiler->contentRectToTileIndices(contentRect, left, top, right, bottom);
+    m_tiler->contentRectToTileIndices(visibleContentRect(), left, top, right, bottom);
     markOcclusionsAndRequestTextures(left, top, right, bottom, occlusion);
     m_skipsDraw = !updateTiles(left, top, right, bottom, queue, occlusion, stats, didPaint);
     if (m_skipsDraw)
@@ -729,7 +725,7 @@ void TiledLayerChromium::updateContentRect(CCTextureUpdateQueue& queue, const In
         return;
 
     // If we have already painting everything visible. Do some pre-painting while idle.
-    IntRect idlePaintContentRect = idlePaintRect(contentRect);
+    IntRect idlePaintContentRect = idlePaintRect();
     if (idlePaintContentRect.isEmpty())
         return;
 
@@ -765,13 +761,13 @@ void TiledLayerChromium::updateContentRect(CCTextureUpdateQueue& queue, const In
     }
 }
 
-bool TiledLayerChromium::needsIdlePaint(const IntRect& visibleContentRect)
+bool TiledLayerChromium::needsIdlePaint()
 {
     // Don't trigger more paints if we failed (as we'll just fail again).
-    if (m_failedUpdate || visibleContentRect.isEmpty() || m_tiler->hasEmptyBounds())
+    if (m_failedUpdate || visibleContentRect().isEmpty() || m_tiler->hasEmptyBounds() || !drawsContent())
         return false;
 
-    IntRect idlePaintContentRect = idlePaintRect(visibleContentRect);
+    IntRect idlePaintContentRect = idlePaintRect();
     if (idlePaintContentRect.isEmpty())
         return false;
 
@@ -795,15 +791,15 @@ bool TiledLayerChromium::needsIdlePaint(const IntRect& visibleContentRect)
     return false;
 }
 
-IntRect TiledLayerChromium::idlePaintRect(const IntRect& visibleContentRect)
+IntRect TiledLayerChromium::idlePaintRect()
 {
     // Don't inflate an empty rect.
-    if (visibleContentRect.isEmpty())
-        return visibleContentRect;
+    if (visibleContentRect().isEmpty())
+        return IntRect();
 
     // FIXME: This can be made a lot larger now! We should increase
     //        this slowly while insuring it doesn't cause any perf issues.
-    IntRect prepaintRect = visibleContentRect;
+    IntRect prepaintRect = visibleContentRect();
     prepaintRect.inflateX(m_tiler->tileSize().width());
     prepaintRect.inflateY(m_tiler->tileSize().height() * 2);
     IntRect contentRect(IntPoint::zero(), contentBounds());
index 33263e5..2abc112 100644 (file)
@@ -60,6 +60,8 @@ public:
 
     virtual Region visibleContentOpaqueRegion() const OVERRIDE;
 
+    virtual void update(CCTextureUpdateQueue&, const CCOcclusionTracker*, CCRenderingStats&) OVERRIDE;
+
 protected:
     TiledLayerChromium();
 
@@ -82,13 +84,9 @@ protected:
     // Reset state on tiles that will be used for updating the layer.
     void resetUpdateState();
 
-    // Prepare data needed to update textures that intersect with contentRect.
-    void updateContentRect(CCTextureUpdateQueue&, const IntRect& contentRect, const CCOcclusionTracker*, CCRenderingStats&);
-
     // After preparing an update, returns true if more painting is needed.
-    bool needsIdlePaint(const IntRect& visibleContentRect);
-
-    IntRect idlePaintRect(const IntRect& visibleContentRect);
+    bool needsIdlePaint();
+    IntRect idlePaintRect();
 
     bool skipsDraw() const { return m_skipsDraw; }
 
@@ -104,8 +102,6 @@ private:
     bool tileOnlyNeedsPartialUpdate(UpdatableTile*);
     bool tileNeedsBufferedUpdate(UpdatableTile*);
 
-    void setTexturePrioritiesInRect(const CCPriorityCalculator&, const IntRect& visibleContentRect);
-
     void markOcclusionsAndRequestTextures(int left, int top, int right, int bottom, const CCOcclusionTracker*);
 
     bool updateTiles(int left, int top, int right, int bottom, CCTextureUpdateQueue&, const CCOcclusionTracker*, CCRenderingStats&, bool& didPaint);
index e7f730f..0e25311 100644 (file)
@@ -1,3 +1,17 @@
+2012-08-22  Eric Penner  <epenner@google.com>
+
+        [chromium] Simplify updateContentRect, removing rect parameter, refactor unit tests.
+        https://bugs.webkit.org/show_bug.cgi?id=94165
+
+        Reviewed by Adrienne Walker.
+
+        Refactored tests to remove lots of boilerplate code.
+
+        * tests/CCTiledLayerTestCommon.cpp:
+        * tests/CCTiledLayerTestCommon.h:
+        (FakeTiledLayerChromium):
+        * tests/TiledLayerChromiumTest.cpp:
+
 2012-08-22  Iain Merrick  <husky@chromium.org>
 
         [chromium] Remove WebFrame::setSelectionToRange
index 58f37c6..dcaae59 100644 (file)
@@ -115,11 +115,6 @@ void FakeTiledLayerChromium::setNeedsDisplayRect(const FloatRect& rect)
     TiledLayerChromium::setNeedsDisplayRect(rect);
 }
 
-void FakeTiledLayerChromium::update(CCTextureUpdateQueue& queue, const CCOcclusionTracker* occlusion, CCRenderingStats& stats)
-{
-    updateContentRect(queue, visibleContentRect(), occlusion, stats);
-}
-
 void FakeTiledLayerChromium::setTexturePriorities(const CCPriorityCalculator& calculator)
 {
     // Ensure there is always a target render surface available. If none has been
index 5de1c5f..3adb4bf 100644 (file)
@@ -112,7 +112,6 @@ public:
     static WebCore::IntSize tileSize() { return WebCore::IntSize(100, 100); }
 
     using WebCore::TiledLayerChromium::invalidateContentRect;
-    using WebCore::TiledLayerChromium::updateContentRect;
     using WebCore::TiledLayerChromium::needsIdlePaint;
     using WebCore::TiledLayerChromium::skipsDraw;
     using WebCore::TiledLayerChromium::numPaintedTiles;
@@ -121,9 +120,6 @@ public:
     virtual void setNeedsDisplayRect(const WebCore::FloatRect&) OVERRIDE;
     const WebCore::FloatRect& lastNeedsDisplayRect() const { return m_lastNeedsDisplayRect; }
 
-    // Updates the visibleContentRect().
-    virtual void update(WebCore::CCTextureUpdateQueue&, const WebCore::CCOcclusionTracker*, WebCore::CCRenderingStats&) OVERRIDE;
-
     virtual void setTexturePriorities(const WebCore::CCPriorityCalculator&) OVERRIDE;
 
     virtual WebCore::CCPrioritizedTextureManager* textureManager() const OVERRIDE { return m_textureManager; }
index 689b817..2efb8e5 100644 (file)
@@ -77,6 +77,8 @@ class TiledLayerChromiumTest : public testing::Test {
 public:
     TiledLayerChromiumTest()
         : m_context(WebKit::createFakeCCGraphicsContext())
+        , m_textureManager(CCPrioritizedTextureManager::create(60*1024*1024, 1024, CCRenderer::ContentPool))
+        , m_occlusion(0)
     {
         DebugScopedSetImplThread implThread;
         m_resourceProvider = CCResourceProvider::create(m_context.get());
@@ -92,6 +94,42 @@ public:
     {
         CCTextureUpdateController::updateTextures(m_resourceProvider.get(), &m_copier, &m_uploader, &m_queue, count);
     }
+
+    bool updateAndPush(FakeTiledLayerChromium* layer1,
+                       CCLayerImpl* layerImpl1,
+                       FakeTiledLayerChromium* layer2 = 0,
+                       CCLayerImpl* layerImpl2 = 0)
+    {
+        // Get textures
+        m_textureManager->clearPriorities();
+        if (layer1)
+            layer1->setTexturePriorities(m_priorityCalculator);
+        if (layer2)
+            layer2->setTexturePriorities(m_priorityCalculator);     
+        m_textureManager->prioritizeTextures();
+
+        // Update content
+        if (layer1)
+            layer1->update(m_queue, m_occlusion, m_stats);
+        if (layer2)
+            layer2->update(m_queue, m_occlusion, m_stats);
+
+        bool needsUpdate = false;
+        if (layer1)
+            needsUpdate |= layer1->needsIdlePaint();
+        if (layer2)
+            needsUpdate |= layer2->needsIdlePaint();
+
+        // Update textures and push.
+        updateTextures();
+        if (layer1)
+            layer1->pushPropertiesTo(layerImpl1);
+        if (layer2)
+            layer2->pushPropertiesTo(layerImpl2);
+
+        return needsUpdate;
+    }
+
 public:
     OwnPtr<CCGraphicsContext> m_context;
     OwnPtr<CCResourceProvider> m_resourceProvider;
@@ -100,14 +138,13 @@ public:
     FakeTextureCopier m_copier;
     FakeTextureUploader m_uploader;
     CCPriorityCalculator m_priorityCalculator;
+    OwnPtr<CCPrioritizedTextureManager> m_textureManager;
+    TestCCOcclusionTracker* m_occlusion;
 };
 
-
-
 TEST_F(TiledLayerChromiumTest, pushDirtyTiles)
 {
-    OwnPtr<CCPrioritizedTextureManager> textureManager = CCPrioritizedTextureManager::create(4*1024*1024, 1024, CCRenderer::ContentPool);
-    RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get()));
+    RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m_textureManager.get()));
     DebugScopedSetImplThread implThread;
     OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1)));
 
@@ -115,25 +152,17 @@ TEST_F(TiledLayerChromiumTest, pushDirtyTiles)
     layer->setBounds(IntSize(100, 200));
     layer->setVisibleContentRect(IntRect(0, 0, 100, 200));
     layer->invalidateContentRect(IntRect(0, 0, 100, 200));
-
-    layer->setTexturePriorities(m_priorityCalculator);
-    textureManager->prioritizeTextures();
-
-    layer->updateContentRect(m_queue, IntRect(0, 0, 100, 200), 0, m_stats);
-    updateTextures();
-    layer->pushPropertiesTo(layerImpl.get());
+    updateAndPush(layer.get(), layerImpl.get());
 
     // We should have both tiles on the impl side.
     EXPECT_TRUE(layerImpl->hasTileAt(0, 0));
     EXPECT_TRUE(layerImpl->hasTileAt(0, 1));
 
-    // Invalidates both tiles...
+    // Invalidates both tiles, but then only update one of them.
+    layer->setBounds(IntSize(100, 200));
+    layer->setVisibleContentRect(IntRect(0, 0, 100, 100));
     layer->invalidateContentRect(IntRect(0, 0, 100, 200));
-    // ....but then only update one of them.
-    layer->setTexturePriorities(m_priorityCalculator);
-    textureManager->prioritizeTextures();
-    layer->updateContentRect(m_queue, IntRect(0, 0, 100, 100), 0, m_stats);
-    layer->pushPropertiesTo(layerImpl.get());
+    updateAndPush(layer.get(), layerImpl.get());
 
     // We should only have the first tile since the other tile was invalidated but not painted.
     EXPECT_TRUE(layerImpl->hasTileAt(0, 0));
@@ -142,24 +171,17 @@ TEST_F(TiledLayerChromiumTest, pushDirtyTiles)
 
 TEST_F(TiledLayerChromiumTest, pushOccludedDirtyTiles)
 {
-    OwnPtr<CCPrioritizedTextureManager> textureManager = CCPrioritizedTextureManager::create(4*1024*1024, 1024, CCRenderer::ContentPool);
-    RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get()));
+    RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m_textureManager.get()));
     DebugScopedSetImplThread implThread;
     OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1)));
     TestCCOcclusionTracker occluded;
+    m_occlusion = &occluded;
 
     // The tile size is 100x100, so this invalidates and then paints two tiles.
     layer->setBounds(IntSize(100, 200));
-    layer->setDrawableContentRect(IntRect(0, 0, 100, 200));
     layer->setVisibleContentRect(IntRect(0, 0, 100, 200));
     layer->invalidateContentRect(IntRect(0, 0, 100, 200));
-
-    layer->setTexturePriorities(m_priorityCalculator);
-    textureManager->prioritizeTextures();
-
-    layer->updateContentRect(m_queue, IntRect(0, 0, 100, 200), &occluded, m_stats);
-    updateTextures();
-    layer->pushPropertiesTo(layerImpl.get());
+    updateAndPush(layer.get(), layerImpl.get());
 
     EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1);
     EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 20000, 1);
@@ -173,9 +195,7 @@ TEST_F(TiledLayerChromiumTest, pushOccludedDirtyTiles)
     layer->invalidateContentRect(IntRect(0, 0, 50, 50));
     // ....but the area is occluded.
     occluded.setOcclusion(IntRect(0, 0, 50, 50));
-    layer->updateContentRect(m_queue, IntRect(0, 0, 100, 100), &occluded, m_stats);
-    updateTextures();
-    layer->pushPropertiesTo(layerImpl.get());
+    updateAndPush(layer.get(), layerImpl.get());
 
     EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1);
     EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 20000 + 2500, 1);
@@ -188,8 +208,7 @@ TEST_F(TiledLayerChromiumTest, pushOccludedDirtyTiles)
 
 TEST_F(TiledLayerChromiumTest, pushDeletedTiles)
 {
-    OwnPtr<CCPrioritizedTextureManager> textureManager = CCPrioritizedTextureManager::create(4*1024*1024, 1024, CCRenderer::ContentPool);
-    RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get()));
+    RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m_textureManager.get()));
     DebugScopedSetImplThread implThread;
     OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1)));
 
@@ -197,21 +216,15 @@ TEST_F(TiledLayerChromiumTest, pushDeletedTiles)
     layer->setBounds(IntSize(100, 200));
     layer->setVisibleContentRect(IntRect(0, 0, 100, 200));
     layer->invalidateContentRect(IntRect(0, 0, 100, 200));
-
-    layer->setTexturePriorities(m_priorityCalculator);
-    textureManager->prioritizeTextures();
-
-    layer->updateContentRect(m_queue, IntRect(0, 0, 100, 200), 0, m_stats);
-    updateTextures();
-    layer->pushPropertiesTo(layerImpl.get());
+    updateAndPush(layer.get(), layerImpl.get());
 
     // We should have both tiles on the impl side.
     EXPECT_TRUE(layerImpl->hasTileAt(0, 0));
     EXPECT_TRUE(layerImpl->hasTileAt(0, 1));
 
-    textureManager->clearPriorities();
-    textureManager->clearAllMemory(m_resourceProvider.get());
-    textureManager->setMaxMemoryLimitBytes(4*1024*1024);
+    m_textureManager->clearPriorities();
+    m_textureManager->clearAllMemory(m_resourceProvider.get());
+    m_textureManager->setMaxMemoryLimitBytes(4*1024*1024);
 
     // This should drop the tiles on the impl thread.
     layer->pushPropertiesTo(layerImpl.get());
@@ -220,203 +233,140 @@ TEST_F(TiledLayerChromiumTest, pushDeletedTiles)
     EXPECT_FALSE(layerImpl->hasTileAt(0, 0));
     EXPECT_FALSE(layerImpl->hasTileAt(0, 1));
 
-    // This should recreate and update the deleted textures.
-    layer->setTexturePriorities(m_priorityCalculator);
-    textureManager->prioritizeTextures();
-    layer->updateContentRect(m_queue, IntRect(0, 0, 100, 100), 0, m_stats);
-    updateTextures();
-    layer->pushPropertiesTo(layerImpl.get());
+    // This should recreate and update one of the deleted textures.
+    layer->setVisibleContentRect(IntRect(0, 0, 100, 100));
+    updateAndPush(layer.get(), layerImpl.get());
 
-    // We should only have the first tile since the other tile was invalidated but not painted.
+    // We should have one tiles on the impl side.
     EXPECT_TRUE(layerImpl->hasTileAt(0, 0));
     EXPECT_FALSE(layerImpl->hasTileAt(0, 1));
 }
 
 TEST_F(TiledLayerChromiumTest, pushIdlePaintTiles)
 {
-    OwnPtr<CCPrioritizedTextureManager> textureManager = CCPrioritizedTextureManager::create(4*1024*1024, 1024, CCRenderer::ContentPool);
-    RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get()));
+    RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m_textureManager.get()));
     DebugScopedSetImplThread implThread;
     OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1)));
 
     // The tile size is 100x100. Setup 5x5 tiles with one visible tile in the center.
-    IntSize contentBounds(500, 500);
-    IntRect contentRect(IntPoint::zero(), contentBounds);
-    IntRect visibleRect(200, 200, 100, 100);
-
-    // This invalidates 25 tiles and then paints one visible tile.
-    layer->setBounds(contentBounds);
-    layer->setVisibleContentRect(visibleRect);
-    layer->invalidateContentRect(contentRect);
-
-    layer->setTexturePriorities(m_priorityCalculator);
-    textureManager->prioritizeTextures();
-
-    layer->updateContentRect(m_queue, visibleRect, 0, m_stats);
-    updateTextures();
-
-    // We should need idle-painting for 3x3 tiles in the center.
-    EXPECT_TRUE(layer->needsIdlePaint(visibleRect));
-
-    layer->pushPropertiesTo(layerImpl.get());
+    // This paints 1 visible of the 25 invalid tiles.
+    layer->setBounds(IntSize(500, 500));
+    layer->setVisibleContentRect(IntRect(200, 200, 100, 100));
+    layer->invalidateContentRect(IntRect(0, 0, 500, 500));
+    bool needsUpdate = updateAndPush(layer.get(), layerImpl.get());
+    // We should need idle-painting for surrounding tiles.
+    EXPECT_TRUE(needsUpdate);
 
     // We should have one tile on the impl side.
     EXPECT_TRUE(layerImpl->hasTileAt(2, 2));
 
     // For the next four updates, we should detect we still need idle painting.
     for (int i = 0; i < 4; i++) {
-        layer->setTexturePriorities(m_priorityCalculator);
-        textureManager->prioritizeTextures();
-
-        layer->updateContentRect(m_queue, visibleRect, 0, m_stats);
-        EXPECT_TRUE(layer->needsIdlePaint(visibleRect));
-        updateTextures();
-        layer->pushPropertiesTo(layerImpl.get());
+        needsUpdate = updateAndPush(layer.get(), layerImpl.get());
+        EXPECT_TRUE(needsUpdate);
     }
 
-    // After four passes of idle painting, we should be finished painting
-    // EXPECT_FALSE(layer->needsIdlePaint(visibleRect));
-
     // We should have one tile surrounding the visible tile on all sides, but no other tiles.
     IntRect idlePaintTiles(1, 1, 3, 3);
     for (int i = 0; i < 5; i++) {
-        for (int j = 0; j < 5; j++) {
-            if (idlePaintTiles.contains(i, j))
-                EXPECT_TRUE(layerImpl->hasTileAt(i, j));
-            else
-                EXPECT_FALSE(layerImpl->hasTileAt(i, j));
-        }
+        for (int j = 0; j < 5; j++)
+            EXPECT_EQ(layerImpl->hasTileAt(i, j), idlePaintTiles.contains(i, j));
     }
+
+    // We should always finish painting eventually.
+    for (int i = 0; i < 20; i++)
+        needsUpdate = updateAndPush(layer.get(), layerImpl.get());
+    EXPECT_FALSE(needsUpdate);
 }
 
 TEST_F(TiledLayerChromiumTest, pushTilesAfterIdlePaintFailed)
 {
     // Start with 2mb of memory, but the test is going to try to use just more than 1mb, so we reduce to 1mb later.
-    OwnPtr<CCPrioritizedTextureManager> textureManager = CCPrioritizedTextureManager::create(2*1024*1024, 1024, CCRenderer::ContentPool);
+    m_textureManager->setMaxMemoryLimitBytes(2 * 1024 * 1024);    
     DebugScopedSetImplThread implThread;
-    RefPtr<FakeTiledLayerChromium> layer1 = adoptRef(new FakeTiledLayerChromium(textureManager.get()));
+    RefPtr<FakeTiledLayerChromium> layer1 = adoptRef(new FakeTiledLayerChromium(m_textureManager.get()));
     OwnPtr<FakeCCTiledLayerImpl> layerImpl1(adoptPtr(new FakeCCTiledLayerImpl(1)));
-    RefPtr<FakeTiledLayerChromium> layer2 = adoptRef(new FakeTiledLayerChromium(textureManager.get()));
+    RefPtr<FakeTiledLayerChromium> layer2 = adoptRef(new FakeTiledLayerChromium(m_textureManager.get()));
     OwnPtr<FakeCCTiledLayerImpl> layerImpl2(adoptPtr(new FakeCCTiledLayerImpl(2)));
 
     // For this test we have two layers. layer1 exhausts most texture memory, leaving room for 2 more tiles from
     // layer2, but not all three tiles. First we paint layer1, and one tile from layer2. Then when we idle paint
     // layer2, we will fail on the third tile of layer2, and this should not leave the second tile in a bad state.
 
+    // This uses 960000 bytes, leaving 88576 bytes of memory left, which is enough for 2 tiles only in the other layer.
+    IntRect layer1Rect(0, 0, 100, 2400);
+    
     // This requires 4*30000 bytes of memory.
     IntRect layer2Rect(0, 0, 100, 300);
-    layer2->setBounds(layer2Rect.size());
-    layer2->setVisibleContentRect(layer2Rect);
-    layer2->invalidateContentRect(layer2Rect);
-
-    // This uses 960000 bytes, leaving 88576 bytes of memory left, which is enough for 2 tiles only in the other layer.
-    IntRect layerRect(IntPoint::zero(), IntSize(100, 2400));
-    layer1->setBounds(layerRect.size());
-    layer1->setVisibleContentRect(layerRect);
-    layer1->invalidateContentRect(layerRect);
 
     // Paint a single tile in layer2 so that it will idle paint.
-    layer2->setTexturePriorities(m_priorityCalculator);
-    layer1->setTexturePriorities(m_priorityCalculator);
-    textureManager->prioritizeTextures();
-    layer1->updateContentRect(m_queue, layerRect, 0, m_stats);
-    layer2->updateContentRect(m_queue, IntRect(0, 0, 100, 100), 0, m_stats);
-
+    layer1->setBounds(layer1Rect.size());
+    layer1->setVisibleContentRect(layer1Rect);
+    layer2->setBounds(layer2Rect.size());
+    layer2->setVisibleContentRect(IntRect(0, 0, 100, 100));
+    bool needsUpdate = updateAndPush(layer1.get(), layerImpl1.get(),
+                                     layer2.get(), layerImpl2.get());
     // We should need idle-painting for both remaining tiles in layer2.
-    EXPECT_TRUE(layer2->needsIdlePaint(layer2Rect));
-
-    // Commit the frame over to impl.
-    updateTextures();
-    layer1->pushPropertiesTo(layerImpl1.get());
-    layer2->pushPropertiesTo(layerImpl2.get());
+    EXPECT_TRUE(needsUpdate);
 
     // Reduce our memory limits to 1mb.
-    textureManager->setMaxMemoryLimitBytes(1024 * 1024);
+    m_textureManager->setMaxMemoryLimitBytes(1024 * 1024);
 
     // Now idle paint layer2. We are going to run out of memory though!
-    layer2->setTexturePriorities(m_priorityCalculator);
-    layer1->setTexturePriorities(m_priorityCalculator);
-    textureManager->prioritizeTextures();
-    layer2->updateContentRect(m_queue, IntRect(0, 0, 100, 100), 0, m_stats);
-
     // Oh well, commit the frame and push.
-    updateTextures();
-    layer1->pushPropertiesTo(layerImpl1.get());
-    layer2->pushPropertiesTo(layerImpl2.get());
+    for (int i = 0; i < 4; i++) {
+        needsUpdate = updateAndPush(layer1.get(), layerImpl1.get(),
+                                    layer2.get(), layerImpl2.get());
+    }
 
     // Sanity check, we should have textures for the big layer.
     EXPECT_TRUE(layerImpl1->hasTextureIdForTileAt(0, 0));
+    EXPECT_TRUE(layerImpl1->hasTextureIdForTileAt(0, 23));
 
-    // We should only have the first tile from layer2 since it failed to idle update.
+    // We should only have the first two tiles from layer2 since
+    // it failed to idle update the last tile.
     EXPECT_TRUE(layerImpl2->hasTileAt(0, 0));
     EXPECT_TRUE(layerImpl2->hasTextureIdForTileAt(0, 0));
-    EXPECT_FALSE(layerImpl2->hasTileAt(0, 1));
-    EXPECT_FALSE(layerImpl2->hasTileAt(0, 2));
-
-    // Now if layer2 becomes fully visible, we should be able to paint it and push valid textures.
-    layer2->setTexturePriorities(m_priorityCalculator);
-    layer1->setTexturePriorities(m_priorityCalculator);
-    textureManager->prioritizeTextures();
-    layer2->updateContentRect(m_queue, layer2Rect, 0, m_stats);
-    layer1->updateContentRect(m_queue, layerRect, 0, m_stats);
-
-    updateTextures();
-    layer1->pushPropertiesTo(layerImpl1.get());
-    layer2->pushPropertiesTo(layerImpl2.get());
-
-    EXPECT_TRUE(layerImpl2->hasTileAt(0, 0));
     EXPECT_TRUE(layerImpl2->hasTileAt(0, 1));
-    EXPECT_TRUE(layerImpl2->hasTileAt(0, 2));
-    EXPECT_TRUE(layerImpl2->hasTextureIdForTileAt(0, 0));
     EXPECT_TRUE(layerImpl2->hasTextureIdForTileAt(0, 1));
-    EXPECT_TRUE(layerImpl2->hasTextureIdForTileAt(0, 2));
+    
+    EXPECT_FALSE(needsUpdate);
+    EXPECT_FALSE(layerImpl2->hasTileAt(0, 2));
 }
 
 TEST_F(TiledLayerChromiumTest, pushIdlePaintedOccludedTiles)
 {
-    OwnPtr<CCPrioritizedTextureManager> textureManager = CCPrioritizedTextureManager::create(4*1024*1024, 1024, CCRenderer::ContentPool);
-    RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get()));
+    RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m_textureManager.get()));
     DebugScopedSetImplThread implThread;
     OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1)));
     TestCCOcclusionTracker occluded;
-
+    m_occlusion = &occluded;
+    
     // The tile size is 100x100, so this invalidates one occluded tile, culls it during paint, but prepaints it.
     occluded.setOcclusion(IntRect(0, 0, 100, 100));
 
     layer->setBounds(IntSize(100, 100));
     layer->setVisibleContentRect(IntRect(0, 0, 100, 100));
-    layer->invalidateContentRect(IntRect(0, 0, 100, 100));
+    updateAndPush(layer.get(), layerImpl.get());
 
-    layer->setTexturePriorities(m_priorityCalculator);
-    textureManager->prioritizeTextures();
-    layer->updateContentRect(m_queue, IntRect(0, 0, 100, 100), &occluded, m_stats);
-    updateTextures();
-    layer->pushPropertiesTo(layerImpl.get());
-
-    // We should have the prepainted tile on the impl side.
+    // We should have the prepainted tile on the impl side, but culled it during paint.
     EXPECT_TRUE(layerImpl->hasTileAt(0, 0));
+    EXPECT_EQ(1, occluded.overdrawMetrics().tilesCulledForUpload());
 }
 
 TEST_F(TiledLayerChromiumTest, pushTilesMarkedDirtyDuringPaint)
 {
-    OwnPtr<CCPrioritizedTextureManager> textureManager = CCPrioritizedTextureManager::create(4*1024*1024, 1024, CCRenderer::ContentPool);
-    RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get()));
+    RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m_textureManager.get()));
     DebugScopedSetImplThread implThread;
     OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1)));
 
     // The tile size is 100x100, so this invalidates and then paints two tiles.
     // However, during the paint, we invalidate one of the tiles. This should
     // not prevent the tile from being pushed.
-    layer->setBounds(IntSize(100, 200));
-    layer->invalidateContentRect(IntRect(0, 0, 100, 200));
-    layer->setVisibleContentRect(IntRect(0, 0, 100, 200));
     layer->fakeLayerTextureUpdater()->setRectToInvalidate(IntRect(0, 50, 100, 50), layer.get());
-
-    layer->setTexturePriorities(m_priorityCalculator);
-    textureManager->prioritizeTextures();
-    layer->updateContentRect(m_queue, IntRect(0, 0, 100, 200), 0, m_stats);
-    updateTextures();
-    layer->pushPropertiesTo(layerImpl.get());
+    layer->setBounds(IntSize(100, 200));
+    layer->setVisibleContentRect(IntRect(0, 0, 100, 200));    
+    updateAndPush(layer.get(), layerImpl.get());
 
     // We should have both tiles on the impl side.
     EXPECT_TRUE(layerImpl->hasTileAt(0, 0));
@@ -425,34 +375,20 @@ TEST_F(TiledLayerChromiumTest, pushTilesMarkedDirtyDuringPaint)
 
 TEST_F(TiledLayerChromiumTest, pushTilesLayerMarkedDirtyDuringPaintOnNextLayer)
 {
-    OwnPtr<CCPrioritizedTextureManager> textureManager = CCPrioritizedTextureManager::create(4*1024*1024, 1024, CCRenderer::ContentPool);
-    RefPtr<FakeTiledLayerChromium> layer1 = adoptRef(new FakeTiledLayerChromium(textureManager.get()));
-    RefPtr<FakeTiledLayerChromium> layer2 = adoptRef(new FakeTiledLayerChromium(textureManager.get()));
+    RefPtr<FakeTiledLayerChromium> layer1 = adoptRef(new FakeTiledLayerChromium(m_textureManager.get()));
+    RefPtr<FakeTiledLayerChromium> layer2 = adoptRef(new FakeTiledLayerChromium(m_textureManager.get()));
     DebugScopedSetImplThread implThread;
     OwnPtr<FakeCCTiledLayerImpl> layer1Impl(adoptPtr(new FakeCCTiledLayerImpl(1)));
     OwnPtr<FakeCCTiledLayerImpl> layer2Impl(adoptPtr(new FakeCCTiledLayerImpl(2)));
 
+    // Invalidate a tile on layer1, during update of layer 2.
+    layer2->fakeLayerTextureUpdater()->setRectToInvalidate(IntRect(0, 50, 100, 50), layer1.get());
     layer1->setBounds(IntSize(100, 200));
-    layer1->setVisibleContentRect(IntRect(0, 0, 100, 200));
-    layer1->invalidateContentRect(IntRect(0, 0, 100, 200));
-
+    layer1->setVisibleContentRect(IntRect(0, 0, 100, 200));    
     layer2->setBounds(IntSize(100, 200));
-    layer2->setVisibleContentRect(IntRect(0, 0, 100, 200));
-    layer2->invalidateContentRect(IntRect(0, 0, 100, 200));
-
-    layer1->setTexturePriorities(m_priorityCalculator);
-    layer2->setTexturePriorities(m_priorityCalculator);
-    textureManager->prioritizeTextures();
-
-    layer1->updateContentRect(m_queue, IntRect(0, 0, 100, 200), 0, m_stats);
-
-    // Invalidate a tile on layer1
-    layer2->fakeLayerTextureUpdater()->setRectToInvalidate(IntRect(0, 50, 100, 50), layer1.get());
-    layer2->updateContentRect(m_queue, IntRect(0, 0, 100, 200), 0, m_stats);
-
-    updateTextures();
-    layer1->pushPropertiesTo(layer1Impl.get());
-    layer2->pushPropertiesTo(layer2Impl.get());
+    layer2->setVisibleContentRect(IntRect(0, 0, 100, 200));    
+    updateAndPush(layer1.get(), layer1Impl.get(),
+                  layer2.get(), layer2Impl.get());
 
     // We should have both tiles on the impl side for all layers.
     EXPECT_TRUE(layer1Impl->hasTileAt(0, 0));
@@ -463,32 +399,19 @@ TEST_F(TiledLayerChromiumTest, pushTilesLayerMarkedDirtyDuringPaintOnNextLayer)
 
 TEST_F(TiledLayerChromiumTest, pushTilesLayerMarkedDirtyDuringPaintOnPreviousLayer)
 {
-    OwnPtr<CCPrioritizedTextureManager> textureManager = CCPrioritizedTextureManager::create(4*1024*1024, 1024, CCRenderer::ContentPool);
-    RefPtr<FakeTiledLayerChromium> layer1 = adoptRef(new FakeTiledLayerChromium(textureManager.get()));
-    RefPtr<FakeTiledLayerChromium> layer2 = adoptRef(new FakeTiledLayerChromium(textureManager.get()));
+    RefPtr<FakeTiledLayerChromium> layer1 = adoptRef(new FakeTiledLayerChromium(m_textureManager.get()));
+    RefPtr<FakeTiledLayerChromium> layer2 = adoptRef(new FakeTiledLayerChromium(m_textureManager.get()));
     DebugScopedSetImplThread implThread;
     OwnPtr<FakeCCTiledLayerImpl> layer1Impl(adoptPtr(new FakeCCTiledLayerImpl(1)));
     OwnPtr<FakeCCTiledLayerImpl> layer2Impl(adoptPtr(new FakeCCTiledLayerImpl(2)));
 
+    layer1->fakeLayerTextureUpdater()->setRectToInvalidate(IntRect(0, 50, 100, 50), layer2.get());
     layer1->setBounds(IntSize(100, 200));
-    layer1->setVisibleContentRect(IntRect(0, 0, 100, 200));
-    layer1->invalidateContentRect(IntRect(0, 0, 100, 200));
-
+    layer1->setVisibleContentRect(IntRect(0, 0, 100, 200));    
     layer2->setBounds(IntSize(100, 200));
-    layer2->setVisibleContentRect(IntRect(0, 0, 100, 200));
-    layer2->invalidateContentRect(IntRect(0, 0, 100, 200));
-
-    layer1->setTexturePriorities(m_priorityCalculator);
-    layer2->setTexturePriorities(m_priorityCalculator);
-    textureManager->prioritizeTextures();
-
-    // Invalidate a tile on layer2
-    layer1->fakeLayerTextureUpdater()->setRectToInvalidate(IntRect(0, 50, 100, 50), layer2.get());
-    layer1->updateContentRect(m_queue, IntRect(0, 0, 100, 200), 0, m_stats);
-    layer2->updateContentRect(m_queue, IntRect(0, 0, 100, 200), 0, m_stats);
-    updateTextures();
-    layer1->pushPropertiesTo(layer1Impl.get());
-    layer2->pushPropertiesTo(layer2Impl.get());
+    layer2->setVisibleContentRect(IntRect(0, 0, 100, 200));    
+    updateAndPush(layer1.get(), layer1Impl.get(),
+                  layer2.get(), layer2Impl.get());
 
     // We should have both tiles on the impl side for all layers.
     EXPECT_TRUE(layer1Impl->hasTileAt(0, 0));
@@ -518,10 +441,10 @@ TEST_F(TiledLayerChromiumTest, paintSmallAnimatedLayersImmediately)
         if (runOutOfMemory[i])
             layerWidth *= 2;
 
-        OwnPtr<CCPrioritizedTextureManager> textureManager = CCPrioritizedTextureManager::create(memoryForLayer, 1024, CCRenderer::ContentPool);
+        m_textureManager->setMaxMemoryLimitBytes(memoryForLayer);
         DebugScopedSetImplThread implThread;
 
-        RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get()));
+        RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m_textureManager.get()));
         OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1)));
 
         // Full size layer with half being visible.
@@ -539,8 +462,8 @@ TEST_F(TiledLayerChromiumTest, paintSmallAnimatedLayersImmediately)
         // The layer should paint it's entire contents on the first paint
         // if it is close to the viewport size and has the available memory.
         layer->setTexturePriorities(m_priorityCalculator);
-        textureManager->prioritizeTextures();
-        layer->updateContentRect(m_queue, visibleRect, 0, m_stats);
+        m_textureManager->prioritizeTextures();
+        layer->update(m_queue, 0, m_stats);
         updateTextures();
         layer->pushPropertiesTo(layerImpl.get());
 
@@ -565,49 +488,31 @@ TEST_F(TiledLayerChromiumTest, paintSmallAnimatedLayersImmediately)
 
 TEST_F(TiledLayerChromiumTest, idlePaintOutOfMemory)
 {
-    // The tile size is 100x100. Setup 3x3 tiles with one 1x1 visible tile in the center.
-    IntSize contentBounds(300, 300);
-    IntRect contentRect(IntPoint::zero(), contentBounds);
-    IntRect visibleRect(100, 100, 100, 100);
-
-    // We have enough memory for only the visible rect, so we will run out of memory in first idle paint.
-    int memoryLimit = 4 * 100 * 100; // 1 tiles, 4 bytes per pixel.
-
-    OwnPtr<CCPrioritizedTextureManager> textureManager = CCPrioritizedTextureManager::create(memoryLimit, 1024, CCRenderer::ContentPool);
-    RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get()));
+    RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m_textureManager.get()));
     DebugScopedSetImplThread implThread;
     OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1)));
 
-    // Invalidates 9 tiles and then paints one visible tile.
-    layer->setBounds(contentBounds);
-    layer->setVisibleContentRect(visibleRect);
-    layer->invalidateContentRect(contentRect);
+    // We have enough memory for only the visible rect, so we will run out of memory in first idle paint.
+    int memoryLimit = 4 * 100 * 100; // 1 tiles, 4 bytes per pixel.
+    m_textureManager->setMaxMemoryLimitBytes(memoryLimit);
 
-    layer->setTexturePriorities(m_priorityCalculator);
-    textureManager->prioritizeTextures();
-    layer->updateContentRect(m_queue, visibleRect, 0, m_stats);
+    // The tile size is 100x100, so this invalidates and then paints two tiles.
+    bool needsUpdate = false;
+    layer->setBounds(IntSize(300, 300));
+    layer->setVisibleContentRect(IntRect(100, 100, 100, 100));
+    for (int i = 0; i < 2; i++)
+        needsUpdate = updateAndPush(layer.get(), layerImpl.get());
 
     // Idle-painting should see no more priority tiles for painting.
-    EXPECT_FALSE(layer->needsIdlePaint(visibleRect));
-
-    updateTextures();
-    layer->pushPropertiesTo(layerImpl.get());
+    EXPECT_FALSE(needsUpdate);
 
     // We should have one tile on the impl side.
     EXPECT_TRUE(layerImpl->hasTileAt(1, 1));
-
-    layer->setTexturePriorities(m_priorityCalculator);
-    textureManager->prioritizeTextures();
-    layer->updateContentRect(m_queue, visibleRect, 0, m_stats);
-
-    // We shouldn't signal we need another idle paint.
-    EXPECT_FALSE(layer->needsIdlePaint(visibleRect));
 }
 
 TEST_F(TiledLayerChromiumTest, idlePaintZeroSizedLayer)
 {
-    OwnPtr<CCPrioritizedTextureManager> textureManager = CCPrioritizedTextureManager::create(20000, 1024, CCRenderer::ContentPool);
-    RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get()));
+    RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m_textureManager.get()));
     DebugScopedSetImplThread implThread;
     OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1)));
 
@@ -617,25 +522,16 @@ TEST_F(TiledLayerChromiumTest, idlePaintZeroSizedLayer)
         layer->setDrawTransformIsAnimating(animating[i]);
 
         // The layer's bounds are empty.
-        IntRect contentRect;
-
-        layer->setBounds(contentRect.size());
-        layer->setVisibleContentRect(contentRect);
-        layer->invalidateContentRect(contentRect);
-
-        layer->setTexturePriorities(m_priorityCalculator);
-        textureManager->prioritizeTextures();
-
         // Empty layers don't paint or idle-paint.
-        layer->updateContentRect(m_queue, contentRect, 0, m_stats);
-
+        layer->setBounds(IntSize());
+        layer->setVisibleContentRect(IntRect());
+        bool needsUpdate = updateAndPush(layer.get(), layerImpl.get());
+        
         // Empty layers don't have tiles.
         EXPECT_EQ(0u, layer->numPaintedTiles());
 
         // Empty layers don't need prepaint.
-        EXPECT_FALSE(layer->needsIdlePaint(contentRect));
-
-        layer->pushPropertiesTo(layerImpl.get());
+        EXPECT_FALSE(needsUpdate);
 
         // Empty layers don't have tiles.
         EXPECT_FALSE(layerImpl->hasTileAt(0, 0));
@@ -644,14 +540,9 @@ TEST_F(TiledLayerChromiumTest, idlePaintZeroSizedLayer)
 
 TEST_F(TiledLayerChromiumTest, idlePaintNonVisibleLayers)
 {
-    IntSize contentBounds(100, 100);
-    IntRect contentRect(IntPoint::zero(), contentBounds);
-
-    OwnPtr<CCPrioritizedTextureManager> textureManager = CCPrioritizedTextureManager::create(4*1024*1024, 1024, CCRenderer::ContentPool);
-    RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get()));
+    RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m_textureManager.get()));
     DebugScopedSetImplThread implThread;
     OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1)));
-    layer->setBounds(contentBounds);
 
     // Alternate between not visible and visible.
     IntRect v(0, 0, 100, 100);
@@ -662,71 +553,53 @@ TEST_F(TiledLayerChromiumTest, idlePaintNonVisibleLayers)
     // We should not have any tiles except for when the layer was visible
     // or after the layer was visible and we didn't invalidate.
     bool haveTile[10] = { false, false, true, true, false, false, true, true, true, true };
-
+    
     for (int i = 0; i < 10; i++) {
+        layer->setBounds(IntSize(100, 100));
         layer->setVisibleContentRect(visibleRect[i]);
 
-        // Skip invalidation once to insure the tile stays in memory while not visible.
         if (invalidate[i])
-            layer->invalidateContentRect(contentRect);
-
-        // Paint / idle-paint.
-        textureManager->clearPriorities();
-        layer->setTexturePriorities(m_priorityCalculator);
-        textureManager->prioritizeTextures();
-        layer->updateContentRect(m_queue, visibleRect[i], 0, m_stats);
-
-        updateTextures();
-
+            layer->invalidateContentRect(IntRect(0, 0, 100, 100));
+        bool needsUpdate = updateAndPush(layer.get(), layerImpl.get());
+        
         // We should never signal idle paint, as we painted the entire layer
         // or the layer was not visible.
-        EXPECT_FALSE(layer->needsIdlePaint(visibleRect[i]));
-
-        layer->pushPropertiesTo(layerImpl.get());
+        EXPECT_FALSE(needsUpdate);
         EXPECT_EQ(layerImpl->hasTileAt(0, 0), haveTile[i]);
     }
 }
 
-
 TEST_F(TiledLayerChromiumTest, invalidateFromPrepare)
 {
-    OwnPtr<CCPrioritizedTextureManager> textureManager = CCPrioritizedTextureManager::create(4*1024*1024, 1024, CCRenderer::ContentPool);
-    RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get()));
+    RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m_textureManager.get()));
     DebugScopedSetImplThread implThread;
     OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1)));
 
     // The tile size is 100x100, so this invalidates and then paints two tiles.
     layer->setBounds(IntSize(100, 200));
     layer->setVisibleContentRect(IntRect(0, 0, 100, 200));
-    layer->invalidateContentRect(IntRect(0, 0, 100, 200));
-    layer->setTexturePriorities(m_priorityCalculator);
-    textureManager->prioritizeTextures();
-    layer->updateContentRect(m_queue, IntRect(0, 0, 100, 200), 0, m_stats);
-    updateTextures(1000);
-    layer->pushPropertiesTo(layerImpl.get());
+    updateAndPush(layer.get(), layerImpl.get());
 
     // We should have both tiles on the impl side.
     EXPECT_TRUE(layerImpl->hasTileAt(0, 0));
     EXPECT_TRUE(layerImpl->hasTileAt(0, 1));
 
     layer->fakeLayerTextureUpdater()->clearPrepareCount();
-    // Invoke updateContentRect again. As the layer is valid updateContentRect shouldn't be invoked on
+    // Invoke update again. As the layer is valid update shouldn't be invoked on
     // the LayerTextureUpdater.
-    layer->updateContentRect(m_queue, IntRect(0, 0, 100, 200), 0, m_stats);
-    updateTextures(1000);
+    updateAndPush(layer.get(), layerImpl.get());
     EXPECT_EQ(0, layer->fakeLayerTextureUpdater()->prepareCount());
 
-    layer->invalidateContentRect(IntRect(0, 0, 50, 50));
-    // setRectToInvalidate triggers invalidateContentRect() being invoked from updateContentRect.
+    // setRectToInvalidate triggers invalidateContentRect() being invoked from update.
     layer->fakeLayerTextureUpdater()->setRectToInvalidate(IntRect(25, 25, 50, 50), layer.get());
     layer->fakeLayerTextureUpdater()->clearPrepareCount();
-    layer->updateContentRect(m_queue, IntRect(0, 0, 100, 200), 0, m_stats);
-    updateTextures(1000);
+    layer->invalidateContentRect(IntRect(0, 0, 50, 50));
+    updateAndPush(layer.get(), layerImpl.get());
     EXPECT_EQ(1, layer->fakeLayerTextureUpdater()->prepareCount());
     layer->fakeLayerTextureUpdater()->clearPrepareCount();
-    // The layer should still be invalid as updateContentRect invoked invalidate.
-    layer->updateContentRect(m_queue, IntRect(0, 0, 100, 200), 0, m_stats);
-    updateTextures(1000);
+
+    // The layer should still be invalid as update invoked invalidate.
+    updateAndPush(layer.get(), layerImpl.get()); // visible
     EXPECT_EQ(1, layer->fakeLayerTextureUpdater()->prepareCount());
 }
 
@@ -734,9 +607,7 @@ TEST_F(TiledLayerChromiumTest, verifyUpdateRectWhenContentBoundsAreScaled)
 {
     // The updateRect (that indicates what was actually painted) should be in
     // layer space, not the content space.
-
-    OwnPtr<CCPrioritizedTextureManager> textureManager = CCPrioritizedTextureManager::create(4*1024*1024, 1024, CCRenderer::ContentPool);
-    RefPtr<FakeTiledLayerWithScaledBounds> layer = adoptRef(new FakeTiledLayerWithScaledBounds(textureManager.get()));
+    RefPtr<FakeTiledLayerWithScaledBounds> layer = adoptRef(new FakeTiledLayerWithScaledBounds(m_textureManager.get()));
     DebugScopedSetImplThread implThread;
 
     IntRect layerBounds(0, 0, 300, 200);
@@ -751,16 +622,16 @@ TEST_F(TiledLayerChromiumTest, verifyUpdateRectWhenContentBoundsAreScaled)
     layer->invalidateContentRect(contentBounds);
 
     layer->setTexturePriorities(m_priorityCalculator);
-    textureManager->prioritizeTextures();
-    layer->updateContentRect(m_queue, contentBounds, 0, m_stats);
+    m_textureManager->prioritizeTextures();
+    layer->update(m_queue, 0, m_stats);
     EXPECT_FLOAT_RECT_EQ(FloatRect(0, 0, 300, 300 * 0.8), layer->updateRect());
     updateTextures();
 
     // After the tiles are updated once, another invalidate only needs to update the bounds of the layer.
     layer->setTexturePriorities(m_priorityCalculator);
-    textureManager->prioritizeTextures();
+    m_textureManager->prioritizeTextures();
     layer->invalidateContentRect(contentBounds);
-    layer->updateContentRect(m_queue, contentBounds, 0, m_stats);
+    layer->update(m_queue, 0, m_stats);
     EXPECT_FLOAT_RECT_EQ(FloatRect(layerBounds), layer->updateRect());
     updateTextures();
 
@@ -768,15 +639,14 @@ TEST_F(TiledLayerChromiumTest, verifyUpdateRectWhenContentBoundsAreScaled)
     IntRect partialDamage(30, 100, 10, 10);
     layer->invalidateContentRect(partialDamage);
     layer->setTexturePriorities(m_priorityCalculator);
-    textureManager->prioritizeTextures();
-    layer->updateContentRect(m_queue, contentBounds, 0, m_stats);
+    m_textureManager->prioritizeTextures();
+    layer->update(m_queue, 0, m_stats);
     EXPECT_FLOAT_RECT_EQ(FloatRect(45, 80, 15, 8), layer->updateRect());
 }
 
 TEST_F(TiledLayerChromiumTest, verifyInvalidationWhenContentsScaleChanges)
 {
-    OwnPtr<CCPrioritizedTextureManager> textureManager = CCPrioritizedTextureManager::create(4*1024*1024, 1024, CCRenderer::ContentPool);
-    RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get()));
+    RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m_textureManager.get()));
     DebugScopedSetImplThread implThread;
     OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1)));
 
@@ -790,8 +660,8 @@ TEST_F(TiledLayerChromiumTest, verifyInvalidationWhenContentsScaleChanges)
 
     // Push the tiles to the impl side and check that there is exactly one.
     layer->setTexturePriorities(m_priorityCalculator);
-    textureManager->prioritizeTextures();
-    layer->updateContentRect(m_queue, IntRect(0, 0, 100, 100), 0, m_stats);
+    m_textureManager->prioritizeTextures();
+    layer->update(m_queue, 0, m_stats);
     updateTextures();
     layer->pushPropertiesTo(layerImpl.get());
     EXPECT_TRUE(layerImpl->hasTileAt(0, 0));
@@ -807,8 +677,8 @@ TEST_F(TiledLayerChromiumTest, verifyInvalidationWhenContentsScaleChanges)
 
     // The impl side should get 2x2 tiles now.
     layer->setTexturePriorities(m_priorityCalculator);
-    textureManager->prioritizeTextures();
-    layer->updateContentRect(m_queue, IntRect(0, 0, 200, 200), 0, m_stats);
+    m_textureManager->prioritizeTextures();
+    layer->update(m_queue, 0, m_stats);
     updateTextures();
     layer->pushPropertiesTo(layerImpl.get());
     EXPECT_TRUE(layerImpl->hasTileAt(0, 0));
@@ -820,8 +690,7 @@ TEST_F(TiledLayerChromiumTest, verifyInvalidationWhenContentsScaleChanges)
     // impl side.
     layer->setNeedsDisplay();
     layer->setTexturePriorities(m_priorityCalculator);
-    layer->updateContentRect(m_queue, IntRect(1, 0, 0, 1), 0, m_stats);
-    textureManager->prioritizeTextures();
+    m_textureManager->prioritizeTextures();
 
     layer->pushPropertiesTo(layerImpl.get());
     EXPECT_FALSE(layerImpl->hasTileAt(0, 0));
@@ -883,16 +752,15 @@ TEST_F(TiledLayerChromiumTest, skipsDrawGetsReset)
 
 TEST_F(TiledLayerChromiumTest, resizeToSmaller)
 {
-    OwnPtr<CCPrioritizedTextureManager> textureManager = CCPrioritizedTextureManager::create(60*1024*1024, 1024, CCRenderer::ContentPool);
-    RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get()));
+    RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m_textureManager.get()));
 
     layer->setBounds(IntSize(700, 700));
     layer->setVisibleContentRect(IntRect(0, 0, 700, 700));
     layer->invalidateContentRect(IntRect(0, 0, 700, 700));
 
     layer->setTexturePriorities(m_priorityCalculator);
-    textureManager->prioritizeTextures();
-    layer->updateContentRect(m_queue, IntRect(0, 0, 700, 700), 0, m_stats);
+    m_textureManager->prioritizeTextures();
+    layer->update(m_queue, 0, m_stats);
 
     layer->setBounds(IntSize(200, 200));
     layer->invalidateContentRect(IntRect(0, 0, 200, 200));
@@ -900,8 +768,7 @@ TEST_F(TiledLayerChromiumTest, resizeToSmaller)
 
 TEST_F(TiledLayerChromiumTest, hugeLayerUpdateCrash)
 {
-    OwnPtr<CCPrioritizedTextureManager> textureManager = CCPrioritizedTextureManager::create(60*1024*1024, 1024, CCRenderer::ContentPool);
-    RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get()));
+    RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m_textureManager.get()));
 
     int size = 1 << 30;
     layer->setBounds(IntSize(size, size));
@@ -910,8 +777,8 @@ TEST_F(TiledLayerChromiumTest, hugeLayerUpdateCrash)
 
     // Ensure no crash for bounds where size * size would overflow an int.
     layer->setTexturePriorities(m_priorityCalculator);
-    textureManager->prioritizeTextures();
-    layer->updateContentRect(m_queue, IntRect(0, 0, 700, 700), 0, m_stats);
+    m_textureManager->prioritizeTextures();
+    layer->update(m_queue, 0, m_stats);
 }
 
 TEST_F(TiledLayerChromiumTest, partialUpdates)
@@ -1044,8 +911,7 @@ TEST_F(TiledLayerChromiumTest, partialUpdates)
 
 TEST_F(TiledLayerChromiumTest, tilesPaintedWithoutOcclusion)
 {
-    OwnPtr<CCPrioritizedTextureManager> textureManager = CCPrioritizedTextureManager::create(4*1024*1024, 1024, CCRenderer::ContentPool);
-    RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get()));
+    RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m_textureManager.get()));
 
     // The tile size is 100x100, so this invalidates and then paints two tiles.
     layer->setBounds(IntSize(100, 200));
@@ -1054,15 +920,14 @@ TEST_F(TiledLayerChromiumTest, tilesPaintedWithoutOcclusion)
     layer->invalidateContentRect(IntRect(0, 0, 100, 200));
 
     layer->setTexturePriorities(m_priorityCalculator);
-    textureManager->prioritizeTextures();
-    layer->updateContentRect(m_queue, IntRect(0, 0, 100, 200), 0, m_stats);
+    m_textureManager->prioritizeTextures();
+    layer->update(m_queue, 0, m_stats);
     EXPECT_EQ(2, layer->fakeLayerTextureUpdater()->prepareRectCount());
 }
 
 TEST_F(TiledLayerChromiumTest, tilesPaintedWithOcclusion)
 {
-    OwnPtr<CCPrioritizedTextureManager> textureManager = CCPrioritizedTextureManager::create(4*1024*1024, 1024, CCRenderer::ContentPool);
-    RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get()));
+    RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m_textureManager.get()));
     TestCCOcclusionTracker occluded;
 
     // The tile size is 100x100.
@@ -1075,8 +940,8 @@ TEST_F(TiledLayerChromiumTest, tilesPaintedWithOcclusion)
     layer->invalidateContentRect(IntRect(0, 0, 600, 600));
 
     layer->setTexturePriorities(m_priorityCalculator);
-    textureManager->prioritizeTextures();
-    layer->updateContentRect(m_queue, IntRect(0, 0, 600, 600), &occluded, m_stats);
+    m_textureManager->prioritizeTextures();
+    layer->update(m_queue, &occluded, m_stats);
     EXPECT_EQ(36-3, layer->fakeLayerTextureUpdater()->prepareRectCount());
 
     EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1);
@@ -1085,11 +950,11 @@ TEST_F(TiledLayerChromiumTest, tilesPaintedWithOcclusion)
 
     layer->fakeLayerTextureUpdater()->clearPrepareRectCount();
     layer->setTexturePriorities(m_priorityCalculator);
-    textureManager->prioritizeTextures();
+    m_textureManager->prioritizeTextures();
 
     occluded.setOcclusion(IntRect(250, 200, 300, 100));
     layer->invalidateContentRect(IntRect(0, 0, 600, 600));
-    layer->updateContentRect(m_queue, IntRect(0, 0, 600, 600), &occluded, m_stats);
+    layer->update(m_queue, &occluded, m_stats);
     EXPECT_EQ(36-2, layer->fakeLayerTextureUpdater()->prepareRectCount());
 
     EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1);
@@ -1098,11 +963,11 @@ TEST_F(TiledLayerChromiumTest, tilesPaintedWithOcclusion)
 
     layer->fakeLayerTextureUpdater()->clearPrepareRectCount();
     layer->setTexturePriorities(m_priorityCalculator);
-    textureManager->prioritizeTextures();
+    m_textureManager->prioritizeTextures();
 
     occluded.setOcclusion(IntRect(250, 250, 300, 100));
     layer->invalidateContentRect(IntRect(0, 0, 600, 600));
-    layer->updateContentRect(m_queue, IntRect(0, 0, 600, 600), &occluded, m_stats);
+    layer->update(m_queue, &occluded, m_stats);
     EXPECT_EQ(36, layer->fakeLayerTextureUpdater()->prepareRectCount());
 
     EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1);
@@ -1112,8 +977,7 @@ TEST_F(TiledLayerChromiumTest, tilesPaintedWithOcclusion)
 
 TEST_F(TiledLayerChromiumTest, tilesPaintedWithOcclusionAndVisiblityConstraints)
 {
-    OwnPtr<CCPrioritizedTextureManager> textureManager = CCPrioritizedTextureManager::create(4*1024*1024, 1024, CCRenderer::ContentPool);
-    RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get()));
+    RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m_textureManager.get()));
     TestCCOcclusionTracker occluded;
 
     // The tile size is 100x100.
@@ -1127,8 +991,8 @@ TEST_F(TiledLayerChromiumTest, tilesPaintedWithOcclusionAndVisiblityConstraints)
     layer->invalidateContentRect(IntRect(0, 0, 600, 600));
 
     layer->setTexturePriorities(m_priorityCalculator);
-    textureManager->prioritizeTextures();
-    layer->updateContentRect(m_queue, IntRect(0, 0, 600, 360), &occluded, m_stats);
+    m_textureManager->prioritizeTextures();
+    layer->update(m_queue, &occluded, m_stats);
     EXPECT_EQ(24-3, layer->fakeLayerTextureUpdater()->prepareRectCount());
 
     EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1);
@@ -1143,8 +1007,8 @@ TEST_F(TiledLayerChromiumTest, tilesPaintedWithOcclusionAndVisiblityConstraints)
     layer->setVisibleContentRect(IntRect(0, 0, 600, 350));
     layer->invalidateContentRect(IntRect(0, 0, 600, 600));
     layer->setTexturePriorities(m_priorityCalculator);
-    textureManager->prioritizeTextures();
-    layer->updateContentRect(m_queue, IntRect(0, 0, 600, 350), &occluded, m_stats);
+    m_textureManager->prioritizeTextures();
+    layer->update(m_queue, &occluded, m_stats);
     EXPECT_EQ(24-6, layer->fakeLayerTextureUpdater()->prepareRectCount());
 
     EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1);
@@ -1159,8 +1023,8 @@ TEST_F(TiledLayerChromiumTest, tilesPaintedWithOcclusionAndVisiblityConstraints)
     layer->setVisibleContentRect(IntRect(0, 0, 600, 340));
     layer->invalidateContentRect(IntRect(0, 0, 600, 600));
     layer->setTexturePriorities(m_priorityCalculator);
-    textureManager->prioritizeTextures();
-    layer->updateContentRect(m_queue, IntRect(0, 0, 600, 340), &occluded, m_stats);
+    m_textureManager->prioritizeTextures();
+    layer->update(m_queue, &occluded, m_stats);
     EXPECT_EQ(24-6, layer->fakeLayerTextureUpdater()->prepareRectCount());
 
     EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1);
@@ -1171,8 +1035,7 @@ TEST_F(TiledLayerChromiumTest, tilesPaintedWithOcclusionAndVisiblityConstraints)
 
 TEST_F(TiledLayerChromiumTest, tilesNotPaintedWithoutInvalidation)
 {
-    OwnPtr<CCPrioritizedTextureManager> textureManager = CCPrioritizedTextureManager::create(4*1024*1024, 1024, CCRenderer::ContentPool);
-    RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get()));
+    RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m_textureManager.get()));
     TestCCOcclusionTracker occluded;
 
     // The tile size is 100x100.
@@ -1184,8 +1047,8 @@ TEST_F(TiledLayerChromiumTest, tilesNotPaintedWithoutInvalidation)
     layer->setVisibleContentRect(IntRect(0, 0, 600, 600));
     layer->invalidateContentRect(IntRect(0, 0, 600, 600));
     layer->setTexturePriorities(m_priorityCalculator);
-    textureManager->prioritizeTextures();
-    layer->updateContentRect(m_queue, IntRect(0, 0, 600, 600), &occluded, m_stats);
+    m_textureManager->prioritizeTextures();
+    layer->update(m_queue, &occluded, m_stats);
     EXPECT_EQ(36-3, layer->fakeLayerTextureUpdater()->prepareRectCount());
     {
         DebugScopedSetImplThread implThread;
@@ -1198,10 +1061,10 @@ TEST_F(TiledLayerChromiumTest, tilesNotPaintedWithoutInvalidation)
 
     layer->fakeLayerTextureUpdater()->clearPrepareRectCount();
     layer->setTexturePriorities(m_priorityCalculator);
-    textureManager->prioritizeTextures();
+    m_textureManager->prioritizeTextures();
 
     // Repaint without marking it dirty. The 3 culled tiles will be pre-painted now.
-    layer->updateContentRect(m_queue, IntRect(0, 0, 600, 600), &occluded, m_stats);
+    layer->update(m_queue, &occluded, m_stats);
     EXPECT_EQ(3, layer->fakeLayerTextureUpdater()->prepareRectCount());
 
     EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1);
@@ -1211,8 +1074,7 @@ TEST_F(TiledLayerChromiumTest, tilesNotPaintedWithoutInvalidation)
 
 TEST_F(TiledLayerChromiumTest, tilesPaintedWithOcclusionAndTransforms)
 {
-    OwnPtr<CCPrioritizedTextureManager> textureManager = CCPrioritizedTextureManager::create(4*1024*1024, 1024, CCRenderer::ContentPool);
-    RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get()));
+    RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m_textureManager.get()));
     TestCCOcclusionTracker occluded;
 
     // The tile size is 100x100.
@@ -1230,8 +1092,8 @@ TEST_F(TiledLayerChromiumTest, tilesPaintedWithOcclusionAndTransforms)
     layer->setVisibleContentRect(IntRect(IntPoint(), layer->contentBounds()));
     layer->invalidateContentRect(IntRect(0, 0, 600, 600));
     layer->setTexturePriorities(m_priorityCalculator);
-    textureManager->prioritizeTextures();
-    layer->updateContentRect(m_queue, IntRect(0, 0, 600, 600), &occluded, m_stats);
+    m_textureManager->prioritizeTextures();
+    layer->update(m_queue, &occluded, m_stats);
     EXPECT_EQ(36-3, layer->fakeLayerTextureUpdater()->prepareRectCount());
 
     EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1);
@@ -1241,8 +1103,7 @@ TEST_F(TiledLayerChromiumTest, tilesPaintedWithOcclusionAndTransforms)
 
 TEST_F(TiledLayerChromiumTest, tilesPaintedWithOcclusionAndScaling)
 {
-    OwnPtr<CCPrioritizedTextureManager> textureManager = CCPrioritizedTextureManager::create(4*1024*1024, 1024, CCRenderer::ContentPool);
-    RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get()));
+    RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m_textureManager.get()));
     TestCCOcclusionTracker occluded;
 
     // The tile size is 100x100.
@@ -1262,8 +1123,8 @@ TEST_F(TiledLayerChromiumTest, tilesPaintedWithOcclusionAndScaling)
     layer->setVisibleContentRect(IntRect(IntPoint(), layer->contentBounds()));
     layer->invalidateContentRect(IntRect(0, 0, 600, 600));
     layer->setTexturePriorities(m_priorityCalculator);
-    textureManager->prioritizeTextures();
-    layer->updateContentRect(m_queue, IntRect(0, 0, 600, 600), &occluded, m_stats);
+    m_textureManager->prioritizeTextures();
+    layer->update(m_queue, &occluded, m_stats);
     // The content is half the size of the layer (so the number of tiles is fewer).
     // In this case, the content is 300x300, and since the tile size is 100, the
     // number of tiles 3x3.
@@ -1283,8 +1144,8 @@ TEST_F(TiledLayerChromiumTest, tilesPaintedWithOcclusionAndScaling)
     layer->setVisibleContentRect(IntRect(IntPoint(), layer->contentBounds()));
     layer->invalidateContentRect(IntRect(0, 0, 600, 600));
     layer->setTexturePriorities(m_priorityCalculator);
-    textureManager->prioritizeTextures();
-    layer->updateContentRect(m_queue, IntRect(0, 0, 600, 600), &occluded, m_stats);
+    m_textureManager->prioritizeTextures();
+    layer->update(m_queue, &occluded, m_stats);
     EXPECT_EQ(9-1, layer->fakeLayerTextureUpdater()->prepareRectCount());
 
     EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1);
@@ -1304,8 +1165,8 @@ TEST_F(TiledLayerChromiumTest, tilesPaintedWithOcclusionAndScaling)
     layer->setVisibleContentRect(IntRect(IntPoint(), layer->contentBounds()));
     layer->invalidateContentRect(IntRect(0, 0, 600, 600));
     layer->setTexturePriorities(m_priorityCalculator);
-    textureManager->prioritizeTextures();
-    layer->updateContentRect(m_queue, IntRect(0, 0, 600, 600), &occluded, m_stats);
+    m_textureManager->prioritizeTextures();
+    layer->update(m_queue, &occluded, m_stats);
     EXPECT_EQ(9-1, layer->fakeLayerTextureUpdater()->prepareRectCount());
 
     EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1);
@@ -1315,8 +1176,7 @@ TEST_F(TiledLayerChromiumTest, tilesPaintedWithOcclusionAndScaling)
 
 TEST_F(TiledLayerChromiumTest, visibleContentOpaqueRegion)
 {
-    OwnPtr<CCPrioritizedTextureManager> textureManager = CCPrioritizedTextureManager::create(4*1024*1024, 1024, CCRenderer::ContentPool);
-    RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get()));
+    RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m_textureManager.get()));
     TestCCOcclusionTracker occluded;
     DebugScopedSetImplThread implThread;
 
@@ -1334,12 +1194,12 @@ TEST_F(TiledLayerChromiumTest, visibleContentOpaqueRegion)
     layer->setDrawOpacity(1);
 
     layer->setTexturePriorities(m_priorityCalculator);
-    textureManager->prioritizeTextures();
+    m_textureManager->prioritizeTextures();
 
     // If the layer doesn't paint opaque content, then the visibleContentOpaqueRegion should be empty.
     layer->fakeLayerTextureUpdater()->setOpaquePaintRect(IntRect());
     layer->invalidateContentRect(contentBounds);
-    layer->updateContentRect(m_queue, contentBounds, &occluded, m_stats);
+    layer->update(m_queue, &occluded, m_stats);
     opaqueContents = layer->visibleContentOpaqueRegion();
     EXPECT_TRUE(opaqueContents.isEmpty());
 
@@ -1352,7 +1212,7 @@ TEST_F(TiledLayerChromiumTest, visibleContentOpaqueRegion)
     opaquePaintRect = IntRect(10, 10, 90, 190);
     layer->fakeLayerTextureUpdater()->setOpaquePaintRect(opaquePaintRect);
     layer->invalidateContentRect(contentBounds);
-    layer->updateContentRect(m_queue, contentBounds, &occluded, m_stats);
+    layer->update(m_queue, &occluded, m_stats);
     updateTextures();
     opaqueContents = layer->visibleContentOpaqueRegion();
     EXPECT_EQ_RECT(intersection(opaquePaintRect, visibleBounds), opaqueContents.bounds());
@@ -1365,7 +1225,7 @@ TEST_F(TiledLayerChromiumTest, visibleContentOpaqueRegion)
 
     // If we paint again without invalidating, the same stuff should be opaque.
     layer->fakeLayerTextureUpdater()->setOpaquePaintRect(IntRect());
-    layer->updateContentRect(m_queue, contentBounds, &occluded, m_stats);
+    layer->update(m_queue, &occluded, m_stats);
     updateTextures();
     opaqueContents = layer->visibleContentOpaqueRegion();
     EXPECT_EQ_RECT(intersection(opaquePaintRect, visibleBounds), opaqueContents.bounds());
@@ -1380,7 +1240,7 @@ TEST_F(TiledLayerChromiumTest, visibleContentOpaqueRegion)
     // not be affected.
     layer->fakeLayerTextureUpdater()->setOpaquePaintRect(IntRect());
     layer->invalidateContentRect(IntRect(0, 0, 1, 1));
-    layer->updateContentRect(m_queue, contentBounds, &occluded, m_stats);
+    layer->update(m_queue, &occluded, m_stats);
     updateTextures();
     opaqueContents = layer->visibleContentOpaqueRegion();
     EXPECT_EQ_RECT(intersection(opaquePaintRect, visibleBounds), opaqueContents.bounds());
@@ -1395,7 +1255,7 @@ TEST_F(TiledLayerChromiumTest, visibleContentOpaqueRegion)
     // not be affected.
     layer->fakeLayerTextureUpdater()->setOpaquePaintRect(IntRect());
     layer->invalidateContentRect(IntRect(10, 10, 1, 1));
-    layer->updateContentRect(m_queue, contentBounds, &occluded, m_stats);
+    layer->update(m_queue, &occluded, m_stats);
     updateTextures();
     opaqueContents = layer->visibleContentOpaqueRegion();
     EXPECT_EQ_RECT(intersection(IntRect(10, 100, 90, 100), visibleBounds), opaqueContents.bounds());
@@ -1409,8 +1269,7 @@ TEST_F(TiledLayerChromiumTest, visibleContentOpaqueRegion)
 
 TEST_F(TiledLayerChromiumTest, pixelsPaintedMetrics)
 {
-    OwnPtr<CCPrioritizedTextureManager> textureManager = CCPrioritizedTextureManager::create(4*1024*1024, 1024, CCRenderer::ContentPool);
-    RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get()));
+    RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m_textureManager.get()));
     TestCCOcclusionTracker occluded;
     DebugScopedSetImplThread implThread;
 
@@ -1428,12 +1287,12 @@ TEST_F(TiledLayerChromiumTest, pixelsPaintedMetrics)
     layer->setDrawOpacity(1);
 
     layer->setTexturePriorities(m_priorityCalculator);
-    textureManager->prioritizeTextures();
+    m_textureManager->prioritizeTextures();
 
     // Invalidates and paints the whole layer.
     layer->fakeLayerTextureUpdater()->setOpaquePaintRect(IntRect());
     layer->invalidateContentRect(contentBounds);
-    layer->updateContentRect(m_queue, contentBounds, &occluded, m_stats);
+    layer->update(m_queue, &occluded, m_stats);
     updateTextures();
     opaqueContents = layer->visibleContentOpaqueRegion();
     EXPECT_TRUE(opaqueContents.isEmpty());
@@ -1448,7 +1307,7 @@ TEST_F(TiledLayerChromiumTest, pixelsPaintedMetrics)
     layer->fakeLayerTextureUpdater()->setOpaquePaintRect(IntRect());
     layer->invalidateContentRect(IntRect(0, 0, 1, 1));
     layer->invalidateContentRect(IntRect(50, 200, 10, 10));
-    layer->updateContentRect(m_queue, contentBounds, &occluded, m_stats);
+    layer->update(m_queue, &occluded, m_stats);
     updateTextures();
     opaqueContents = layer->visibleContentOpaqueRegion();
     EXPECT_TRUE(opaqueContents.isEmpty());
@@ -1662,9 +1521,7 @@ private:
 
 TEST_F(TiledLayerChromiumTest, nonIntegerContentsScaleIsNotDistortedDuringPaint)
 {
-    OwnPtr<CCPrioritizedTextureManager> textureManager(CCPrioritizedTextureManager::create(4000000, 4000000, CCRenderer::ContentPool));
-
-    RefPtr<UpdateTrackingTiledLayerChromium> layer = adoptRef(new UpdateTrackingTiledLayerChromium(textureManager.get()));
+    RefPtr<UpdateTrackingTiledLayerChromium> layer = adoptRef(new UpdateTrackingTiledLayerChromium(m_textureManager.get()));
 
     IntRect layerRect(0, 0, 30, 31);
     layer->setPosition(layerRect.location());
@@ -1677,10 +1534,10 @@ TEST_F(TiledLayerChromiumTest, nonIntegerContentsScaleIsNotDistortedDuringPaint)
     layer->setDrawableContentRect(contentRect);
 
     layer->setTexturePriorities(m_priorityCalculator);
-    textureManager->prioritizeTextures();
+    m_textureManager->prioritizeTextures();
 
     // Update the whole tile.
-    layer->updateContentRect(m_queue, contentRect, 0, m_stats);
+    layer->update(m_queue, 0, m_stats);
     layer->trackingLayerPainter()->resetPaintedRect();
 
     EXPECT_INT_RECT_EQ(IntRect(), layer->trackingLayerPainter()->paintedRect());
@@ -1692,16 +1549,14 @@ TEST_F(TiledLayerChromiumTest, nonIntegerContentsScaleIsNotDistortedDuringPaint)
 
     // Invalidate the entire layer in content space. When painting, the rect given to webkit should match the layer's bounds.
     layer->invalidateContentRect(contentRect);
-    layer->updateContentRect(m_queue, contentRect, 0, m_stats);
+    layer->update(m_queue, 0, m_stats);
 
     EXPECT_INT_RECT_EQ(layerRect, layer->trackingLayerPainter()->paintedRect());
 }
 
 TEST_F(TiledLayerChromiumTest, nonIntegerContentsScaleIsNotDistortedDuringInvalidation)
 {
-    OwnPtr<CCPrioritizedTextureManager> textureManager(CCPrioritizedTextureManager::create(4000000, 4000000, CCRenderer::ContentPool));
-
-    RefPtr<UpdateTrackingTiledLayerChromium> layer = adoptRef(new UpdateTrackingTiledLayerChromium(textureManager.get()));
+    RefPtr<UpdateTrackingTiledLayerChromium> layer = adoptRef(new UpdateTrackingTiledLayerChromium(m_textureManager.get()));
 
     IntRect layerRect(0, 0, 30, 31);
     layer->setPosition(layerRect.location());
@@ -1713,10 +1568,10 @@ TEST_F(TiledLayerChromiumTest, nonIntegerContentsScaleIsNotDistortedDuringInvali
     layer->setDrawableContentRect(contentRect);
 
     layer->setTexturePriorities(m_priorityCalculator);
-    textureManager->prioritizeTextures();
+    m_textureManager->prioritizeTextures();
 
     // Update the whole tile.
-    layer->updateContentRect(m_queue, contentRect, 0, m_stats);
+    layer->update(m_queue, 0, m_stats);
     layer->trackingLayerPainter()->resetPaintedRect();
 
     EXPECT_INT_RECT_EQ(IntRect(), layer->trackingLayerPainter()->paintedRect());
@@ -1728,7 +1583,7 @@ TEST_F(TiledLayerChromiumTest, nonIntegerContentsScaleIsNotDistortedDuringInvali
 
     // Invalidate the entire layer in layer space. When painting, the rect given to webkit should match the layer's bounds.
     layer->setNeedsDisplayRect(layerRect);
-    layer->updateContentRect(m_queue, contentRect, 0, m_stats);
+    layer->update(m_queue, 0, m_stats);
 
     EXPECT_INT_RECT_EQ(layerRect, layer->trackingLayerPainter()->paintedRect());
 }