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

Side by Side Diff: cc/trees/damage_tracker_unittest.cc

Issue 1697613002: cc :: Move tracking of layer_property_changed to main thread (2) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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 | « cc/proto/property_tree.proto ('k') | cc/trees/layer_tree_host.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/damage_tracker.h" 5 #include "cc/trees/damage_tracker.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "cc/base/math_util.h" 9 #include "cc/base/math_util.h"
10 #include "cc/layers/layer_impl.h" 10 #include "cc/layers/layer_impl.h"
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 // not because of the old damage state. 387 // not because of the old damage state.
388 ClearDamageForAllSurfaces(root.get()); 388 ClearDamageForAllSurfaces(root.get());
389 EmulateDrawingOneFrame(root.get()); 389 EmulateDrawingOneFrame(root.get());
390 root_damage_rect = 390 root_damage_rect =
391 root->render_surface()->damage_tracker()->current_damage_rect(); 391 root->render_surface()->damage_tracker()->current_damage_rect();
392 EXPECT_TRUE(root_damage_rect.IsEmpty()); 392 EXPECT_TRUE(root_damage_rect.IsEmpty());
393 393
394 // Then, test the actual layer movement. 394 // Then, test the actual layer movement.
395 ClearDamageForAllSurfaces(root.get()); 395 ClearDamageForAllSurfaces(root.get());
396 child->SetPosition(gfx::PointF(200.f, 230.f)); 396 child->SetPosition(gfx::PointF(200.f, 230.f));
397 child->NoteLayerPropertyChanged();
397 EmulateDrawingOneFrame(root.get()); 398 EmulateDrawingOneFrame(root.get());
398 399
399 // Expect damage to be the combination of the previous one and the new one. 400 // Expect damage to be the combination of the previous one and the new one.
400 expected_rect.Union(gfx::Rect(200, 230, 30, 30)); 401 expected_rect.Union(gfx::Rect(200, 230, 30, 30));
401 root_damage_rect = 402 root_damage_rect =
402 root->render_surface()->damage_tracker()->current_damage_rect(); 403 root->render_surface()->damage_tracker()->current_damage_rect();
403 EXPECT_FLOAT_RECT_EQ(expected_rect, root_damage_rect); 404 EXPECT_FLOAT_RECT_EQ(expected_rect, root_damage_rect);
404 } 405 }
405 406
406 TEST_F(DamageTrackerTest, VerifyDamageForTransformedLayer) { 407 TEST_F(DamageTrackerTest, VerifyDamageForTransformedLayer) {
407 // If a layer is transformed, the damage rect should still enclose the entire 408 // If a layer is transformed, the damage rect should still enclose the entire
408 // transformed layer. 409 // transformed layer.
409 410
410 scoped_ptr<LayerImpl> root = CreateAndSetUpTestTreeWithOneSurface(); 411 scoped_ptr<LayerImpl> root = CreateAndSetUpTestTreeWithOneSurface();
411 LayerImpl* child = root->children()[0].get(); 412 LayerImpl* child = root->children()[0].get();
412 413
413 gfx::Transform rotation; 414 gfx::Transform rotation;
414 rotation.Rotate(45.0); 415 rotation.Rotate(45.0);
415 416
416 ClearDamageForAllSurfaces(root.get()); 417 ClearDamageForAllSurfaces(root.get());
417 child->SetTransformOrigin(gfx::Point3F( 418 child->SetTransformOrigin(gfx::Point3F(
418 child->bounds().width() * 0.5f, child->bounds().height() * 0.5f, 0.f)); 419 child->bounds().width() * 0.5f, child->bounds().height() * 0.5f, 0.f));
419 child->SetPosition(gfx::PointF(85.f, 85.f)); 420 child->SetPosition(gfx::PointF(85.f, 85.f));
421 child->NoteLayerPropertyChanged();
420 EmulateDrawingOneFrame(root.get()); 422 EmulateDrawingOneFrame(root.get());
421 423
422 // Sanity check that the layer actually moved to (85, 85), damaging its old 424 // Sanity check that the layer actually moved to (85, 85), damaging its old
423 // location and new location. 425 // location and new location.
424 gfx::Rect root_damage_rect = 426 gfx::Rect root_damage_rect =
425 root->render_surface()->damage_tracker()->current_damage_rect(); 427 root->render_surface()->damage_tracker()->current_damage_rect();
426 EXPECT_EQ(gfx::Rect(85, 85, 45, 45).ToString(), root_damage_rect.ToString()); 428 EXPECT_EQ(gfx::Rect(85, 85, 45, 45).ToString(), root_damage_rect.ToString());
427 429
428 // With the anchor on the layer's center, now we can test the rotation more 430 // With the anchor on the layer's center, now we can test the rotation more
429 // intuitively, since it applies about the layer's anchor. 431 // intuitively, since it applies about the layer's anchor.
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
898 // the entire child1 surface, but the damage tracker still needs the correct 900 // the entire child1 surface, but the damage tracker still needs the correct
899 // logic to compute the exposed region on the root surface. 901 // logic to compute the exposed region on the root surface.
900 902
901 // TODO(shawnsingh): the expectations of this test case should change when we 903 // TODO(shawnsingh): the expectations of this test case should change when we
902 // add support for a unique scissor_rect per RenderSurface. In that case, the 904 // add support for a unique scissor_rect per RenderSurface. In that case, the
903 // child1 surface should be completely unchanged, since we are only 905 // child1 surface should be completely unchanged, since we are only
904 // transforming it, while the root surface would be damaged appropriately. 906 // transforming it, while the root surface would be damaged appropriately.
905 907
906 scoped_ptr<LayerImpl> root = CreateAndSetUpTestTreeWithTwoSurfaces(); 908 scoped_ptr<LayerImpl> root = CreateAndSetUpTestTreeWithTwoSurfaces();
907 LayerImpl* child1 = root->children()[0].get(); 909 LayerImpl* child1 = root->children()[0].get();
910 LayerImpl* grand_child1 = child1->children()[0].get();
911 LayerImpl* grand_child2 = child1->children()[1].get();
908 gfx::Rect child_damage_rect; 912 gfx::Rect child_damage_rect;
909 gfx::Rect root_damage_rect; 913 gfx::Rect root_damage_rect;
910 914
911 ClearDamageForAllSurfaces(root.get()); 915 ClearDamageForAllSurfaces(root.get());
912 child1->SetPosition(gfx::PointF(50.f, 50.f)); 916 child1->SetPosition(gfx::PointF(50.f, 50.f));
917 child1->NoteLayerPropertyChanged();
918 grand_child1->NoteLayerPropertyChanged();
919 grand_child2->NoteLayerPropertyChanged();
913 EmulateDrawingOneFrame(root.get()); 920 EmulateDrawingOneFrame(root.get());
914 child_damage_rect = 921 child_damage_rect =
915 child1->render_surface()->damage_tracker()->current_damage_rect(); 922 child1->render_surface()->damage_tracker()->current_damage_rect();
916 root_damage_rect = 923 root_damage_rect =
917 root->render_surface()->damage_tracker()->current_damage_rect(); 924 root->render_surface()->damage_tracker()->current_damage_rect();
918 925
919 // The new surface bounds should be damaged entirely. 926 // The new surface bounds should be damaged entirely.
920 EXPECT_EQ(gfx::Rect(190, 190, 16, 18).ToString(), 927 EXPECT_EQ(gfx::Rect(190, 190, 16, 18).ToString(),
921 child_damage_rect.ToString()); 928 child_damage_rect.ToString());
922 929
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
1081 EXPECT_EQ(gfx::Rect(6, 8).ToString(), grand_child_damage_rect.ToString()); 1088 EXPECT_EQ(gfx::Rect(6, 8).ToString(), grand_child_damage_rect.ToString());
1082 EXPECT_EQ(gfx::Rect(194, 200, 12, 8).ToString(), 1089 EXPECT_EQ(gfx::Rect(194, 200, 12, 8).ToString(),
1083 child_damage_rect.ToString()); 1090 child_damage_rect.ToString());
1084 EXPECT_EQ(gfx::Rect(294, 300, 12, 8).ToString(), root_damage_rect.ToString()); 1091 EXPECT_EQ(gfx::Rect(294, 300, 12, 8).ToString(), root_damage_rect.ToString());
1085 1092
1086 // CASE 2: moving the descendant surface should cause both the original and 1093 // CASE 2: moving the descendant surface should cause both the original and
1087 // reflected areas to be damaged on the target. 1094 // reflected areas to be damaged on the target.
1088 ClearDamageForAllSurfaces(root.get()); 1095 ClearDamageForAllSurfaces(root.get());
1089 gfx::Rect old_content_rect = child1->render_surface()->content_rect(); 1096 gfx::Rect old_content_rect = child1->render_surface()->content_rect();
1090 grand_child1->SetPosition(gfx::PointF(195.f, 205.f)); 1097 grand_child1->SetPosition(gfx::PointF(195.f, 205.f));
1098 grand_child1->NoteLayerPropertyChanged();
1091 EmulateDrawingOneFrame(root.get()); 1099 EmulateDrawingOneFrame(root.get());
1092 ASSERT_EQ(old_content_rect.width(), 1100 ASSERT_EQ(old_content_rect.width(),
1093 child1->render_surface()->content_rect().width()); 1101 child1->render_surface()->content_rect().width());
1094 ASSERT_EQ(old_content_rect.height(), 1102 ASSERT_EQ(old_content_rect.height(),
1095 child1->render_surface()->content_rect().height()); 1103 child1->render_surface()->content_rect().height());
1096 1104
1097 grand_child_damage_rect = 1105 grand_child_damage_rect =
1098 grand_child1->render_surface()-> 1106 grand_child1->render_surface()->
1099 damage_tracker()->current_damage_rect(); 1107 damage_tracker()->current_damage_rect();
1100 child_damage_rect = 1108 child_damage_rect =
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
1470 gfx::Rect root_damage_rect = 1478 gfx::Rect root_damage_rect =
1471 root->render_surface()->damage_tracker()->current_damage_rect(); 1479 root->render_surface()->damage_tracker()->current_damage_rect();
1472 gfx::Rect damage_we_care_about = gfx::Rect(i, i); 1480 gfx::Rect damage_we_care_about = gfx::Rect(i, i);
1473 EXPECT_LE(damage_we_care_about.right(), root_damage_rect.right()); 1481 EXPECT_LE(damage_we_care_about.right(), root_damage_rect.right());
1474 EXPECT_LE(damage_we_care_about.bottom(), root_damage_rect.bottom()); 1482 EXPECT_LE(damage_we_care_about.bottom(), root_damage_rect.bottom());
1475 } 1483 }
1476 } 1484 }
1477 1485
1478 } // namespace 1486 } // namespace
1479 } // namespace cc 1487 } // namespace cc
OLDNEW
« no previous file with comments | « cc/proto/property_tree.proto ('k') | cc/trees/layer_tree_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698