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

Side by Side Diff: components/viz/service/display/surface_aggregator_unittest.cc

Issue 2873593002: Force use of and cache render surface. (Closed)
Patch Set: Rebased to resolve conflict. Created 3 years, 4 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 | « components/viz/service/display/surface_aggregator.cc ('k') | ui/compositor/layer.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 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
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 // On first frame there is no existing cache texture to worry about re-using,
2540 // so we don't worry what this bool is set to.
2541 cc::CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id);
2542
2543 // No Surface changed, so no damage should be given.
2544 {
2545 cc::CompositorFrame aggregated_frame =
2546 aggregator_.Aggregate(root_surface_id);
2547 EXPECT_FALSE(aggregated_frame.render_pass_list[0]
2548 ->has_damage_from_contributing_content);
2549 }
2550
2551 // Change child_frame with damage should set the flag.
2552 {
2553 cc::CompositorFrame child_surface_frame = test::MakeEmptyCompositorFrame();
2554 AddPasses(&child_surface_frame.render_pass_list, gfx::Rect(SurfaceSize()),
2555 child_surface_passes, arraysize(child_surface_passes));
2556 child_support_->SubmitCompositorFrame(child_local_surface_id,
2557 std::move(child_surface_frame));
2558
2559 cc::CompositorFrame aggregated_frame =
2560 aggregator_.Aggregate(root_surface_id);
2561 // True for new child_frame with damage.
2562 EXPECT_TRUE(aggregated_frame.render_pass_list[0]
2563 ->has_damage_from_contributing_content);
2564 }
2565
2566 // Change child_frame without damage should not set the flag.
2567 {
2568 cc::CompositorFrame child_surface_frame = test::MakeEmptyCompositorFrame();
2569 AddPasses(&child_surface_frame.render_pass_list, gfx::Rect(SurfaceSize()),
2570 child_surface_passes, arraysize(child_surface_passes));
2571 child_surface_frame.render_pass_list[0]->damage_rect = gfx::Rect();
2572 child_support_->SubmitCompositorFrame(child_local_surface_id,
2573 std::move(child_surface_frame));
2574
2575 cc::CompositorFrame aggregated_frame =
2576 aggregator_.Aggregate(root_surface_id);
2577 // False for new child_frame without damage.
2578 EXPECT_FALSE(aggregated_frame.render_pass_list[0]
2579 ->has_damage_from_contributing_content);
2580 }
2581 }
2582
2583 // Tests that has_damage_from_contributing_content is aggregated correctly from
2584 // grand child surface quads.
2585 TEST_F(SurfaceAggregatorValidSurfaceTest,
2586 HasDamageByChangingGrandChildSurface) {
2587 auto grand_child_support = CompositorFrameSinkSupport::Create(
2588 nullptr, &manager_, kArbitraryMiddleFrameSinkId, kChildIsRoot,
2589 kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints);
2590
2591 Quad child_surface_quads[] = {Quad::RenderPassQuad(1)};
2592 Pass child_surface_passes[] = {
2593 Pass(child_surface_quads, arraysize(child_surface_quads), 1)};
2594
2595 cc::CompositorFrame child_surface_frame = test::MakeEmptyCompositorFrame();
2596 AddPasses(&child_surface_frame.render_pass_list, gfx::Rect(SurfaceSize()),
2597 child_surface_passes, arraysize(child_surface_passes));
2598
2599 LocalSurfaceId child_local_surface_id = allocator_.GenerateId();
2600 SurfaceId child_surface_id(child_support_->frame_sink_id(),
2601 child_local_surface_id);
2602 child_support_->SubmitCompositorFrame(child_local_surface_id,
2603 std::move(child_surface_frame));
2604
2605 Quad root_surface_quads[] = {
2606 Quad::SurfaceQuad(child_surface_id, InvalidSurfaceId(), 1.f)};
2607 Pass root_passes[] = {
2608 Pass(root_surface_quads, arraysize(root_surface_quads), 1)};
2609
2610 cc::CompositorFrame root_frame = test::MakeEmptyCompositorFrame();
2611 AddPasses(&root_frame.render_pass_list, gfx::Rect(SurfaceSize()), root_passes,
2612 arraysize(root_passes));
2613
2614 SurfaceId root_surface_id(support_->frame_sink_id(), root_local_surface_id_);
2615 support_->SubmitCompositorFrame(root_local_surface_id_,
2616 std::move(root_frame));
2617
2618 // On first frame there is no existing cache texture to worry about re-using,
2619 // so we don't worry what this bool is set to.
2620 cc::CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id);
2621
2622 // No Surface changed, so no damage should be given.
2623 {
2624 cc::CompositorFrame aggregated_frame =
2625 aggregator_.Aggregate(root_surface_id);
2626 EXPECT_FALSE(aggregated_frame.render_pass_list[0]
2627 ->has_damage_from_contributing_content);
2628 }
2629
2630 // Add a grand_child_frame should cause damage.
2631 Quad grand_child_quads[] = {Quad::RenderPassQuad(1)};
2632 Pass grand_child_passes[] = {
2633 Pass(grand_child_quads, arraysize(grand_child_quads), 1)};
2634 LocalSurfaceId grand_child_local_surface_id = allocator_.GenerateId();
2635 SurfaceId grand_child_surface_id(grand_child_support->frame_sink_id(),
2636 grand_child_local_surface_id);
2637 {
2638 cc::CompositorFrame grand_child_frame = test::MakeEmptyCompositorFrame();
2639 AddPasses(&grand_child_frame.render_pass_list, gfx::Rect(SurfaceSize()),
2640 grand_child_passes, arraysize(grand_child_passes));
2641
2642 grand_child_support->SubmitCompositorFrame(grand_child_local_surface_id,
2643 std::move(grand_child_frame));
2644
2645 Quad new_child_surface_quads[] = {
2646 child_surface_quads[0],
2647 Quad::SurfaceQuad(grand_child_surface_id, InvalidSurfaceId(), 1.f)};
2648 Pass new_child_surface_passes[] = {
2649 Pass(new_child_surface_quads, arraysize(new_child_surface_quads), 1)};
2650 child_surface_frame = test::MakeEmptyCompositorFrame();
2651 AddPasses(&child_surface_frame.render_pass_list, gfx::Rect(SurfaceSize()),
2652 new_child_surface_passes, arraysize(new_child_surface_passes));
2653 child_support_->SubmitCompositorFrame(child_local_surface_id,
2654 std::move(child_surface_frame));
2655
2656 cc::CompositorFrame aggregated_frame =
2657 aggregator_.Aggregate(root_surface_id);
2658 // True for new grand_child_frame.
2659 EXPECT_TRUE(aggregated_frame.render_pass_list[0]
2660 ->has_damage_from_contributing_content);
2661 }
2662
2663 // No Surface changed, so no damage should be given.
2664 {
2665 cc::CompositorFrame aggregated_frame =
2666 aggregator_.Aggregate(root_surface_id);
2667 EXPECT_FALSE(aggregated_frame.render_pass_list[0]
2668 ->has_damage_from_contributing_content);
2669 }
2670
2671 // Change grand_child_frame with damage should set the flag.
2672 {
2673 cc::CompositorFrame grand_child_frame = test::MakeEmptyCompositorFrame();
2674 AddPasses(&grand_child_frame.render_pass_list, gfx::Rect(SurfaceSize()),
2675 grand_child_passes, arraysize(grand_child_passes));
2676 grand_child_support->SubmitCompositorFrame(grand_child_local_surface_id,
2677 std::move(grand_child_frame));
2678
2679 cc::CompositorFrame aggregated_frame =
2680 aggregator_.Aggregate(root_surface_id);
2681 // True for new grand_child_frame with damage.
2682 EXPECT_TRUE(aggregated_frame.render_pass_list[0]
2683 ->has_damage_from_contributing_content);
2684 }
2685
2686 // Change grand_child_frame without damage should not set the flag.
2687 {
2688 cc::CompositorFrame grand_child_frame = test::MakeEmptyCompositorFrame();
2689 AddPasses(&grand_child_frame.render_pass_list, gfx::Rect(SurfaceSize()),
2690 grand_child_passes, arraysize(grand_child_passes));
2691 grand_child_frame.render_pass_list[0]->damage_rect = gfx::Rect();
2692 grand_child_support->SubmitCompositorFrame(grand_child_local_surface_id,
2693 std::move(grand_child_frame));
2694
2695 cc::CompositorFrame aggregated_frame =
2696 aggregator_.Aggregate(root_surface_id);
2697 // False for new grand_child_frame without damage.
2698 EXPECT_FALSE(aggregated_frame.render_pass_list[0]
2699 ->has_damage_from_contributing_content);
2700 }
2701
2702 grand_child_support->EvictCurrentSurface();
2703 }
2704
2705 // Tests that has_damage_from_contributing_content is aggregated correctly from
2706 // render pass quads.
2707 TEST_F(SurfaceAggregatorValidSurfaceTest, HasDamageFromRenderPassQuads) {
2708 Quad child_quads[] = {Quad::RenderPassQuad(1)};
2709 Pass child_passes[] = {Pass(child_quads, arraysize(child_quads), 1)};
2710
2711 cc::CompositorFrame child_frame = test::MakeEmptyCompositorFrame();
2712 AddPasses(&child_frame.render_pass_list, gfx::Rect(SurfaceSize()),
2713 child_passes, arraysize(child_passes));
2714
2715 LocalSurfaceId child_local_surface_id = allocator_.GenerateId();
2716 SurfaceId child_surface_id(child_support_->frame_sink_id(),
2717 child_local_surface_id);
2718 child_support_->SubmitCompositorFrame(child_local_surface_id,
2719 std::move(child_frame));
2720
2721 Quad root_surface_quads[] = {
2722 Quad::SurfaceQuad(child_surface_id, InvalidSurfaceId(), 1.f)};
2723 Quad root_render_pass_quads[] = {Quad::RenderPassQuad(1)};
2724
2725 Pass root_passes[] = {
2726 Pass(root_surface_quads, arraysize(root_surface_quads), 1),
2727 Pass(root_render_pass_quads, arraysize(root_render_pass_quads), 2)};
2728
2729 cc::CompositorFrame root_frame = test::MakeEmptyCompositorFrame();
2730 AddPasses(&root_frame.render_pass_list, gfx::Rect(SurfaceSize()), root_passes,
2731 arraysize(root_passes));
2732
2733 support_->SubmitCompositorFrame(root_local_surface_id_,
2734 std::move(root_frame));
2735
2736 SurfaceId root_surface_id(support_->frame_sink_id(), root_local_surface_id_);
2737 cc::CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id);
2738
2739 // On first frame there is no existing cache texture to worry about re-using,
2740 // so we don't worry what this bool is set to.
2741 const auto& aggregated_pass_list = aggregated_frame.render_pass_list;
2742
2743 ASSERT_EQ(2u, aggregated_pass_list.size());
2744
2745 // No Surface changed, so no damage should be given.
2746 {
2747 cc::CompositorFrame aggregated_frame =
2748 aggregator_.Aggregate(root_surface_id);
2749 EXPECT_FALSE(aggregated_frame.render_pass_list[0]
2750 ->has_damage_from_contributing_content);
2751 EXPECT_FALSE(aggregated_frame.render_pass_list[1]
2752 ->has_damage_from_contributing_content);
2753 }
2754
2755 // Changing child_frame should damage both render_pass.
2756 {
2757 cc::CompositorFrame child_frame = test::MakeEmptyCompositorFrame();
2758 AddPasses(&child_frame.render_pass_list, gfx::Rect(SurfaceSize()),
2759 child_passes, arraysize(child_passes));
2760 child_support_->SubmitCompositorFrame(child_local_surface_id,
2761 std::move(child_frame));
2762
2763 cc::CompositorFrame aggregated_frame =
2764 aggregator_.Aggregate(root_surface_id);
2765 // True for new child_frame.
2766 EXPECT_TRUE(aggregated_frame.render_pass_list[0]
2767 ->has_damage_from_contributing_content);
2768 EXPECT_TRUE(aggregated_frame.render_pass_list[1]
2769 ->has_damage_from_contributing_content);
2770 }
2771 }
2772
2773 // Tests that the first frame damage_rect of a cached render pass should be
2774 // fully damaged.
2775 TEST_F(SurfaceAggregatorValidSurfaceTest, DamageRectOfCachedRenderPass) {
2776 int pass_id[] = {1, 2};
2777 Quad root_quads[][1] = {
2778 {Quad::SolidColorQuad(SK_ColorGREEN)}, {Quad::RenderPassQuad(pass_id[0])},
2779 };
2780 Pass root_passes[] = {
2781 Pass(root_quads[0], arraysize(root_quads[0]), pass_id[0]),
2782 Pass(root_quads[1], arraysize(root_quads[1]), pass_id[1])};
2783
2784 cc::CompositorFrame root_frame = test::MakeEmptyCompositorFrame();
2785 AddPasses(&root_frame.render_pass_list, gfx::Rect(SurfaceSize()), root_passes,
2786 arraysize(root_passes));
2787
2788 support_->SubmitCompositorFrame(root_local_surface_id_,
2789 std::move(root_frame));
2790
2791 SurfaceId root_surface_id(support_->frame_sink_id(), root_local_surface_id_);
2792 cc::CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id);
2793
2794 const auto& aggregated_pass_list = aggregated_frame.render_pass_list;
2795
2796 ASSERT_EQ(2u, aggregated_pass_list.size());
2797
2798 // The root surface was enqueued without being aggregated once, so it should
2799 // be treated as completely damaged.
2800 EXPECT_TRUE(
2801 aggregated_pass_list[0]->damage_rect.Contains(gfx::Rect(SurfaceSize())));
2802 EXPECT_TRUE(
2803 aggregated_pass_list[1]->damage_rect.Contains(gfx::Rect(SurfaceSize())));
2804
2805 // For offscreen render pass, only the visible area is damaged.
2806 {
2807 cc::CompositorFrame root_frame = test::MakeEmptyCompositorFrame();
2808 AddPasses(&root_frame.render_pass_list, gfx::Rect(SurfaceSize()),
2809 root_passes, arraysize(root_passes));
2810
2811 auto* nonroot_pass = root_frame.render_pass_list[0].get();
2812 nonroot_pass->transform_to_root_target.Translate(8, 0);
2813
2814 gfx::Rect root_pass_damage = gfx::Rect(0, 0, 10, 10);
2815 auto* root_pass = root_frame.render_pass_list[1].get();
2816 root_pass->damage_rect = root_pass_damage;
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 // Only the visible area is damaged.
2828 EXPECT_EQ(gfx::Rect(0, 0, 2, 10), aggregated_pass_list[0]->damage_rect);
2829 EXPECT_EQ(root_pass_damage, aggregated_pass_list[1]->damage_rect);
2830 }
2831
2832 // For offscreen cached render pass, should have full damage.
2833 {
2834 cc::CompositorFrame root_frame = test::MakeEmptyCompositorFrame();
2835 AddPasses(&root_frame.render_pass_list, gfx::Rect(SurfaceSize()),
2836 root_passes, arraysize(root_passes));
2837
2838 auto* nonroot_pass = root_frame.render_pass_list[0].get();
2839 nonroot_pass->transform_to_root_target.Translate(8, 0);
2840 nonroot_pass->cache_render_pass = true;
2841
2842 gfx::Rect root_pass_damage = gfx::Rect(0, 0, 10, 10);
2843 auto* root_pass = root_frame.render_pass_list[1].get();
2844 root_pass->damage_rect = root_pass_damage;
2845 auto* root_pass_sqs = root_pass->shared_quad_state_list.front();
2846 root_pass_sqs->quad_to_target_transform.Translate(8, 0);
2847
2848 support_->SubmitCompositorFrame(root_local_surface_id_,
2849 std::move(root_frame));
2850
2851 cc::CompositorFrame aggregated_frame =
2852 aggregator_.Aggregate(root_surface_id);
2853 const auto& aggregated_pass_list = aggregated_frame.render_pass_list;
2854
2855 // Should have full damage.
2856 EXPECT_EQ(gfx::Rect(SurfaceSize()), aggregated_pass_list[0]->damage_rect);
2857 EXPECT_EQ(root_pass_damage, aggregated_pass_list[1]->damage_rect);
2858 }
2859 }
2860
2861 // Tests that the first frame damage_rect of cached render pass of a child
2862 // surface should be fully damaged.
2863 TEST_F(SurfaceAggregatorValidSurfaceTest,
2864 DamageRectOfCachedRenderPassInChildSurface) {
2865 int pass_id[] = {1, 2};
2866 Quad child_quads[][1] = {
2867 {Quad::SolidColorQuad(SK_ColorGREEN)}, {Quad::RenderPassQuad(pass_id[0])},
2868 };
2869 Pass child_passes[] = {
2870 Pass(child_quads[0], arraysize(child_quads[0]), pass_id[0]),
2871 Pass(child_quads[1], arraysize(child_quads[1]), pass_id[1])};
2872
2873 cc::CompositorFrame child_frame = test::MakeEmptyCompositorFrame();
2874 AddPasses(&child_frame.render_pass_list, gfx::Rect(SurfaceSize()),
2875 child_passes, arraysize(child_passes));
2876
2877 LocalSurfaceId child_local_surface_id = allocator_.GenerateId();
2878 SurfaceId child_surface_id(child_support_->frame_sink_id(),
2879 child_local_surface_id);
2880 child_support_->SubmitCompositorFrame(child_local_surface_id,
2881 std::move(child_frame));
2882
2883 Quad root_surface_quads[] = {
2884 Quad::SurfaceQuad(child_surface_id, InvalidSurfaceId(), 1.f)};
2885
2886 Pass root_passes[] = {
2887 Pass(root_surface_quads, arraysize(root_surface_quads), 1)};
2888
2889 cc::CompositorFrame root_frame = test::MakeEmptyCompositorFrame();
2890 AddPasses(&root_frame.render_pass_list, gfx::Rect(SurfaceSize()), root_passes,
2891 arraysize(root_passes));
2892
2893 support_->SubmitCompositorFrame(root_local_surface_id_,
2894 std::move(root_frame));
2895
2896 SurfaceId root_surface_id(support_->frame_sink_id(), root_local_surface_id_);
2897 cc::CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id);
2898
2899 const auto& aggregated_pass_list = aggregated_frame.render_pass_list;
2900
2901 ASSERT_EQ(2u, aggregated_pass_list.size());
2902
2903 // The root surface was enqueued without being aggregated once, so it should
2904 // be treated as completely damaged.
2905 EXPECT_TRUE(
2906 aggregated_pass_list[0]->damage_rect.Contains(gfx::Rect(SurfaceSize())));
2907 EXPECT_TRUE(
2908 aggregated_pass_list[1]->damage_rect.Contains(gfx::Rect(SurfaceSize())));
2909
2910 // For offscreen render pass, only the visible area is damaged.
2911 {
2912 cc::CompositorFrame child_frame = test::MakeEmptyCompositorFrame();
2913 AddPasses(&child_frame.render_pass_list, gfx::Rect(SurfaceSize()),
2914 child_passes, arraysize(child_passes));
2915
2916 auto* child_nonroot_pass = child_frame.render_pass_list[0].get();
2917 child_nonroot_pass->transform_to_root_target.Translate(8, 0);
2918
2919 gfx::Rect child_root_pass_damage = gfx::Rect(0, 0, 10, 10);
2920 auto* child_root_pass = child_frame.render_pass_list[1].get();
2921 child_root_pass->damage_rect = child_root_pass_damage;
2922 auto* child_root_pass_sqs = child_root_pass->shared_quad_state_list.front();
2923 child_root_pass_sqs->quad_to_target_transform.Translate(8, 0);
2924
2925 child_support_->SubmitCompositorFrame(child_local_surface_id,
2926 std::move(child_frame));
2927
2928 cc::CompositorFrame aggregated_frame =
2929 aggregator_.Aggregate(root_surface_id);
2930 const auto& aggregated_pass_list = aggregated_frame.render_pass_list;
2931
2932 // Only the visible area is damaged.
2933 EXPECT_EQ(gfx::Rect(0, 0, 2, 10), aggregated_pass_list[0]->damage_rect);
2934 EXPECT_EQ(child_root_pass_damage, aggregated_pass_list[1]->damage_rect);
2935 }
2936
2937 // For offscreen cached render pass, should have full damage.
2938 {
2939 cc::CompositorFrame child_frame = test::MakeEmptyCompositorFrame();
2940 AddPasses(&child_frame.render_pass_list, gfx::Rect(SurfaceSize()),
2941 child_passes, arraysize(child_passes));
2942
2943 auto* child_nonroot_pass = child_frame.render_pass_list[0].get();
2944 child_nonroot_pass->transform_to_root_target.Translate(8, 0);
2945 child_nonroot_pass->cache_render_pass = true;
2946
2947 gfx::Rect child_root_pass_damage = gfx::Rect(0, 0, 10, 10);
2948 auto* child_root_pass = child_frame.render_pass_list[1].get();
2949 child_root_pass->damage_rect = child_root_pass_damage;
2950 auto* child_root_pass_sqs = child_root_pass->shared_quad_state_list.front();
2951 child_root_pass_sqs->quad_to_target_transform.Translate(8, 0);
2952
2953 child_support_->SubmitCompositorFrame(child_local_surface_id,
2954 std::move(child_frame));
2955
2956 cc::CompositorFrame aggregated_frame =
2957 aggregator_.Aggregate(root_surface_id);
2958 const auto& aggregated_pass_list = aggregated_frame.render_pass_list;
2959
2960 // Should have full damage.
2961 EXPECT_EQ(gfx::Rect(SurfaceSize()), aggregated_pass_list[0]->damage_rect);
2962 EXPECT_EQ(child_root_pass_damage, aggregated_pass_list[1]->damage_rect);
2963 }
2964 }
2965
2966 // Tests that quads outside the damage rect are not ignored for cached render
2967 // pass.
2968 TEST_F(SurfaceAggregatorPartialSwapTest, NotIgnoreOutsideForCachedRenderPass) {
2969 LocalSurfaceId child_local_surface_id = allocator_.GenerateId();
2970 SurfaceId child_surface_id(child_support_->frame_sink_id(),
2971 child_local_surface_id);
2972 // The child surface has two quads, one with a visible rect of 15,15 6x6 and
2973 // the other other with a visible rect of 10,10 2x2 (relative to root target
2974 // space).
2975 {
2976 int pass_id[] = {1, 2};
2977 Quad child_quads[][1] = {
2978 {Quad::SolidColorQuad(SK_ColorGREEN)},
2979 {Quad::RenderPassQuad(pass_id[0])},
2980 };
2981 Pass child_passes[] = {
2982 Pass(child_quads[0], arraysize(child_quads[0]), pass_id[0]),
2983 Pass(child_quads[1], arraysize(child_quads[1]), pass_id[1])};
2984
2985 cc::RenderPassList child_pass_list;
2986 AddPasses(&child_pass_list, gfx::Rect(SurfaceSize()), child_passes,
2987 arraysize(child_passes));
2988
2989 child_pass_list[0]->quad_list.ElementAt(0)->visible_rect =
2990 gfx::Rect(1, 1, 3, 3);
2991 auto* child_sqs = child_pass_list[0]->shared_quad_state_list.ElementAt(0u);
2992 child_sqs->quad_to_target_transform.Translate(3, 3);
2993 child_sqs->quad_to_target_transform.Scale(2, 2);
2994
2995 child_pass_list[0]->cache_render_pass = true;
2996
2997 child_pass_list[1]->quad_list.ElementAt(0)->visible_rect =
2998 gfx::Rect(0, 0, 2, 2);
2999
3000 SubmitPassListAsFrame(child_support_.get(), child_local_surface_id,
3001 &child_pass_list);
3002 }
3003
3004 {
3005 int pass_id[] = {1, 2};
3006 Quad root_quads[][1] = {
3007 {Quad::SurfaceQuad(child_surface_id, InvalidSurfaceId(), 1.f)},
3008 {Quad::RenderPassQuad(pass_id[0])},
3009 };
3010 Pass root_passes[] = {
3011 Pass(root_quads[0], arraysize(root_quads[0]), pass_id[0]),
3012 Pass(root_quads[1], arraysize(root_quads[1]), pass_id[1])};
3013
3014 cc::RenderPassList root_pass_list;
3015 AddPasses(&root_pass_list, gfx::Rect(SurfaceSize()), root_passes,
3016 arraysize(root_passes));
3017
3018 auto* root_pass = root_pass_list[1].get();
3019 root_pass->shared_quad_state_list.front()
3020 ->quad_to_target_transform.Translate(10, 10);
3021 root_pass->damage_rect = gfx::Rect(0, 0, 1, 1);
3022
3023 SubmitPassListAsFrame(support_.get(), root_local_surface_id_,
3024 &root_pass_list);
3025 }
3026
3027 SurfaceId root_surface_id(support_->frame_sink_id(), root_local_surface_id_);
3028 cc::CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id);
3029
3030 const auto& aggregated_pass_list = aggregated_frame.render_pass_list;
3031
3032 ASSERT_EQ(3u, aggregated_pass_list.size());
3033
3034 // Damage rect for first aggregation should contain entire root surface.
3035 EXPECT_EQ(gfx::Rect(SurfaceSize()), aggregated_pass_list[2]->damage_rect);
3036 EXPECT_EQ(1u, aggregated_pass_list[0]->quad_list.size());
3037 EXPECT_EQ(1u, aggregated_pass_list[1]->quad_list.size());
3038 EXPECT_EQ(1u, aggregated_pass_list[2]->quad_list.size());
3039
3040 // Test should not ignore outside for cached render pass.
3041 // Create a root surface with a smaller damage rect.
3042 {
3043 int pass_id[] = {1, 2};
3044 Quad root_quads[][1] = {
3045 {Quad::SurfaceQuad(child_surface_id, InvalidSurfaceId(), 1.f)},
3046 {Quad::RenderPassQuad(pass_id[0])},
3047 };
3048 Pass root_passes[] = {
3049 Pass(root_quads[0], arraysize(root_quads[0]), pass_id[0]),
3050 Pass(root_quads[1], arraysize(root_quads[1]), pass_id[1])};
3051
3052 cc::RenderPassList root_pass_list;
3053 AddPasses(&root_pass_list, gfx::Rect(SurfaceSize()), root_passes,
3054 arraysize(root_passes));
3055
3056 auto* root_pass = root_pass_list[1].get();
3057 root_pass->shared_quad_state_list.front()
3058 ->quad_to_target_transform.Translate(10, 10);
3059 root_pass->damage_rect = gfx::Rect(10, 10, 2, 2);
3060 SubmitPassListAsFrame(support_.get(), root_local_surface_id_,
3061 &root_pass_list);
3062 }
3063
3064 {
3065 cc::CompositorFrame aggregated_frame =
3066 aggregator_.Aggregate(root_surface_id);
3067 const auto& aggregated_pass_list = aggregated_frame.render_pass_list;
3068
3069 ASSERT_EQ(3u, aggregated_pass_list.size());
3070
3071 // The first quad is a cached render pass, should be included and fully
3072 // damaged.
3073 EXPECT_EQ(gfx::Rect(1, 1, 3, 3),
3074 aggregated_pass_list[0]->quad_list.back()->visible_rect);
3075 EXPECT_EQ(gfx::Rect(0, 0, 2, 2),
3076 aggregated_pass_list[1]->quad_list.back()->visible_rect);
3077 EXPECT_EQ(gfx::Rect(SurfaceSize()), aggregated_pass_list[0]->damage_rect);
3078 EXPECT_EQ(gfx::Rect(10, 10, 2, 2), aggregated_pass_list[1]->damage_rect);
3079 EXPECT_EQ(gfx::Rect(10, 10, 2, 2), aggregated_pass_list[2]->damage_rect);
3080 EXPECT_EQ(1u, aggregated_pass_list[0]->quad_list.size());
3081 EXPECT_EQ(1u, aggregated_pass_list[1]->quad_list.size());
3082 EXPECT_EQ(1u, aggregated_pass_list[2]->quad_list.size());
3083 }
3084 }
3085
2509 } // namespace 3086 } // namespace
2510 } // namespace viz 3087 } // namespace viz
OLDNEW
« no previous file with comments | « components/viz/service/display/surface_aggregator.cc ('k') | ui/compositor/layer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698