Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(418)

Unified Diff: Source/WebKit/chromium/tests/LayerRendererChromiumTest.cpp

Issue 10690121: Merge 121076 - [chromium] LayerRendererChromium is not getting visibility messages in single thread… (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/1180/
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/WebKit/chromium/tests/LayerRendererChromiumTest.cpp
===================================================================
--- Source/WebKit/chromium/tests/LayerRendererChromiumTest.cpp (revision 122257)
+++ Source/WebKit/chromium/tests/LayerRendererChromiumTest.cpp (working copy)
@@ -83,12 +83,13 @@
}
// CCRendererClient methods.
- virtual const IntSize& deviceViewportSize() const OVERRIDE { static IntSize fakeSize; return fakeSize; }
+ virtual const IntSize& deviceViewportSize() const OVERRIDE { static IntSize fakeSize(1, 1); return fakeSize; }
virtual const CCLayerTreeSettings& settings() const OVERRIDE { static CCLayerTreeSettings fakeSettings; return fakeSettings; }
virtual void didLoseContext() OVERRIDE { }
virtual void onSwapBuffersComplete() OVERRIDE { }
virtual void setFullRootLayerDamage() OVERRIDE { m_setFullRootLayerDamageCount++; }
- virtual void setContentsMemoryAllocationLimitBytes(size_t bytes) OVERRIDE { m_memoryAllocationLimitBytes = bytes; }
+ virtual void releaseContentsTextures() OVERRIDE { }
+ virtual void setMemoryAllocationLimitBytes(size_t bytes) OVERRIDE { m_memoryAllocationLimitBytes = bytes; }
// Methods added for test.
int setFullRootLayerDamageCount() const { return m_setFullRootLayerDamageCount; }
@@ -167,20 +168,34 @@
}
// Test LayerRendererChromium discardFramebuffer functionality:
-// Suggest discarding framebuffer when one exists.
+// Suggest discarding framebuffer when one exists and the renderer is not visible.
// Expected: it is discarded and damage tracker is reset.
-TEST_F(LayerRendererChromiumTest, SuggestBackbufferNoShouldDiscardBackbufferAndDamageRootLayer)
+TEST_F(LayerRendererChromiumTest, SuggestBackbufferNoShouldDiscardBackbufferAndDamageRootLayerWhileNotVisible)
{
+ m_layerRendererChromium.setVisible(false);
m_mockContext.setMemoryAllocation(m_suggestHaveBackbufferNo);
EXPECT_EQ(1, m_mockClient.setFullRootLayerDamageCount());
EXPECT_TRUE(m_layerRendererChromium.isFramebufferDiscarded());
}
// Test LayerRendererChromium discardFramebuffer functionality:
+// Suggest discarding framebuffer when one exists and the renderer is visible.
+// Expected: the allocation is ignored.
+TEST_F(LayerRendererChromiumTest, SuggestBackbufferNoDoNothingWhenVisible)
+{
+ m_layerRendererChromium.setVisible(true);
+ m_mockContext.setMemoryAllocation(m_suggestHaveBackbufferNo);
+ EXPECT_EQ(0, m_mockClient.setFullRootLayerDamageCount());
+ EXPECT_FALSE(m_layerRendererChromium.isFramebufferDiscarded());
+}
+
+
+// Test LayerRendererChromium discardFramebuffer functionality:
// Suggest discarding framebuffer when one does not exist.
// Expected: it does nothing.
TEST_F(LayerRendererChromiumTest, SuggestBackbufferNoWhenItDoesntExistShouldDoNothing)
{
+ m_layerRendererChromium.setVisible(false);
m_mockContext.setMemoryAllocation(m_suggestHaveBackbufferNo);
EXPECT_EQ(1, m_mockClient.setFullRootLayerDamageCount());
EXPECT_TRUE(m_layerRendererChromium.isFramebufferDiscarded());
@@ -191,37 +206,37 @@
}
// Test LayerRendererChromium discardFramebuffer functionality:
-// Suggest discarding framebuffer, then try to swapBuffers.
-// Expected: framebuffer is discarded, swaps are ignored, and damage is reset after discard and after each swap.
-TEST_F(LayerRendererChromiumTest, SwapBuffersWhileBackbufferDiscardedShouldIgnoreSwapAndDamageRootLayer)
+// Begin drawing a frame while a framebuffer is discarded.
+// Expected: will recreate framebuffer.
+TEST_F(LayerRendererChromiumTest, DiscardedBackbufferIsRecreatedForScopeDuration)
{
+ m_layerRendererChromium.setVisible(false);
m_mockContext.setMemoryAllocation(m_suggestHaveBackbufferNo);
EXPECT_TRUE(m_layerRendererChromium.isFramebufferDiscarded());
EXPECT_EQ(1, m_mockClient.setFullRootLayerDamageCount());
- swapBuffers();
- EXPECT_EQ(0, m_mockContext.frameCount());
- EXPECT_EQ(2, m_mockClient.setFullRootLayerDamageCount());
+ m_layerRendererChromium.setVisible(true);
+ m_layerRendererChromium.beginDrawingFrame(m_mockClient.rootRenderPass());
+ EXPECT_FALSE(m_layerRendererChromium.isFramebufferDiscarded());
swapBuffers();
- EXPECT_EQ(0, m_mockContext.frameCount());
- EXPECT_EQ(3, m_mockClient.setFullRootLayerDamageCount());
+ EXPECT_EQ(1, m_mockContext.frameCount());
}
-// Test LayerRendererChromium discardFramebuffer functionality:
-// Begin drawing a frame while a framebuffer is discarded.
-// Expected: will recreate framebuffer.
-TEST_F(LayerRendererChromiumTest, DiscardedBackbufferIsRecreatredForScopeDuration)
+TEST_F(LayerRendererChromiumTest, FramebufferDiscardedAfterReadbackWhenNotVisible)
{
+ m_layerRendererChromium.setVisible(false);
m_mockContext.setMemoryAllocation(m_suggestHaveBackbufferNo);
EXPECT_TRUE(m_layerRendererChromium.isFramebufferDiscarded());
EXPECT_EQ(1, m_mockClient.setFullRootLayerDamageCount());
+ char pixels[4];
m_layerRendererChromium.beginDrawingFrame(m_mockClient.rootRenderPass());
EXPECT_FALSE(m_layerRendererChromium.isFramebufferDiscarded());
- swapBuffers();
- EXPECT_EQ(1, m_mockContext.frameCount());
+ m_layerRendererChromium.getFramebufferPixels(pixels, IntRect(0, 0, 1, 1));
+ EXPECT_TRUE(m_layerRendererChromium.isFramebufferDiscarded());
+ EXPECT_EQ(2, m_mockClient.setFullRootLayerDamageCount());
}
class ForbidSynchronousCallContext : public FakeWebGraphicsContext3D {
« no previous file with comments | « Source/WebKit/chromium/tests/FakeWebGraphicsContext3D.h ('k') | Source/WebKit/chromium/tests/TiledLayerChromiumTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698