| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/trees/layer_tree_host.h" | 5 #include "cc/trees/layer_tree_host.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/synchronization/lock.h" | 9 #include "base/synchronization/lock.h" |
| 10 #include "cc/animation/timing_function.h" | 10 #include "cc/animation/timing_function.h" |
| (...skipping 2339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2350 scoped_refptr<Layer> layer = PictureLayer::Create(&client_); | 2350 scoped_refptr<Layer> layer = PictureLayer::Create(&client_); |
| 2351 layer->SetTransform(gfx::Transform(0.0, 0.0, 0.0, 0.0, 0.0, 0.0)); | 2351 layer->SetTransform(gfx::Transform(0.0, 0.0, 0.0, 0.0, 0.0, 0.0)); |
| 2352 layer->SetBounds(gfx::Size(10, 10)); | 2352 layer->SetBounds(gfx::Size(10, 10)); |
| 2353 layer_tree_host()->root_layer()->AddChild(layer); | 2353 layer_tree_host()->root_layer()->AddChild(layer); |
| 2354 } | 2354 } |
| 2355 | 2355 |
| 2356 virtual void BeginTest() OVERRIDE { | 2356 virtual void BeginTest() OVERRIDE { |
| 2357 PostSetNeedsCommitToMainThread(); | 2357 PostSetNeedsCommitToMainThread(); |
| 2358 } | 2358 } |
| 2359 | 2359 |
| 2360 virtual void TreeActivatedOnThread(LayerTreeHostImpl* host_impl) { | 2360 virtual void TreeActivatedOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { |
| 2361 EndTest(); | 2361 EndTest(); |
| 2362 } | 2362 } |
| 2363 | 2363 |
| 2364 virtual void AfterTest() OVERRIDE { | 2364 virtual void AfterTest() OVERRIDE { |
| 2365 } | 2365 } |
| 2366 | 2366 |
| 2367 FakeContentLayerClient client_; | 2367 FakeContentLayerClient client_; |
| 2368 }; | 2368 }; |
| 2369 | 2369 |
| 2370 MULTI_THREAD_TEST_F( | 2370 MULTI_THREAD_TEST_F( |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2570 root->AddChild(child); | 2570 root->AddChild(child); |
| 2571 | 2571 |
| 2572 layer_tree_host()->SetRootLayer(root); | 2572 layer_tree_host()->SetRootLayer(root); |
| 2573 LayerTreeHostTest::SetupTree(); | 2573 LayerTreeHostTest::SetupTree(); |
| 2574 } | 2574 } |
| 2575 | 2575 |
| 2576 virtual void BeginTest() OVERRIDE { | 2576 virtual void BeginTest() OVERRIDE { |
| 2577 PostSetNeedsCommitToMainThread(); | 2577 PostSetNeedsCommitToMainThread(); |
| 2578 } | 2578 } |
| 2579 | 2579 |
| 2580 virtual void DidCommitAndDrawFrame() { | 2580 virtual void DidCommitAndDrawFrame() OVERRIDE { |
| 2581 WaitForCallback(); | 2581 WaitForCallback(); |
| 2582 } | 2582 } |
| 2583 | 2583 |
| 2584 void WaitForCallback() { | 2584 void WaitForCallback() { |
| 2585 base::MessageLoop::current()->PostTask( | 2585 base::MessageLoop::current()->PostTask( |
| 2586 FROM_HERE, | 2586 FROM_HERE, |
| 2587 base::Bind( | 2587 base::Bind( |
| 2588 &LayerTreeHostTestAsyncReadback::NextStep, | 2588 &LayerTreeHostTestAsyncReadback::NextStep, |
| 2589 base::Unretained(this))); | 2589 base::Unretained(this))); |
| 2590 } | 2590 } |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2632 break; | 2632 break; |
| 2633 } | 2633 } |
| 2634 } | 2634 } |
| 2635 | 2635 |
| 2636 void BitmapCallback(scoped_ptr<SkBitmap> bitmap) { | 2636 void BitmapCallback(scoped_ptr<SkBitmap> bitmap) { |
| 2637 EXPECT_TRUE(layer_tree_host()->proxy()->IsMainThread()); | 2637 EXPECT_TRUE(layer_tree_host()->proxy()->IsMainThread()); |
| 2638 EXPECT_TRUE(bitmap); | 2638 EXPECT_TRUE(bitmap); |
| 2639 callbacks_.push_back(gfx::Size(bitmap->width(), bitmap->height())); | 2639 callbacks_.push_back(gfx::Size(bitmap->width(), bitmap->height())); |
| 2640 } | 2640 } |
| 2641 | 2641 |
| 2642 virtual void AfterTest() { | 2642 virtual void AfterTest() OVERRIDE { |
| 2643 EXPECT_EQ(4u, callbacks_.size()); | 2643 EXPECT_EQ(4u, callbacks_.size()); |
| 2644 } | 2644 } |
| 2645 | 2645 |
| 2646 virtual scoped_ptr<OutputSurface> CreateOutputSurface() OVERRIDE { | 2646 virtual scoped_ptr<OutputSurface> CreateOutputSurface() OVERRIDE { |
| 2647 if (use_gl_renderer_) | 2647 if (use_gl_renderer_) |
| 2648 return FakeOutputSurface::Create3d().PassAs<OutputSurface>(); | 2648 return FakeOutputSurface::Create3d().PassAs<OutputSurface>(); |
| 2649 return FakeOutputSurface::CreateSoftware( | 2649 return FakeOutputSurface::CreateSoftware( |
| 2650 make_scoped_ptr(new SoftwareOutputDevice)).PassAs<OutputSurface>(); | 2650 make_scoped_ptr(new SoftwareOutputDevice)).PassAs<OutputSurface>(); |
| 2651 } | 2651 } |
| 2652 | 2652 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2693 | 2693 |
| 2694 layer_tree_host()->SetRootLayer(root_); | 2694 layer_tree_host()->SetRootLayer(root_); |
| 2695 LayerTreeHostTest::SetupTree(); | 2695 LayerTreeHostTest::SetupTree(); |
| 2696 } | 2696 } |
| 2697 | 2697 |
| 2698 virtual void BeginTest() OVERRIDE { | 2698 virtual void BeginTest() OVERRIDE { |
| 2699 callback_count_ = 0; | 2699 callback_count_ = 0; |
| 2700 PostSetNeedsCommitToMainThread(); | 2700 PostSetNeedsCommitToMainThread(); |
| 2701 } | 2701 } |
| 2702 | 2702 |
| 2703 virtual void DidCommit() { | 2703 virtual void DidCommit() OVERRIDE { |
| 2704 int frame = layer_tree_host()->commit_number(); | 2704 int frame = layer_tree_host()->commit_number(); |
| 2705 switch (frame) { | 2705 switch (frame) { |
| 2706 case 1: | 2706 case 1: |
| 2707 main_destroyed_->RequestCopyAsBitmap(base::Bind( | 2707 main_destroyed_->RequestCopyAsBitmap(base::Bind( |
| 2708 &LayerTreeHostTestAsyncReadbackLayerDestroyed::BitmapCallback, | 2708 &LayerTreeHostTestAsyncReadbackLayerDestroyed::BitmapCallback, |
| 2709 base::Unretained(this))); | 2709 base::Unretained(this))); |
| 2710 impl_destroyed_->RequestCopyAsBitmap(base::Bind( | 2710 impl_destroyed_->RequestCopyAsBitmap(base::Bind( |
| 2711 &LayerTreeHostTestAsyncReadbackLayerDestroyed::BitmapCallback, | 2711 &LayerTreeHostTestAsyncReadbackLayerDestroyed::BitmapCallback, |
| 2712 base::Unretained(this))); | 2712 base::Unretained(this))); |
| 2713 EXPECT_EQ(0, callback_count_); | 2713 EXPECT_EQ(0, callback_count_); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2748 break; | 2748 break; |
| 2749 } | 2749 } |
| 2750 } | 2750 } |
| 2751 | 2751 |
| 2752 void BitmapCallback(scoped_ptr<SkBitmap> bitmap) { | 2752 void BitmapCallback(scoped_ptr<SkBitmap> bitmap) { |
| 2753 EXPECT_TRUE(layer_tree_host()->proxy()->IsMainThread()); | 2753 EXPECT_TRUE(layer_tree_host()->proxy()->IsMainThread()); |
| 2754 EXPECT_FALSE(bitmap); | 2754 EXPECT_FALSE(bitmap); |
| 2755 ++callback_count_; | 2755 ++callback_count_; |
| 2756 } | 2756 } |
| 2757 | 2757 |
| 2758 virtual void AfterTest() {} | 2758 virtual void AfterTest() OVERRIDE {} |
| 2759 | 2759 |
| 2760 int callback_count_; | 2760 int callback_count_; |
| 2761 FakeContentLayerClient client_; | 2761 FakeContentLayerClient client_; |
| 2762 scoped_refptr<FakeContentLayer> root_; | 2762 scoped_refptr<FakeContentLayer> root_; |
| 2763 scoped_refptr<FakeContentLayer> main_destroyed_; | 2763 scoped_refptr<FakeContentLayer> main_destroyed_; |
| 2764 scoped_refptr<FakeContentLayer> impl_destroyed_; | 2764 scoped_refptr<FakeContentLayer> impl_destroyed_; |
| 2765 }; | 2765 }; |
| 2766 | 2766 |
| 2767 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestAsyncReadbackLayerDestroyed); | 2767 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestAsyncReadbackLayerDestroyed); |
| 2768 | 2768 |
| 2769 } // namespace | 2769 } // namespace |
| 2770 } // namespace cc | 2770 } // namespace cc |
| OLD | NEW |