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

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

Issue 2018223002: Clear ui::Layer damaged_region_ after commit. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
« ui/compositor/layer.cc ('K') | « ui/compositor/layer.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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>
(...skipping 908 matching lines...) Expand 10 before | Expand all | Expand 10 after
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,
946 root->damaged_region_for_testing()->bounds());
947 WaitForCommit();
948 EXPECT_TRUE(root->damaged_region_for_testing()->IsEmpty());
949
950 compositor()->SetRootLayer(nullptr);
951 }
952
929 void ExpectRgba(int x, int y, SkColor expected_color, SkColor actual_color) { 953 void ExpectRgba(int x, int y, SkColor expected_color, SkColor actual_color) {
930 EXPECT_EQ(expected_color, actual_color) 954 EXPECT_EQ(expected_color, actual_color)
931 << "Pixel error at x=" << x << " y=" << y << "; " 955 << "Pixel error at x=" << x << " y=" << y << "; "
932 << "actual RGBA=(" 956 << "actual RGBA=("
933 << SkColorGetR(actual_color) << "," 957 << SkColorGetR(actual_color) << ","
934 << SkColorGetG(actual_color) << "," 958 << SkColorGetG(actual_color) << ","
935 << SkColorGetB(actual_color) << "," 959 << SkColorGetB(actual_color) << ","
936 << SkColorGetA(actual_color) << "); " 960 << SkColorGetA(actual_color) << "); "
937 << "expected RGBA=(" 961 << "expected RGBA=("
938 << SkColorGetR(expected_color) << "," 962 << SkColorGetR(expected_color) << ","
(...skipping 938 matching lines...) Expand 10 before | Expand all | Expand 10 after
1877 root->SetOpacity(0.5f); 1901 root->SetOpacity(0.5f);
1878 WaitForSwap(); 1902 WaitForSwap();
1879 EXPECT_EQ(1u, animation_observer.animation_step_count()); 1903 EXPECT_EQ(1u, animation_observer.animation_step_count());
1880 1904
1881 EXPECT_FALSE(animation_observer.shutdown()); 1905 EXPECT_FALSE(animation_observer.shutdown());
1882 ResetCompositor(); 1906 ResetCompositor();
1883 EXPECT_TRUE(animation_observer.shutdown()); 1907 EXPECT_TRUE(animation_observer.shutdown());
1884 } 1908 }
1885 1909
1886 } // namespace ui 1910 } // namespace ui
OLDNEW
« ui/compositor/layer.cc ('K') | « ui/compositor/layer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698