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 2344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2355 scoped_refptr<Layer> layer = PictureLayer::Create(&client_); | 2355 scoped_refptr<Layer> layer = PictureLayer::Create(&client_); |
2356 layer->SetTransform(gfx::Transform(0.0, 0.0, 0.0, 0.0, 0.0, 0.0)); | 2356 layer->SetTransform(gfx::Transform(0.0, 0.0, 0.0, 0.0, 0.0, 0.0)); |
2357 layer->SetBounds(gfx::Size(10, 10)); | 2357 layer->SetBounds(gfx::Size(10, 10)); |
2358 layer_tree_host()->root_layer()->AddChild(layer); | 2358 layer_tree_host()->root_layer()->AddChild(layer); |
2359 } | 2359 } |
2360 | 2360 |
2361 virtual void BeginTest() OVERRIDE { | 2361 virtual void BeginTest() OVERRIDE { |
2362 PostSetNeedsCommitToMainThread(); | 2362 PostSetNeedsCommitToMainThread(); |
2363 } | 2363 } |
2364 | 2364 |
2365 virtual void TreeActivatedOnThread(LayerTreeHostImpl* host_impl) { | 2365 virtual void TreeActivatedOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { |
2366 EndTest(); | 2366 EndTest(); |
2367 } | 2367 } |
2368 | 2368 |
2369 virtual void AfterTest() OVERRIDE { | 2369 virtual void AfterTest() OVERRIDE { |
2370 } | 2370 } |
2371 | 2371 |
2372 FakeContentLayerClient client_; | 2372 FakeContentLayerClient client_; |
2373 }; | 2373 }; |
2374 | 2374 |
2375 MULTI_THREAD_TEST_F( | 2375 MULTI_THREAD_TEST_F( |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2575 root->AddChild(child); | 2575 root->AddChild(child); |
2576 | 2576 |
2577 layer_tree_host()->SetRootLayer(root); | 2577 layer_tree_host()->SetRootLayer(root); |
2578 LayerTreeHostTest::SetupTree(); | 2578 LayerTreeHostTest::SetupTree(); |
2579 } | 2579 } |
2580 | 2580 |
2581 virtual void BeginTest() OVERRIDE { | 2581 virtual void BeginTest() OVERRIDE { |
2582 PostSetNeedsCommitToMainThread(); | 2582 PostSetNeedsCommitToMainThread(); |
2583 } | 2583 } |
2584 | 2584 |
2585 virtual void DidCommitAndDrawFrame() { | 2585 virtual void DidCommitAndDrawFrame() OVERRIDE { |
2586 int frame = layer_tree_host()->commit_number(); | 2586 int frame = layer_tree_host()->commit_number(); |
2587 switch (frame) { | 2587 switch (frame) { |
2588 case 1: | 2588 case 1: |
2589 child->RequestCopyAsBitmap(base::Bind( | 2589 child->RequestCopyAsBitmap(base::Bind( |
2590 &LayerTreeHostTestAsyncReadback::BitmapCallback, | 2590 &LayerTreeHostTestAsyncReadback::BitmapCallback, |
2591 base::Unretained(this))); | 2591 base::Unretained(this))); |
2592 EXPECT_EQ(0u, callbacks_.size()); | 2592 EXPECT_EQ(0u, callbacks_.size()); |
2593 break; | 2593 break; |
2594 case 2: | 2594 case 2: |
2595 // Flush the message loops and make sure the callbacks run. | 2595 // Flush the message loops and make sure the callbacks run. |
(...skipping 29 matching lines...) Expand all Loading... |
2625 break; | 2625 break; |
2626 } | 2626 } |
2627 } | 2627 } |
2628 | 2628 |
2629 void BitmapCallback(scoped_ptr<SkBitmap> bitmap) { | 2629 void BitmapCallback(scoped_ptr<SkBitmap> bitmap) { |
2630 EXPECT_TRUE(layer_tree_host()->proxy()->IsMainThread()); | 2630 EXPECT_TRUE(layer_tree_host()->proxy()->IsMainThread()); |
2631 EXPECT_TRUE(bitmap); | 2631 EXPECT_TRUE(bitmap); |
2632 callbacks_.push_back(gfx::Size(bitmap->width(), bitmap->height())); | 2632 callbacks_.push_back(gfx::Size(bitmap->width(), bitmap->height())); |
2633 } | 2633 } |
2634 | 2634 |
2635 virtual void AfterTest() {} | 2635 virtual void AfterTest() OVERRIDE {} |
2636 | 2636 |
2637 virtual scoped_ptr<OutputSurface> CreateOutputSurface() OVERRIDE { | 2637 virtual scoped_ptr<OutputSurface> CreateOutputSurface() OVERRIDE { |
2638 if (use_gl_renderer_) | 2638 if (use_gl_renderer_) |
2639 return FakeOutputSurface::Create3d().PassAs<OutputSurface>(); | 2639 return FakeOutputSurface::Create3d().PassAs<OutputSurface>(); |
2640 return FakeOutputSurface::CreateSoftware( | 2640 return FakeOutputSurface::CreateSoftware( |
2641 make_scoped_ptr(new SoftwareOutputDevice)).PassAs<OutputSurface>(); | 2641 make_scoped_ptr(new SoftwareOutputDevice)).PassAs<OutputSurface>(); |
2642 } | 2642 } |
2643 | 2643 |
2644 bool use_gl_renderer_; | 2644 bool use_gl_renderer_; |
2645 std::vector<gfx::Size> callbacks_; | 2645 std::vector<gfx::Size> callbacks_; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2684 | 2684 |
2685 layer_tree_host()->SetRootLayer(root_); | 2685 layer_tree_host()->SetRootLayer(root_); |
2686 LayerTreeHostTest::SetupTree(); | 2686 LayerTreeHostTest::SetupTree(); |
2687 } | 2687 } |
2688 | 2688 |
2689 virtual void BeginTest() OVERRIDE { | 2689 virtual void BeginTest() OVERRIDE { |
2690 callback_count_ = 0; | 2690 callback_count_ = 0; |
2691 PostSetNeedsCommitToMainThread(); | 2691 PostSetNeedsCommitToMainThread(); |
2692 } | 2692 } |
2693 | 2693 |
2694 virtual void DidCommit() { | 2694 virtual void DidCommit() OVERRIDE { |
2695 int frame = layer_tree_host()->commit_number(); | 2695 int frame = layer_tree_host()->commit_number(); |
2696 switch (frame) { | 2696 switch (frame) { |
2697 case 1: | 2697 case 1: |
2698 main_destroyed_->RequestCopyAsBitmap(base::Bind( | 2698 main_destroyed_->RequestCopyAsBitmap(base::Bind( |
2699 &LayerTreeHostTestAsyncReadbackLayerDestroyed::BitmapCallback, | 2699 &LayerTreeHostTestAsyncReadbackLayerDestroyed::BitmapCallback, |
2700 base::Unretained(this))); | 2700 base::Unretained(this))); |
2701 impl_destroyed_->RequestCopyAsBitmap(base::Bind( | 2701 impl_destroyed_->RequestCopyAsBitmap(base::Bind( |
2702 &LayerTreeHostTestAsyncReadbackLayerDestroyed::BitmapCallback, | 2702 &LayerTreeHostTestAsyncReadbackLayerDestroyed::BitmapCallback, |
2703 base::Unretained(this))); | 2703 base::Unretained(this))); |
2704 EXPECT_EQ(0, callback_count_); | 2704 EXPECT_EQ(0, callback_count_); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2739 break; | 2739 break; |
2740 } | 2740 } |
2741 } | 2741 } |
2742 | 2742 |
2743 void BitmapCallback(scoped_ptr<SkBitmap> bitmap) { | 2743 void BitmapCallback(scoped_ptr<SkBitmap> bitmap) { |
2744 EXPECT_TRUE(layer_tree_host()->proxy()->IsMainThread()); | 2744 EXPECT_TRUE(layer_tree_host()->proxy()->IsMainThread()); |
2745 EXPECT_FALSE(bitmap); | 2745 EXPECT_FALSE(bitmap); |
2746 ++callback_count_; | 2746 ++callback_count_; |
2747 } | 2747 } |
2748 | 2748 |
2749 virtual void AfterTest() {} | 2749 virtual void AfterTest() OVERRIDE {} |
2750 | 2750 |
2751 int callback_count_; | 2751 int callback_count_; |
2752 FakeContentLayerClient client_; | 2752 FakeContentLayerClient client_; |
2753 scoped_refptr<FakeContentLayer> root_; | 2753 scoped_refptr<FakeContentLayer> root_; |
2754 scoped_refptr<FakeContentLayer> main_destroyed_; | 2754 scoped_refptr<FakeContentLayer> main_destroyed_; |
2755 scoped_refptr<FakeContentLayer> impl_destroyed_; | 2755 scoped_refptr<FakeContentLayer> impl_destroyed_; |
2756 }; | 2756 }; |
2757 | 2757 |
2758 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestAsyncReadbackLayerDestroyed); | 2758 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestAsyncReadbackLayerDestroyed); |
2759 | 2759 |
2760 } // namespace | 2760 } // namespace |
2761 } // namespace cc | 2761 } // namespace cc |
OLD | NEW |