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

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

Issue 1715973002: cc: Move tracking of layer_property_changed to main thread (3) (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/layer.proto ('k') | cc/trees/layer_tree_host_unittest.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 1178 matching lines...) Expand 10 before | Expand all | Expand 10 after
1189 // Advance one frame without damage so that we know the damage rect is not 1189 // Advance one frame without damage so that we know the damage rect is not
1190 // leftover from the previous case. 1190 // leftover from the previous case.
1191 ClearDamageForAllSurfaces(root.get()); 1191 ClearDamageForAllSurfaces(root.get());
1192 EmulateDrawingOneFrame(root.get()); 1192 EmulateDrawingOneFrame(root.get());
1193 child_damage_rect = 1193 child_damage_rect =
1194 child->render_surface()->damage_tracker()->current_damage_rect(); 1194 child->render_surface()->damage_tracker()->current_damage_rect();
1195 EXPECT_TRUE(child_damage_rect.IsEmpty()); 1195 EXPECT_TRUE(child_damage_rect.IsEmpty());
1196 1196
1197 // Then test the property change. 1197 // Then test the property change.
1198 ClearDamageForAllSurfaces(root.get()); 1198 ClearDamageForAllSurfaces(root.get());
1199 mask_layer->SetStackingOrderChanged(true); 1199 mask_layer->NoteLayerPropertyChanged();
1200 1200
1201 EmulateDrawingOneFrame(root.get()); 1201 EmulateDrawingOneFrame(root.get());
1202 child_damage_rect = 1202 child_damage_rect =
1203 child->render_surface()->damage_tracker()->current_damage_rect(); 1203 child->render_surface()->damage_tracker()->current_damage_rect();
1204 EXPECT_EQ(gfx::Rect(30, 30).ToString(), child_damage_rect.ToString()); 1204 EXPECT_EQ(gfx::Rect(30, 30).ToString(), child_damage_rect.ToString());
1205 1205
1206 // CASE 3: removing the mask also damages the entire target surface. 1206 // CASE 3: removing the mask also damages the entire target surface.
1207 // 1207 //
1208 1208
1209 // Advance one frame without damage so that we know the damage rect is not 1209 // Advance one frame without damage so that we know the damage rect is not
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1263 LayerImpl* replica_mask_layer = grand_child1_replica->mask_layer(); 1263 LayerImpl* replica_mask_layer = grand_child1_replica->mask_layer();
1264 1264
1265 EmulateDrawingOneFrame(root.get()); 1265 EmulateDrawingOneFrame(root.get());
1266 1266
1267 // Sanity check that the appropriate render surfaces were created 1267 // Sanity check that the appropriate render surfaces were created
1268 ASSERT_TRUE(grand_child1->render_surface()); 1268 ASSERT_TRUE(grand_child1->render_surface());
1269 1269
1270 // CASE 1: a property change on the mask should damage only the reflected 1270 // CASE 1: a property change on the mask should damage only the reflected
1271 // region on the target surface. 1271 // region on the target surface.
1272 ClearDamageForAllSurfaces(root.get()); 1272 ClearDamageForAllSurfaces(root.get());
1273 replica_mask_layer->SetStackingOrderChanged(true); 1273 replica_mask_layer->NoteLayerPropertyChanged();
1274 EmulateDrawingOneFrame(root.get()); 1274 EmulateDrawingOneFrame(root.get());
1275 1275
1276 gfx::Rect grand_child_damage_rect = 1276 gfx::Rect grand_child_damage_rect =
1277 grand_child1->render_surface()->damage_tracker()->current_damage_rect(); 1277 grand_child1->render_surface()->damage_tracker()->current_damage_rect();
1278 gfx::Rect child_damage_rect = 1278 gfx::Rect child_damage_rect =
1279 child1->render_surface()->damage_tracker()->current_damage_rect(); 1279 child1->render_surface()->damage_tracker()->current_damage_rect();
1280 1280
1281 EXPECT_TRUE(grand_child_damage_rect.IsEmpty()); 1281 EXPECT_TRUE(grand_child_damage_rect.IsEmpty());
1282 EXPECT_EQ(gfx::Rect(194, 200, 6, 8).ToString(), child_damage_rect.ToString()); 1282 EXPECT_EQ(gfx::Rect(194, 200, 6, 8).ToString(), child_damage_rect.ToString());
1283 1283
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1341 LayerImpl* replica_mask_layer = grand_child1_replica->mask_layer(); 1341 LayerImpl* replica_mask_layer = grand_child1_replica->mask_layer();
1342 1342
1343 EmulateDrawingOneFrame(root.get()); 1343 EmulateDrawingOneFrame(root.get());
1344 1344
1345 // Sanity check that the appropriate render surfaces were created 1345 // Sanity check that the appropriate render surfaces were created
1346 ASSERT_TRUE(grand_child1->render_surface()); 1346 ASSERT_TRUE(grand_child1->render_surface());
1347 1347
1348 // A property change on the replica_mask should damage the reflected region on 1348 // A property change on the replica_mask should damage the reflected region on
1349 // the target surface. 1349 // the target surface.
1350 ClearDamageForAllSurfaces(root.get()); 1350 ClearDamageForAllSurfaces(root.get());
1351 replica_mask_layer->SetStackingOrderChanged(true); 1351 replica_mask_layer->NoteLayerPropertyChanged();
1352 1352
1353 EmulateDrawingOneFrame(root.get()); 1353 EmulateDrawingOneFrame(root.get());
1354 1354
1355 gfx::Rect child_damage_rect = 1355 gfx::Rect child_damage_rect =
1356 child1->render_surface()->damage_tracker()->current_damage_rect(); 1356 child1->render_surface()->damage_tracker()->current_damage_rect();
1357 EXPECT_EQ(gfx::Rect(206, 200, 6, 8).ToString(), child_damage_rect.ToString()); 1357 EXPECT_EQ(gfx::Rect(206, 200, 6, 8).ToString(), child_damage_rect.ToString());
1358 } 1358 }
1359 1359
1360 TEST_F(DamageTrackerTest, DamageWhenAddedExternally) { 1360 TEST_F(DamageTrackerTest, DamageWhenAddedExternally) {
1361 scoped_ptr<LayerImpl> root = CreateAndSetUpTestTreeWithOneSurface(); 1361 scoped_ptr<LayerImpl> root = CreateAndSetUpTestTreeWithOneSurface();
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
1478 gfx::Rect root_damage_rect = 1478 gfx::Rect root_damage_rect =
1479 root->render_surface()->damage_tracker()->current_damage_rect(); 1479 root->render_surface()->damage_tracker()->current_damage_rect();
1480 gfx::Rect damage_we_care_about = gfx::Rect(i, i); 1480 gfx::Rect damage_we_care_about = gfx::Rect(i, i);
1481 EXPECT_LE(damage_we_care_about.right(), root_damage_rect.right()); 1481 EXPECT_LE(damage_we_care_about.right(), root_damage_rect.right());
1482 EXPECT_LE(damage_we_care_about.bottom(), root_damage_rect.bottom()); 1482 EXPECT_LE(damage_we_care_about.bottom(), root_damage_rect.bottom());
1483 } 1483 }
1484 } 1484 }
1485 1485
1486 } // namespace 1486 } // namespace
1487 } // namespace cc 1487 } // namespace cc
OLDNEW
« no previous file with comments | « cc/proto/layer.proto ('k') | cc/trees/layer_tree_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698