Commit 12233c36 authored by vollick@chromium.org's avatar vollick@chromium.org

Avoids some asserts with ToT WebKit by using valid layers. Using all empty...

Avoids some asserts with ToT WebKit by using valid layers. Using all empty layers or resetting the root layer unnecessarily was causing problems.

BUG=None
TEST=compositor_unittest

Review URL: http://codereview.chromium.org/8561014

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@110935 0039d316-1c4b-4281-b951-d872f2087c98
parent 570f1e14
......@@ -35,6 +35,8 @@ void Compositor::ScheduleDraw() {
}
void Compositor::SetRootLayer(Layer* root_layer) {
if (root_layer_ == root_layer)
return;
if (root_layer_)
root_layer_->SetCompositor(NULL);
root_layer_ = root_layer;
......
......@@ -1119,27 +1119,29 @@ TEST_F(LayerWithRealCompositorTest, MAYBE_DrawPixels) {
// Checks the logic around Compositor::SetRootLayer and Layer::SetCompositor.
TEST_F(LayerWithRealCompositorTest, MAYBE_SetRootLayer) {
Compositor* compositor = GetCompositor();
Layer l1;
EXPECT_EQ(NULL, l1.GetCompositor());
scoped_ptr<Layer> l1(CreateColorLayer(SK_ColorRED,
gfx::Rect(20, 20, 400, 400)));
scoped_ptr<Layer> l2(CreateColorLayer(SK_ColorBLUE,
gfx::Rect(10, 10, 350, 350)));
Layer l2;
EXPECT_EQ(NULL, l2.GetCompositor());
EXPECT_EQ(NULL, l1->GetCompositor());
EXPECT_EQ(NULL, l2->GetCompositor());
compositor->SetRootLayer(&l1);
EXPECT_EQ(compositor, l1.GetCompositor());
compositor->SetRootLayer(l1.get());
EXPECT_EQ(compositor, l1->GetCompositor());
l1.Add(&l2);
EXPECT_EQ(compositor, l2.GetCompositor());
l1->Add(l2.get());
EXPECT_EQ(compositor, l2->GetCompositor());
l1.Remove(&l2);
EXPECT_EQ(NULL, l2.GetCompositor());
l1->Remove(l2.get());
EXPECT_EQ(NULL, l2->GetCompositor());
l1.Add(&l2);
EXPECT_EQ(compositor, l2.GetCompositor());
l1->Add(l2.get());
EXPECT_EQ(compositor, l2->GetCompositor());
compositor->SetRootLayer(NULL);
EXPECT_EQ(NULL, l1.GetCompositor());
EXPECT_EQ(NULL, l2.GetCompositor());
EXPECT_EQ(NULL, l1->GetCompositor());
EXPECT_EQ(NULL, l2->GetCompositor());
}
// Checks that compositor observers are notified when:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment