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

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
« no previous file with comments | « 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 static void EmptyReleaseCallback(const gpu::SyncToken& sync_token,
930 bool is_lost) {}
931
932 // Checks that the damage rect for a TextureLayer is empty after a commit.
933 TEST_F(LayerWithNullDelegateTest, EmptyDamagedRect) {
934 std::unique_ptr<Layer> root(CreateLayer(LAYER_SOLID_COLOR));
935 cc::TextureMailbox mailbox(gpu::Mailbox::Generate(), gpu::SyncToken(), 0);
936 root->SetTextureMailbox(mailbox, cc::SingleReleaseCallback::Create(
937 base::Bind(EmptyReleaseCallback)),
938 gfx::Size(10, 10));
939 compositor()->SetRootLayer(root.get());
940
941 root->SetBounds(gfx::Rect(0, 0, 10, 10));
942 root->SetVisible(true);
943 WaitForCommit();
944
945 gfx::Rect damaged_rect(0, 0, 5, 5);
946 root->SchedulePaint(damaged_rect);
947 EXPECT_EQ(damaged_rect, root->damaged_region_for_testing().bounds());
948 WaitForCommit();
949 EXPECT_TRUE(root->damaged_region_for_testing().IsEmpty());
950
951 compositor()->SetRootLayer(nullptr);
952 root.reset();
953 WaitForCommit();
954 }
955
929 void ExpectRgba(int x, int y, SkColor expected_color, SkColor actual_color) { 956 void ExpectRgba(int x, int y, SkColor expected_color, SkColor actual_color) {
930 EXPECT_EQ(expected_color, actual_color) 957 EXPECT_EQ(expected_color, actual_color)
931 << "Pixel error at x=" << x << " y=" << y << "; " 958 << "Pixel error at x=" << x << " y=" << y << "; "
932 << "actual RGBA=(" 959 << "actual RGBA=("
933 << SkColorGetR(actual_color) << "," 960 << SkColorGetR(actual_color) << ","
934 << SkColorGetG(actual_color) << "," 961 << SkColorGetG(actual_color) << ","
935 << SkColorGetB(actual_color) << "," 962 << SkColorGetB(actual_color) << ","
936 << SkColorGetA(actual_color) << "); " 963 << SkColorGetA(actual_color) << "); "
937 << "expected RGBA=(" 964 << "expected RGBA=("
938 << SkColorGetR(expected_color) << "," 965 << SkColorGetR(expected_color) << ","
(...skipping 938 matching lines...) Expand 10 before | Expand all | Expand 10 after
1877 root->SetOpacity(0.5f); 1904 root->SetOpacity(0.5f);
1878 WaitForSwap(); 1905 WaitForSwap();
1879 EXPECT_EQ(1u, animation_observer.animation_step_count()); 1906 EXPECT_EQ(1u, animation_observer.animation_step_count());
1880 1907
1881 EXPECT_FALSE(animation_observer.shutdown()); 1908 EXPECT_FALSE(animation_observer.shutdown());
1882 ResetCompositor(); 1909 ResetCompositor();
1883 EXPECT_TRUE(animation_observer.shutdown()); 1910 EXPECT_TRUE(animation_observer.shutdown());
1884 } 1911 }
1885 1912
1886 } // namespace ui 1913 } // namespace ui
OLDNEW
« no previous file with comments | « ui/compositor/layer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698