Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(176)

Side by Side Diff: ui/compositor/layer_unittest.cc

Issue 2335043002: CC Animation: Move animations_ from ElementAnimations to AnimationPlayer. (Closed)
Patch Set: Clean it up harder. Rework UpdateClientAnimationState. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ui/compositor/layer.h" 5 #include "ui/compositor/layer.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
11 11
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
14 #include "base/files/file_path.h" 14 #include "base/files/file_path.h"
15 #include "base/files/file_util.h" 15 #include "base/files/file_util.h"
16 #include "base/json/json_reader.h" 16 #include "base/json/json_reader.h"
17 #include "base/macros.h" 17 #include "base/macros.h"
18 #include "base/memory/ptr_util.h" 18 #include "base/memory/ptr_util.h"
19 #include "base/message_loop/message_loop.h" 19 #include "base/message_loop/message_loop.h"
20 #include "base/path_service.h" 20 #include "base/path_service.h"
21 #include "base/strings/string_util.h" 21 #include "base/strings/string_util.h"
22 #include "base/strings/stringprintf.h" 22 #include "base/strings/stringprintf.h"
23 #include "base/strings/utf_string_conversions.h" 23 #include "base/strings/utf_string_conversions.h"
24 #include "base/trace_event/trace_event.h" 24 #include "base/trace_event/trace_event.h"
25 #include "cc/animation/animation_player.h"
25 #include "cc/layers/layer.h" 26 #include "cc/layers/layer.h"
26 #include "cc/output/copy_output_request.h" 27 #include "cc/output/copy_output_request.h"
27 #include "cc/output/copy_output_result.h" 28 #include "cc/output/copy_output_result.h"
28 #include "cc/surfaces/surface_id.h" 29 #include "cc/surfaces/surface_id.h"
29 #include "cc/surfaces/surface_sequence.h" 30 #include "cc/surfaces/surface_sequence.h"
30 #include "cc/test/pixel_test_utils.h" 31 #include "cc/test/pixel_test_utils.h"
31 #include "testing/gtest/include/gtest/gtest.h" 32 #include "testing/gtest/include/gtest/gtest.h"
32 #include "third_party/khronos/GLES2/gl2.h" 33 #include "third_party/khronos/GLES2/gl2.h"
33 #include "ui/compositor/compositor_observer.h" 34 #include "ui/compositor/compositor_observer.h"
34 #include "ui/compositor/dip_util.h" 35 #include "ui/compositor/dip_util.h"
(...skipping 1749 matching lines...) Expand 10 before | Expand all | Expand 10 after
1784 1785
1785 // Tests Layer::AddThreadedAnimation and Layer::RemoveThreadedAnimation. 1786 // Tests Layer::AddThreadedAnimation and Layer::RemoveThreadedAnimation.
1786 TEST_F(LayerWithRealCompositorTest, AddRemoveThreadedAnimations) { 1787 TEST_F(LayerWithRealCompositorTest, AddRemoveThreadedAnimations) {
1787 std::unique_ptr<Layer> root(CreateLayer(LAYER_TEXTURED)); 1788 std::unique_ptr<Layer> root(CreateLayer(LAYER_TEXTURED));
1788 std::unique_ptr<Layer> l1(CreateLayer(LAYER_TEXTURED)); 1789 std::unique_ptr<Layer> l1(CreateLayer(LAYER_TEXTURED));
1789 std::unique_ptr<Layer> l2(CreateLayer(LAYER_TEXTURED)); 1790 std::unique_ptr<Layer> l2(CreateLayer(LAYER_TEXTURED));
1790 1791
1791 l1->SetAnimator(LayerAnimator::CreateImplicitAnimator()); 1792 l1->SetAnimator(LayerAnimator::CreateImplicitAnimator());
1792 l2->SetAnimator(LayerAnimator::CreateImplicitAnimator()); 1793 l2->SetAnimator(LayerAnimator::CreateImplicitAnimator());
1793 1794
1794 EXPECT_FALSE(l1->HasPendingThreadedAnimationsForTesting()); 1795 auto player1 = l1->GetAnimator()->GetAnimationPlayerForTesting();
1796 auto player2 = l2->GetAnimator()->GetAnimationPlayerForTesting();
1797
1798 EXPECT_FALSE(player1->has_any_animation());
1795 1799
1796 // Trigger a threaded animation. 1800 // Trigger a threaded animation.
1797 l1->SetOpacity(0.5f); 1801 l1->SetOpacity(0.5f);
1798 1802
1799 EXPECT_TRUE(l1->HasPendingThreadedAnimationsForTesting()); 1803 EXPECT_TRUE(player1->has_any_animation());
1800 1804
1801 // Ensure we can remove a pending threaded animation. 1805 // Ensure we can remove a pending threaded animation.
1802 l1->GetAnimator()->StopAnimating(); 1806 l1->GetAnimator()->StopAnimating();
1803 1807
1804 EXPECT_FALSE(l1->HasPendingThreadedAnimationsForTesting()); 1808 EXPECT_FALSE(player1->has_any_animation());
1805 1809
1806 // Trigger another threaded animation. 1810 // Trigger another threaded animation.
1807 l1->SetOpacity(0.2f); 1811 l1->SetOpacity(0.2f);
1808 1812
1809 EXPECT_TRUE(l1->HasPendingThreadedAnimationsForTesting()); 1813 EXPECT_TRUE(player1->has_any_animation());
1810 1814
1811 root->Add(l1.get()); 1815 root->Add(l1.get());
1812 GetCompositor()->SetRootLayer(root.get()); 1816 GetCompositor()->SetRootLayer(root.get());
1813 1817
1814 // Now that l1 is part of a tree, it should have dispatched the pending 1818 // Now l1 is part of a tree.
1815 // animation. 1819 EXPECT_TRUE(player1->has_any_animation());
1816 EXPECT_FALSE(l1->HasPendingThreadedAnimationsForTesting());
1817 1820
1818 // Ensure that l1 no longer holds on to animations.
1819 l1->SetOpacity(0.1f); 1821 l1->SetOpacity(0.1f);
1820 EXPECT_FALSE(l1->HasPendingThreadedAnimationsForTesting()); 1822 // IMMEDIATELY_SET_NEW_TARGET is a default preemption strategy for conflicting
1823 // animations.
1824 EXPECT_FALSE(player1->has_any_animation());
1821 1825
1822 // Ensure that adding a layer to an existing tree causes its pending 1826 // Adding a layer to an existing tree.
1823 // animations to get dispatched.
1824 l2->SetOpacity(0.5f); 1827 l2->SetOpacity(0.5f);
1825 EXPECT_TRUE(l2->HasPendingThreadedAnimationsForTesting()); 1828 EXPECT_TRUE(player2->has_any_animation());
1826 1829
1827 l1->Add(l2.get()); 1830 l1->Add(l2.get());
1828 EXPECT_FALSE(l2->HasPendingThreadedAnimationsForTesting()); 1831 EXPECT_TRUE(player2->has_any_animation());
1829 } 1832 }
1830 1833
1831 // Tests that in-progress threaded animations complete when a Layer's 1834 // Tests that in-progress threaded animations complete when a Layer's
1832 // cc::Layer changes. 1835 // cc::Layer changes.
1833 TEST_F(LayerWithRealCompositorTest, SwitchCCLayerAnimations) { 1836 TEST_F(LayerWithRealCompositorTest, SwitchCCLayerAnimations) {
1834 std::unique_ptr<Layer> root(CreateLayer(LAYER_TEXTURED)); 1837 std::unique_ptr<Layer> root(CreateLayer(LAYER_TEXTURED));
1835 std::unique_ptr<Layer> l1(CreateLayer(LAYER_TEXTURED)); 1838 std::unique_ptr<Layer> l1(CreateLayer(LAYER_TEXTURED));
1836 GetCompositor()->SetRootLayer(root.get()); 1839 GetCompositor()->SetRootLayer(root.get());
1837 root->Add(l1.get()); 1840 root->Add(l1.get());
1838 1841
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
2115 root->SetOpacity(0.5f); 2118 root->SetOpacity(0.5f);
2116 WaitForSwap(); 2119 WaitForSwap();
2117 EXPECT_EQ(1u, animation_observer.animation_step_count()); 2120 EXPECT_EQ(1u, animation_observer.animation_step_count());
2118 2121
2119 EXPECT_FALSE(animation_observer.shutdown()); 2122 EXPECT_FALSE(animation_observer.shutdown());
2120 ResetCompositor(); 2123 ResetCompositor();
2121 EXPECT_TRUE(animation_observer.shutdown()); 2124 EXPECT_TRUE(animation_observer.shutdown());
2122 } 2125 }
2123 2126
2124 } // namespace ui 2127 } // namespace ui
OLDNEW
« cc/animation/element_animations.h ('K') | « ui/compositor/layer_animator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698