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

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

Issue 2835393003: Reject frames with invalid BeginFrameAck in CompositorFrameSinkSupport (Closed)
Patch Set: Fixed header Created 3 years, 8 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
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>
11 11
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/ptr_util.h" 13 #include "base/memory/ptr_util.h"
14 #include "cc/output/compositor_frame.h" 14 #include "cc/output/compositor_frame.h"
15 #include "cc/quads/render_pass.h" 15 #include "cc/quads/render_pass.h"
16 #include "cc/quads/render_pass_draw_quad.h" 16 #include "cc/quads/render_pass_draw_quad.h"
17 #include "cc/quads/solid_color_draw_quad.h" 17 #include "cc/quads/solid_color_draw_quad.h"
18 #include "cc/quads/surface_draw_quad.h" 18 #include "cc/quads/surface_draw_quad.h"
19 #include "cc/quads/texture_draw_quad.h" 19 #include "cc/quads/texture_draw_quad.h"
20 #include "cc/resources/shared_bitmap_manager.h" 20 #include "cc/resources/shared_bitmap_manager.h"
21 #include "cc/surfaces/compositor_frame_sink_support.h" 21 #include "cc/surfaces/compositor_frame_sink_support.h"
22 #include "cc/surfaces/local_surface_id_allocator.h" 22 #include "cc/surfaces/local_surface_id_allocator.h"
23 #include "cc/surfaces/surface.h" 23 #include "cc/surfaces/surface.h"
24 #include "cc/surfaces/surface_manager.h" 24 #include "cc/surfaces/surface_manager.h"
25 #include "cc/test/compositor_frame_helpers.h"
25 #include "cc/test/fake_compositor_frame_sink_support_client.h" 26 #include "cc/test/fake_compositor_frame_sink_support_client.h"
26 #include "cc/test/fake_resource_provider.h" 27 #include "cc/test/fake_resource_provider.h"
27 #include "cc/test/render_pass_test_utils.h" 28 #include "cc/test/render_pass_test_utils.h"
28 #include "cc/test/surface_aggregator_test_helpers.h" 29 #include "cc/test/surface_aggregator_test_helpers.h"
29 #include "cc/test/test_shared_bitmap_manager.h" 30 #include "cc/test/test_shared_bitmap_manager.h"
30 #include "testing/gmock/include/gmock/gmock.h" 31 #include "testing/gmock/include/gmock/gmock.h"
31 #include "testing/gtest/include/gtest/gtest.h" 32 #include "testing/gtest/include/gtest/gtest.h"
32 #include "third_party/skia/include/core/SkColor.h" 33 #include "third_party/skia/include/core/SkColor.h"
33 34
34 namespace cc { 35 namespace cc {
(...skipping 15 matching lines...) Expand all
50 static SurfaceId invalid(FrameSinkId(), 51 static SurfaceId invalid(FrameSinkId(),
51 LocalSurfaceId(0xdeadbeef, kArbitraryToken)); 52 LocalSurfaceId(0xdeadbeef, kArbitraryToken));
52 return invalid; 53 return invalid;
53 } 54 }
54 55
55 gfx::Size SurfaceSize() { 56 gfx::Size SurfaceSize() {
56 static gfx::Size size(100, 100); 57 static gfx::Size size(100, 100);
57 return size; 58 return size;
58 } 59 }
59 60
60 CompositorFrame MakeCompositorFrame() {
61 CompositorFrame frame;
62 frame.metadata.begin_frame_ack.source_id = BeginFrameArgs::kManualSourceId;
63 frame.metadata.begin_frame_ack.sequence_number =
64 BeginFrameArgs::kStartingFrameNumber;
65 return frame;
66 }
67
68 class SurfaceAggregatorTest : public testing::Test { 61 class SurfaceAggregatorTest : public testing::Test {
69 public: 62 public:
70 explicit SurfaceAggregatorTest(bool use_damage_rect) 63 explicit SurfaceAggregatorTest(bool use_damage_rect)
71 : support_( 64 : support_(
72 CompositorFrameSinkSupport::Create(&fake_client_, 65 CompositorFrameSinkSupport::Create(&fake_client_,
73 &manager_, 66 &manager_,
74 kArbitraryRootFrameSinkId, 67 kArbitraryRootFrameSinkId,
75 kRootIsRoot, 68 kRootIsRoot,
76 kHandlesFrameSinkIdInvalidation, 69 kHandlesFrameSinkIdInvalidation,
77 kNeedsSyncPoints)), 70 kNeedsSyncPoints)),
78 aggregator_(&manager_, NULL, use_damage_rect) {} 71 aggregator_(&manager_, NULL, use_damage_rect) {}
79 72
80 SurfaceAggregatorTest() : SurfaceAggregatorTest(false) {} 73 SurfaceAggregatorTest() : SurfaceAggregatorTest(false) {}
81 74
82 void TearDown() override { 75 void TearDown() override {
83 support_->EvictFrame(); 76 support_->EvictFrame();
84 testing::Test::TearDown(); 77 testing::Test::TearDown();
85 } 78 }
86 79
87 protected: 80 protected:
88 SurfaceManager manager_; 81 SurfaceManager manager_;
89 FakeCompositorFrameSinkSupportClient fake_client_; 82 FakeCompositorFrameSinkSupportClient fake_client_;
90 std::unique_ptr<CompositorFrameSinkSupport> support_; 83 std::unique_ptr<CompositorFrameSinkSupport> support_;
91 SurfaceAggregator aggregator_; 84 SurfaceAggregator aggregator_;
92 }; 85 };
93 86
94 TEST_F(SurfaceAggregatorTest, ValidSurfaceNoFrame) { 87 TEST_F(SurfaceAggregatorTest, ValidSurfaceNoFrame) {
95 LocalSurfaceId local_surface_id(7, base::UnguessableToken::Create()); 88 LocalSurfaceId local_surface_id(7, base::UnguessableToken::Create());
96 SurfaceId one_id(kArbitraryRootFrameSinkId, local_surface_id); 89 SurfaceId one_id(kArbitraryRootFrameSinkId, local_surface_id);
97 support_->SubmitCompositorFrame(local_surface_id, MakeCompositorFrame()); 90 support_->SubmitCompositorFrame(local_surface_id,
91 test::MakeCompositorFrame());
98 92
99 CompositorFrame frame = aggregator_.Aggregate(one_id); 93 CompositorFrame frame = aggregator_.Aggregate(one_id);
100 EXPECT_TRUE(frame.render_pass_list.empty()); 94 EXPECT_TRUE(frame.render_pass_list.empty());
101 } 95 }
102 96
103 class SurfaceAggregatorValidSurfaceTest : public SurfaceAggregatorTest { 97 class SurfaceAggregatorValidSurfaceTest : public SurfaceAggregatorTest {
104 public: 98 public:
105 explicit SurfaceAggregatorValidSurfaceTest(bool use_damage_rect) 99 explicit SurfaceAggregatorValidSurfaceTest(bool use_damage_rect)
106 : SurfaceAggregatorTest(use_damage_rect), 100 : SurfaceAggregatorTest(use_damage_rect),
107 child_support_( 101 child_support_(
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 for (size_t i = 0; i < expected_surface_count; i++) { 141 for (size_t i = 0; i < expected_surface_count; i++) {
148 EXPECT_TRUE( 142 EXPECT_TRUE(
149 aggregator_.previous_contained_surfaces().find(surface_ids[i]) != 143 aggregator_.previous_contained_surfaces().find(surface_ids[i]) !=
150 aggregator_.previous_contained_surfaces().end()); 144 aggregator_.previous_contained_surfaces().end());
151 } 145 }
152 } 146 }
153 147
154 void SubmitPassListAsFrame(CompositorFrameSinkSupport* support, 148 void SubmitPassListAsFrame(CompositorFrameSinkSupport* support,
155 const LocalSurfaceId& local_surface_id, 149 const LocalSurfaceId& local_surface_id,
156 RenderPassList* pass_list) { 150 RenderPassList* pass_list) {
157 CompositorFrame frame = MakeCompositorFrame(); 151 CompositorFrame frame = test::MakeCompositorFrame();
158 pass_list->swap(frame.render_pass_list); 152 pass_list->swap(frame.render_pass_list);
159 153
160 support->SubmitCompositorFrame(local_surface_id, std::move(frame)); 154 support->SubmitCompositorFrame(local_surface_id, std::move(frame));
161 } 155 }
162 156
163 void SubmitCompositorFrame(CompositorFrameSinkSupport* support, 157 void SubmitCompositorFrame(CompositorFrameSinkSupport* support,
164 test::Pass* passes, 158 test::Pass* passes,
165 size_t pass_count, 159 size_t pass_count,
166 const LocalSurfaceId& local_surface_id) { 160 const LocalSurfaceId& local_surface_id) {
167 RenderPassList pass_list; 161 RenderPassList pass_list;
168 AddPasses(&pass_list, gfx::Rect(SurfaceSize()), passes, pass_count); 162 AddPasses(&pass_list, gfx::Rect(SurfaceSize()), passes, pass_count);
169 SubmitPassListAsFrame(support, local_surface_id, &pass_list); 163 SubmitPassListAsFrame(support, local_surface_id, &pass_list);
170 } 164 }
171 165
172 void QueuePassAsFrame(std::unique_ptr<RenderPass> pass, 166 void QueuePassAsFrame(std::unique_ptr<RenderPass> pass,
173 const LocalSurfaceId& local_surface_id, 167 const LocalSurfaceId& local_surface_id,
174 CompositorFrameSinkSupport* support) { 168 CompositorFrameSinkSupport* support) {
175 CompositorFrame child_frame = MakeCompositorFrame(); 169 CompositorFrame child_frame = test::MakeCompositorFrame();
176 child_frame.render_pass_list.push_back(std::move(pass)); 170 child_frame.render_pass_list.push_back(std::move(pass));
177 171
178 support->SubmitCompositorFrame(local_surface_id, std::move(child_frame)); 172 support->SubmitCompositorFrame(local_surface_id, std::move(child_frame));
179 } 173 }
180 174
181 protected: 175 protected:
182 LocalSurfaceId root_local_surface_id_; 176 LocalSurfaceId root_local_surface_id_;
183 Surface* root_surface_; 177 Surface* root_surface_;
184 LocalSurfaceIdAllocator allocator_; 178 LocalSurfaceIdAllocator allocator_;
185 std::unique_ptr<CompositorFrameSinkSupport> child_support_; 179 std::unique_ptr<CompositorFrameSinkSupport> child_support_;
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 577
584 test::Quad root_quads[] = { 578 test::Quad root_quads[] = {
585 test::Quad::SolidColorQuad(SK_ColorWHITE), 579 test::Quad::SolidColorQuad(SK_ColorWHITE),
586 test::Quad::SurfaceQuad(embedded_surface_id, InvalidSurfaceId(), 1.f), 580 test::Quad::SurfaceQuad(embedded_surface_id, InvalidSurfaceId(), 1.f),
587 test::Quad::SolidColorQuad(SK_ColorBLACK)}; 581 test::Quad::SolidColorQuad(SK_ColorBLACK)};
588 test::Quad root_quads2[] = {test::Quad::SolidColorQuad(SK_ColorRED)}; 582 test::Quad root_quads2[] = {test::Quad::SolidColorQuad(SK_ColorRED)};
589 test::Pass root_passes[] = { 583 test::Pass root_passes[] = {
590 test::Pass(root_quads, arraysize(root_quads), 1), 584 test::Pass(root_quads, arraysize(root_quads), 1),
591 test::Pass(root_quads2, arraysize(root_quads2), 2)}; 585 test::Pass(root_quads2, arraysize(root_quads2), 2)};
592 { 586 {
593 CompositorFrame frame = MakeCompositorFrame(); 587 CompositorFrame frame = test::MakeCompositorFrame();
594 AddPasses(&frame.render_pass_list, gfx::Rect(SurfaceSize()), root_passes, 588 AddPasses(&frame.render_pass_list, gfx::Rect(SurfaceSize()), root_passes,
595 arraysize(root_passes)); 589 arraysize(root_passes));
596 frame.render_pass_list[0]->copy_requests.push_back(std::move(copy_request)); 590 frame.render_pass_list[0]->copy_requests.push_back(std::move(copy_request));
597 frame.render_pass_list[1]->copy_requests.push_back( 591 frame.render_pass_list[1]->copy_requests.push_back(
598 std::move(copy_request2)); 592 std::move(copy_request2));
599 593
600 support_->SubmitCompositorFrame(root_local_surface_id_, std::move(frame)); 594 support_->SubmitCompositorFrame(root_local_surface_id_, std::move(frame));
601 } 595 }
602 596
603 SurfaceId root_surface_id(support_->frame_sink_id(), root_local_surface_id_); 597 SurfaceId root_surface_id(support_->frame_sink_id(), root_local_surface_id_);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
670 parent_local_surface_id); 664 parent_local_surface_id);
671 665
672 test::Quad parent_quads[] = { 666 test::Quad parent_quads[] = {
673 test::Quad::SolidColorQuad(SK_ColorGRAY), 667 test::Quad::SolidColorQuad(SK_ColorGRAY),
674 test::Quad::SurfaceQuad(embedded_surface_id, InvalidSurfaceId(), 1.f), 668 test::Quad::SurfaceQuad(embedded_surface_id, InvalidSurfaceId(), 1.f),
675 test::Quad::SolidColorQuad(SK_ColorLTGRAY)}; 669 test::Quad::SolidColorQuad(SK_ColorLTGRAY)};
676 test::Pass parent_passes[] = { 670 test::Pass parent_passes[] = {
677 test::Pass(parent_quads, arraysize(parent_quads))}; 671 test::Pass(parent_quads, arraysize(parent_quads))};
678 672
679 { 673 {
680 CompositorFrame frame = MakeCompositorFrame(); 674 CompositorFrame frame = test::MakeCompositorFrame();
681 675
682 AddPasses(&frame.render_pass_list, gfx::Rect(SurfaceSize()), parent_passes, 676 AddPasses(&frame.render_pass_list, gfx::Rect(SurfaceSize()), parent_passes,
683 arraysize(parent_passes)); 677 arraysize(parent_passes));
684 678
685 frame.metadata.referenced_surfaces.push_back(embedded_surface_id); 679 frame.metadata.referenced_surfaces.push_back(embedded_surface_id);
686 680
687 parent_support->SubmitCompositorFrame(parent_local_surface_id, 681 parent_support->SubmitCompositorFrame(parent_local_surface_id,
688 std::move(frame)); 682 std::move(frame));
689 } 683 }
690 684
691 test::Quad root_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE), 685 test::Quad root_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE),
692 test::Quad::SolidColorQuad(SK_ColorBLACK)}; 686 test::Quad::SolidColorQuad(SK_ColorBLACK)};
693 test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))}; 687 test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))};
694 688
695 { 689 {
696 CompositorFrame frame = MakeCompositorFrame(); 690 CompositorFrame frame = test::MakeCompositorFrame();
697 AddPasses(&frame.render_pass_list, gfx::Rect(SurfaceSize()), root_passes, 691 AddPasses(&frame.render_pass_list, gfx::Rect(SurfaceSize()), root_passes,
698 arraysize(root_passes)); 692 arraysize(root_passes));
699 693
700 frame.metadata.referenced_surfaces.push_back(parent_surface_id); 694 frame.metadata.referenced_surfaces.push_back(parent_surface_id);
701 // Reference to Surface ID of a Surface that doesn't exist should be 695 // Reference to Surface ID of a Surface that doesn't exist should be
702 // included in previous_contained_surfaces, but otherwise ignored. 696 // included in previous_contained_surfaces, but otherwise ignored.
703 frame.metadata.referenced_surfaces.push_back(nonexistent_surface_id); 697 frame.metadata.referenced_surfaces.push_back(nonexistent_surface_id);
704 698
705 support_->SubmitCompositorFrame(root_local_surface_id_, std::move(frame)); 699 support_->SubmitCompositorFrame(root_local_surface_id_, std::move(frame));
706 } 700 }
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
1117 std::unique_ptr<CompositorFrameSinkSupport> child_two_support = 1111 std::unique_ptr<CompositorFrameSinkSupport> child_two_support =
1118 CompositorFrameSinkSupport::Create( 1112 CompositorFrameSinkSupport::Create(
1119 nullptr, &manager_, kArbitraryFrameSinkId3, kChildIsRoot, 1113 nullptr, &manager_, kArbitraryFrameSinkId3, kChildIsRoot,
1120 kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints); 1114 kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints);
1121 int pass_id = 1; 1115 int pass_id = 1;
1122 LocalSurfaceId grandchild_local_surface_id = allocator_.GenerateId(); 1116 LocalSurfaceId grandchild_local_surface_id = allocator_.GenerateId();
1123 SurfaceId grandchild_surface_id(grandchild_support->frame_sink_id(), 1117 SurfaceId grandchild_surface_id(grandchild_support->frame_sink_id(),
1124 grandchild_local_surface_id); 1118 grandchild_local_surface_id);
1125 1119
1126 grandchild_support->SubmitCompositorFrame(grandchild_local_surface_id, 1120 grandchild_support->SubmitCompositorFrame(grandchild_local_surface_id,
1127 MakeCompositorFrame()); 1121 test::MakeCompositorFrame());
1128 std::unique_ptr<RenderPass> grandchild_pass = RenderPass::Create(); 1122 std::unique_ptr<RenderPass> grandchild_pass = RenderPass::Create();
1129 gfx::Rect output_rect(SurfaceSize()); 1123 gfx::Rect output_rect(SurfaceSize());
1130 gfx::Rect damage_rect(SurfaceSize()); 1124 gfx::Rect damage_rect(SurfaceSize());
1131 gfx::Transform transform_to_root_target; 1125 gfx::Transform transform_to_root_target;
1132 grandchild_pass->SetNew(pass_id, output_rect, damage_rect, 1126 grandchild_pass->SetNew(pass_id, output_rect, damage_rect,
1133 transform_to_root_target); 1127 transform_to_root_target);
1134 AddSolidColorQuadWithBlendMode( 1128 AddSolidColorQuadWithBlendMode(
1135 SurfaceSize(), grandchild_pass.get(), blend_modes[2]); 1129 SurfaceSize(), grandchild_pass.get(), blend_modes[2]);
1136 QueuePassAsFrame(std::move(grandchild_pass), grandchild_local_surface_id, 1130 QueuePassAsFrame(std::move(grandchild_pass), grandchild_local_surface_id,
1137 grandchild_support.get()); 1131 grandchild_support.get());
1138 1132
1139 LocalSurfaceId child_one_local_surface_id = allocator_.GenerateId(); 1133 LocalSurfaceId child_one_local_surface_id = allocator_.GenerateId();
1140 SurfaceId child_one_surface_id(child_one_support->frame_sink_id(), 1134 SurfaceId child_one_surface_id(child_one_support->frame_sink_id(),
1141 child_one_local_surface_id); 1135 child_one_local_surface_id);
1142 child_one_support->SubmitCompositorFrame(child_one_local_surface_id, 1136 child_one_support->SubmitCompositorFrame(child_one_local_surface_id,
1143 MakeCompositorFrame()); 1137 test::MakeCompositorFrame());
1144 1138
1145 std::unique_ptr<RenderPass> child_one_pass = RenderPass::Create(); 1139 std::unique_ptr<RenderPass> child_one_pass = RenderPass::Create();
1146 child_one_pass->SetNew(pass_id, output_rect, damage_rect, 1140 child_one_pass->SetNew(pass_id, output_rect, damage_rect,
1147 transform_to_root_target); 1141 transform_to_root_target);
1148 AddSolidColorQuadWithBlendMode( 1142 AddSolidColorQuadWithBlendMode(
1149 SurfaceSize(), child_one_pass.get(), blend_modes[1]); 1143 SurfaceSize(), child_one_pass.get(), blend_modes[1]);
1150 SurfaceDrawQuad* grandchild_surface_quad = 1144 SurfaceDrawQuad* grandchild_surface_quad =
1151 child_one_pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); 1145 child_one_pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>();
1152 grandchild_surface_quad->SetNew( 1146 grandchild_surface_quad->SetNew(
1153 child_one_pass->shared_quad_state_list.back(), gfx::Rect(SurfaceSize()), 1147 child_one_pass->shared_quad_state_list.back(), gfx::Rect(SurfaceSize()),
1154 gfx::Rect(SurfaceSize()), grandchild_surface_id, 1148 gfx::Rect(SurfaceSize()), grandchild_surface_id,
1155 SurfaceDrawQuadType::PRIMARY, nullptr); 1149 SurfaceDrawQuadType::PRIMARY, nullptr);
1156 AddSolidColorQuadWithBlendMode( 1150 AddSolidColorQuadWithBlendMode(
1157 SurfaceSize(), child_one_pass.get(), blend_modes[3]); 1151 SurfaceSize(), child_one_pass.get(), blend_modes[3]);
1158 QueuePassAsFrame(std::move(child_one_pass), child_one_local_surface_id, 1152 QueuePassAsFrame(std::move(child_one_pass), child_one_local_surface_id,
1159 child_one_support.get()); 1153 child_one_support.get());
1160 1154
1161 LocalSurfaceId child_two_local_surface_id = allocator_.GenerateId(); 1155 LocalSurfaceId child_two_local_surface_id = allocator_.GenerateId();
1162 SurfaceId child_two_surface_id(child_two_support->frame_sink_id(), 1156 SurfaceId child_two_surface_id(child_two_support->frame_sink_id(),
1163 child_two_local_surface_id); 1157 child_two_local_surface_id);
1164 child_two_support->SubmitCompositorFrame(child_two_local_surface_id, 1158 child_two_support->SubmitCompositorFrame(child_two_local_surface_id,
1165 MakeCompositorFrame()); 1159 test::MakeCompositorFrame());
1166 1160
1167 std::unique_ptr<RenderPass> child_two_pass = RenderPass::Create(); 1161 std::unique_ptr<RenderPass> child_two_pass = RenderPass::Create();
1168 child_two_pass->SetNew(pass_id, output_rect, damage_rect, 1162 child_two_pass->SetNew(pass_id, output_rect, damage_rect,
1169 transform_to_root_target); 1163 transform_to_root_target);
1170 AddSolidColorQuadWithBlendMode( 1164 AddSolidColorQuadWithBlendMode(
1171 SurfaceSize(), child_two_pass.get(), blend_modes[5]); 1165 SurfaceSize(), child_two_pass.get(), blend_modes[5]);
1172 QueuePassAsFrame(std::move(child_two_pass), child_two_local_surface_id, 1166 QueuePassAsFrame(std::move(child_two_pass), child_two_local_surface_id,
1173 child_two_support.get()); 1167 child_two_support.get());
1174 1168
1175 std::unique_ptr<RenderPass> root_pass = RenderPass::Create(); 1169 std::unique_ptr<RenderPass> root_pass = RenderPass::Create();
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
1253 int child_pass_id[] = {1, 2}; 1247 int child_pass_id[] = {1, 2};
1254 test::Quad child_quads[][1] = { 1248 test::Quad child_quads[][1] = {
1255 {test::Quad::SolidColorQuad(SK_ColorGREEN)}, 1249 {test::Quad::SolidColorQuad(SK_ColorGREEN)},
1256 {test::Quad::RenderPassQuad(child_pass_id[0])}, 1250 {test::Quad::RenderPassQuad(child_pass_id[0])},
1257 }; 1251 };
1258 test::Pass child_passes[] = { 1252 test::Pass child_passes[] = {
1259 test::Pass(child_quads[0], arraysize(child_quads[0]), child_pass_id[0]), 1253 test::Pass(child_quads[0], arraysize(child_quads[0]), child_pass_id[0]),
1260 test::Pass(child_quads[1], arraysize(child_quads[1]), 1254 test::Pass(child_quads[1], arraysize(child_quads[1]),
1261 child_pass_id[1])}; 1255 child_pass_id[1])};
1262 1256
1263 CompositorFrame child_frame = MakeCompositorFrame(); 1257 CompositorFrame child_frame = test::MakeCompositorFrame();
1264 AddPasses(&child_frame.render_pass_list, gfx::Rect(SurfaceSize()), 1258 AddPasses(&child_frame.render_pass_list, gfx::Rect(SurfaceSize()),
1265 child_passes, arraysize(child_passes)); 1259 child_passes, arraysize(child_passes));
1266 1260
1267 RenderPass* child_nonroot_pass = child_frame.render_pass_list[0].get(); 1261 RenderPass* child_nonroot_pass = child_frame.render_pass_list[0].get();
1268 child_nonroot_pass->transform_to_root_target.Translate(8, 0); 1262 child_nonroot_pass->transform_to_root_target.Translate(8, 0);
1269 SharedQuadState* child_nonroot_pass_sqs = 1263 SharedQuadState* child_nonroot_pass_sqs =
1270 child_nonroot_pass->shared_quad_state_list.front(); 1264 child_nonroot_pass->shared_quad_state_list.front();
1271 child_nonroot_pass_sqs->quad_to_target_transform.Translate(5, 0); 1265 child_nonroot_pass_sqs->quad_to_target_transform.Translate(5, 0);
1272 1266
1273 RenderPass* child_root_pass = child_frame.render_pass_list[1].get(); 1267 RenderPass* child_root_pass = child_frame.render_pass_list[1].get();
(...skipping 11 matching lines...) Expand all
1285 LocalSurfaceId middle_local_surface_id = allocator_.GenerateId(); 1279 LocalSurfaceId middle_local_surface_id = allocator_.GenerateId();
1286 SurfaceId middle_surface_id(middle_support->frame_sink_id(), 1280 SurfaceId middle_surface_id(middle_support->frame_sink_id(),
1287 middle_local_surface_id); 1281 middle_local_surface_id);
1288 { 1282 {
1289 test::Quad middle_quads[] = { 1283 test::Quad middle_quads[] = {
1290 test::Quad::SurfaceQuad(child_surface_id, InvalidSurfaceId(), 1.f)}; 1284 test::Quad::SurfaceQuad(child_surface_id, InvalidSurfaceId(), 1.f)};
1291 test::Pass middle_passes[] = { 1285 test::Pass middle_passes[] = {
1292 test::Pass(middle_quads, arraysize(middle_quads)), 1286 test::Pass(middle_quads, arraysize(middle_quads)),
1293 }; 1287 };
1294 1288
1295 CompositorFrame middle_frame = MakeCompositorFrame(); 1289 CompositorFrame middle_frame = test::MakeCompositorFrame();
1296 AddPasses(&middle_frame.render_pass_list, gfx::Rect(SurfaceSize()), 1290 AddPasses(&middle_frame.render_pass_list, gfx::Rect(SurfaceSize()),
1297 middle_passes, arraysize(middle_passes)); 1291 middle_passes, arraysize(middle_passes));
1298 1292
1299 RenderPass* middle_root_pass = middle_frame.render_pass_list[0].get(); 1293 RenderPass* middle_root_pass = middle_frame.render_pass_list[0].get();
1300 middle_root_pass->quad_list.ElementAt(0)->visible_rect = 1294 middle_root_pass->quad_list.ElementAt(0)->visible_rect =
1301 gfx::Rect(0, 1, 100, 7); 1295 gfx::Rect(0, 1, 100, 7);
1302 SharedQuadState* middle_root_pass_sqs = 1296 SharedQuadState* middle_root_pass_sqs =
1303 middle_root_pass->shared_quad_state_list.front(); 1297 middle_root_pass->shared_quad_state_list.front();
1304 middle_root_pass_sqs->quad_to_target_transform.Scale(2, 3); 1298 middle_root_pass_sqs->quad_to_target_transform.Scale(2, 3);
1305 1299
1306 middle_support->SubmitCompositorFrame(middle_local_surface_id, 1300 middle_support->SubmitCompositorFrame(middle_local_surface_id,
1307 std::move(middle_frame)); 1301 std::move(middle_frame));
1308 } 1302 }
1309 1303
1310 // Root surface. 1304 // Root surface.
1311 test::Quad secondary_quads[] = { 1305 test::Quad secondary_quads[] = {
1312 test::Quad::SolidColorQuad(1), 1306 test::Quad::SolidColorQuad(1),
1313 test::Quad::SurfaceQuad(middle_surface_id, InvalidSurfaceId(), 1.f)}; 1307 test::Quad::SurfaceQuad(middle_surface_id, InvalidSurfaceId(), 1.f)};
1314 test::Quad root_quads[] = {test::Quad::SolidColorQuad(1)}; 1308 test::Quad root_quads[] = {test::Quad::SolidColorQuad(1)};
1315 test::Pass root_passes[] = { 1309 test::Pass root_passes[] = {
1316 test::Pass(secondary_quads, arraysize(secondary_quads)), 1310 test::Pass(secondary_quads, arraysize(secondary_quads)),
1317 test::Pass(root_quads, arraysize(root_quads))}; 1311 test::Pass(root_quads, arraysize(root_quads))};
1318 1312
1319 CompositorFrame root_frame = MakeCompositorFrame(); 1313 CompositorFrame root_frame = test::MakeCompositorFrame();
1320 AddPasses(&root_frame.render_pass_list, gfx::Rect(SurfaceSize()), root_passes, 1314 AddPasses(&root_frame.render_pass_list, gfx::Rect(SurfaceSize()), root_passes,
1321 arraysize(root_passes)); 1315 arraysize(root_passes));
1322 1316
1323 root_frame.render_pass_list[0] 1317 root_frame.render_pass_list[0]
1324 ->shared_quad_state_list.front() 1318 ->shared_quad_state_list.front()
1325 ->quad_to_target_transform.Translate(0, 7); 1319 ->quad_to_target_transform.Translate(0, 7);
1326 root_frame.render_pass_list[0] 1320 root_frame.render_pass_list[0]
1327 ->shared_quad_state_list.ElementAt(1) 1321 ->shared_quad_state_list.ElementAt(1)
1328 ->quad_to_target_transform.Translate(0, 10); 1322 ->quad_to_target_transform.Translate(0, 10);
1329 root_frame.render_pass_list[0]->quad_list.ElementAt(1)->visible_rect = 1323 root_frame.render_pass_list[0]->quad_list.ElementAt(1)->visible_rect =
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
1413 // Tests that damage rects are aggregated correctly when surfaces change. 1407 // Tests that damage rects are aggregated correctly when surfaces change.
1414 TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateDamageRect) { 1408 TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateDamageRect) {
1415 std::unique_ptr<CompositorFrameSinkSupport> parent_support = 1409 std::unique_ptr<CompositorFrameSinkSupport> parent_support =
1416 CompositorFrameSinkSupport::Create( 1410 CompositorFrameSinkSupport::Create(
1417 nullptr, &manager_, kArbitraryMiddleFrameSinkId, kChildIsRoot, 1411 nullptr, &manager_, kArbitraryMiddleFrameSinkId, kChildIsRoot,
1418 kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints); 1412 kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints);
1419 test::Quad child_quads[] = {test::Quad::RenderPassQuad(1)}; 1413 test::Quad child_quads[] = {test::Quad::RenderPassQuad(1)};
1420 test::Pass child_passes[] = { 1414 test::Pass child_passes[] = {
1421 test::Pass(child_quads, arraysize(child_quads), 1)}; 1415 test::Pass(child_quads, arraysize(child_quads), 1)};
1422 1416
1423 CompositorFrame child_frame = MakeCompositorFrame(); 1417 CompositorFrame child_frame = test::MakeCompositorFrame();
1424 AddPasses(&child_frame.render_pass_list, gfx::Rect(SurfaceSize()), 1418 AddPasses(&child_frame.render_pass_list, gfx::Rect(SurfaceSize()),
1425 child_passes, arraysize(child_passes)); 1419 child_passes, arraysize(child_passes));
1426 1420
1427 RenderPass* child_root_pass = child_frame.render_pass_list[0].get(); 1421 RenderPass* child_root_pass = child_frame.render_pass_list[0].get();
1428 SharedQuadState* child_root_pass_sqs = 1422 SharedQuadState* child_root_pass_sqs =
1429 child_root_pass->shared_quad_state_list.front(); 1423 child_root_pass->shared_quad_state_list.front();
1430 child_root_pass_sqs->quad_to_target_transform.Translate(8, 0); 1424 child_root_pass_sqs->quad_to_target_transform.Translate(8, 0);
1431 1425
1432 LocalSurfaceId child_local_surface_id = allocator_.GenerateId(); 1426 LocalSurfaceId child_local_surface_id = allocator_.GenerateId();
1433 SurfaceId child_surface_id(child_support_->frame_sink_id(), 1427 SurfaceId child_surface_id(child_support_->frame_sink_id(),
1434 child_local_surface_id); 1428 child_local_surface_id);
1435 child_support_->SubmitCompositorFrame(child_local_surface_id, 1429 child_support_->SubmitCompositorFrame(child_local_surface_id,
1436 std::move(child_frame)); 1430 std::move(child_frame));
1437 1431
1438 test::Quad parent_surface_quads[] = { 1432 test::Quad parent_surface_quads[] = {
1439 test::Quad::SurfaceQuad(child_surface_id, InvalidSurfaceId(), 1.f)}; 1433 test::Quad::SurfaceQuad(child_surface_id, InvalidSurfaceId(), 1.f)};
1440 test::Pass parent_surface_passes[] = { 1434 test::Pass parent_surface_passes[] = {
1441 test::Pass(parent_surface_quads, arraysize(parent_surface_quads), 1)}; 1435 test::Pass(parent_surface_quads, arraysize(parent_surface_quads), 1)};
1442 1436
1443 // Parent surface is only used to test if the transform is applied correctly 1437 // Parent surface is only used to test if the transform is applied correctly
1444 // to the child surface's damage. 1438 // to the child surface's damage.
1445 CompositorFrame parent_surface_frame = MakeCompositorFrame(); 1439 CompositorFrame parent_surface_frame = test::MakeCompositorFrame();
1446 AddPasses(&parent_surface_frame.render_pass_list, gfx::Rect(SurfaceSize()), 1440 AddPasses(&parent_surface_frame.render_pass_list, gfx::Rect(SurfaceSize()),
1447 parent_surface_passes, arraysize(parent_surface_passes)); 1441 parent_surface_passes, arraysize(parent_surface_passes));
1448 1442
1449 LocalSurfaceId parent_local_surface_id = allocator_.GenerateId(); 1443 LocalSurfaceId parent_local_surface_id = allocator_.GenerateId();
1450 SurfaceId parent_surface_id(parent_support->frame_sink_id(), 1444 SurfaceId parent_surface_id(parent_support->frame_sink_id(),
1451 parent_local_surface_id); 1445 parent_local_surface_id);
1452 parent_support->SubmitCompositorFrame(parent_local_surface_id, 1446 parent_support->SubmitCompositorFrame(parent_local_surface_id,
1453 std::move(parent_surface_frame)); 1447 std::move(parent_surface_frame));
1454 1448
1455 test::Quad root_surface_quads[] = { 1449 test::Quad root_surface_quads[] = {
1456 test::Quad::SurfaceQuad(parent_surface_id, InvalidSurfaceId(), 1.f)}; 1450 test::Quad::SurfaceQuad(parent_surface_id, InvalidSurfaceId(), 1.f)};
1457 test::Quad root_render_pass_quads[] = {test::Quad::RenderPassQuad(1)}; 1451 test::Quad root_render_pass_quads[] = {test::Quad::RenderPassQuad(1)};
1458 1452
1459 test::Pass root_passes[] = { 1453 test::Pass root_passes[] = {
1460 test::Pass(root_surface_quads, arraysize(root_surface_quads), 1), 1454 test::Pass(root_surface_quads, arraysize(root_surface_quads), 1),
1461 test::Pass(root_render_pass_quads, arraysize(root_render_pass_quads), 2)}; 1455 test::Pass(root_render_pass_quads, arraysize(root_render_pass_quads), 2)};
1462 1456
1463 CompositorFrame root_frame = MakeCompositorFrame(); 1457 CompositorFrame root_frame = test::MakeCompositorFrame();
1464 AddPasses(&root_frame.render_pass_list, gfx::Rect(SurfaceSize()), root_passes, 1458 AddPasses(&root_frame.render_pass_list, gfx::Rect(SurfaceSize()), root_passes,
1465 arraysize(root_passes)); 1459 arraysize(root_passes));
1466 1460
1467 root_frame.render_pass_list[0] 1461 root_frame.render_pass_list[0]
1468 ->shared_quad_state_list.front() 1462 ->shared_quad_state_list.front()
1469 ->quad_to_target_transform.Translate(0, 10); 1463 ->quad_to_target_transform.Translate(0, 10);
1470 root_frame.render_pass_list[0]->damage_rect = gfx::Rect(5, 5, 10, 10); 1464 root_frame.render_pass_list[0]->damage_rect = gfx::Rect(5, 5, 10, 10);
1471 root_frame.render_pass_list[1]->damage_rect = gfx::Rect(5, 5, 100, 100); 1465 root_frame.render_pass_list[1]->damage_rect = gfx::Rect(5, 5, 100, 100);
1472 1466
1473 support_->SubmitCompositorFrame(root_local_surface_id_, 1467 support_->SubmitCompositorFrame(root_local_surface_id_,
1474 std::move(root_frame)); 1468 std::move(root_frame));
1475 1469
1476 SurfaceId root_surface_id(support_->frame_sink_id(), root_local_surface_id_); 1470 SurfaceId root_surface_id(support_->frame_sink_id(), root_local_surface_id_);
1477 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); 1471 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id);
1478 1472
1479 const RenderPassList& aggregated_pass_list = 1473 const RenderPassList& aggregated_pass_list =
1480 aggregated_frame.render_pass_list; 1474 aggregated_frame.render_pass_list;
1481 1475
1482 ASSERT_EQ(2u, aggregated_pass_list.size()); 1476 ASSERT_EQ(2u, aggregated_pass_list.size());
1483 1477
1484 // Damage rect for first aggregation should contain entire root surface. 1478 // Damage rect for first aggregation should contain entire root surface.
1485 EXPECT_TRUE( 1479 EXPECT_TRUE(
1486 aggregated_pass_list[1]->damage_rect.Contains(gfx::Rect(SurfaceSize()))); 1480 aggregated_pass_list[1]->damage_rect.Contains(gfx::Rect(SurfaceSize())));
1487 1481
1488 { 1482 {
1489 CompositorFrame child_frame = MakeCompositorFrame(); 1483 CompositorFrame child_frame = test::MakeCompositorFrame();
1490 AddPasses(&child_frame.render_pass_list, gfx::Rect(SurfaceSize()), 1484 AddPasses(&child_frame.render_pass_list, gfx::Rect(SurfaceSize()),
1491 child_passes, arraysize(child_passes)); 1485 child_passes, arraysize(child_passes));
1492 1486
1493 RenderPass* child_root_pass = child_frame.render_pass_list[0].get(); 1487 RenderPass* child_root_pass = child_frame.render_pass_list[0].get();
1494 SharedQuadState* child_root_pass_sqs = 1488 SharedQuadState* child_root_pass_sqs =
1495 child_root_pass->shared_quad_state_list.front(); 1489 child_root_pass->shared_quad_state_list.front();
1496 child_root_pass_sqs->quad_to_target_transform.Translate(8, 0); 1490 child_root_pass_sqs->quad_to_target_transform.Translate(8, 0);
1497 child_root_pass->damage_rect = gfx::Rect(10, 10, 10, 10); 1491 child_root_pass->damage_rect = gfx::Rect(10, 10, 10, 10);
1498 1492
1499 child_support_->SubmitCompositorFrame(child_local_surface_id, 1493 child_support_->SubmitCompositorFrame(child_local_surface_id,
1500 std::move(child_frame)); 1494 std::move(child_frame));
1501 1495
1502 SurfaceId root_surface_id(support_->frame_sink_id(), 1496 SurfaceId root_surface_id(support_->frame_sink_id(),
1503 root_local_surface_id_); 1497 root_local_surface_id_);
1504 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); 1498 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id);
1505 1499
1506 const RenderPassList& aggregated_pass_list = 1500 const RenderPassList& aggregated_pass_list =
1507 aggregated_frame.render_pass_list; 1501 aggregated_frame.render_pass_list;
1508 1502
1509 ASSERT_EQ(2u, aggregated_pass_list.size()); 1503 ASSERT_EQ(2u, aggregated_pass_list.size());
1510 1504
1511 // Outer surface didn't change, so transformed inner damage rect should be 1505 // Outer surface didn't change, so transformed inner damage rect should be
1512 // used. 1506 // used.
1513 EXPECT_EQ(gfx::Rect(10, 20, 10, 10).ToString(), 1507 EXPECT_EQ(gfx::Rect(10, 20, 10, 10).ToString(),
1514 aggregated_pass_list[1]->damage_rect.ToString()); 1508 aggregated_pass_list[1]->damage_rect.ToString());
1515 } 1509 }
1516 1510
1517 { 1511 {
1518 CompositorFrame root_frame = MakeCompositorFrame(); 1512 CompositorFrame root_frame = test::MakeCompositorFrame();
1519 AddPasses(&root_frame.render_pass_list, gfx::Rect(SurfaceSize()), 1513 AddPasses(&root_frame.render_pass_list, gfx::Rect(SurfaceSize()),
1520 root_passes, arraysize(root_passes)); 1514 root_passes, arraysize(root_passes));
1521 1515
1522 root_frame.render_pass_list[0] 1516 root_frame.render_pass_list[0]
1523 ->shared_quad_state_list.front() 1517 ->shared_quad_state_list.front()
1524 ->quad_to_target_transform.Translate(0, 10); 1518 ->quad_to_target_transform.Translate(0, 10);
1525 root_frame.render_pass_list[0]->damage_rect = gfx::Rect(0, 0, 1, 1); 1519 root_frame.render_pass_list[0]->damage_rect = gfx::Rect(0, 0, 1, 1);
1526 1520
1527 support_->SubmitCompositorFrame(root_local_surface_id_, 1521 support_->SubmitCompositorFrame(root_local_surface_id_,
1528 std::move(root_frame)); 1522 std::move(root_frame));
1529 } 1523 }
1530 1524
1531 { 1525 {
1532 CompositorFrame root_frame = MakeCompositorFrame(); 1526 CompositorFrame root_frame = test::MakeCompositorFrame();
1533 AddPasses(&root_frame.render_pass_list, gfx::Rect(SurfaceSize()), 1527 AddPasses(&root_frame.render_pass_list, gfx::Rect(SurfaceSize()),
1534 root_passes, arraysize(root_passes)); 1528 root_passes, arraysize(root_passes));
1535 1529
1536 root_frame.render_pass_list[0] 1530 root_frame.render_pass_list[0]
1537 ->shared_quad_state_list.front() 1531 ->shared_quad_state_list.front()
1538 ->quad_to_target_transform.Translate(0, 10); 1532 ->quad_to_target_transform.Translate(0, 10);
1539 root_frame.render_pass_list[0]->damage_rect = gfx::Rect(1, 1, 1, 1); 1533 root_frame.render_pass_list[0]->damage_rect = gfx::Rect(1, 1, 1, 1);
1540 1534
1541 support_->SubmitCompositorFrame(root_local_surface_id_, 1535 support_->SubmitCompositorFrame(root_local_surface_id_,
1542 std::move(root_frame)); 1536 std::move(root_frame));
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1588 parent_support->EvictFrame(); 1582 parent_support->EvictFrame();
1589 } 1583 }
1590 1584
1591 // Check that damage is correctly calculated for surfaces. 1585 // Check that damage is correctly calculated for surfaces.
1592 TEST_F(SurfaceAggregatorValidSurfaceTest, SwitchSurfaceDamage) { 1586 TEST_F(SurfaceAggregatorValidSurfaceTest, SwitchSurfaceDamage) {
1593 test::Quad root_render_pass_quads[] = {test::Quad::SolidColorQuad(1)}; 1587 test::Quad root_render_pass_quads[] = {test::Quad::SolidColorQuad(1)};
1594 1588
1595 test::Pass root_passes[] = { 1589 test::Pass root_passes[] = {
1596 test::Pass(root_render_pass_quads, arraysize(root_render_pass_quads), 2)}; 1590 test::Pass(root_render_pass_quads, arraysize(root_render_pass_quads), 2)};
1597 1591
1598 CompositorFrame root_frame = MakeCompositorFrame(); 1592 CompositorFrame root_frame = test::MakeCompositorFrame();
1599 AddPasses(&root_frame.render_pass_list, gfx::Rect(SurfaceSize()), root_passes, 1593 AddPasses(&root_frame.render_pass_list, gfx::Rect(SurfaceSize()), root_passes,
1600 arraysize(root_passes)); 1594 arraysize(root_passes));
1601 1595
1602 root_frame.render_pass_list[0]->damage_rect = gfx::Rect(5, 5, 100, 100); 1596 root_frame.render_pass_list[0]->damage_rect = gfx::Rect(5, 5, 100, 100);
1603 1597
1604 support_->SubmitCompositorFrame(root_local_surface_id_, 1598 support_->SubmitCompositorFrame(root_local_surface_id_,
1605 std::move(root_frame)); 1599 std::move(root_frame));
1606 1600
1607 { 1601 {
1608 SurfaceId root_surface_id(support_->frame_sink_id(), 1602 SurfaceId root_surface_id(support_->frame_sink_id(),
(...skipping 12 matching lines...) Expand all
1621 1615
1622 LocalSurfaceId second_root_local_surface_id = allocator_.GenerateId(); 1616 LocalSurfaceId second_root_local_surface_id = allocator_.GenerateId();
1623 SurfaceId second_root_surface_id(support_->frame_sink_id(), 1617 SurfaceId second_root_surface_id(support_->frame_sink_id(),
1624 second_root_local_surface_id); 1618 second_root_local_surface_id);
1625 { 1619 {
1626 test::Quad root_render_pass_quads[] = {test::Quad::SolidColorQuad(1)}; 1620 test::Quad root_render_pass_quads[] = {test::Quad::SolidColorQuad(1)};
1627 1621
1628 test::Pass root_passes[] = {test::Pass( 1622 test::Pass root_passes[] = {test::Pass(
1629 root_render_pass_quads, arraysize(root_render_pass_quads), 2)}; 1623 root_render_pass_quads, arraysize(root_render_pass_quads), 2)};
1630 1624
1631 CompositorFrame root_frame = MakeCompositorFrame(); 1625 CompositorFrame root_frame = test::MakeCompositorFrame();
1632 AddPasses(&root_frame.render_pass_list, gfx::Rect(SurfaceSize()), 1626 AddPasses(&root_frame.render_pass_list, gfx::Rect(SurfaceSize()),
1633 root_passes, arraysize(root_passes)); 1627 root_passes, arraysize(root_passes));
1634 1628
1635 root_frame.render_pass_list[0]->damage_rect = gfx::Rect(1, 2, 3, 4); 1629 root_frame.render_pass_list[0]->damage_rect = gfx::Rect(1, 2, 3, 4);
1636 1630
1637 support_->SubmitCompositorFrame(second_root_local_surface_id, 1631 support_->SubmitCompositorFrame(second_root_local_surface_id,
1638 std::move(root_frame)); 1632 std::move(root_frame));
1639 } 1633 }
1640 { 1634 {
1641 CompositorFrame aggregated_frame = 1635 CompositorFrame aggregated_frame =
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
1966 std::unique_ptr<ResourceProvider> resource_provider_; 1960 std::unique_ptr<ResourceProvider> resource_provider_;
1967 std::unique_ptr<SurfaceAggregator> aggregator_; 1961 std::unique_ptr<SurfaceAggregator> aggregator_;
1968 }; 1962 };
1969 1963
1970 void SubmitCompositorFrameWithResources(ResourceId* resource_ids, 1964 void SubmitCompositorFrameWithResources(ResourceId* resource_ids,
1971 size_t num_resource_ids, 1965 size_t num_resource_ids,
1972 bool valid, 1966 bool valid,
1973 SurfaceId child_id, 1967 SurfaceId child_id,
1974 CompositorFrameSinkSupport* support, 1968 CompositorFrameSinkSupport* support,
1975 SurfaceId surface_id) { 1969 SurfaceId surface_id) {
1976 CompositorFrame frame = MakeCompositorFrame(); 1970 CompositorFrame frame = test::MakeCompositorFrame();
1977 std::unique_ptr<RenderPass> pass = RenderPass::Create(); 1971 std::unique_ptr<RenderPass> pass = RenderPass::Create();
1978 pass->id = 1; 1972 pass->id = 1;
1979 SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState(); 1973 SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState();
1980 sqs->opacity = 1.f; 1974 sqs->opacity = 1.f;
1981 if (child_id.is_valid()) { 1975 if (child_id.is_valid()) {
1982 SurfaceDrawQuad* surface_quad = 1976 SurfaceDrawQuad* surface_quad =
1983 pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); 1977 pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>();
1984 surface_quad->SetNew(sqs, gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1), 1978 surface_quad->SetNew(sqs, gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1),
1985 child_id, SurfaceDrawQuadType::PRIMARY, nullptr); 1979 child_id, SurfaceDrawQuadType::PRIMARY, nullptr);
1986 } 1980 }
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
2050 2044
2051 TEST_F(SurfaceAggregatorWithResourcesTest, TakeInvalidResources) { 2045 TEST_F(SurfaceAggregatorWithResourcesTest, TakeInvalidResources) {
2052 FakeCompositorFrameSinkSupportClient client; 2046 FakeCompositorFrameSinkSupportClient client;
2053 std::unique_ptr<CompositorFrameSinkSupport> support = 2047 std::unique_ptr<CompositorFrameSinkSupport> support =
2054 CompositorFrameSinkSupport::Create( 2048 CompositorFrameSinkSupport::Create(
2055 &client, &manager_, kArbitraryRootFrameSinkId, kRootIsRoot, 2049 &client, &manager_, kArbitraryRootFrameSinkId, kRootIsRoot,
2056 kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints); 2050 kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints);
2057 LocalSurfaceId local_surface_id(7u, base::UnguessableToken::Create()); 2051 LocalSurfaceId local_surface_id(7u, base::UnguessableToken::Create());
2058 SurfaceId surface_id(support->frame_sink_id(), local_surface_id); 2052 SurfaceId surface_id(support->frame_sink_id(), local_surface_id);
2059 2053
2060 CompositorFrame frame = MakeCompositorFrame(); 2054 CompositorFrame frame = test::MakeCompositorFrame();
2061 std::unique_ptr<RenderPass> pass = RenderPass::Create(); 2055 std::unique_ptr<RenderPass> pass = RenderPass::Create();
2062 pass->id = 1; 2056 pass->id = 1;
2063 TransferableResource resource; 2057 TransferableResource resource;
2064 resource.id = 11; 2058 resource.id = 11;
2065 // ResourceProvider is software but resource is not, so it should be 2059 // ResourceProvider is software but resource is not, so it should be
2066 // ignored. 2060 // ignored.
2067 resource.is_software = false; 2061 resource.is_software = false;
2068 frame.resource_list.push_back(resource); 2062 frame.resource_list.push_back(resource);
2069 frame.render_pass_list.push_back(std::move(pass)); 2063 frame.render_pass_list.push_back(std::move(pass));
2070 support->SubmitCompositorFrame(local_surface_id, std::move(frame)); 2064 support->SubmitCompositorFrame(local_surface_id, std::move(frame));
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
2221 pass->id = 1; 2215 pass->id = 1;
2222 SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState(); 2216 SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState();
2223 sqs->opacity = 1.f; 2217 sqs->opacity = 1.f;
2224 SurfaceDrawQuad* surface_quad = 2218 SurfaceDrawQuad* surface_quad =
2225 pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); 2219 pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>();
2226 2220
2227 surface_quad->SetNew(sqs, gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1), 2221 surface_quad->SetNew(sqs, gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1),
2228 surface1_id, SurfaceDrawQuadType::PRIMARY, nullptr); 2222 surface1_id, SurfaceDrawQuadType::PRIMARY, nullptr);
2229 pass->copy_requests.push_back(CopyOutputRequest::CreateEmptyRequest()); 2223 pass->copy_requests.push_back(CopyOutputRequest::CreateEmptyRequest());
2230 2224
2231 CompositorFrame frame = MakeCompositorFrame(); 2225 CompositorFrame frame = test::MakeCompositorFrame();
2232 frame.render_pass_list.push_back(std::move(pass)); 2226 frame.render_pass_list.push_back(std::move(pass));
2233 2227
2234 support2->SubmitCompositorFrame(local_frame2_id, std::move(frame)); 2228 support2->SubmitCompositorFrame(local_frame2_id, std::move(frame));
2235 } 2229 }
2236 2230
2237 frame = aggregator_->Aggregate(surface2_id); 2231 frame = aggregator_->Aggregate(surface2_id);
2238 EXPECT_EQ(1u, frame.render_pass_list.size()); 2232 EXPECT_EQ(1u, frame.render_pass_list.size());
2239 render_pass = frame.render_pass_list.front().get(); 2233 render_pass = frame.render_pass_list.front().get();
2240 2234
2241 // Parent has copy request, so texture should not be drawn. 2235 // Parent has copy request, so texture should not be drawn.
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
2295 aggregated_frame = aggregator_.Aggregate(surface_id); 2289 aggregated_frame = aggregator_.Aggregate(surface_id);
2296 EXPECT_EQ(3u, aggregated_frame.render_pass_list.size()); 2290 EXPECT_EQ(3u, aggregated_frame.render_pass_list.size());
2297 EXPECT_EQ(color_space1, aggregated_frame.render_pass_list[0]->color_space); 2291 EXPECT_EQ(color_space1, aggregated_frame.render_pass_list[0]->color_space);
2298 EXPECT_EQ(color_space1, aggregated_frame.render_pass_list[1]->color_space); 2292 EXPECT_EQ(color_space1, aggregated_frame.render_pass_list[1]->color_space);
2299 EXPECT_EQ(color_space3, aggregated_frame.render_pass_list[2]->color_space); 2293 EXPECT_EQ(color_space3, aggregated_frame.render_pass_list[2]->color_space);
2300 } 2294 }
2301 2295
2302 } // namespace 2296 } // namespace
2303 } // namespace cc 2297 } // namespace cc
2304 2298
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698