summaryrefslogtreecommitdiffstats
path: root/cc/layer_unittest.cc
diff options
context:
space:
mode:
authorjunov@chromium.org <junov@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-26 00:57:38 +0000
committerjunov@chromium.org <junov@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-26 00:57:38 +0000
commit031ccfff942f5a5d797137613c87f738264e1423 (patch)
tree78397a67ad8526a2c8fbf596586d4d2dee46a3d9 /cc/layer_unittest.cc
parent574ef63851a8d31b411f88adc34b1371ee6779dd (diff)
downloadchromium_src-031ccfff942f5a5d797137613c87f738264e1423.zip
chromium_src-031ccfff942f5a5d797137613c87f738264e1423.tar.gz
chromium_src-031ccfff942f5a5d797137613c87f738264e1423.tar.bz2
Prevent TextureLayer from triggering commits and texture acquisitions when
the layer does not draw its contents. BUG=138448 TEST=cc_unittests TextureLayerTest.syncImplWhenDrawing Review URL: https://chromiumcodereview.appspot.com/11226061 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@164228 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/layer_unittest.cc')
-rw-r--r--cc/layer_unittest.cc14
1 files changed, 13 insertions, 1 deletions
diff --git a/cc/layer_unittest.cc b/cc/layer_unittest.cc
index 2235b42..60a0539 100644
--- a/cc/layer_unittest.cc
+++ b/cc/layer_unittest.cc
@@ -157,7 +157,6 @@ TEST_F(LayerTest, addAndRemoveChild)
EXPECT_FALSE(child->parent());
EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, m_layerTreeHost->setRootLayer(parent));
-
EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, parent->addChild(child));
ASSERT_EQ(static_cast<size_t>(1), parent->children().size());
@@ -421,6 +420,7 @@ TEST_F(LayerTest, checkSetNeedsDisplayCausesCorrectBehavior)
scoped_refptr<Layer> testLayer = Layer::create();
testLayer->setLayerTreeHost(m_layerTreeHost.get());
+ EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setIsDrawable(true));
IntSize testBounds = IntSize(501, 508);
@@ -436,6 +436,7 @@ TEST_F(LayerTest, checkSetNeedsDisplayCausesCorrectBehavior)
EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setBounds(testBounds));
testLayer = Layer::create();
testLayer->setLayerTreeHost(m_layerTreeHost.get());
+ EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setIsDrawable(true));
EXPECT_FALSE(testLayer->needsDisplay());
// The real test begins here.
@@ -455,6 +456,7 @@ TEST_F(LayerTest, checkSetNeedsDisplayCausesCorrectBehavior)
// Case 4: Layer should accept dirty rects that go beyond its bounds.
testLayer = Layer::create();
testLayer->setLayerTreeHost(m_layerTreeHost.get());
+ EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setIsDrawable(true));
EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setBounds(testBounds));
EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setNeedsDisplayRect(outOfBoundsDirtyRect));
EXPECT_TRUE(testLayer->needsDisplay());
@@ -462,15 +464,24 @@ TEST_F(LayerTest, checkSetNeedsDisplayCausesCorrectBehavior)
// Case 5: setNeedsDisplay() without the dirty rect arg.
testLayer = Layer::create();
testLayer->setLayerTreeHost(m_layerTreeHost.get());
+ EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setIsDrawable(true));
EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setBounds(testBounds));
EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setNeedsDisplay());
EXPECT_TRUE(testLayer->needsDisplay());
+
+ // Case 6: setNeedsDisplay() with a non-drawable layer
+ testLayer = Layer::create();
+ testLayer->setLayerTreeHost(m_layerTreeHost.get());
+ EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setBounds(testBounds));
+ EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setNeedsDisplayRect(dirty1));
+ EXPECT_TRUE(testLayer->needsDisplay());
}
TEST_F(LayerTest, checkPropertyChangeCausesCorrectBehavior)
{
scoped_refptr<Layer> testLayer = Layer::create();
testLayer->setLayerTreeHost(m_layerTreeHost.get());
+ EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setIsDrawable(true));
scoped_refptr<Layer> dummyLayer = Layer::create(); // just a dummy layer for this test case.
@@ -577,6 +588,7 @@ private:
TEST_F(LayerTest, checkContentsScaleChangeTriggersNeedsDisplay)
{
scoped_refptr<LayerWithContentScaling> testLayer = make_scoped_refptr(new LayerWithContentScaling());
+ testLayer->setIsDrawable(true);
testLayer->setLayerTreeHost(m_layerTreeHost.get());
IntSize testBounds = IntSize(320, 240);