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

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

Issue 2866063002: Improve overdraw with multiple windows (Closed)
Patch Set: Created 3 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
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 "cc/trees/occlusion_tracker.h" 5 #include "cc/trees/occlusion_tracker.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "cc/animation/animation_host.h" 9 #include "cc/animation/animation_host.h"
10 #include "cc/base/filter_operation.h" 10 #include "cc/base/filter_operation.h"
(...skipping 1420 matching lines...) Expand 10 before | Expand all | Expand 10 after
1431 parent, this->identity_matrix, gfx::PointF(occlusion_rect.origin()), 1431 parent, this->identity_matrix, gfx::PointF(occlusion_rect.origin()),
1432 occlusion_rect.size(), true); 1432 occlusion_rect.size(), true);
1433 occluding_layer->test_properties()->force_render_surface = false; 1433 occluding_layer->test_properties()->force_render_surface = false;
1434 this->CalcDrawEtc(parent); 1434 this->CalcDrawEtc(parent);
1435 1435
1436 TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 200, 200)); 1436 TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 200, 200));
1437 1437
1438 // This layer occludes pixels directly beside the filtered_surface. 1438 // This layer occludes pixels directly beside the filtered_surface.
1439 // Because filtered surface blends pixels in a radius, it will need to see 1439 // Because filtered surface blends pixels in a radius, it will need to see
1440 // some of the pixels (up to radius far) underneath the occluding layers. 1440 // some of the pixels (up to radius far) underneath the occluding layers.
1441 this->VisitLayer(occluding_layer, &occlusion); 1441 this->VisitLayer(occluding_layer, &occlusion);
danakj 2017/05/17 15:15:56 This line would create an occluded area of 0,0,50,
1442 1442
1443 EXPECT_EQ(occlusion_rect.ToString(), 1443 EXPECT_EQ(occlusion_rect.ToString(),
1444 occlusion.occlusion_from_inside_target().ToString()); 1444 occlusion.occlusion_from_inside_target().ToString());
1445 EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); 1445 EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty());
1446 1446
1447 this->VisitLayer(filtered_surface, &occlusion); 1447 this->VisitLayer(filtered_surface, &occlusion);
danakj 2017/05/17 15:15:56 filtered_surface is not opaque, so no occlusion ad
1448 1448
1449 // The occlusion is used fully inside the surface. 1449 // The occlusion is used fully inside the surface.
1450 gfx::Rect occlusion_inside_surface = 1450 gfx::Rect occlusion_inside_surface =
1451 occlusion_rect - gfx::Vector2d(50, 50); 1451 occlusion_rect - gfx::Vector2d(50, 50);
1452 EXPECT_TRUE(occlusion.occlusion_from_inside_target().IsEmpty()); 1452 EXPECT_TRUE(occlusion.occlusion_from_inside_target().IsEmpty());
1453 EXPECT_EQ(occlusion_inside_surface.ToString(), 1453 EXPECT_EQ(occlusion_inside_surface.ToString(),
danakj 2017/05/17 15:15:56 which is verified here
1454 occlusion.occlusion_from_outside_target().ToString()); 1454 occlusion.occlusion_from_outside_target().ToString());
1455 1455
1456 // The surface has a background filter, so it needs pixels that are 1456 // The surface has a background filter, so it needs pixels that are
1457 // currently considered occluded in order to be drawn. The pixels it 1457 // currently considered occluded in order to be drawn. The pixels it
1458 // needs should be removed from the occluded area, so that they are drawn 1458 // needs should be removed from the occluded area, so that they are drawn
1459 // when we get to the parent. 1459 // when we get to the parent.
1460 this->VisitContributingSurface(filtered_surface, &occlusion); 1460 this->VisitContributingSurface(filtered_surface, &occlusion);
danakj 2017/05/17 15:15:57 this is moving the current context back to the roo
1461 this->EnterLayer(parent, &occlusion); 1461 this->EnterLayer(parent, &occlusion);
danakj 2017/05/17 15:15:57 this enters the root layer to ask what parts of it
1462 1462
1463 gfx::Rect expected_occlusion; 1463 gfx::Rect expected_occlusion;
1464 switch (i) { 1464 switch (i) {
1465 case LEFT: 1465 case LEFT:
1466 // The right half of the occlusion is close enough to cast a shadow 1466 // The occlusion needs for the shadow reaches 3*5+10 pixel to the
danakj 2017/05/15 21:47:43 I think this part of the comment should be kept, e
yiyix 2017/05/17 03:00:32 Done.
danakj 2017/05/15 21:47:42 pixels
yiyix 2017/05/17 03:00:32 Done.
1467 // that would be visible in the background filter. The shadow reaches 1467 // right and the rect in filtered_surface which is (25, 25, 20*80), so
danakj 2017/05/15 21:47:43 20, 80
yiyix 2017/05/17 03:00:32 Done.
1468 // 3*5 + 10 = 25 pixels to the right. 1468 // the expected occlusion is (0, 25, 45*80).
danakj 2017/05/15 21:47:43 But I don't actually understand what's shrinking t
yiyix 2017/05/17 03:00:32 From what I understand, there are 2 rects: occludi
danakj 2017/05/15 21:47:43 45, 80 (it reads like a triple with a product oth
yiyix 2017/05/17 03:00:32 Done.
1469 expected_occlusion = gfx::Rect(0, 0, 25, 200); 1469 expected_occlusion = gfx::Rect(0, 25, 45, 80);
1470 break; 1470 break;
1471 case RIGHT: 1471 case RIGHT:
1472 // The shadow spreads 3*5 - 10 = 5 pixels to the left, so the 1472 // The shadow spreads 3*5 - 10 = 5 pixels to the left, so the
1473 // occlusion must recede by 5 to account for that. 1473 // occlusion must recede by 5 to account for that.
1474 expected_occlusion = gfx::Rect(105, 0, 45, 200); 1474 expected_occlusion = gfx::Rect(105, 0, 45, 200);
1475 break; 1475 break;
1476 case TOP: 1476 case TOP:
1477 // Similar to LEFT. 1477 // Similar to LEFT.
1478 expected_occlusion = gfx::Rect(0, 0, 200, 25); 1478 expected_occlusion = gfx::Rect(25, 0, 80, 45);
1479 break; 1479 break;
1480 case BOTTOM: 1480 case BOTTOM:
1481 // Similar to RIGHT. 1481 // Similar to RIGHT.
1482 expected_occlusion = gfx::Rect(0, 105, 200, 45); 1482 expected_occlusion = gfx::Rect(0, 105, 200, 45);
1483 break; 1483 break;
1484 } 1484 }
1485 1485
1486 EXPECT_EQ(expected_occlusion.ToString(), 1486 EXPECT_EQ(expected_occlusion.ToString(),
1487 occlusion.occlusion_from_inside_target().ToString()); 1487 occlusion.occlusion_from_inside_target().ToString());
1488 EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); 1488 EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty());
(...skipping 944 matching lines...) Expand 10 before | Expand all | Expand 10 after
2433 EXPECT_EQ(gfx::Rect(), 2433 EXPECT_EQ(gfx::Rect(),
2434 occlusion.UnoccludedSurfaceContentRect( 2434 occlusion.UnoccludedSurfaceContentRect(
2435 surface, gfx::Rect(80, 70, 50, 50))); 2435 surface, gfx::Rect(80, 70, 50, 50)));
2436 } 2436 }
2437 }; 2437 };
2438 2438
2439 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestUnoccludedSurfaceQuery) 2439 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestUnoccludedSurfaceQuery)
2440 2440
2441 } // namespace 2441 } // namespace
2442 } // namespace cc 2442 } // namespace cc
OLDNEW
« cc/base/simple_enclosed_region_unittest.cc ('K') | « cc/base/simple_enclosed_region_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698