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

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

Issue 219963005: cc: Add support for partial swaps when using impl-side painting. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: use Contains() api instead of custom code Created 6 years, 7 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/trees/damage_tracker.cc ('k') | cc/trees/layer_tree_host_impl.h » ('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 "cc/base/math_util.h" 7 #include "cc/base/math_util.h"
8 #include "cc/layers/layer_impl.h" 8 #include "cc/layers/layer_impl.h"
9 #include "cc/output/filter_operation.h" 9 #include "cc/output/filter_operation.h"
10 #include "cc/output/filter_operations.h" 10 #include "cc/output/filter_operations.h"
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 child->SetUpdateRect(gfx::RectF(20.f, 25.f, 1.f, 2.f)); 261 child->SetUpdateRect(gfx::RectF(20.f, 25.f, 1.f, 2.f));
262 EmulateDrawingOneFrame(root.get()); 262 EmulateDrawingOneFrame(root.get());
263 263
264 // Damage position on the surface should be: position of update_rect (20, 25) 264 // Damage position on the surface should be: position of update_rect (20, 25)
265 // relative to the child (100, 100). 265 // relative to the child (100, 100).
266 root_damage_rect = 266 root_damage_rect =
267 root->render_surface()->damage_tracker()->current_damage_rect(); 267 root->render_surface()->damage_tracker()->current_damage_rect();
268 EXPECT_EQ(gfx::Rect(120, 125, 1, 2).ToString(), root_damage_rect.ToString()); 268 EXPECT_EQ(gfx::Rect(120, 125, 1, 2).ToString(), root_damage_rect.ToString());
269 } 269 }
270 270
271 TEST_F(DamageTrackerTest, VerifyDamageForLayerDamageRects) {
272 scoped_ptr<LayerImpl> root = CreateAndSetUpTestTreeWithOneSurface();
273 LayerImpl* child = root->children()[0];
274
275 // CASE 1: Adding the layer damage rect should cause the corresponding damage
276 // to the surface.
277 ClearDamageForAllSurfaces(root.get());
278 child->AddDamageRect(gfx::RectF(10.f, 11.f, 12.f, 13.f));
279 EmulateDrawingOneFrame(root.get());
280
281 // Damage position on the surface should be: position of layer damage_rect
282 // (10, 11) relative to the child (100, 100).
283 gfx::Rect root_damage_rect =
284 root->render_surface()->damage_tracker()->current_damage_rect();
285 EXPECT_EQ(true, root_damage_rect.Contains(gfx::Rect(110, 111, 12, 13)));
286
287 // CASE 2: The same layer damage rect twice in a row still produces the same
288 // damage.
289 ClearDamageForAllSurfaces(root.get());
290 child->AddDamageRect(gfx::RectF(10.f, 11.f, 12.f, 13.f));
291 EmulateDrawingOneFrame(root.get());
292 root_damage_rect =
293 root->render_surface()->damage_tracker()->current_damage_rect();
294 EXPECT_EQ(true, root_damage_rect.Contains(gfx::Rect(110, 111, 12, 13)));
295
296 // CASE 3: Adding a different layer damage rect should cause damage on the
297 // new damaged region, but no additional exposed old region.
298 ClearDamageForAllSurfaces(root.get());
299 child->AddDamageRect(gfx::RectF(20.f, 25.f, 1.f, 2.f));
300 EmulateDrawingOneFrame(root.get());
301
302 // Damage position on the surface should be: position of layer damage_rect
303 // (20, 25) relative to the child (100, 100).
304 root_damage_rect =
305 root->render_surface()->damage_tracker()->current_damage_rect();
306 EXPECT_EQ(true, root_damage_rect.Contains(gfx::Rect(120, 125, 1, 2)));
307
308 // CASE 4: Adding multiple layer damage rects should cause a unified
309 // damage on root damage rect.
310 ClearDamageForAllSurfaces(root.get());
311 child->AddDamageRect(gfx::RectF(20.f, 25.f, 1.f, 2.f));
312 child->AddDamageRect(gfx::RectF(20.f, 25.f, 3.f, 4.f));
313 EmulateDrawingOneFrame(root.get());
314
315 // Damage position on the surface should be: position of layer damage_rect
316 // (20, 25) relative to the child (100, 100).
317 root_damage_rect =
318 root->render_surface()->damage_tracker()->current_damage_rect();
319 EXPECT_EQ(true, root_damage_rect.Contains(gfx::Rect(120, 125, 3, 4)));
reveman 2014/04/28 16:33:46 EXPECT_EQ(true, root_damage_rect.Contains(gfx::Rec
reveman 2014/04/28 19:16:30 Sorry, I read this wrong. That check doesn't make
320 }
321
322 TEST_F(DamageTrackerTest, VerifyDamageForLayerUpdateAndDamageRects) {
323 scoped_ptr<LayerImpl> root = CreateAndSetUpTestTreeWithOneSurface();
324 LayerImpl* child = root->children()[0];
325
326 // CASE 1: Adding the layer damage rect and update rect should cause the
327 // corresponding damage to the surface.
328 ClearDamageForAllSurfaces(root.get());
329 child->AddDamageRect(gfx::RectF(5.f, 6.f, 12.f, 13.f));
330 child->SetUpdateRect(gfx::RectF(15.f, 16.f, 14.f, 10.f));
331 EmulateDrawingOneFrame(root.get());
332
333 // Damage position on the surface should be: position of unified layer
334 // damage_rect and update rect (5, 6)
335 // relative to the child (100, 100).
336 gfx::Rect root_damage_rect =
337 root->render_surface()->damage_tracker()->current_damage_rect();
338 EXPECT_EQ(true, root_damage_rect.Contains(gfx::Rect(105, 106, 24, 20)));
339
340 // CASE 2: The same layer damage rect and update rect twice in a row still
341 // produces the same damage.
342 ClearDamageForAllSurfaces(root.get());
343 child->AddDamageRect(gfx::RectF(10.f, 11.f, 12.f, 13.f));
344 child->SetUpdateRect(gfx::RectF(10.f, 11.f, 14.f, 15.f));
345 EmulateDrawingOneFrame(root.get());
346 root_damage_rect =
347 root->render_surface()->damage_tracker()->current_damage_rect();
348 EXPECT_EQ(true, root_damage_rect.Contains(gfx::Rect(110, 111, 14, 15)));
349
350 // CASE 3: Adding a different layer damage rect and update rect should cause
351 // damage on the new damaged region, but no additional exposed old region.
352 ClearDamageForAllSurfaces(root.get());
353 child->AddDamageRect(gfx::RectF(20.f, 25.f, 2.f, 3.f));
354 child->SetUpdateRect(gfx::RectF(5.f, 10.f, 7.f, 8.f));
355 EmulateDrawingOneFrame(root.get());
356
357 // Damage position on the surface should be: position of unified layer damage
358 // rect and update rect (5, 10) relative to the child (100, 100).
359 root_damage_rect =
360 root->render_surface()->damage_tracker()->current_damage_rect();
361 EXPECT_EQ(true, root_damage_rect.Contains(gfx::Rect(105, 110, 17, 18)));
362 }
363
271 TEST_F(DamageTrackerTest, VerifyDamageForPropertyChanges) { 364 TEST_F(DamageTrackerTest, VerifyDamageForPropertyChanges) {
272 scoped_ptr<LayerImpl> root = CreateAndSetUpTestTreeWithOneSurface(); 365 scoped_ptr<LayerImpl> root = CreateAndSetUpTestTreeWithOneSurface();
273 LayerImpl* child = root->children()[0]; 366 LayerImpl* child = root->children()[0];
274 367
275 // CASE 1: The layer's property changed flag takes priority over update rect. 368 // CASE 1: The layer's property changed flag takes priority over update rect.
276 // 369 //
277 ClearDamageForAllSurfaces(root.get()); 370 ClearDamageForAllSurfaces(root.get());
278 child->SetUpdateRect(gfx::RectF(10.f, 11.f, 12.f, 13.f)); 371 child->SetUpdateRect(gfx::RectF(10.f, 11.f, 12.f, 13.f));
279 child->SetOpacity(0.5f); 372 child->SetOpacity(0.5f);
280 EmulateDrawingOneFrame(root.get()); 373 EmulateDrawingOneFrame(root.get());
(...skipping 1100 matching lines...) Expand 10 before | Expand all | Expand 10 after
1381 gfx::Rect root_damage_rect = 1474 gfx::Rect root_damage_rect =
1382 root->render_surface()->damage_tracker()->current_damage_rect(); 1475 root->render_surface()->damage_tracker()->current_damage_rect();
1383 gfx::Rect damage_we_care_about = gfx::Rect(i, i); 1476 gfx::Rect damage_we_care_about = gfx::Rect(i, i);
1384 EXPECT_LE(damage_we_care_about.right(), root_damage_rect.right()); 1477 EXPECT_LE(damage_we_care_about.right(), root_damage_rect.right());
1385 EXPECT_LE(damage_we_care_about.bottom(), root_damage_rect.bottom()); 1478 EXPECT_LE(damage_we_care_about.bottom(), root_damage_rect.bottom());
1386 } 1479 }
1387 } 1480 }
1388 1481
1389 } // namespace 1482 } // namespace
1390 } // namespace cc 1483 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/damage_tracker.cc ('k') | cc/trees/layer_tree_host_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698