diff options
| author | vollick@chromium.org <vollick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-21 16:09:25 +0000 |
|---|---|---|
| committer | vollick@chromium.org <vollick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-21 16:09:25 +0000 |
| commit | 12233c36eee3a1c047746aedb6d94ca49051d73d (patch) | |
| tree | 512a34c05e04e3132dde99bb74412505c64e9a51 | |
| parent | 570f1e1450a94b9ac2fc25f2c4a1847e16a7a132 (diff) | |
| download | chromium_src-12233c36eee3a1c047746aedb6d94ca49051d73d.zip chromium_src-12233c36eee3a1c047746aedb6d94ca49051d73d.tar.gz chromium_src-12233c36eee3a1c047746aedb6d94ca49051d73d.tar.bz2 | |
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
| -rw-r--r-- | ui/gfx/compositor/compositor.cc | 2 | ||||
| -rw-r--r-- | ui/gfx/compositor/layer_unittest.cc | 30 |
2 files changed, 18 insertions, 14 deletions
diff --git a/ui/gfx/compositor/compositor.cc b/ui/gfx/compositor/compositor.cc index 485dc2d..97508f3 100644 --- a/ui/gfx/compositor/compositor.cc +++ b/ui/gfx/compositor/compositor.cc @@ -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; diff --git a/ui/gfx/compositor/layer_unittest.cc b/ui/gfx/compositor/layer_unittest.cc index c8a609f..d9203ad 100644 --- a/ui/gfx/compositor/layer_unittest.cc +++ b/ui/gfx/compositor/layer_unittest.cc @@ -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: |
