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

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

Issue 2721763002: SetPreviousFrameSurface should copy latency info to the new surface (Closed)
Patch Set: c Created 3 years, 9 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 | « no previous file | cc/surfaces/surface.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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/compositor_frame_sink_support.h" 5 #include "cc/surfaces/compositor_frame_sink_support.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "cc/output/compositor_frame.h" 8 #include "cc/output/compositor_frame.h"
9 #include "cc/surfaces/compositor_frame_sink_support_client.h" 9 #include "cc/surfaces/compositor_frame_sink_support_client.h"
10 #include "cc/surfaces/frame_sink_id.h" 10 #include "cc/surfaces/frame_sink_id.h"
(...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after
678 678
679 // Verify that the parent Surface has activated and no longer has a pending 679 // Verify that the parent Surface has activated and no longer has a pending
680 // CompositorFrame. Also verify that |child_id1| is no longer a child 680 // CompositorFrame. Also verify that |child_id1| is no longer a child
681 // reference of |parent_id|. 681 // reference of |parent_id|.
682 EXPECT_TRUE(parent_surface()->HasActiveFrame()); 682 EXPECT_TRUE(parent_surface()->HasActiveFrame());
683 EXPECT_FALSE(parent_surface()->HasPendingFrame()); 683 EXPECT_FALSE(parent_surface()->HasPendingFrame());
684 EXPECT_THAT(parent_surface()->blocking_surfaces_for_testing(), IsEmpty()); 684 EXPECT_THAT(parent_surface()->blocking_surfaces_for_testing(), IsEmpty());
685 EXPECT_THAT(GetChildReferences(parent_id), UnorderedElementsAre(child_id2)); 685 EXPECT_THAT(GetChildReferences(parent_id), UnorderedElementsAre(child_id2));
686 } 686 }
687 687
688 // Checks whether the latency info are moved to the new surface from the old
689 // one when LocalSurfaceId changes. No frame has unresolved dependencies.
690 TEST_F(CompositorFrameSinkSupportTest,
691 LatencyInfoCarriedOverOnResize_NoUnresolvedDependencies) {
692 const SurfaceId parent_id1 = MakeSurfaceId(kParentFrameSink, 1);
693 const SurfaceId parent_id2 = MakeSurfaceId(kParentFrameSink, 2);
694 const ui::LatencyComponentType latency_type1 =
695 ui::WINDOW_SNAPSHOT_FRAME_NUMBER_COMPONENT;
696 const int64_t latency_id1 = 234;
697 const int64_t latency_sequence_number1 = 5645432;
698 const ui::LatencyComponentType latency_type2 = ui::TAB_SHOW_COMPONENT;
699 const int64_t latency_id2 = 31434351;
700 const int64_t latency_sequence_number2 = 663788;
701
702 // Submit a frame with latency info
703 ui::LatencyInfo info;
704 info.AddLatencyNumber(latency_type1, latency_id1, latency_sequence_number1);
705
706 CompositorFrame frame;
707 frame.metadata.latency_info.push_back(info);
708
709 parent_support().SubmitCompositorFrame(parent_id1.local_surface_id(),
710 std::move(frame));
711
712 // Submit another frame with some other latency info and a different
713 // LocalSurfaceId.
714 ui::LatencyInfo info2;
715 info2.AddLatencyNumber(latency_type2, latency_id2, latency_sequence_number2);
716
717 CompositorFrame frame2;
718 frame2.metadata.latency_info.push_back(info2);
719
720 parent_support().SubmitCompositorFrame(parent_id2.local_surface_id(),
721 std::move(frame2));
722
723 // Confirm that the new surface has both latency info elements.
724 Surface* surface = surface_manager().GetSurfaceForId(parent_id2);
725 std::vector<ui::LatencyInfo> info_list;
726 surface->TakeLatencyInfo(&info_list);
727 EXPECT_EQ(2u, info_list.size());
728
729 ui::LatencyInfo aggregated_latency_info = info_list[0];
730 aggregated_latency_info.AddNewLatencyFrom(info_list[1]);
731 EXPECT_EQ(2u, aggregated_latency_info.latency_components().size());
732
733 ui::LatencyInfo::LatencyComponent comp1;
734 EXPECT_TRUE(
735 aggregated_latency_info.FindLatency(latency_type1, latency_id1, &comp1));
736 EXPECT_EQ(latency_sequence_number1, comp1.sequence_number);
737 }
738
739 // Checks whether the latency info are moved to the new surface from the old
740 // one when LocalSurfaceId changes. Old surface has unresolved dependencies.
741 TEST_F(CompositorFrameSinkSupportTest,
742 LatencyInfoCarriedOverOnResize_OldSurfaceHasPendingAndActiveFrame) {
743 const SurfaceId parent_id1 = MakeSurfaceId(kParentFrameSink, 1);
744 const SurfaceId parent_id2 = MakeSurfaceId(kParentFrameSink, 2);
745 const SurfaceId child_id = MakeSurfaceId(kChildFrameSink1, 1);
746
747 const ui::LatencyComponentType latency_type1 =
748 ui::WINDOW_SNAPSHOT_FRAME_NUMBER_COMPONENT;
749 const int64_t latency_id1 = 234;
750 const int64_t latency_sequence_number1 = 5645432;
751 const ui::LatencyComponentType latency_type2 = ui::TAB_SHOW_COMPONENT;
752 const int64_t latency_id2 = 31434351;
753 const int64_t latency_sequence_number2 = 663788;
754
755 // Submit a frame with no unresolved dependecy.
756 ui::LatencyInfo info;
757 info.AddLatencyNumber(latency_type1, latency_id1, latency_sequence_number1);
758
759 CompositorFrame frame;
760 frame.metadata.latency_info.push_back(info);
761
762 parent_support().SubmitCompositorFrame(parent_id1.local_surface_id(),
763 std::move(frame));
764
765 // Submit a frame with unresolved dependencies.
766 ui::LatencyInfo info2;
767 info2.AddLatencyNumber(latency_type2, latency_id2, latency_sequence_number2);
768
769 CompositorFrame frame2 = MakeCompositorFrame({child_id});
770 frame2.metadata.latency_info.push_back(info2);
771
772 parent_support().SubmitCompositorFrame(parent_id1.local_surface_id(),
773 std::move(frame2));
Fady Samuel 2017/03/01 19:35:19 nit: Add an expectation that the surface has a pen
Saman Sami 2017/03/01 19:49:30 Done.
774
775 // Submit a frame with a new local surface id.
776 parent_support().SubmitCompositorFrame(parent_id2.local_surface_id(),
777 CompositorFrame());
778
779 // Confirm that the new surface has latency info from both active and pending
780 // frame of the old surface.
781 Surface* surface = surface_manager().GetSurfaceForId(parent_id2);
Fady Samuel 2017/03/01 19:35:19 ASSERT_NE(nullptr, surface)? Also, given this is t
Saman Sami 2017/03/01 19:49:30 I prefer the assert.
782 std::vector<ui::LatencyInfo> info_list;
783 surface->TakeLatencyInfo(&info_list);
784 EXPECT_EQ(2u, info_list.size());
785
786 ui::LatencyInfo aggregated_latency_info = info_list[0];
787 aggregated_latency_info.AddNewLatencyFrom(info_list[1]);
788 EXPECT_EQ(2u, aggregated_latency_info.latency_components().size());
789
790 ui::LatencyInfo::LatencyComponent comp1;
791 EXPECT_TRUE(
792 aggregated_latency_info.FindLatency(latency_type1, latency_id1, &comp1));
793 EXPECT_EQ(latency_sequence_number1, comp1.sequence_number);
794 }
795
796 // Checks whether the latency info are moved to the new surface from the old
797 // one when LocalSurfaceId changes. The new surface has unresolved dependencies.
798 TEST_F(CompositorFrameSinkSupportTest,
799 LatencyInfoCarriedOverOnResize_NewSurfaceHasPendingFrame) {
800 const SurfaceId parent_id1 = MakeSurfaceId(kParentFrameSink, 1);
801 const SurfaceId parent_id2 = MakeSurfaceId(kParentFrameSink, 2);
802 const SurfaceId child_id = MakeSurfaceId(kChildFrameSink1, 1);
803
804 const ui::LatencyComponentType latency_type1 =
805 ui::WINDOW_SNAPSHOT_FRAME_NUMBER_COMPONENT;
806 const int64_t latency_id1 = 234;
807 const int64_t latency_sequence_number1 = 5645432;
808 const ui::LatencyComponentType latency_type2 = ui::TAB_SHOW_COMPONENT;
809 const int64_t latency_id2 = 31434351;
810 const int64_t latency_sequence_number2 = 663788;
811
812 // Submit a frame with no unresolved dependencies.
813 ui::LatencyInfo info;
814 info.AddLatencyNumber(latency_type1, latency_id1, latency_sequence_number1);
815
816 CompositorFrame frame;
817 frame.metadata.latency_info.push_back(info);
818
819 parent_support().SubmitCompositorFrame(parent_id1.local_surface_id(),
820 std::move(frame));
821
822 // Submit a frame with a new local surface id and with unresolved
823 // dependencies.
824 ui::LatencyInfo info2;
825 info2.AddLatencyNumber(latency_type2, latency_id2, latency_sequence_number2);
826
827 CompositorFrame frame2 = MakeCompositorFrame({child_id});
828 frame2.metadata.latency_info.push_back(info2);
829
830 parent_support().SubmitCompositorFrame(parent_id2.local_surface_id(),
831 std::move(frame2));
Fady Samuel 2017/03/01 19:35:19 Verify there's a pending frame.
Saman Sami 2017/03/01 19:49:30 I do it below.
832
833 // Confirm that the new surface has a pending frame and no active frame.
834 Surface* surface = surface_manager().GetSurfaceForId(parent_id2);
835 EXPECT_TRUE(surface->HasPendingFrame());
836 EXPECT_FALSE(surface->HasActiveFrame());
837
838 // Resolve the dependencies. The frame in parent's surface must become active.
839 child_support1().SubmitCompositorFrame(child_id.local_surface_id(),
840 CompositorFrame());
841 EXPECT_FALSE(surface->HasPendingFrame());
842 EXPECT_TRUE(surface->HasActiveFrame());
843
844 // Both latency info elements must exist in the now-activated frame of the
845 // new surface.
846 std::vector<ui::LatencyInfo> info_list;
847 surface->TakeLatencyInfo(&info_list);
848 EXPECT_EQ(2u, info_list.size());
849
850 ui::LatencyInfo aggregated_latency_info = info_list[0];
851 aggregated_latency_info.AddNewLatencyFrom(info_list[1]);
852 EXPECT_EQ(2u, aggregated_latency_info.latency_components().size());
853
854 ui::LatencyInfo::LatencyComponent comp1;
855 EXPECT_TRUE(
856 aggregated_latency_info.FindLatency(latency_type1, latency_id1, &comp1));
857 EXPECT_EQ(latency_sequence_number1, comp1.sequence_number);
858 }
859
688 } // namespace test 860 } // namespace test
689 } // namespace cc 861 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | cc/surfaces/surface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698