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

Side by Side Diff: cc/surfaces/surface_aggregator_unittest.cc

Issue 1945533002: Add way to mark other Surface a predecessor for a Surface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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/surfaces/surface_aggregator.cc ('k') | cc/surfaces/surface_factory.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/surfaces/surface_aggregator.h" 5 #include "cc/surfaces/surface_aggregator.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <utility> 10 #include <utility>
(...skipping 1428 matching lines...) Expand 10 before | Expand all | Expand 10 after
1439 1439
1440 ASSERT_EQ(2u, aggregated_pass_list.size()); 1440 ASSERT_EQ(2u, aggregated_pass_list.size());
1441 1441
1442 EXPECT_TRUE(aggregated_pass_list[1]->damage_rect.Contains( 1442 EXPECT_TRUE(aggregated_pass_list[1]->damage_rect.Contains(
1443 gfx::Rect(SurfaceSize()))); 1443 gfx::Rect(SurfaceSize())));
1444 } 1444 }
1445 1445
1446 factory_.Destroy(child_surface_id); 1446 factory_.Destroy(child_surface_id);
1447 } 1447 }
1448 1448
1449 // Check that damage is correctly calculated for surfaces with
1450 // SetPreviousFrameSurface.
1451 TEST_F(SurfaceAggregatorValidSurfaceTest, SwitchSurfaceDamage) {
1452 test::Quad root_render_pass_quads[] = {test::Quad::SolidColorQuad(1)};
1453
1454 test::Pass root_passes[] = {test::Pass(root_render_pass_quads,
1455 arraysize(root_render_pass_quads),
1456 RenderPassId(2, 1))};
1457
1458 RenderPassList root_pass_list;
1459 AddPasses(&root_pass_list, gfx::Rect(SurfaceSize()), root_passes,
1460 arraysize(root_passes));
1461
1462 root_pass_list[0]->damage_rect = gfx::Rect(5, 5, 100, 100);
1463
1464 std::unique_ptr<DelegatedFrameData> root_frame_data(new DelegatedFrameData);
1465 root_pass_list.swap(root_frame_data->render_pass_list);
1466
1467 std::unique_ptr<CompositorFrame> root_frame(new CompositorFrame);
1468 root_frame->delegated_frame_data = std::move(root_frame_data);
1469
1470 factory_.SubmitCompositorFrame(root_surface_id_, std::move(root_frame),
1471 SurfaceFactory::DrawCallback());
1472
1473 {
1474 std::unique_ptr<CompositorFrame> aggregated_frame =
1475 aggregator_.Aggregate(root_surface_id_);
1476
1477 ASSERT_TRUE(aggregated_frame);
1478 ASSERT_TRUE(aggregated_frame->delegated_frame_data);
1479
1480 DelegatedFrameData* frame_data =
1481 aggregated_frame->delegated_frame_data.get();
1482
1483 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list;
1484
1485 ASSERT_EQ(1u, aggregated_pass_list.size());
1486
1487 // Damage rect for first aggregation should contain entire root surface.
1488 EXPECT_TRUE(aggregated_pass_list[0]->damage_rect.Contains(
1489 gfx::Rect(SurfaceSize())));
1490 }
1491
1492 SurfaceId second_root_surface_id = allocator_.GenerateId();
1493 {
1494 test::Quad root_render_pass_quads[] = {test::Quad::SolidColorQuad(1)};
1495
1496 test::Pass root_passes[] = {test::Pass(root_render_pass_quads,
1497 arraysize(root_render_pass_quads),
1498 RenderPassId(2, 1))};
1499
1500 RenderPassList root_pass_list;
1501 AddPasses(&root_pass_list, gfx::Rect(SurfaceSize()), root_passes,
1502 arraysize(root_passes));
1503
1504 root_pass_list[0]->damage_rect = gfx::Rect(1, 2, 3, 4);
1505
1506 std::unique_ptr<DelegatedFrameData> root_frame_data(new DelegatedFrameData);
1507 root_pass_list.swap(root_frame_data->render_pass_list);
1508
1509 std::unique_ptr<CompositorFrame> root_frame(new CompositorFrame);
1510 root_frame->delegated_frame_data = std::move(root_frame_data);
1511
1512 factory_.Create(second_root_surface_id);
1513 factory_.SubmitCompositorFrame(second_root_surface_id,
1514 std::move(root_frame),
1515 SurfaceFactory::DrawCallback());
1516 factory_.SetPreviousFrameSurface(second_root_surface_id, root_surface_id_);
1517 }
1518 {
1519 std::unique_ptr<CompositorFrame> aggregated_frame =
1520 aggregator_.Aggregate(second_root_surface_id);
1521
1522 ASSERT_TRUE(aggregated_frame);
1523 ASSERT_TRUE(aggregated_frame->delegated_frame_data);
1524
1525 DelegatedFrameData* frame_data =
1526 aggregated_frame->delegated_frame_data.get();
1527
1528 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list;
1529
1530 ASSERT_EQ(1u, aggregated_pass_list.size());
1531
1532 // Frame from SetPreviousFrameSurface was aggregated last, so damage rect
1533 // from new surface should be used.
1534 EXPECT_EQ(gfx::Rect(1, 2, 3, 4), aggregated_pass_list[0]->damage_rect);
1535 }
1536 {
1537 std::unique_ptr<CompositorFrame> aggregated_frame =
1538 aggregator_.Aggregate(second_root_surface_id);
1539
1540 ASSERT_TRUE(aggregated_frame);
1541 ASSERT_TRUE(aggregated_frame->delegated_frame_data);
1542
1543 DelegatedFrameData* frame_data =
1544 aggregated_frame->delegated_frame_data.get();
1545
1546 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list;
1547
1548 ASSERT_EQ(1u, aggregated_pass_list.size());
1549
1550 // No new frame, so no new damage.
1551 EXPECT_TRUE(aggregated_pass_list[0]->damage_rect.IsEmpty());
1552 }
1553 factory_.Destroy(second_root_surface_id);
1554 }
1555
1449 class SurfaceAggregatorPartialSwapTest 1556 class SurfaceAggregatorPartialSwapTest
1450 : public SurfaceAggregatorValidSurfaceTest { 1557 : public SurfaceAggregatorValidSurfaceTest {
1451 public: 1558 public:
1452 SurfaceAggregatorPartialSwapTest() 1559 SurfaceAggregatorPartialSwapTest()
1453 : SurfaceAggregatorValidSurfaceTest(true) {} 1560 : SurfaceAggregatorValidSurfaceTest(true) {}
1454 }; 1561 };
1455 1562
1456 // Tests that quads outside the damage rect are ignored. 1563 // Tests that quads outside the damage rect are ignored.
1457 TEST_F(SurfaceAggregatorPartialSwapTest, IgnoreOutside) { 1564 TEST_F(SurfaceAggregatorPartialSwapTest, IgnoreOutside) {
1458 SurfaceId child_surface_id = allocator_.GenerateId(); 1565 SurfaceId child_surface_id = allocator_.GenerateId();
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after
1999 EXPECT_EQ(9u, pass_list->back()->quad_list.size()); 2106 EXPECT_EQ(9u, pass_list->back()->quad_list.size());
2000 2107
2001 factory.Destroy(root_surface_id); 2108 factory.Destroy(root_surface_id);
2002 factory.Destroy(child_surface_id); 2109 factory.Destroy(child_surface_id);
2003 factory.Destroy(middle_surface_id); 2110 factory.Destroy(middle_surface_id);
2004 } 2111 }
2005 2112
2006 } // namespace 2113 } // namespace
2007 } // namespace cc 2114 } // namespace cc
2008 2115
OLDNEW
« no previous file with comments | « cc/surfaces/surface_aggregator.cc ('k') | cc/surfaces/surface_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698