diff options
author | Simon Hausmann <simon.hausmann@nokia.com> | 2012-09-10 19:10:20 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2012-09-10 19:10:20 +0200 |
commit | 284837daa07b29d6a63a748544a90b1f5842ac5c (patch) | |
tree | ecd258180bde91fe741e0cfd2638beb3c6da7e8e /Source/WebKit/chromium/tests/TiledLayerChromiumTest.cpp | |
parent | 2e2ba8ff45915f40ed3e014101269c175f2a89a0 (diff) | |
download | qtwebkit-284837daa07b29d6a63a748544a90b1f5842ac5c.tar.gz |
Imported WebKit commit 68645295d2e3e09af2c942f092556f06aa5f8b0d (http://svn.webkit.org/repository/webkit/trunk@128073)
New snapshot
Diffstat (limited to 'Source/WebKit/chromium/tests/TiledLayerChromiumTest.cpp')
-rw-r--r-- | Source/WebKit/chromium/tests/TiledLayerChromiumTest.cpp | 257 |
1 files changed, 120 insertions, 137 deletions
diff --git a/Source/WebKit/chromium/tests/TiledLayerChromiumTest.cpp b/Source/WebKit/chromium/tests/TiledLayerChromiumTest.cpp index 00ee28a68..85821a8b3 100644 --- a/Source/WebKit/chromium/tests/TiledLayerChromiumTest.cpp +++ b/Source/WebKit/chromium/tests/TiledLayerChromiumTest.cpp @@ -28,7 +28,7 @@ #include "BitmapCanvasLayerTextureUpdater.h" #include "CCAnimationTestCommon.h" -#include "CCLayerTreeTestCommon.h" +#include "CCGeometryTestUtils.h" #include "CCOverdrawMetrics.h" #include "CCRenderingStats.h" #include "CCSingleThreadProxy.h" // For DebugScopedSetImplThread @@ -37,8 +37,8 @@ #include "FakeCCGraphicsContext.h" #include "FakeCCLayerTreeHostClient.h" #include "LayerPainterChromium.h" +#include "WebCompositorInitializer.h" #include <gtest/gtest.h> -#include <public/WebCompositor.h> #include <public/WebTransformationMatrix.h> using namespace WebCore; @@ -46,12 +46,6 @@ using namespace WebKitTests; using namespace WTF; using WebKit::WebTransformationMatrix; -#define EXPECT_EQ_RECT(a, b) \ - EXPECT_EQ(a.x(), b.x()); \ - EXPECT_EQ(a.y(), b.y()); \ - EXPECT_EQ(a.width(), b.width()); \ - EXPECT_EQ(a.height(), b.height()); - namespace { class TestCCOcclusionTracker : public CCOcclusionTracker { @@ -76,29 +70,72 @@ private: class TiledLayerChromiumTest : public testing::Test { public: TiledLayerChromiumTest() - : m_context(WebKit::createFakeCCGraphicsContext()) + : m_compositorInitializer(0) + , m_context(WebKit::createFakeCCGraphicsContext()) , m_textureManager(CCPrioritizedTextureManager::create(60*1024*1024, 1024, CCRenderer::ContentPool)) , m_occlusion(0) { - DebugScopedSetImplThread implThread; + DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked; m_resourceProvider = CCResourceProvider::create(m_context.get()); } virtual ~TiledLayerChromiumTest() { - DebugScopedSetImplThread implThread; + textureManagerClearAllMemory(m_textureManager.get(), m_resourceProvider.get()); + DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked; m_resourceProvider.clear(); } + // Helper classes and functions that set the current thread to be the impl thread + // before doing the action that they wrap. + class ScopedFakeCCTiledLayerImpl { + public: + ScopedFakeCCTiledLayerImpl(int id) + { + DebugScopedSetImplThread implThread; + m_layerImpl = new FakeCCTiledLayerImpl(id); + } + ~ScopedFakeCCTiledLayerImpl() + { + DebugScopedSetImplThread implThread; + delete m_layerImpl; + } + FakeCCTiledLayerImpl* get() + { + return m_layerImpl; + } + FakeCCTiledLayerImpl* operator->() + { + return m_layerImpl; + } + private: + FakeCCTiledLayerImpl* m_layerImpl; + }; + void textureManagerClearAllMemory(CCPrioritizedTextureManager* textureManager, CCResourceProvider* resourceProvider) + { + DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked; + textureManager->clearAllMemory(resourceProvider); + } void updateTextures(int count = 500) { + DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked; CCTextureUpdateController::updateTextures(m_resourceProvider.get(), &m_copier, &m_uploader, &m_queue, count); } + void layerPushPropertiesTo(FakeTiledLayerChromium* layer, FakeCCTiledLayerImpl* layerImpl) + { + DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked; + layer->pushPropertiesTo(layerImpl); + } + void layerUpdate(FakeTiledLayerChromium* layer, TestCCOcclusionTracker* occluded) + { + DebugScopedSetMainThread mainThread; + layer->update(m_queue, occluded, m_stats); + } bool updateAndPush(FakeTiledLayerChromium* layer1, - CCLayerImpl* layerImpl1, + FakeCCTiledLayerImpl* layerImpl1, FakeTiledLayerChromium* layer2 = 0, - CCLayerImpl* layerImpl2 = 0) + FakeCCTiledLayerImpl* layerImpl2 = 0) { // Get textures m_textureManager->clearPriorities(); @@ -123,14 +160,15 @@ public: // Update textures and push. updateTextures(); if (layer1) - layer1->pushPropertiesTo(layerImpl1); + layerPushPropertiesTo(layer1, layerImpl1); if (layer2) - layer2->pushPropertiesTo(layerImpl2); + layerPushPropertiesTo(layer2, layerImpl2); return needsUpdate; } public: + WebKitTests::WebCompositorInitializer m_compositorInitializer; OwnPtr<CCGraphicsContext> m_context; OwnPtr<CCResourceProvider> m_resourceProvider; CCTextureUpdateQueue m_queue; @@ -145,8 +183,7 @@ public: TEST_F(TiledLayerChromiumTest, pushDirtyTiles) { RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m_textureManager.get())); - DebugScopedSetImplThread implThread; - OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1))); + ScopedFakeCCTiledLayerImpl layerImpl(1); // The tile size is 100x100, so this invalidates and then paints two tiles. layer->setBounds(IntSize(100, 200)); @@ -172,8 +209,7 @@ TEST_F(TiledLayerChromiumTest, pushDirtyTiles) TEST_F(TiledLayerChromiumTest, pushOccludedDirtyTiles) { RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m_textureManager.get())); - DebugScopedSetImplThread implThread; - OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1))); + ScopedFakeCCTiledLayerImpl layerImpl(1); TestCCOcclusionTracker occluded; m_occlusion = &occluded; @@ -209,8 +245,7 @@ TEST_F(TiledLayerChromiumTest, pushOccludedDirtyTiles) TEST_F(TiledLayerChromiumTest, pushDeletedTiles) { RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m_textureManager.get())); - DebugScopedSetImplThread implThread; - OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1))); + ScopedFakeCCTiledLayerImpl layerImpl(1); // The tile size is 100x100, so this invalidates and then paints two tiles. layer->setBounds(IntSize(100, 200)); @@ -223,11 +258,11 @@ TEST_F(TiledLayerChromiumTest, pushDeletedTiles) EXPECT_TRUE(layerImpl->hasTileAt(0, 1)); m_textureManager->clearPriorities(); - m_textureManager->clearAllMemory(m_resourceProvider.get()); + textureManagerClearAllMemory(m_textureManager.get(), m_resourceProvider.get()); m_textureManager->setMaxMemoryLimitBytes(4*1024*1024); // This should drop the tiles on the impl thread. - layer->pushPropertiesTo(layerImpl.get()); + layerPushPropertiesTo(layer.get(), layerImpl.get()); // We should now have no textures on the impl thread. EXPECT_FALSE(layerImpl->hasTileAt(0, 0)); @@ -245,8 +280,7 @@ TEST_F(TiledLayerChromiumTest, pushDeletedTiles) TEST_F(TiledLayerChromiumTest, pushIdlePaintTiles) { RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m_textureManager.get())); - DebugScopedSetImplThread implThread; - OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1))); + ScopedFakeCCTiledLayerImpl layerImpl(1); // The tile size is 100x100. Setup 5x5 tiles with one visible tile in the center. // This paints 1 visible of the 25 invalid tiles. @@ -283,11 +317,10 @@ 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. m_textureManager->setMaxMemoryLimitBytes(2 * 1024 * 1024); - DebugScopedSetImplThread implThread; RefPtr<FakeTiledLayerChromium> layer1 = adoptRef(new FakeTiledLayerChromium(m_textureManager.get())); - OwnPtr<FakeCCTiledLayerImpl> layerImpl1(adoptPtr(new FakeCCTiledLayerImpl(1))); + ScopedFakeCCTiledLayerImpl layerImpl1(1); RefPtr<FakeTiledLayerChromium> layer2 = adoptRef(new FakeTiledLayerChromium(m_textureManager.get())); - OwnPtr<FakeCCTiledLayerImpl> layerImpl2(adoptPtr(new FakeCCTiledLayerImpl(2))); + ScopedFakeCCTiledLayerImpl layerImpl2(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 @@ -337,8 +370,7 @@ TEST_F(TiledLayerChromiumTest, pushTilesAfterIdlePaintFailed) TEST_F(TiledLayerChromiumTest, pushIdlePaintedOccludedTiles) { RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m_textureManager.get())); - DebugScopedSetImplThread implThread; - OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1))); + ScopedFakeCCTiledLayerImpl layerImpl(1); TestCCOcclusionTracker occluded; m_occlusion = &occluded; @@ -357,8 +389,7 @@ TEST_F(TiledLayerChromiumTest, pushIdlePaintedOccludedTiles) TEST_F(TiledLayerChromiumTest, pushTilesMarkedDirtyDuringPaint) { RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m_textureManager.get())); - DebugScopedSetImplThread implThread; - OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1))); + ScopedFakeCCTiledLayerImpl layerImpl(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 @@ -377,9 +408,8 @@ TEST_F(TiledLayerChromiumTest, pushTilesLayerMarkedDirtyDuringPaintOnNextLayer) { 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))); + ScopedFakeCCTiledLayerImpl layer1Impl(1); + ScopedFakeCCTiledLayerImpl layer2Impl(2); // Invalidate a tile on layer1, during update of layer 2. layer2->fakeLayerTextureUpdater()->setRectToInvalidate(IntRect(0, 50, 100, 50), layer1.get()); @@ -401,9 +431,8 @@ TEST_F(TiledLayerChromiumTest, pushTilesLayerMarkedDirtyDuringPaintOnPreviousLay { 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))); + ScopedFakeCCTiledLayerImpl layer1Impl(1); + ScopedFakeCCTiledLayerImpl layer2Impl(2); layer1->fakeLayerTextureUpdater()->setRectToInvalidate(IntRect(0, 50, 100, 50), layer2.get()); layer1->setBounds(IntSize(100, 200)); @@ -424,7 +453,6 @@ TEST_F(TiledLayerChromiumTest, paintSmallAnimatedLayersImmediately) { // Create a CCLayerTreeHost that has the right viewportsize, // so the layer is considered small enough. - WebKit::WebCompositor::initialize(0); FakeCCLayerTreeHostClient fakeCCLayerTreeHostClient; OwnPtr<CCLayerTreeHost> ccLayerTreeHost = CCLayerTreeHost::create(&fakeCCLayerTreeHostClient, CCLayerTreeSettings()); @@ -442,10 +470,9 @@ TEST_F(TiledLayerChromiumTest, paintSmallAnimatedLayersImmediately) layerWidth *= 2; m_textureManager->setMaxMemoryLimitBytes(memoryForLayer); - DebugScopedSetImplThread implThread; RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m_textureManager.get())); - OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1))); + ScopedFakeCCTiledLayerImpl layerImpl(1); // Full size layer with half being visible. IntSize contentBounds(layerWidth, layerHeight); @@ -465,7 +492,7 @@ TEST_F(TiledLayerChromiumTest, paintSmallAnimatedLayersImmediately) m_textureManager->prioritizeTextures(); layer->update(m_queue, 0, m_stats); updateTextures(); - layer->pushPropertiesTo(layerImpl.get()); + layerPushPropertiesTo(layer.get(), layerImpl.get()); // We should have all the tiles for the small animated layer. // We should still have the visible tiles when we didn't @@ -483,14 +510,12 @@ TEST_F(TiledLayerChromiumTest, paintSmallAnimatedLayersImmediately) } } ccLayerTreeHost.clear(); - WebKit::WebCompositor::shutdown(); } TEST_F(TiledLayerChromiumTest, idlePaintOutOfMemory) { RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m_textureManager.get())); - DebugScopedSetImplThread implThread; - OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1))); + ScopedFakeCCTiledLayerImpl layerImpl(1); // 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. @@ -513,8 +538,7 @@ TEST_F(TiledLayerChromiumTest, idlePaintOutOfMemory) TEST_F(TiledLayerChromiumTest, idlePaintZeroSizedLayer) { RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m_textureManager.get())); - DebugScopedSetImplThread implThread; - OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1))); + ScopedFakeCCTiledLayerImpl layerImpl(1); bool animating[2] = {false, true}; for (int i = 0; i < 2; i++) { @@ -541,8 +565,7 @@ TEST_F(TiledLayerChromiumTest, idlePaintZeroSizedLayer) TEST_F(TiledLayerChromiumTest, idlePaintNonVisibleLayers) { RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m_textureManager.get())); - DebugScopedSetImplThread implThread; - OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1))); + ScopedFakeCCTiledLayerImpl layerImpl(1); // Alternate between not visible and visible. IntRect v(0, 0, 100, 100); @@ -572,8 +595,7 @@ TEST_F(TiledLayerChromiumTest, idlePaintNonVisibleLayers) TEST_F(TiledLayerChromiumTest, invalidateFromPrepare) { RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m_textureManager.get())); - DebugScopedSetImplThread implThread; - OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1))); + ScopedFakeCCTiledLayerImpl layerImpl(1); // The tile size is 100x100, so this invalidates and then paints two tiles. layer->setBounds(IntSize(100, 200)); @@ -608,7 +630,6 @@ TEST_F(TiledLayerChromiumTest, verifyUpdateRectWhenContentBoundsAreScaled) // The updateRect (that indicates what was actually painted) should be in // layer space, not the content space. RefPtr<FakeTiledLayerWithScaledBounds> layer = adoptRef(new FakeTiledLayerWithScaledBounds(m_textureManager.get())); - DebugScopedSetImplThread implThread; IntRect layerBounds(0, 0, 300, 200); IntRect contentBounds(0, 0, 200, 250); @@ -647,8 +668,7 @@ TEST_F(TiledLayerChromiumTest, verifyUpdateRectWhenContentBoundsAreScaled) TEST_F(TiledLayerChromiumTest, verifyInvalidationWhenContentsScaleChanges) { RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m_textureManager.get())); - DebugScopedSetImplThread implThread; - OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1))); + ScopedFakeCCTiledLayerImpl layerImpl(1); // Create a layer with one tile. layer->setBounds(IntSize(100, 100)); @@ -663,7 +683,7 @@ TEST_F(TiledLayerChromiumTest, verifyInvalidationWhenContentsScaleChanges) m_textureManager->prioritizeTextures(); layer->update(m_queue, 0, m_stats); updateTextures(); - layer->pushPropertiesTo(layerImpl.get()); + layerPushPropertiesTo(layer.get(), layerImpl.get()); EXPECT_TRUE(layerImpl->hasTileAt(0, 0)); EXPECT_FALSE(layerImpl->hasTileAt(0, 1)); EXPECT_FALSE(layerImpl->hasTileAt(1, 0)); @@ -680,7 +700,7 @@ TEST_F(TiledLayerChromiumTest, verifyInvalidationWhenContentsScaleChanges) m_textureManager->prioritizeTextures(); layer->update(m_queue, 0, m_stats); updateTextures(); - layer->pushPropertiesTo(layerImpl.get()); + layerPushPropertiesTo(layer.get(), layerImpl.get()); EXPECT_TRUE(layerImpl->hasTileAt(0, 0)); EXPECT_TRUE(layerImpl->hasTileAt(0, 1)); EXPECT_TRUE(layerImpl->hasTileAt(1, 0)); @@ -692,7 +712,7 @@ TEST_F(TiledLayerChromiumTest, verifyInvalidationWhenContentsScaleChanges) layer->setTexturePriorities(m_priorityCalculator); m_textureManager->prioritizeTextures(); - layer->pushPropertiesTo(layerImpl.get()); + layerPushPropertiesTo(layer.get(), layerImpl.get()); EXPECT_FALSE(layerImpl->hasTileAt(0, 0)); EXPECT_FALSE(layerImpl->hasTileAt(0, 1)); EXPECT_FALSE(layerImpl->hasTileAt(1, 0)); @@ -701,8 +721,6 @@ TEST_F(TiledLayerChromiumTest, verifyInvalidationWhenContentsScaleChanges) TEST_F(TiledLayerChromiumTest, skipsDrawGetsReset) { - // Initialize without threading support. - WebKit::WebCompositor::initialize(0); FakeCCLayerTreeHostClient fakeCCLayerTreeHostClient; OwnPtr<CCLayerTreeHost> ccLayerTreeHost = CCLayerTreeHost::create(&fakeCCLayerTreeHostClient, CCLayerTreeSettings()); ASSERT_TRUE(ccLayerTreeHost->initializeRendererIfNeeded()); @@ -744,10 +762,9 @@ TEST_F(TiledLayerChromiumTest, skipsDrawGetsReset) ccLayerTreeHost->updateLayers(m_queue, memoryLimit); EXPECT_FALSE(rootLayer->skipsDraw()); - ccLayerTreeHost->contentsTextureManager()->clearAllMemory(m_resourceProvider.get()); + textureManagerClearAllMemory(ccLayerTreeHost->contentsTextureManager(), m_resourceProvider.get()); ccLayerTreeHost->setRootLayer(0); ccLayerTreeHost.clear(); - WebKit::WebCompositor::shutdown(); } TEST_F(TiledLayerChromiumTest, resizeToSmaller) @@ -783,9 +800,6 @@ TEST_F(TiledLayerChromiumTest, hugeLayerUpdateCrash) TEST_F(TiledLayerChromiumTest, partialUpdates) { - // Initialize without threading support. - WebKit::WebCompositor::initialize(0); - CCLayerTreeSettings settings; settings.maxPartialTextureUpdates = 4; @@ -809,8 +823,7 @@ TEST_F(TiledLayerChromiumTest, partialUpdates) // Full update of all 6 tiles. ccLayerTreeHost->updateLayers(m_queue, std::numeric_limits<size_t>::max()); { - DebugScopedSetImplThread implThread; - OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1))); + ScopedFakeCCTiledLayerImpl layerImpl(1); updateTextures(4); EXPECT_EQ(4, layer->fakeLayerTextureUpdater()->updateCount()); EXPECT_TRUE(m_queue.hasMoreUpdates()); @@ -819,7 +832,7 @@ TEST_F(TiledLayerChromiumTest, partialUpdates) EXPECT_EQ(2, layer->fakeLayerTextureUpdater()->updateCount()); EXPECT_FALSE(m_queue.hasMoreUpdates()); layer->fakeLayerTextureUpdater()->clearUpdateCount(); - layer->pushPropertiesTo(layerImpl.get()); + layerPushPropertiesTo(layer.get(), layerImpl.get()); } ccLayerTreeHost->commitComplete(); @@ -827,8 +840,7 @@ TEST_F(TiledLayerChromiumTest, partialUpdates) layer->invalidateContentRect(IntRect(0, 0, 300, 150)); ccLayerTreeHost->updateLayers(m_queue, std::numeric_limits<size_t>::max()); { - DebugScopedSetImplThread implThread; - OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1))); + ScopedFakeCCTiledLayerImpl layerImpl(1); updateTextures(4); EXPECT_EQ(3, layer->fakeLayerTextureUpdater()->updateCount()); EXPECT_TRUE(m_queue.hasMoreUpdates()); @@ -837,15 +849,14 @@ TEST_F(TiledLayerChromiumTest, partialUpdates) EXPECT_EQ(3, layer->fakeLayerTextureUpdater()->updateCount()); EXPECT_FALSE(m_queue.hasMoreUpdates()); layer->fakeLayerTextureUpdater()->clearUpdateCount(); - layer->pushPropertiesTo(layerImpl.get()); + layerPushPropertiesTo(layer.get(), layerImpl.get()); } ccLayerTreeHost->commitComplete(); // Partial update of 6 tiles. layer->invalidateContentRect(IntRect(50, 50, 200, 100)); { - DebugScopedSetImplThread implThread; - OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1))); + ScopedFakeCCTiledLayerImpl layerImpl(1); ccLayerTreeHost->updateLayers(m_queue, std::numeric_limits<size_t>::max()); updateTextures(4); EXPECT_EQ(2, layer->fakeLayerTextureUpdater()->updateCount()); @@ -855,24 +866,22 @@ TEST_F(TiledLayerChromiumTest, partialUpdates) EXPECT_EQ(4, layer->fakeLayerTextureUpdater()->updateCount()); EXPECT_FALSE(m_queue.hasMoreUpdates()); layer->fakeLayerTextureUpdater()->clearUpdateCount(); - layer->pushPropertiesTo(layerImpl.get()); + layerPushPropertiesTo(layer.get(), layerImpl.get()); } ccLayerTreeHost->commitComplete(); // Checkerboard all tiles. layer->invalidateContentRect(IntRect(0, 0, 300, 200)); { - DebugScopedSetImplThread implThread; - OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1))); - layer->pushPropertiesTo(layerImpl.get()); + ScopedFakeCCTiledLayerImpl layerImpl(1); + layerPushPropertiesTo(layer.get(), layerImpl.get()); } ccLayerTreeHost->commitComplete(); // Partial update of 6 checkerboard tiles. layer->invalidateContentRect(IntRect(50, 50, 200, 100)); { - DebugScopedSetImplThread implThread; - OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1))); + ScopedFakeCCTiledLayerImpl layerImpl(1); ccLayerTreeHost->updateLayers(m_queue, std::numeric_limits<size_t>::max()); updateTextures(4); EXPECT_EQ(4, layer->fakeLayerTextureUpdater()->updateCount()); @@ -882,31 +891,26 @@ TEST_F(TiledLayerChromiumTest, partialUpdates) EXPECT_EQ(2, layer->fakeLayerTextureUpdater()->updateCount()); EXPECT_FALSE(m_queue.hasMoreUpdates()); layer->fakeLayerTextureUpdater()->clearUpdateCount(); - layer->pushPropertiesTo(layerImpl.get()); + layerPushPropertiesTo(layer.get(), layerImpl.get()); } ccLayerTreeHost->commitComplete(); // Partial update of 4 tiles. layer->invalidateContentRect(IntRect(50, 50, 100, 100)); { - DebugScopedSetImplThread implThread; - OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1))); + ScopedFakeCCTiledLayerImpl layerImpl(1); ccLayerTreeHost->updateLayers(m_queue, std::numeric_limits<size_t>::max()); updateTextures(4); EXPECT_EQ(4, layer->fakeLayerTextureUpdater()->updateCount()); EXPECT_FALSE(m_queue.hasMoreUpdates()); layer->fakeLayerTextureUpdater()->clearUpdateCount(); - layer->pushPropertiesTo(layerImpl.get()); + layerPushPropertiesTo(layer.get(), layerImpl.get()); } ccLayerTreeHost->commitComplete(); - { - DebugScopedSetImplThread implThread; - ccLayerTreeHost->contentsTextureManager()->clearAllMemory(m_resourceProvider.get()); - } + textureManagerClearAllMemory(ccLayerTreeHost->contentsTextureManager(), m_resourceProvider.get()); ccLayerTreeHost->setRootLayer(0); ccLayerTreeHost.clear(); - WebKit::WebCompositor::shutdown(); } TEST_F(TiledLayerChromiumTest, tilesPaintedWithoutOcclusion) @@ -1051,7 +1055,6 @@ TEST_F(TiledLayerChromiumTest, tilesNotPaintedWithoutInvalidation) layer->update(m_queue, &occluded, m_stats); EXPECT_EQ(36-3, layer->fakeLayerTextureUpdater()->prepareRectCount()); { - DebugScopedSetImplThread implThread; updateTextures(); } @@ -1178,7 +1181,6 @@ TEST_F(TiledLayerChromiumTest, visibleContentOpaqueRegion) { RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m_textureManager.get())); TestCCOcclusionTracker occluded; - DebugScopedSetImplThread implThread; // The tile size is 100x100, so this invalidates and then paints two tiles in various ways. @@ -1215,7 +1217,7 @@ TEST_F(TiledLayerChromiumTest, visibleContentOpaqueRegion) layer->update(m_queue, &occluded, m_stats); updateTextures(); opaqueContents = layer->visibleContentOpaqueRegion(); - EXPECT_EQ_RECT(intersection(opaquePaintRect, visibleBounds), opaqueContents.bounds()); + EXPECT_RECT_EQ(intersection(opaquePaintRect, visibleBounds), opaqueContents.bounds()); EXPECT_EQ(1u, opaqueContents.rects().size()); EXPECT_NEAR(occluded.overdrawMetrics().pixelsPainted(), 20000 * 2, 1); @@ -1228,7 +1230,7 @@ TEST_F(TiledLayerChromiumTest, visibleContentOpaqueRegion) layer->update(m_queue, &occluded, m_stats); updateTextures(); opaqueContents = layer->visibleContentOpaqueRegion(); - EXPECT_EQ_RECT(intersection(opaquePaintRect, visibleBounds), opaqueContents.bounds()); + EXPECT_RECT_EQ(intersection(opaquePaintRect, visibleBounds), opaqueContents.bounds()); EXPECT_EQ(1u, opaqueContents.rects().size()); EXPECT_NEAR(occluded.overdrawMetrics().pixelsPainted(), 20000 * 2, 1); @@ -1243,7 +1245,7 @@ TEST_F(TiledLayerChromiumTest, visibleContentOpaqueRegion) layer->update(m_queue, &occluded, m_stats); updateTextures(); opaqueContents = layer->visibleContentOpaqueRegion(); - EXPECT_EQ_RECT(intersection(opaquePaintRect, visibleBounds), opaqueContents.bounds()); + EXPECT_RECT_EQ(intersection(opaquePaintRect, visibleBounds), opaqueContents.bounds()); EXPECT_EQ(1u, opaqueContents.rects().size()); EXPECT_NEAR(occluded.overdrawMetrics().pixelsPainted(), 20000 * 2 + 1, 1); @@ -1258,7 +1260,7 @@ TEST_F(TiledLayerChromiumTest, visibleContentOpaqueRegion) layer->update(m_queue, &occluded, m_stats); updateTextures(); opaqueContents = layer->visibleContentOpaqueRegion(); - EXPECT_EQ_RECT(intersection(IntRect(10, 100, 90, 100), visibleBounds), opaqueContents.bounds()); + EXPECT_RECT_EQ(intersection(IntRect(10, 100, 90, 100), visibleBounds), opaqueContents.bounds()); EXPECT_EQ(1u, opaqueContents.rects().size()); EXPECT_NEAR(occluded.overdrawMetrics().pixelsPainted(), 20000 * 2 + 1 + 1, 1); @@ -1271,7 +1273,6 @@ TEST_F(TiledLayerChromiumTest, pixelsPaintedMetrics) { RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m_textureManager.get())); TestCCOcclusionTracker occluded; - DebugScopedSetImplThread implThread; // The tile size is 100x100, so this invalidates and then paints two tiles in various ways. @@ -1322,9 +1323,6 @@ TEST_F(TiledLayerChromiumTest, pixelsPaintedMetrics) TEST_F(TiledLayerChromiumTest, dontAllocateContentsWhenTargetSurfaceCantBeAllocated) { - // Initialize without threading support. - WebKit::WebCompositor::initialize(0); - // Tile size is 100x100. IntRect rootRect(0, 0, 300, 200); IntRect childRect(0, 0, 300, 100); @@ -1373,7 +1371,6 @@ TEST_F(TiledLayerChromiumTest, dontAllocateContentsWhenTargetSurfaceCantBeAlloca child2->invalidateContentRect(child2Rect); ccLayerTreeHost->updateLayers(m_queue, std::numeric_limits<size_t>::max()); { - DebugScopedSetImplThread implThread; updateTextures(1000); EXPECT_EQ(6, root->fakeLayerTextureUpdater()->updateCount()); EXPECT_EQ(3, child->fakeLayerTextureUpdater()->updateCount()); @@ -1384,12 +1381,12 @@ TEST_F(TiledLayerChromiumTest, dontAllocateContentsWhenTargetSurfaceCantBeAlloca child->fakeLayerTextureUpdater()->clearUpdateCount(); child2->fakeLayerTextureUpdater()->clearUpdateCount(); - OwnPtr<FakeCCTiledLayerImpl> rootImpl(adoptPtr(new FakeCCTiledLayerImpl(root->id()))); - OwnPtr<FakeCCTiledLayerImpl> childImpl(adoptPtr(new FakeCCTiledLayerImpl(child->id()))); - OwnPtr<FakeCCTiledLayerImpl> child2Impl(adoptPtr(new FakeCCTiledLayerImpl(child2->id()))); - root->pushPropertiesTo(rootImpl.get()); - child->pushPropertiesTo(childImpl.get()); - child2->pushPropertiesTo(child2Impl.get()); + ScopedFakeCCTiledLayerImpl rootImpl(root->id()); + ScopedFakeCCTiledLayerImpl childImpl(child->id()); + ScopedFakeCCTiledLayerImpl child2Impl(child2->id()); + layerPushPropertiesTo(root.get(), rootImpl.get()); + layerPushPropertiesTo(child.get(), childImpl.get()); + layerPushPropertiesTo(child2.get(), child2Impl.get()); for (unsigned i = 0; i < 3; ++i) { for (unsigned j = 0; j < 2; ++j) @@ -1408,7 +1405,6 @@ TEST_F(TiledLayerChromiumTest, dontAllocateContentsWhenTargetSurfaceCantBeAlloca child2->invalidateContentRect(child2Rect); ccLayerTreeHost->updateLayers(m_queue, (3 * 2 + 3 * 1) * (100 * 100) * 4); { - DebugScopedSetImplThread implThread; updateTextures(1000); EXPECT_EQ(6, root->fakeLayerTextureUpdater()->updateCount()); EXPECT_EQ(0, child->fakeLayerTextureUpdater()->updateCount()); @@ -1419,12 +1415,12 @@ TEST_F(TiledLayerChromiumTest, dontAllocateContentsWhenTargetSurfaceCantBeAlloca child->fakeLayerTextureUpdater()->clearUpdateCount(); child2->fakeLayerTextureUpdater()->clearUpdateCount(); - OwnPtr<FakeCCTiledLayerImpl> rootImpl(adoptPtr(new FakeCCTiledLayerImpl(root->id()))); - OwnPtr<FakeCCTiledLayerImpl> childImpl(adoptPtr(new FakeCCTiledLayerImpl(child->id()))); - OwnPtr<FakeCCTiledLayerImpl> child2Impl(adoptPtr(new FakeCCTiledLayerImpl(child2->id()))); - root->pushPropertiesTo(rootImpl.get()); - child->pushPropertiesTo(childImpl.get()); - child2->pushPropertiesTo(child2Impl.get()); + ScopedFakeCCTiledLayerImpl rootImpl(root->id()); + ScopedFakeCCTiledLayerImpl childImpl(child->id()); + ScopedFakeCCTiledLayerImpl child2Impl(child2->id()); + layerPushPropertiesTo(root.get(), rootImpl.get()); + layerPushPropertiesTo(child.get(), childImpl.get()); + layerPushPropertiesTo(child2.get(), child2Impl.get()); for (unsigned i = 0; i < 3; ++i) { for (unsigned j = 0; j < 2; ++j) @@ -1444,7 +1440,6 @@ TEST_F(TiledLayerChromiumTest, dontAllocateContentsWhenTargetSurfaceCantBeAlloca child2->invalidateContentRect(child2Rect); ccLayerTreeHost->updateLayers(m_queue, (3 * 1) * (100 * 100) * 4); { - DebugScopedSetImplThread implThread; updateTextures(1000); EXPECT_EQ(0, root->fakeLayerTextureUpdater()->updateCount()); EXPECT_EQ(0, child->fakeLayerTextureUpdater()->updateCount()); @@ -1455,12 +1450,12 @@ TEST_F(TiledLayerChromiumTest, dontAllocateContentsWhenTargetSurfaceCantBeAlloca child->fakeLayerTextureUpdater()->clearUpdateCount(); child2->fakeLayerTextureUpdater()->clearUpdateCount(); - OwnPtr<FakeCCTiledLayerImpl> rootImpl(adoptPtr(new FakeCCTiledLayerImpl(root->id()))); - OwnPtr<FakeCCTiledLayerImpl> childImpl(adoptPtr(new FakeCCTiledLayerImpl(child->id()))); - OwnPtr<FakeCCTiledLayerImpl> child2Impl(adoptPtr(new FakeCCTiledLayerImpl(child2->id()))); - root->pushPropertiesTo(rootImpl.get()); - child->pushPropertiesTo(childImpl.get()); - child2->pushPropertiesTo(child2Impl.get()); + ScopedFakeCCTiledLayerImpl rootImpl(root->id()); + ScopedFakeCCTiledLayerImpl childImpl(child->id()); + ScopedFakeCCTiledLayerImpl child2Impl(child2->id()); + layerPushPropertiesTo(root.get(), rootImpl.get()); + layerPushPropertiesTo(child.get(), childImpl.get()); + layerPushPropertiesTo(child2.get(), child2Impl.get()); for (unsigned i = 0; i < 3; ++i) { for (unsigned j = 0; j < 2; ++j) @@ -1471,13 +1466,9 @@ TEST_F(TiledLayerChromiumTest, dontAllocateContentsWhenTargetSurfaceCantBeAlloca } ccLayerTreeHost->commitComplete(); - { - DebugScopedSetImplThread implThread; - ccLayerTreeHost->contentsTextureManager()->clearAllMemory(m_resourceProvider.get()); - } + textureManagerClearAllMemory(ccLayerTreeHost->contentsTextureManager(), m_resourceProvider.get()); ccLayerTreeHost->setRootLayer(0); ccLayerTreeHost.clear(); - WebKit::WebCompositor::shutdown(); } class TrackingLayerPainter : public LayerPainterChromium { @@ -1540,18 +1531,14 @@ TEST_F(TiledLayerChromiumTest, nonIntegerContentsScaleIsNotDistortedDuringPaint) layer->update(m_queue, 0, m_stats); layer->trackingLayerPainter()->resetPaintedRect(); - EXPECT_INT_RECT_EQ(IntRect(), layer->trackingLayerPainter()->paintedRect()); - - { - DebugScopedSetImplThread implThread; - updateTextures(); - } + EXPECT_RECT_EQ(IntRect(), layer->trackingLayerPainter()->paintedRect()); + updateTextures(); // Invalidate the entire layer in content space. When painting, the rect given to webkit should match the layer's bounds. layer->invalidateContentRect(contentRect); layer->update(m_queue, 0, m_stats); - EXPECT_INT_RECT_EQ(layerRect, layer->trackingLayerPainter()->paintedRect()); + EXPECT_RECT_EQ(layerRect, layer->trackingLayerPainter()->paintedRect()); } TEST_F(TiledLayerChromiumTest, nonIntegerContentsScaleIsNotDistortedDuringInvalidation) @@ -1574,18 +1561,14 @@ TEST_F(TiledLayerChromiumTest, nonIntegerContentsScaleIsNotDistortedDuringInvali layer->update(m_queue, 0, m_stats); layer->trackingLayerPainter()->resetPaintedRect(); - EXPECT_INT_RECT_EQ(IntRect(), layer->trackingLayerPainter()->paintedRect()); - - { - DebugScopedSetImplThread implThread; - updateTextures(); - } + EXPECT_RECT_EQ(IntRect(), layer->trackingLayerPainter()->paintedRect()); + updateTextures(); // Invalidate the entire layer in layer space. When painting, the rect given to webkit should match the layer's bounds. layer->setNeedsDisplayRect(layerRect); layer->update(m_queue, 0, m_stats); - EXPECT_INT_RECT_EQ(layerRect, layer->trackingLayerPainter()->paintedRect()); + EXPECT_RECT_EQ(layerRect, layer->trackingLayerPainter()->paintedRect()); } } // namespace |