OLD | NEW |
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> |
(...skipping 908 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
919 | 919 |
920 // The CompositorDelegate (us) should have been told to draw for a move. | 920 // The CompositorDelegate (us) should have been told to draw for a move. |
921 WaitForDraw(); | 921 WaitForDraw(); |
922 | 922 |
923 l1->SetBounds(gfx::Rect(5, 5, 100, 100)); | 923 l1->SetBounds(gfx::Rect(5, 5, 100, 100)); |
924 | 924 |
925 // The CompositorDelegate (us) should have been told to draw for a resize. | 925 // The CompositorDelegate (us) should have been told to draw for a resize. |
926 WaitForDraw(); | 926 WaitForDraw(); |
927 } | 927 } |
928 | 928 |
929 // Checks that the damage rect for a TextureLayer is empty after a commit. | |
930 TEST_F(LayerWithNullDelegateTest, EmptyDamagedRect) { | |
931 std::unique_ptr<Layer> root(CreateLayer(LAYER_SOLID_COLOR)); | |
932 cc::TextureMailbox mailbox(gpu::Mailbox::Generate(), gpu::SyncToken(), 0); | |
933 bool callback_run = false; | |
934 root->SetTextureMailbox(mailbox, cc::SingleReleaseCallback::Create(base::Bind( | |
935 ReturnMailbox, &callback_run)), | |
936 gfx::Size(10, 10)); | |
937 compositor()->SetRootLayer(root.get()); | |
938 | |
939 root->SetBounds(gfx::Rect(0, 0, 10, 10)); | |
940 root->SetVisible(true); | |
941 WaitForCommit(); | |
942 | |
943 gfx::Rect damaged_rect(0, 0, 5, 5); | |
944 root->SchedulePaint(damaged_rect); | |
945 EXPECT_EQ(damaged_rect, root->damaged_region_for_testing().bounds()); | |
946 WaitForCommit(); | |
947 EXPECT_TRUE(root->damaged_region_for_testing().IsEmpty()); | |
948 | |
949 compositor()->SetRootLayer(nullptr); | |
950 } | |
951 | |
952 void ExpectRgba(int x, int y, SkColor expected_color, SkColor actual_color) { | 929 void ExpectRgba(int x, int y, SkColor expected_color, SkColor actual_color) { |
953 EXPECT_EQ(expected_color, actual_color) | 930 EXPECT_EQ(expected_color, actual_color) |
954 << "Pixel error at x=" << x << " y=" << y << "; " | 931 << "Pixel error at x=" << x << " y=" << y << "; " |
955 << "actual RGBA=(" | 932 << "actual RGBA=(" |
956 << SkColorGetR(actual_color) << "," | 933 << SkColorGetR(actual_color) << "," |
957 << SkColorGetG(actual_color) << "," | 934 << SkColorGetG(actual_color) << "," |
958 << SkColorGetB(actual_color) << "," | 935 << SkColorGetB(actual_color) << "," |
959 << SkColorGetA(actual_color) << "); " | 936 << SkColorGetA(actual_color) << "); " |
960 << "expected RGBA=(" | 937 << "expected RGBA=(" |
961 << SkColorGetR(expected_color) << "," | 938 << SkColorGetR(expected_color) << "," |
(...skipping 938 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1900 root->SetOpacity(0.5f); | 1877 root->SetOpacity(0.5f); |
1901 WaitForSwap(); | 1878 WaitForSwap(); |
1902 EXPECT_EQ(1u, animation_observer.animation_step_count()); | 1879 EXPECT_EQ(1u, animation_observer.animation_step_count()); |
1903 | 1880 |
1904 EXPECT_FALSE(animation_observer.shutdown()); | 1881 EXPECT_FALSE(animation_observer.shutdown()); |
1905 ResetCompositor(); | 1882 ResetCompositor(); |
1906 EXPECT_TRUE(animation_observer.shutdown()); | 1883 EXPECT_TRUE(animation_observer.shutdown()); |
1907 } | 1884 } |
1908 | 1885 |
1909 } // namespace ui | 1886 } // namespace ui |
OLD | NEW |