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

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

Issue 506273002: Aggregate damage rects in surface aggregator (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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/surfaces_pixeltest.cc » ('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/output/compositor_frame.h" 5 #include "cc/output/compositor_frame.h"
6 #include "cc/output/delegated_frame_data.h" 6 #include "cc/output/delegated_frame_data.h"
7 #include "cc/quads/render_pass.h" 7 #include "cc/quads/render_pass.h"
8 #include "cc/quads/render_pass_draw_quad.h" 8 #include "cc/quads/render_pass_draw_quad.h"
9 #include "cc/quads/solid_color_draw_quad.h" 9 #include "cc/quads/solid_color_draw_quad.h"
10 #include "cc/quads/surface_draw_quad.h" 10 #include "cc/quads/surface_draw_quad.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 protected: 54 protected:
55 SurfaceManager manager_; 55 SurfaceManager manager_;
56 EmptySurfaceFactoryClient empty_client_; 56 EmptySurfaceFactoryClient empty_client_;
57 SurfaceFactory factory_; 57 SurfaceFactory factory_;
58 SurfaceAggregator aggregator_; 58 SurfaceAggregator aggregator_;
59 }; 59 };
60 60
61 TEST_F(SurfaceAggregatorTest, ValidSurfaceNoFrame) { 61 TEST_F(SurfaceAggregatorTest, ValidSurfaceNoFrame) {
62 SurfaceId one_id(7); 62 SurfaceId one_id(7);
63 factory_.Create(one_id, SurfaceSize()); 63 factory_.Create(one_id, SurfaceSize());
64 std::set<SurfaceId> surface_set; 64 scoped_ptr<CompositorFrame> frame = aggregator_.Aggregate(one_id);
65 scoped_ptr<CompositorFrame> frame =
66 aggregator_.Aggregate(one_id, &surface_set);
67 EXPECT_FALSE(frame); 65 EXPECT_FALSE(frame);
68 factory_.Destroy(one_id); 66 factory_.Destroy(one_id);
69 } 67 }
70 68
71 class SurfaceAggregatorValidSurfaceTest : public SurfaceAggregatorTest { 69 class SurfaceAggregatorValidSurfaceTest : public SurfaceAggregatorTest {
72 public: 70 public:
73 SurfaceAggregatorValidSurfaceTest() : allocator_(1u) {} 71 SurfaceAggregatorValidSurfaceTest() : allocator_(1u) {}
74 72
75 virtual void SetUp() { 73 virtual void SetUp() {
76 SurfaceAggregatorTest::SetUp(); 74 SurfaceAggregatorTest::SetUp();
77 root_surface_id_ = allocator_.GenerateId(); 75 root_surface_id_ = allocator_.GenerateId();
78 factory_.Create(root_surface_id_, SurfaceSize()); 76 factory_.Create(root_surface_id_, SurfaceSize());
79 } 77 }
80 78
81 virtual void TearDown() { 79 virtual void TearDown() {
82 factory_.Destroy(root_surface_id_); 80 factory_.Destroy(root_surface_id_);
83 SurfaceAggregatorTest::TearDown(); 81 SurfaceAggregatorTest::TearDown();
84 } 82 }
85 83
86 void AggregateAndVerify(test::Pass* expected_passes, 84 void AggregateAndVerify(test::Pass* expected_passes,
87 size_t expected_pass_count, 85 size_t expected_pass_count,
88 SurfaceId* surface_ids, 86 SurfaceId* surface_ids,
89 size_t expected_surface_count) { 87 size_t expected_surface_count) {
90 std::set<SurfaceId> surface_set;
91 scoped_ptr<CompositorFrame> aggregated_frame = 88 scoped_ptr<CompositorFrame> aggregated_frame =
92 aggregator_.Aggregate(root_surface_id_, &surface_set); 89 aggregator_.Aggregate(root_surface_id_);
93 90
94 ASSERT_TRUE(aggregated_frame); 91 ASSERT_TRUE(aggregated_frame);
95 ASSERT_TRUE(aggregated_frame->delegated_frame_data); 92 ASSERT_TRUE(aggregated_frame->delegated_frame_data);
96 93
97 DelegatedFrameData* frame_data = 94 DelegatedFrameData* frame_data =
98 aggregated_frame->delegated_frame_data.get(); 95 aggregated_frame->delegated_frame_data.get();
99 96
100 TestPassesMatchExpectations( 97 TestPassesMatchExpectations(
101 expected_passes, expected_pass_count, &frame_data->render_pass_list); 98 expected_passes, expected_pass_count, &frame_data->render_pass_list);
102 99
103 EXPECT_EQ(expected_surface_count, surface_set.size()); 100 EXPECT_EQ(expected_surface_count,
101 aggregator_.previous_contained_surfaces().size());
104 for (size_t i = 0; i < expected_surface_count; i++) { 102 for (size_t i = 0; i < expected_surface_count; i++) {
105 EXPECT_TRUE(surface_set.find(surface_ids[i]) != surface_set.end()); 103 EXPECT_TRUE(
104 aggregator_.previous_contained_surfaces().find(surface_ids[i]) !=
105 aggregator_.previous_contained_surfaces().end());
106 } 106 }
107 } 107 }
108 108
109 void SubmitFrame(test::Pass* passes, 109 void SubmitFrame(test::Pass* passes,
110 size_t pass_count, 110 size_t pass_count,
111 SurfaceId surface_id) { 111 SurfaceId surface_id) {
112 RenderPassList pass_list; 112 RenderPassList pass_list;
113 AddPasses(&pass_list, gfx::Rect(SurfaceSize()), passes, pass_count); 113 AddPasses(&pass_list, gfx::Rect(SurfaceSize()), passes, pass_count);
114 114
115 scoped_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData); 115 scoped_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData);
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 {test::Quad::SurfaceQuad(embedded_surface_id), 220 {test::Quad::SurfaceQuad(embedded_surface_id),
221 test::Quad::RenderPassQuad(pass_ids[0])}, 221 test::Quad::RenderPassQuad(pass_ids[0])},
222 {test::Quad::SolidColorQuad(7), test::Quad::RenderPassQuad(pass_ids[1])}}; 222 {test::Quad::SolidColorQuad(7), test::Quad::RenderPassQuad(pass_ids[1])}};
223 test::Pass root_passes[] = { 223 test::Pass root_passes[] = {
224 test::Pass(root_quads[0], arraysize(root_quads[0]), pass_ids[0]), 224 test::Pass(root_quads[0], arraysize(root_quads[0]), pass_ids[0]),
225 test::Pass(root_quads[1], arraysize(root_quads[1]), pass_ids[1]), 225 test::Pass(root_quads[1], arraysize(root_quads[1]), pass_ids[1]),
226 test::Pass(root_quads[2], arraysize(root_quads[2]), pass_ids[2])}; 226 test::Pass(root_quads[2], arraysize(root_quads[2]), pass_ids[2])};
227 227
228 SubmitFrame(root_passes, arraysize(root_passes), root_surface_id_); 228 SubmitFrame(root_passes, arraysize(root_passes), root_surface_id_);
229 229
230 std::set<SurfaceId> surface_set;
231 scoped_ptr<CompositorFrame> aggregated_frame = 230 scoped_ptr<CompositorFrame> aggregated_frame =
232 aggregator_.Aggregate(root_surface_id_, &surface_set); 231 aggregator_.Aggregate(root_surface_id_);
233 232
234 ASSERT_TRUE(aggregated_frame); 233 ASSERT_TRUE(aggregated_frame);
235 ASSERT_TRUE(aggregated_frame->delegated_frame_data); 234 ASSERT_TRUE(aggregated_frame->delegated_frame_data);
236 235
237 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get(); 236 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get();
238 237
239 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; 238 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list;
240 239
241 ASSERT_EQ(5u, aggregated_pass_list.size()); 240 ASSERT_EQ(5u, aggregated_pass_list.size());
242 RenderPassId actual_pass_ids[] = { 241 RenderPassId actual_pass_ids[] = {
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 // Pass IDs from the parent surface may collide with ones from the child. 443 // Pass IDs from the parent surface may collide with ones from the child.
445 RenderPassId parent_pass_id[] = {RenderPassId(2, 1), RenderPassId(1, 2)}; 444 RenderPassId parent_pass_id[] = {RenderPassId(2, 1), RenderPassId(1, 2)};
446 test::Quad parent_quad[][1] = { 445 test::Quad parent_quad[][1] = {
447 {test::Quad::SurfaceQuad(child_surface_id)}, 446 {test::Quad::SurfaceQuad(child_surface_id)},
448 {test::Quad::RenderPassQuad(parent_pass_id[0])}}; 447 {test::Quad::RenderPassQuad(parent_pass_id[0])}};
449 test::Pass parent_passes[] = { 448 test::Pass parent_passes[] = {
450 test::Pass(parent_quad[0], arraysize(parent_quad[0]), parent_pass_id[0]), 449 test::Pass(parent_quad[0], arraysize(parent_quad[0]), parent_pass_id[0]),
451 test::Pass(parent_quad[1], arraysize(parent_quad[1]), parent_pass_id[1])}; 450 test::Pass(parent_quad[1], arraysize(parent_quad[1]), parent_pass_id[1])};
452 451
453 SubmitFrame(parent_passes, arraysize(parent_passes), root_surface_id_); 452 SubmitFrame(parent_passes, arraysize(parent_passes), root_surface_id_);
454 std::set<SurfaceId> surface_set;
455 scoped_ptr<CompositorFrame> aggregated_frame = 453 scoped_ptr<CompositorFrame> aggregated_frame =
456 aggregator_.Aggregate(root_surface_id_, &surface_set); 454 aggregator_.Aggregate(root_surface_id_);
457 455
458 ASSERT_TRUE(aggregated_frame); 456 ASSERT_TRUE(aggregated_frame);
459 ASSERT_TRUE(aggregated_frame->delegated_frame_data); 457 ASSERT_TRUE(aggregated_frame->delegated_frame_data);
460 458
461 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get(); 459 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get();
462 460
463 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; 461 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list;
464 462
465 ASSERT_EQ(3u, aggregated_pass_list.size()); 463 ASSERT_EQ(3u, aggregated_pass_list.size());
466 RenderPassId actual_pass_ids[] = {aggregated_pass_list[0]->id, 464 RenderPassId actual_pass_ids[] = {aggregated_pass_list[0]->id,
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 root_pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); 614 root_pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>();
617 child_two_surface_quad->SetNew(root_pass->shared_quad_state_list.back(), 615 child_two_surface_quad->SetNew(root_pass->shared_quad_state_list.back(),
618 gfx::Rect(SurfaceSize()), 616 gfx::Rect(SurfaceSize()),
619 gfx::Rect(SurfaceSize()), 617 gfx::Rect(SurfaceSize()),
620 child_two_surface_id); 618 child_two_surface_id);
621 AddSolidColorQuadWithBlendMode( 619 AddSolidColorQuadWithBlendMode(
622 SurfaceSize(), root_pass.get(), blend_modes[6]); 620 SurfaceSize(), root_pass.get(), blend_modes[6]);
623 621
624 QueuePassAsFrame(root_pass.Pass(), root_surface_id_); 622 QueuePassAsFrame(root_pass.Pass(), root_surface_id_);
625 623
626 std::set<SurfaceId> surface_set;
627 scoped_ptr<CompositorFrame> aggregated_frame = 624 scoped_ptr<CompositorFrame> aggregated_frame =
628 aggregator_.Aggregate(root_surface_id_, &surface_set); 625 aggregator_.Aggregate(root_surface_id_);
629 626
630 ASSERT_TRUE(aggregated_frame); 627 ASSERT_TRUE(aggregated_frame);
631 ASSERT_TRUE(aggregated_frame->delegated_frame_data); 628 ASSERT_TRUE(aggregated_frame->delegated_frame_data);
632 629
633 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get(); 630 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get();
634 631
635 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; 632 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list;
636 633
637 ASSERT_EQ(1u, aggregated_pass_list.size()); 634 ASSERT_EQ(1u, aggregated_pass_list.size());
638 635
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
720 ->content_to_target_transform.Translate(0, 10); 717 ->content_to_target_transform.Translate(0, 10);
721 718
722 scoped_ptr<DelegatedFrameData> root_frame_data(new DelegatedFrameData); 719 scoped_ptr<DelegatedFrameData> root_frame_data(new DelegatedFrameData);
723 root_pass_list.swap(root_frame_data->render_pass_list); 720 root_pass_list.swap(root_frame_data->render_pass_list);
724 721
725 scoped_ptr<CompositorFrame> root_frame(new CompositorFrame); 722 scoped_ptr<CompositorFrame> root_frame(new CompositorFrame);
726 root_frame->delegated_frame_data = root_frame_data.Pass(); 723 root_frame->delegated_frame_data = root_frame_data.Pass();
727 724
728 factory_.SubmitFrame(root_surface_id_, root_frame.Pass(), base::Closure()); 725 factory_.SubmitFrame(root_surface_id_, root_frame.Pass(), base::Closure());
729 726
730 std::set<SurfaceId> surface_set;
731 scoped_ptr<CompositorFrame> aggregated_frame = 727 scoped_ptr<CompositorFrame> aggregated_frame =
732 aggregator_.Aggregate(root_surface_id_, &surface_set); 728 aggregator_.Aggregate(root_surface_id_);
733 729
734 ASSERT_TRUE(aggregated_frame); 730 ASSERT_TRUE(aggregated_frame);
735 ASSERT_TRUE(aggregated_frame->delegated_frame_data); 731 ASSERT_TRUE(aggregated_frame->delegated_frame_data);
736 732
737 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get(); 733 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get();
738 734
739 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; 735 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list;
740 736
741 ASSERT_EQ(2u, aggregated_pass_list.size()); 737 ASSERT_EQ(2u, aggregated_pass_list.size());
742 738
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
790 786
791 // The second quad in the root pass is aggregated from the child, so its 787 // The second quad in the root pass is aggregated from the child, so its
792 // clip rect must be transformed by the child's translation. 788 // clip rect must be transformed by the child's translation.
793 EXPECT_EQ( 789 EXPECT_EQ(
794 gfx::Rect(0, 10, 5, 5).ToString(), 790 gfx::Rect(0, 10, 5, 5).ToString(),
795 aggregated_pass_list[1]->shared_quad_state_list[1]->clip_rect.ToString()); 791 aggregated_pass_list[1]->shared_quad_state_list[1]->clip_rect.ToString());
796 792
797 factory_.Destroy(child_surface_id); 793 factory_.Destroy(child_surface_id);
798 } 794 }
799 795
796 // Tests that damage rects are aggregated correctly when surfaces change.
797 TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateDamageRect) {
798 SurfaceId child_surface_id = allocator_.GenerateId();
799 factory_.Create(child_surface_id, SurfaceSize());
800 RenderPassId child_pass_id = RenderPassId(1, 1);
801 test::Quad child_quads[] = {test::Quad::RenderPassQuad(child_pass_id)};
802 test::Pass child_passes[] = {
803 test::Pass(child_quads, arraysize(child_quads), child_pass_id)};
804
805 RenderPassList child_pass_list;
806 AddPasses(&child_pass_list,
807 gfx::Rect(SurfaceSize()),
808 child_passes,
809 arraysize(child_passes));
810
811 RenderPass* child_root_pass = child_pass_list.at(0u);
812 SharedQuadState* child_root_pass_sqs =
813 child_root_pass->shared_quad_state_list[0];
814 child_root_pass_sqs->content_to_target_transform.Translate(8, 0);
815
816 scoped_ptr<DelegatedFrameData> child_frame_data(new DelegatedFrameData);
817 child_pass_list.swap(child_frame_data->render_pass_list);
818
819 scoped_ptr<CompositorFrame> child_frame(new CompositorFrame);
820 child_frame->delegated_frame_data = child_frame_data.Pass();
821
822 factory_.SubmitFrame(child_surface_id, child_frame.Pass(), base::Closure());
823
824 test::Quad root_quads[] = {test::Quad::SurfaceQuad(child_surface_id)};
825 test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))};
826
827 RenderPassList root_pass_list;
828 AddPasses(&root_pass_list,
829 gfx::Rect(SurfaceSize()),
830 root_passes,
831 arraysize(root_passes));
832
833 root_pass_list.at(0)
834 ->shared_quad_state_list[0]
835 ->content_to_target_transform.Translate(0, 10);
836 root_pass_list.at(0)->damage_rect = gfx::Rect(5, 5, 10, 10);
837
838 scoped_ptr<DelegatedFrameData> root_frame_data(new DelegatedFrameData);
839 root_pass_list.swap(root_frame_data->render_pass_list);
840
841 scoped_ptr<CompositorFrame> root_frame(new CompositorFrame);
842 root_frame->delegated_frame_data = root_frame_data.Pass();
843
844 factory_.SubmitFrame(root_surface_id_, root_frame.Pass(), base::Closure());
845
846 scoped_ptr<CompositorFrame> aggregated_frame =
847 aggregator_.Aggregate(root_surface_id_);
848
849 ASSERT_TRUE(aggregated_frame);
850 ASSERT_TRUE(aggregated_frame->delegated_frame_data);
851
852 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get();
853
854 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list;
855
856 ASSERT_EQ(1u, aggregated_pass_list.size());
857
858 // Damage rect for first aggregation should contain entire root surface.
859 EXPECT_TRUE(
860 aggregated_pass_list[0]->damage_rect.Contains(gfx::Rect(SurfaceSize())));
861
862 {
863 AddPasses(&child_pass_list,
864 gfx::Rect(SurfaceSize()),
865 child_passes,
866 arraysize(child_passes));
867
868 RenderPass* child_root_pass = child_pass_list.at(0u);
869 SharedQuadState* child_root_pass_sqs =
870 child_root_pass->shared_quad_state_list[0];
871 child_root_pass_sqs->content_to_target_transform.Translate(8, 0);
872 child_root_pass->damage_rect = gfx::Rect(10, 10, 10, 10);
873
874 scoped_ptr<DelegatedFrameData> child_frame_data(new DelegatedFrameData);
875 child_pass_list.swap(child_frame_data->render_pass_list);
876
877 scoped_ptr<CompositorFrame> child_frame(new CompositorFrame);
878 child_frame->delegated_frame_data = child_frame_data.Pass();
879
880 factory_.SubmitFrame(child_surface_id, child_frame.Pass(), base::Closure());
881
882 scoped_ptr<CompositorFrame> aggregated_frame =
883 aggregator_.Aggregate(root_surface_id_);
884
885 ASSERT_TRUE(aggregated_frame);
886 ASSERT_TRUE(aggregated_frame->delegated_frame_data);
887
888 DelegatedFrameData* frame_data =
889 aggregated_frame->delegated_frame_data.get();
890
891 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list;
892
893 ASSERT_EQ(1u, aggregated_pass_list.size());
894
895 // Outer surface didn't change, so transformed inner damage rect should be
896 // used.
897 EXPECT_EQ(gfx::Rect(10, 20, 10, 10).ToString(),
898 aggregated_pass_list[0]->damage_rect.ToString());
899 }
900
901 {
902 RenderPassList root_pass_list;
903 AddPasses(&root_pass_list,
904 gfx::Rect(SurfaceSize()),
905 root_passes,
906 arraysize(root_passes));
907
908 root_pass_list.at(0)
909 ->shared_quad_state_list[0]
910 ->content_to_target_transform.Translate(0, 10);
911 root_pass_list.at(0)->damage_rect = gfx::Rect(0, 0, 1, 1);
912
913 scoped_ptr<DelegatedFrameData> root_frame_data(new DelegatedFrameData);
914 root_pass_list.swap(root_frame_data->render_pass_list);
915
916 scoped_ptr<CompositorFrame> root_frame(new CompositorFrame);
917 root_frame->delegated_frame_data = root_frame_data.Pass();
918
919 factory_.SubmitFrame(root_surface_id_, root_frame.Pass(), base::Closure());
920 }
921
922 {
923 RenderPassList root_pass_list;
924 AddPasses(&root_pass_list,
925 gfx::Rect(SurfaceSize()),
926 root_passes,
927 arraysize(root_passes));
928
929 root_pass_list.at(0)
930 ->shared_quad_state_list[0]
931 ->content_to_target_transform.Translate(0, 10);
932 root_pass_list.at(0)->damage_rect = gfx::Rect(1, 1, 1, 1);
933
934 scoped_ptr<DelegatedFrameData> root_frame_data(new DelegatedFrameData);
935 root_pass_list.swap(root_frame_data->render_pass_list);
936
937 scoped_ptr<CompositorFrame> root_frame(new CompositorFrame);
938 root_frame->delegated_frame_data = root_frame_data.Pass();
939
940 factory_.SubmitFrame(root_surface_id_, root_frame.Pass(), base::Closure());
941
942 scoped_ptr<CompositorFrame> aggregated_frame =
943 aggregator_.Aggregate(root_surface_id_);
944
945 ASSERT_TRUE(aggregated_frame);
946 ASSERT_TRUE(aggregated_frame->delegated_frame_data);
947
948 DelegatedFrameData* frame_data =
949 aggregated_frame->delegated_frame_data.get();
950
951 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list;
952
953 ASSERT_EQ(1u, aggregated_pass_list.size());
954
955 // The root surface was enqueued without being aggregated once, so it should
956 // be treated as completely damaged.
957 EXPECT_TRUE(aggregated_pass_list[0]->damage_rect.Contains(
958 gfx::Rect(SurfaceSize())));
959 }
960
961 factory_.Destroy(child_surface_id);
962 }
963
800 class SurfaceAggregatorWithResourcesTest : public testing::Test { 964 class SurfaceAggregatorWithResourcesTest : public testing::Test {
801 public: 965 public:
802 virtual void SetUp() { 966 virtual void SetUp() {
803 output_surface_ = FakeOutputSurface::CreateSoftware( 967 output_surface_ = FakeOutputSurface::CreateSoftware(
804 make_scoped_ptr(new SoftwareOutputDevice)); 968 make_scoped_ptr(new SoftwareOutputDevice));
805 output_surface_->BindToClient(&output_surface_client_); 969 output_surface_->BindToClient(&output_surface_client_);
806 shared_bitmap_manager_.reset(new TestSharedBitmapManager); 970 shared_bitmap_manager_.reset(new TestSharedBitmapManager);
807 971
808 resource_provider_ = ResourceProvider::Create(output_surface_.get(), 972 resource_provider_ = ResourceProvider::Create(output_surface_.get(),
809 shared_bitmap_manager_.get(), 973 shared_bitmap_manager_.get(),
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
892 1056
893 TEST_F(SurfaceAggregatorWithResourcesTest, TakeResourcesOneSurface) { 1057 TEST_F(SurfaceAggregatorWithResourcesTest, TakeResourcesOneSurface) {
894 ResourceTrackingSurfaceFactoryClient client; 1058 ResourceTrackingSurfaceFactoryClient client;
895 SurfaceFactory factory(&manager_, &client); 1059 SurfaceFactory factory(&manager_, &client);
896 SurfaceId surface_id(7u); 1060 SurfaceId surface_id(7u);
897 factory.Create(surface_id, SurfaceSize()); 1061 factory.Create(surface_id, SurfaceSize());
898 1062
899 ResourceProvider::ResourceId ids[] = {11, 12, 13}; 1063 ResourceProvider::ResourceId ids[] = {11, 12, 13};
900 SubmitFrameWithResources(ids, arraysize(ids), &factory, surface_id); 1064 SubmitFrameWithResources(ids, arraysize(ids), &factory, surface_id);
901 1065
902 std::set<SurfaceId> surface_set; 1066 scoped_ptr<CompositorFrame> frame = aggregator_->Aggregate(surface_id);
903 scoped_ptr<CompositorFrame> frame =
904 aggregator_->Aggregate(surface_id, &surface_set);
905 1067
906 // Nothing should be available to be returned yet. 1068 // Nothing should be available to be returned yet.
907 EXPECT_TRUE(client.returned_resources().empty()); 1069 EXPECT_TRUE(client.returned_resources().empty());
908 1070
909 SubmitFrameWithResources(NULL, 0u, &factory, surface_id); 1071 SubmitFrameWithResources(NULL, 0u, &factory, surface_id);
910 1072
911 surface_set.clear(); 1073 frame = aggregator_->Aggregate(surface_id);
912 frame = aggregator_->Aggregate(surface_id, &surface_set);
913 1074
914 ASSERT_EQ(3u, client.returned_resources().size()); 1075 ASSERT_EQ(3u, client.returned_resources().size());
915 ResourceProvider::ResourceId returned_ids[3]; 1076 ResourceProvider::ResourceId returned_ids[3];
916 for (size_t i = 0; i < 3; ++i) { 1077 for (size_t i = 0; i < 3; ++i) {
917 returned_ids[i] = client.returned_resources()[i].id; 1078 returned_ids[i] = client.returned_resources()[i].id;
918 } 1079 }
919 EXPECT_THAT(returned_ids, 1080 EXPECT_THAT(returned_ids,
920 testing::WhenSorted(testing::ElementsAreArray(ids))); 1081 testing::WhenSorted(testing::ElementsAreArray(ids)));
921 factory.Destroy(surface_id); 1082 factory.Destroy(surface_id);
922 } 1083 }
923 1084
924 } // namespace 1085 } // namespace
925 } // namespace cc 1086 } // namespace cc
926 1087
OLDNEW
« no previous file with comments | « cc/surfaces/surface_aggregator.cc ('k') | cc/surfaces/surfaces_pixeltest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698