Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 | 1 |
| 2 // Copyright 2014 The Chromium Authors. All rights reserved. | 2 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 3 // Use of this source code is governed by a BSD-style license that can be | 3 // Use of this source code is governed by a BSD-style license that can be |
| 4 // found in the LICENSE file. | 4 // found in the LICENSE file. |
| 5 | 5 |
| 6 #include "components/viz/service/display/surface_aggregator.h" | 6 #include "components/viz/service/display/surface_aggregator.h" |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 2488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2499 EXPECT_EQ(color_space2, aggregated_frame.render_pass_list[1]->color_space); | 2499 EXPECT_EQ(color_space2, aggregated_frame.render_pass_list[1]->color_space); |
| 2500 | 2500 |
| 2501 aggregator_.SetOutputColorSpace(color_space1, color_space3); | 2501 aggregator_.SetOutputColorSpace(color_space1, color_space3); |
| 2502 aggregated_frame = aggregator_.Aggregate(surface_id); | 2502 aggregated_frame = aggregator_.Aggregate(surface_id); |
| 2503 EXPECT_EQ(3u, aggregated_frame.render_pass_list.size()); | 2503 EXPECT_EQ(3u, aggregated_frame.render_pass_list.size()); |
| 2504 EXPECT_EQ(color_space1, aggregated_frame.render_pass_list[0]->color_space); | 2504 EXPECT_EQ(color_space1, aggregated_frame.render_pass_list[0]->color_space); |
| 2505 EXPECT_EQ(color_space1, aggregated_frame.render_pass_list[1]->color_space); | 2505 EXPECT_EQ(color_space1, aggregated_frame.render_pass_list[1]->color_space); |
| 2506 EXPECT_EQ(color_space3, aggregated_frame.render_pass_list[2]->color_space); | 2506 EXPECT_EQ(color_space3, aggregated_frame.render_pass_list[2]->color_space); |
| 2507 } | 2507 } |
| 2508 | 2508 |
| 2509 // Tests that has_damage_from_contributing_content is aggregated correctly from | |
| 2510 // child surface quads. | |
| 2511 TEST_F(SurfaceAggregatorValidSurfaceTest, HasDamageByChangingChildSurface) { | |
| 2512 Quad child_surface_quads[] = {Quad::RenderPassQuad(1)}; | |
| 2513 Pass child_surface_passes[] = { | |
| 2514 Pass(child_surface_quads, arraysize(child_surface_quads), 1)}; | |
| 2515 | |
| 2516 cc::CompositorFrame child_surface_frame = test::MakeEmptyCompositorFrame(); | |
| 2517 AddPasses(&child_surface_frame.render_pass_list, gfx::Rect(SurfaceSize()), | |
| 2518 child_surface_passes, arraysize(child_surface_passes)); | |
| 2519 | |
| 2520 LocalSurfaceId child_local_surface_id = allocator_.GenerateId(); | |
| 2521 SurfaceId child_surface_id(child_support_->frame_sink_id(), | |
| 2522 child_local_surface_id); | |
| 2523 child_support_->SubmitCompositorFrame(child_local_surface_id, | |
| 2524 std::move(child_surface_frame)); | |
| 2525 | |
| 2526 Quad root_surface_quads[] = { | |
| 2527 Quad::SurfaceQuad(child_surface_id, InvalidSurfaceId(), 1.f)}; | |
| 2528 Pass root_passes[] = { | |
| 2529 Pass(root_surface_quads, arraysize(root_surface_quads), 1)}; | |
| 2530 | |
| 2531 cc::CompositorFrame root_frame = test::MakeEmptyCompositorFrame(); | |
| 2532 AddPasses(&root_frame.render_pass_list, gfx::Rect(SurfaceSize()), root_passes, | |
| 2533 arraysize(root_passes)); | |
| 2534 | |
| 2535 SurfaceId root_surface_id(support_->frame_sink_id(), root_local_surface_id_); | |
| 2536 support_->SubmitCompositorFrame(root_local_surface_id_, | |
| 2537 std::move(root_frame)); | |
| 2538 | |
| 2539 cc::CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); | |
| 2540 // First aggregation shold be true. DamageRectForSurface() makes a surface | |
|
danakj
2017/07/27 21:24:34
"should"
Explain why it should, why this bool mat
wutao
2017/07/28 17:05:17
Talked offline to remove this check and add commen
| |
| 2541 // fully damaged the first time it appears. | |
| 2542 EXPECT_TRUE(aggregated_frame.render_pass_list[0] | |
| 2543 ->has_damage_from_contributing_content); | |
| 2544 | |
| 2545 // No Surface changed, so no damage should be given. | |
| 2546 { | |
| 2547 cc::CompositorFrame aggregated_frame = | |
| 2548 aggregator_.Aggregate(root_surface_id); | |
| 2549 EXPECT_FALSE(aggregated_frame.render_pass_list[0] | |
| 2550 ->has_damage_from_contributing_content); | |
| 2551 } | |
| 2552 | |
| 2553 // Change child_frame should cause damage. | |
| 2554 { | |
| 2555 cc::CompositorFrame child_surface_frame = test::MakeEmptyCompositorFrame(); | |
| 2556 AddPasses(&child_surface_frame.render_pass_list, gfx::Rect(SurfaceSize()), | |
|
danakj
2017/07/27 21:24:34
What happens if a new frame comes but has no damag
wutao
2017/07/28 17:05:16
Adding a new test case for this.
| |
| 2557 child_surface_passes, arraysize(child_surface_passes)); | |
| 2558 child_support_->SubmitCompositorFrame(child_local_surface_id, | |
| 2559 std::move(child_surface_frame)); | |
| 2560 | |
| 2561 cc::CompositorFrame aggregated_frame = | |
| 2562 aggregator_.Aggregate(root_surface_id); | |
| 2563 // True for new child_frame. | |
| 2564 EXPECT_TRUE(aggregated_frame.render_pass_list[0] | |
| 2565 ->has_damage_from_contributing_content); | |
| 2566 } | |
| 2567 } | |
| 2568 | |
| 2569 // Tests that has_damage_from_contributing_content is aggregated correctly from | |
| 2570 // grand child surface quads. | |
| 2571 TEST_F(SurfaceAggregatorValidSurfaceTest, | |
| 2572 HasDamageByChangingGrandChildSurface) { | |
| 2573 auto grand_child_support = CompositorFrameSinkSupport::Create( | |
| 2574 nullptr, &manager_, kArbitraryMiddleFrameSinkId, kChildIsRoot, | |
| 2575 kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints); | |
| 2576 | |
| 2577 Quad child_surface_quads[] = {Quad::RenderPassQuad(1)}; | |
| 2578 Pass child_surface_passes[] = { | |
| 2579 Pass(child_surface_quads, arraysize(child_surface_quads), 1)}; | |
| 2580 | |
| 2581 cc::CompositorFrame child_surface_frame = test::MakeEmptyCompositorFrame(); | |
| 2582 AddPasses(&child_surface_frame.render_pass_list, gfx::Rect(SurfaceSize()), | |
| 2583 child_surface_passes, arraysize(child_surface_passes)); | |
| 2584 | |
| 2585 LocalSurfaceId child_local_surface_id = allocator_.GenerateId(); | |
| 2586 SurfaceId child_surface_id(child_support_->frame_sink_id(), | |
| 2587 child_local_surface_id); | |
| 2588 child_support_->SubmitCompositorFrame(child_local_surface_id, | |
| 2589 std::move(child_surface_frame)); | |
| 2590 | |
| 2591 Quad root_surface_quads[] = { | |
| 2592 Quad::SurfaceQuad(child_surface_id, InvalidSurfaceId(), 1.f)}; | |
| 2593 Pass root_passes[] = { | |
| 2594 Pass(root_surface_quads, arraysize(root_surface_quads), 1)}; | |
| 2595 | |
| 2596 cc::CompositorFrame root_frame = test::MakeEmptyCompositorFrame(); | |
| 2597 AddPasses(&root_frame.render_pass_list, gfx::Rect(SurfaceSize()), root_passes, | |
| 2598 arraysize(root_passes)); | |
| 2599 | |
| 2600 SurfaceId root_surface_id(support_->frame_sink_id(), root_local_surface_id_); | |
| 2601 support_->SubmitCompositorFrame(root_local_surface_id_, | |
| 2602 std::move(root_frame)); | |
| 2603 | |
| 2604 cc::CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); | |
| 2605 // First aggregation shold be true. DamageRectForSurface() makes a surface | |
| 2606 // fully damaged the first time it appears. | |
| 2607 EXPECT_TRUE(aggregated_frame.render_pass_list[0] | |
| 2608 ->has_damage_from_contributing_content); | |
| 2609 | |
| 2610 // No Surface changed, so no damage should be given. | |
| 2611 { | |
| 2612 cc::CompositorFrame aggregated_frame = | |
| 2613 aggregator_.Aggregate(root_surface_id); | |
| 2614 EXPECT_FALSE(aggregated_frame.render_pass_list[0] | |
| 2615 ->has_damage_from_contributing_content); | |
| 2616 } | |
| 2617 | |
| 2618 // Add a grand_child_frame should cause damage. | |
| 2619 Quad grand_child_quads[] = {Quad::RenderPassQuad(1)}; | |
| 2620 Pass grand_child_passes[] = { | |
| 2621 Pass(grand_child_quads, arraysize(grand_child_quads), 1)}; | |
| 2622 LocalSurfaceId grand_child_local_surface_id = allocator_.GenerateId(); | |
| 2623 SurfaceId grand_child_surface_id(grand_child_support->frame_sink_id(), | |
| 2624 grand_child_local_surface_id); | |
| 2625 { | |
| 2626 cc::CompositorFrame grand_child_frame = test::MakeEmptyCompositorFrame(); | |
| 2627 AddPasses(&grand_child_frame.render_pass_list, gfx::Rect(SurfaceSize()), | |
| 2628 grand_child_passes, arraysize(grand_child_passes)); | |
| 2629 | |
| 2630 grand_child_support->SubmitCompositorFrame(grand_child_local_surface_id, | |
| 2631 std::move(grand_child_frame)); | |
| 2632 | |
| 2633 Quad new_child_surface_quads[] = { | |
| 2634 child_surface_quads[0], | |
| 2635 Quad::SurfaceQuad(grand_child_surface_id, InvalidSurfaceId(), 1.f)}; | |
| 2636 Pass new_child_surface_passes[] = { | |
| 2637 Pass(new_child_surface_quads, arraysize(new_child_surface_quads), 1)}; | |
| 2638 child_surface_frame = test::MakeEmptyCompositorFrame(); | |
| 2639 AddPasses(&child_surface_frame.render_pass_list, gfx::Rect(SurfaceSize()), | |
| 2640 new_child_surface_passes, arraysize(new_child_surface_passes)); | |
| 2641 child_support_->SubmitCompositorFrame(child_local_surface_id, | |
| 2642 std::move(child_surface_frame)); | |
| 2643 | |
| 2644 cc::CompositorFrame aggregated_frame = | |
| 2645 aggregator_.Aggregate(root_surface_id); | |
| 2646 // True for new grand_child_frame. | |
| 2647 EXPECT_TRUE(aggregated_frame.render_pass_list[0] | |
| 2648 ->has_damage_from_contributing_content); | |
| 2649 } | |
| 2650 | |
| 2651 // No Surface changed, so no damage should be given. | |
| 2652 { | |
| 2653 cc::CompositorFrame aggregated_frame = | |
| 2654 aggregator_.Aggregate(root_surface_id); | |
| 2655 EXPECT_FALSE(aggregated_frame.render_pass_list[0] | |
| 2656 ->has_damage_from_contributing_content); | |
| 2657 } | |
| 2658 | |
| 2659 // Change grand_child_frame should cause damage. | |
| 2660 { | |
| 2661 cc::CompositorFrame grand_child_frame = test::MakeEmptyCompositorFrame(); | |
| 2662 AddPasses(&grand_child_frame.render_pass_list, gfx::Rect(SurfaceSize()), | |
| 2663 grand_child_passes, arraysize(grand_child_passes)); | |
| 2664 grand_child_support->SubmitCompositorFrame(grand_child_local_surface_id, | |
| 2665 std::move(grand_child_frame)); | |
| 2666 | |
| 2667 cc::CompositorFrame aggregated_frame = | |
| 2668 aggregator_.Aggregate(root_surface_id); | |
| 2669 // True for new grand_child_frame. | |
| 2670 EXPECT_TRUE(aggregated_frame.render_pass_list[0] | |
| 2671 ->has_damage_from_contributing_content); | |
| 2672 } | |
| 2673 | |
| 2674 grand_child_support->EvictCurrentSurface(); | |
| 2675 } | |
| 2676 | |
| 2677 // Tests that has_damage_from_contributing_content is aggregated correctly from | |
| 2678 // render pass quads. | |
| 2679 TEST_F(SurfaceAggregatorValidSurfaceTest, HasDamageFromRenderPassQuads) { | |
| 2680 Quad child_quads[] = {Quad::RenderPassQuad(1)}; | |
| 2681 Pass child_passes[] = {Pass(child_quads, arraysize(child_quads), 1)}; | |
| 2682 | |
| 2683 cc::CompositorFrame child_frame = test::MakeEmptyCompositorFrame(); | |
| 2684 AddPasses(&child_frame.render_pass_list, gfx::Rect(SurfaceSize()), | |
| 2685 child_passes, arraysize(child_passes)); | |
| 2686 | |
| 2687 LocalSurfaceId child_local_surface_id = allocator_.GenerateId(); | |
| 2688 SurfaceId child_surface_id(child_support_->frame_sink_id(), | |
| 2689 child_local_surface_id); | |
| 2690 child_support_->SubmitCompositorFrame(child_local_surface_id, | |
| 2691 std::move(child_frame)); | |
| 2692 | |
| 2693 Quad root_surface_quads[] = { | |
| 2694 Quad::SurfaceQuad(child_surface_id, InvalidSurfaceId(), 1.f)}; | |
| 2695 Quad root_render_pass_quads[] = {Quad::RenderPassQuad(1)}; | |
| 2696 | |
| 2697 Pass root_passes[] = { | |
| 2698 Pass(root_surface_quads, arraysize(root_surface_quads), 1), | |
| 2699 Pass(root_render_pass_quads, arraysize(root_render_pass_quads), 2)}; | |
| 2700 | |
| 2701 cc::CompositorFrame root_frame = test::MakeEmptyCompositorFrame(); | |
| 2702 AddPasses(&root_frame.render_pass_list, gfx::Rect(SurfaceSize()), root_passes, | |
| 2703 arraysize(root_passes)); | |
| 2704 | |
| 2705 support_->SubmitCompositorFrame(root_local_surface_id_, | |
| 2706 std::move(root_frame)); | |
| 2707 | |
| 2708 SurfaceId root_surface_id(support_->frame_sink_id(), root_local_surface_id_); | |
| 2709 cc::CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); | |
| 2710 | |
| 2711 const auto& aggregated_pass_list = aggregated_frame.render_pass_list; | |
| 2712 | |
| 2713 ASSERT_EQ(2u, aggregated_pass_list.size()); | |
| 2714 | |
| 2715 // First aggregation shold be true. DamageRectForSurface() makes a surface | |
| 2716 // fully damaged the first time it appears. | |
| 2717 EXPECT_TRUE(aggregated_frame.render_pass_list[0] | |
| 2718 ->has_damage_from_contributing_content); | |
| 2719 EXPECT_TRUE(aggregated_frame.render_pass_list[1] | |
| 2720 ->has_damage_from_contributing_content); | |
| 2721 | |
| 2722 // No Surface changed, so no damage should be given. | |
| 2723 { | |
| 2724 cc::CompositorFrame aggregated_frame = | |
| 2725 aggregator_.Aggregate(root_surface_id); | |
| 2726 EXPECT_FALSE(aggregated_frame.render_pass_list[0] | |
| 2727 ->has_damage_from_contributing_content); | |
| 2728 EXPECT_FALSE(aggregated_frame.render_pass_list[1] | |
| 2729 ->has_damage_from_contributing_content); | |
| 2730 } | |
| 2731 | |
| 2732 // Changing child_frame should damage both render_pass. | |
| 2733 { | |
| 2734 cc::CompositorFrame child_frame = test::MakeEmptyCompositorFrame(); | |
| 2735 AddPasses(&child_frame.render_pass_list, gfx::Rect(SurfaceSize()), | |
| 2736 child_passes, arraysize(child_passes)); | |
| 2737 child_support_->SubmitCompositorFrame(child_local_surface_id, | |
| 2738 std::move(child_frame)); | |
| 2739 | |
| 2740 cc::CompositorFrame aggregated_frame = | |
| 2741 aggregator_.Aggregate(root_surface_id); | |
| 2742 // True for new child_frame. | |
| 2743 EXPECT_TRUE(aggregated_frame.render_pass_list[0] | |
| 2744 ->has_damage_from_contributing_content); | |
| 2745 EXPECT_TRUE(aggregated_frame.render_pass_list[1] | |
| 2746 ->has_damage_from_contributing_content); | |
| 2747 } | |
| 2748 } | |
| 2749 | |
| 2750 // Tests that the first frame damage_rect of a cached render pass should be | |
| 2751 // fully damaged. | |
| 2752 TEST_F(SurfaceAggregatorValidSurfaceTest, DamageRectOfCachedRenderPass) { | |
| 2753 int pass_id[] = {1, 2}; | |
| 2754 Quad root_quads[][1] = { | |
| 2755 {Quad::SolidColorQuad(SK_ColorGREEN)}, {Quad::RenderPassQuad(pass_id[0])}, | |
| 2756 }; | |
| 2757 Pass root_passes[] = { | |
| 2758 Pass(root_quads[0], arraysize(root_quads[0]), pass_id[0]), | |
| 2759 Pass(root_quads[1], arraysize(root_quads[1]), pass_id[1])}; | |
| 2760 | |
| 2761 cc::CompositorFrame root_frame = test::MakeEmptyCompositorFrame(); | |
| 2762 AddPasses(&root_frame.render_pass_list, gfx::Rect(SurfaceSize()), root_passes, | |
| 2763 arraysize(root_passes)); | |
| 2764 | |
| 2765 support_->SubmitCompositorFrame(root_local_surface_id_, | |
| 2766 std::move(root_frame)); | |
| 2767 | |
| 2768 SurfaceId root_surface_id(support_->frame_sink_id(), root_local_surface_id_); | |
| 2769 cc::CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); | |
| 2770 | |
| 2771 const auto& aggregated_pass_list = aggregated_frame.render_pass_list; | |
| 2772 | |
| 2773 ASSERT_EQ(2u, aggregated_pass_list.size()); | |
| 2774 | |
| 2775 // The root surface was enqueued without being aggregated once, so it should | |
| 2776 // be treated as completely damaged. | |
| 2777 EXPECT_TRUE( | |
| 2778 aggregated_pass_list[0]->damage_rect.Contains(gfx::Rect(SurfaceSize()))); | |
| 2779 EXPECT_TRUE( | |
| 2780 aggregated_pass_list[1]->damage_rect.Contains(gfx::Rect(SurfaceSize()))); | |
| 2781 | |
| 2782 // For off screen render pass, only the visible area is damaged. | |
|
danakj
2017/07/27 21:24:34
nit: usually write offscreen, or off-screen works
wutao
2017/07/28 17:05:17
Done.
| |
| 2783 { | |
| 2784 cc::CompositorFrame root_frame = test::MakeEmptyCompositorFrame(); | |
| 2785 AddPasses(&root_frame.render_pass_list, gfx::Rect(SurfaceSize()), | |
| 2786 root_passes, arraysize(root_passes)); | |
| 2787 | |
| 2788 auto* nonroot_pass = root_frame.render_pass_list[0].get(); | |
| 2789 nonroot_pass->transform_to_root_target.Translate(8, 0); | |
| 2790 | |
| 2791 auto* root_pass = root_frame.render_pass_list[1].get(); | |
| 2792 auto* root_pass_sqs = root_pass->shared_quad_state_list.front(); | |
| 2793 root_pass_sqs->quad_to_target_transform.Translate(8, 0); | |
| 2794 | |
| 2795 support_->SubmitCompositorFrame(root_local_surface_id_, | |
| 2796 std::move(root_frame)); | |
| 2797 | |
| 2798 cc::CompositorFrame aggregated_frame = | |
| 2799 aggregator_.Aggregate(root_surface_id); | |
| 2800 const auto& aggregated_pass_list = aggregated_frame.render_pass_list; | |
| 2801 | |
| 2802 // Only the visible area is damaged. | |
|
danakj
2017/07/27 21:24:34
Good test. You could also show that the root pass
wutao
2017/07/28 17:05:16
Done.
| |
| 2803 EXPECT_EQ(gfx::Rect(0, 0, 92, 100), aggregated_pass_list[0]->damage_rect); | |
| 2804 } | |
| 2805 | |
| 2806 // For off screen cached render pass, should have full damage. | |
| 2807 { | |
| 2808 cc::CompositorFrame root_frame = test::MakeEmptyCompositorFrame(); | |
| 2809 AddPasses(&root_frame.render_pass_list, gfx::Rect(SurfaceSize()), | |
| 2810 root_passes, arraysize(root_passes)); | |
| 2811 | |
| 2812 auto* nonroot_pass = root_frame.render_pass_list[0].get(); | |
| 2813 nonroot_pass->transform_to_root_target.Translate(8, 0); | |
| 2814 nonroot_pass->cache_render_pass = true; | |
| 2815 | |
| 2816 auto* root_pass = root_frame.render_pass_list[1].get(); | |
| 2817 auto* root_pass_sqs = root_pass->shared_quad_state_list.front(); | |
| 2818 root_pass_sqs->quad_to_target_transform.Translate(8, 0); | |
| 2819 | |
| 2820 support_->SubmitCompositorFrame(root_local_surface_id_, | |
| 2821 std::move(root_frame)); | |
| 2822 | |
| 2823 cc::CompositorFrame aggregated_frame = | |
| 2824 aggregator_.Aggregate(root_surface_id); | |
| 2825 const auto& aggregated_pass_list = aggregated_frame.render_pass_list; | |
| 2826 | |
| 2827 // Should have full damage. | |
| 2828 EXPECT_EQ(gfx::Rect(SurfaceSize()), aggregated_pass_list[0]->damage_rect); | |
| 2829 } | |
| 2830 } | |
| 2831 | |
| 2832 // Tests that the first frame damage_rect of cached render pass of a child | |
| 2833 // surface should be fully damaged. | |
| 2834 TEST_F(SurfaceAggregatorValidSurfaceTest, | |
| 2835 DamageRectOfCachedRenderPassInChildSurface) { | |
| 2836 int pass_id[] = {1, 2}; | |
| 2837 Quad child_quads[][1] = { | |
| 2838 {Quad::SolidColorQuad(SK_ColorGREEN)}, {Quad::RenderPassQuad(pass_id[0])}, | |
| 2839 }; | |
| 2840 Pass child_passes[] = { | |
| 2841 Pass(child_quads[0], arraysize(child_quads[0]), pass_id[0]), | |
| 2842 Pass(child_quads[1], arraysize(child_quads[1]), pass_id[1])}; | |
| 2843 | |
| 2844 cc::CompositorFrame child_frame = test::MakeEmptyCompositorFrame(); | |
| 2845 AddPasses(&child_frame.render_pass_list, gfx::Rect(SurfaceSize()), | |
| 2846 child_passes, arraysize(child_passes)); | |
| 2847 | |
| 2848 LocalSurfaceId child_local_surface_id = allocator_.GenerateId(); | |
| 2849 SurfaceId child_surface_id(child_support_->frame_sink_id(), | |
| 2850 child_local_surface_id); | |
| 2851 child_support_->SubmitCompositorFrame(child_local_surface_id, | |
| 2852 std::move(child_frame)); | |
| 2853 | |
| 2854 Quad root_surface_quads[] = { | |
| 2855 Quad::SurfaceQuad(child_surface_id, InvalidSurfaceId(), 1.f)}; | |
| 2856 | |
| 2857 Pass root_passes[] = { | |
| 2858 Pass(root_surface_quads, arraysize(root_surface_quads), 1)}; | |
| 2859 | |
| 2860 cc::CompositorFrame root_frame = test::MakeEmptyCompositorFrame(); | |
| 2861 AddPasses(&root_frame.render_pass_list, gfx::Rect(SurfaceSize()), root_passes, | |
| 2862 arraysize(root_passes)); | |
| 2863 | |
| 2864 support_->SubmitCompositorFrame(root_local_surface_id_, | |
| 2865 std::move(root_frame)); | |
| 2866 | |
| 2867 SurfaceId root_surface_id(support_->frame_sink_id(), root_local_surface_id_); | |
| 2868 cc::CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); | |
| 2869 | |
| 2870 const auto& aggregated_pass_list = aggregated_frame.render_pass_list; | |
| 2871 | |
| 2872 ASSERT_EQ(2u, aggregated_pass_list.size()); | |
| 2873 | |
| 2874 // The root surface was enqueued without being aggregated once, so it should | |
| 2875 // be treated as completely damaged. | |
| 2876 EXPECT_TRUE( | |
| 2877 aggregated_pass_list[0]->damage_rect.Contains(gfx::Rect(SurfaceSize()))); | |
| 2878 EXPECT_TRUE( | |
| 2879 aggregated_pass_list[1]->damage_rect.Contains(gfx::Rect(SurfaceSize()))); | |
| 2880 | |
| 2881 // For off screen render pass, only the visible area is damaged. | |
| 2882 { | |
| 2883 cc::CompositorFrame child_frame = test::MakeEmptyCompositorFrame(); | |
| 2884 AddPasses(&child_frame.render_pass_list, gfx::Rect(SurfaceSize()), | |
| 2885 child_passes, arraysize(child_passes)); | |
| 2886 | |
| 2887 auto* child_nonroot_pass = child_frame.render_pass_list[0].get(); | |
| 2888 child_nonroot_pass->transform_to_root_target.Translate(8, 0); | |
| 2889 | |
| 2890 auto* child_root_pass = child_frame.render_pass_list[1].get(); | |
| 2891 auto* child_root_pass_sqs = child_root_pass->shared_quad_state_list.front(); | |
| 2892 child_root_pass_sqs->quad_to_target_transform.Translate(8, 0); | |
| 2893 | |
| 2894 child_support_->SubmitCompositorFrame(child_local_surface_id, | |
| 2895 std::move(child_frame)); | |
| 2896 | |
| 2897 cc::CompositorFrame aggregated_frame = | |
| 2898 aggregator_.Aggregate(root_surface_id); | |
| 2899 const auto& aggregated_pass_list = aggregated_frame.render_pass_list; | |
| 2900 | |
| 2901 // Only the visible area is damaged. | |
|
danakj
2017/07/27 21:24:34
same here?
wutao
2017/07/28 17:05:17
Done.
| |
| 2902 EXPECT_EQ(gfx::Rect(0, 0, 92, 100), aggregated_pass_list[0]->damage_rect); | |
| 2903 } | |
| 2904 | |
| 2905 // For off screen cached render pass, should have full damage. | |
| 2906 { | |
| 2907 cc::CompositorFrame child_frame = test::MakeEmptyCompositorFrame(); | |
| 2908 AddPasses(&child_frame.render_pass_list, gfx::Rect(SurfaceSize()), | |
| 2909 child_passes, arraysize(child_passes)); | |
| 2910 | |
| 2911 auto* child_nonroot_pass = child_frame.render_pass_list[0].get(); | |
| 2912 child_nonroot_pass->transform_to_root_target.Translate(8, 0); | |
| 2913 child_nonroot_pass->cache_render_pass = true; | |
| 2914 | |
| 2915 auto* child_root_pass = child_frame.render_pass_list[1].get(); | |
| 2916 auto* child_root_pass_sqs = child_root_pass->shared_quad_state_list.front(); | |
| 2917 child_root_pass_sqs->quad_to_target_transform.Translate(8, 0); | |
| 2918 | |
| 2919 child_support_->SubmitCompositorFrame(child_local_surface_id, | |
| 2920 std::move(child_frame)); | |
| 2921 | |
| 2922 cc::CompositorFrame aggregated_frame = | |
| 2923 aggregator_.Aggregate(root_surface_id); | |
| 2924 const auto& aggregated_pass_list = aggregated_frame.render_pass_list; | |
| 2925 | |
| 2926 // Should have full damage. | |
| 2927 EXPECT_EQ(gfx::Rect(SurfaceSize()), aggregated_pass_list[0]->damage_rect); | |
| 2928 } | |
| 2929 } | |
| 2930 | |
| 2931 // Tests that quads outside the damage rect are not ignored for cached render | |
| 2932 // pass. | |
| 2933 TEST_F(SurfaceAggregatorPartialSwapTest, NotIgnoreOutsideForCachedRenderPass) { | |
| 2934 LocalSurfaceId child_local_surface_id = allocator_.GenerateId(); | |
| 2935 SurfaceId child_surface_id(child_support_->frame_sink_id(), | |
| 2936 child_local_surface_id); | |
| 2937 // The child surface has two quads, one with a visible rect of 15,15 6x6 and | |
| 2938 // the other other with a visible rect of 10,10 2x2 (relative to root target | |
| 2939 // space). | |
| 2940 { | |
| 2941 int pass_id[] = {1, 2}; | |
| 2942 Quad child_quads[][1] = { | |
| 2943 {Quad::SolidColorQuad(SK_ColorGREEN)}, | |
| 2944 {Quad::RenderPassQuad(pass_id[0])}, | |
| 2945 }; | |
| 2946 Pass child_passes[] = { | |
| 2947 Pass(child_quads[0], arraysize(child_quads[0]), pass_id[0]), | |
| 2948 Pass(child_quads[1], arraysize(child_quads[1]), pass_id[1])}; | |
| 2949 | |
| 2950 cc::RenderPassList child_pass_list; | |
| 2951 AddPasses(&child_pass_list, gfx::Rect(SurfaceSize()), child_passes, | |
| 2952 arraysize(child_passes)); | |
| 2953 | |
| 2954 child_pass_list[0]->quad_list.ElementAt(0)->visible_rect = | |
| 2955 gfx::Rect(1, 1, 3, 3); | |
| 2956 auto* child_sqs = child_pass_list[0]->shared_quad_state_list.ElementAt(0u); | |
| 2957 child_sqs->quad_to_target_transform.Translate(3, 3); | |
| 2958 child_sqs->quad_to_target_transform.Scale(2, 2); | |
| 2959 | |
| 2960 child_pass_list[0]->cache_render_pass = true; | |
| 2961 | |
| 2962 child_pass_list[1]->quad_list.ElementAt(0)->visible_rect = | |
| 2963 gfx::Rect(0, 0, 2, 2); | |
| 2964 | |
| 2965 SubmitPassListAsFrame(child_support_.get(), child_local_surface_id, | |
| 2966 &child_pass_list); | |
| 2967 } | |
| 2968 | |
| 2969 { | |
| 2970 int pass_id[] = {1, 2}; | |
| 2971 Quad root_quads[][1] = { | |
| 2972 {Quad::SurfaceQuad(child_surface_id, InvalidSurfaceId(), 1.f)}, | |
| 2973 {Quad::RenderPassQuad(pass_id[0])}, | |
| 2974 }; | |
| 2975 Pass root_passes[] = { | |
| 2976 Pass(root_quads[0], arraysize(root_quads[0]), pass_id[0]), | |
| 2977 Pass(root_quads[1], arraysize(root_quads[1]), pass_id[1])}; | |
| 2978 | |
| 2979 cc::RenderPassList root_pass_list; | |
| 2980 AddPasses(&root_pass_list, gfx::Rect(SurfaceSize()), root_passes, | |
| 2981 arraysize(root_passes)); | |
| 2982 | |
| 2983 auto* root_pass = root_pass_list[1].get(); | |
| 2984 root_pass->shared_quad_state_list.front() | |
| 2985 ->quad_to_target_transform.Translate(10, 10); | |
| 2986 root_pass->damage_rect = gfx::Rect(0, 0, 1, 1); | |
| 2987 | |
| 2988 SubmitPassListAsFrame(support_.get(), root_local_surface_id_, | |
| 2989 &root_pass_list); | |
| 2990 } | |
| 2991 | |
| 2992 SurfaceId root_surface_id(support_->frame_sink_id(), root_local_surface_id_); | |
| 2993 cc::CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); | |
| 2994 | |
| 2995 const auto& aggregated_pass_list = aggregated_frame.render_pass_list; | |
| 2996 | |
| 2997 ASSERT_EQ(3u, aggregated_pass_list.size()); | |
| 2998 | |
| 2999 // Damage rect for first aggregation should contain entire root surface. | |
| 3000 EXPECT_EQ(gfx::Rect(SurfaceSize()), aggregated_pass_list[2]->damage_rect); | |
| 3001 EXPECT_EQ(1u, aggregated_pass_list[0]->quad_list.size()); | |
| 3002 EXPECT_EQ(1u, aggregated_pass_list[1]->quad_list.size()); | |
| 3003 EXPECT_EQ(1u, aggregated_pass_list[2]->quad_list.size()); | |
| 3004 | |
| 3005 // Test should not ignore outside for cached render pass. | |
| 3006 // Create a root surface with a smaller damage rect. | |
| 3007 { | |
| 3008 int pass_id[] = {1, 2}; | |
| 3009 Quad root_quads[][1] = { | |
| 3010 {Quad::SurfaceQuad(child_surface_id, InvalidSurfaceId(), 1.f)}, | |
| 3011 {Quad::RenderPassQuad(pass_id[0])}, | |
| 3012 }; | |
| 3013 Pass root_passes[] = { | |
| 3014 Pass(root_quads[0], arraysize(root_quads[0]), pass_id[0]), | |
| 3015 Pass(root_quads[1], arraysize(root_quads[1]), pass_id[1])}; | |
| 3016 | |
| 3017 cc::RenderPassList root_pass_list; | |
| 3018 AddPasses(&root_pass_list, gfx::Rect(SurfaceSize()), root_passes, | |
| 3019 arraysize(root_passes)); | |
| 3020 | |
| 3021 auto* root_pass = root_pass_list[1].get(); | |
| 3022 root_pass->shared_quad_state_list.front() | |
| 3023 ->quad_to_target_transform.Translate(10, 10); | |
| 3024 root_pass->damage_rect = gfx::Rect(10, 10, 2, 2); | |
| 3025 SubmitPassListAsFrame(support_.get(), root_local_surface_id_, | |
| 3026 &root_pass_list); | |
| 3027 } | |
| 3028 | |
| 3029 { | |
| 3030 cc::CompositorFrame aggregated_frame = | |
| 3031 aggregator_.Aggregate(root_surface_id); | |
| 3032 const auto& aggregated_pass_list = aggregated_frame.render_pass_list; | |
| 3033 | |
| 3034 ASSERT_EQ(3u, aggregated_pass_list.size()); | |
| 3035 | |
| 3036 // The first quad is a cached render pass, should be included and fully | |
| 3037 // damaged. | |
| 3038 EXPECT_EQ(gfx::Rect(1, 1, 3, 3), | |
| 3039 aggregated_pass_list[0]->quad_list.back()->visible_rect); | |
| 3040 EXPECT_EQ(gfx::Rect(0, 0, 2, 2), | |
| 3041 aggregated_pass_list[1]->quad_list.back()->visible_rect); | |
| 3042 EXPECT_EQ(gfx::Rect(SurfaceSize()), aggregated_pass_list[0]->damage_rect); | |
| 3043 EXPECT_EQ(gfx::Rect(10, 10, 2, 2), aggregated_pass_list[1]->damage_rect); | |
| 3044 EXPECT_EQ(gfx::Rect(10, 10, 2, 2), aggregated_pass_list[2]->damage_rect); | |
| 3045 EXPECT_EQ(1u, aggregated_pass_list[0]->quad_list.size()); | |
| 3046 EXPECT_EQ(1u, aggregated_pass_list[1]->quad_list.size()); | |
| 3047 EXPECT_EQ(1u, aggregated_pass_list[2]->quad_list.size()); | |
| 3048 } | |
| 3049 } | |
| 3050 | |
| 2509 } // namespace | 3051 } // namespace |
| 2510 } // namespace viz | 3052 } // namespace viz |
| OLD | NEW |