OLD | NEW |
---|---|
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> |
(...skipping 16 matching lines...) Expand all Loading... | |
27 #include "cc/test/render_pass_test_utils.h" | 27 #include "cc/test/render_pass_test_utils.h" |
28 #include "cc/test/surface_aggregator_test_helpers.h" | 28 #include "cc/test/surface_aggregator_test_helpers.h" |
29 #include "cc/test/test_shared_bitmap_manager.h" | 29 #include "cc/test/test_shared_bitmap_manager.h" |
30 #include "testing/gmock/include/gmock/gmock.h" | 30 #include "testing/gmock/include/gmock/gmock.h" |
31 #include "testing/gtest/include/gtest/gtest.h" | 31 #include "testing/gtest/include/gtest/gtest.h" |
32 #include "third_party/skia/include/core/SkColor.h" | 32 #include "third_party/skia/include/core/SkColor.h" |
33 | 33 |
34 namespace cc { | 34 namespace cc { |
35 namespace { | 35 namespace { |
36 | 36 |
37 static constexpr FrameSinkId kArbitraryFrameSinkId(1, 1); | 37 static constexpr FrameSinkId kArbitraryRootFrameSinkId(1, 1); |
38 static constexpr FrameSinkId kArbitraryChildFrameSinkId(2, 2); | 38 static constexpr FrameSinkId kArbitraryChildFrameSinkId(2, 2); |
39 static constexpr FrameSinkId kArbitraryMiddleFrameSinkId(3, 3); | |
39 static const base::UnguessableToken kArbitraryToken = | 40 static const base::UnguessableToken kArbitraryToken = |
40 base::UnguessableToken::Create(); | 41 base::UnguessableToken::Create(); |
41 | 42 |
42 SurfaceId InvalidSurfaceId() { | 43 SurfaceId InvalidSurfaceId() { |
43 static SurfaceId invalid(kArbitraryFrameSinkId, | 44 static SurfaceId invalid(kArbitraryRootFrameSinkId, |
44 LocalFrameId(0xdeadbeef, kArbitraryToken)); | 45 LocalFrameId(0xdeadbeef, kArbitraryToken)); |
45 return invalid; | 46 return invalid; |
46 } | 47 } |
47 | 48 |
48 gfx::Size SurfaceSize() { | 49 gfx::Size SurfaceSize() { |
49 static gfx::Size size(100, 100); | 50 static gfx::Size size(100, 100); |
50 return size; | 51 return size; |
51 } | 52 } |
52 | 53 |
53 class EmptySurfaceFactoryClient : public SurfaceFactoryClient { | 54 class EmptySurfaceFactoryClient : public SurfaceFactoryClient { |
54 public: | 55 public: |
55 void ReturnResources(const ReturnedResourceArray& resources) override {} | 56 void ReturnResources(const ReturnedResourceArray& resources) override {} |
56 | 57 |
57 void WillDrawSurface(const LocalFrameId& id, | 58 void WillDrawSurface(const LocalFrameId& id, |
58 const gfx::Rect& damage_rect) override { | 59 const gfx::Rect& damage_rect) override { |
59 last_local_frame_id_ = id; | 60 last_local_frame_id_ = id; |
60 last_damage_rect_ = damage_rect; | 61 last_damage_rect_ = damage_rect; |
61 } | 62 } |
62 | 63 |
63 void SetBeginFrameSource(BeginFrameSource* begin_frame_source) override {} | 64 void SetBeginFrameSource(BeginFrameSource* begin_frame_source) override {} |
64 | 65 |
65 gfx::Rect last_damage_rect_; | 66 gfx::Rect last_damage_rect_; |
66 LocalFrameId last_local_frame_id_; | 67 LocalFrameId last_local_frame_id_; |
67 }; | 68 }; |
68 | 69 |
69 class SurfaceAggregatorTest : public testing::Test { | 70 class SurfaceAggregatorTest : public testing::Test { |
70 public: | 71 public: |
71 explicit SurfaceAggregatorTest(bool use_damage_rect) | 72 explicit SurfaceAggregatorTest(bool use_damage_rect) |
72 : factory_(kArbitraryFrameSinkId, &manager_, &empty_client_), | 73 : factory_(kArbitraryRootFrameSinkId, &manager_, &empty_client_), |
73 aggregator_(&manager_, NULL, use_damage_rect) {} | 74 aggregator_(&manager_, NULL, use_damage_rect) {} |
74 | 75 |
75 SurfaceAggregatorTest() : SurfaceAggregatorTest(false) {} | 76 SurfaceAggregatorTest() : SurfaceAggregatorTest(false) {} |
76 | 77 |
78 void TearDown() override { | |
79 testing::Test::TearDown(); | |
80 factory_.EvictSurface(); | |
danakj
2016/11/15 00:43:41
nit: should do local destruction/shutdown work bef
Saman Sami
2016/11/15 21:12:19
Done.
| |
81 } | |
82 | |
77 protected: | 83 protected: |
78 SurfaceManager manager_; | 84 SurfaceManager manager_; |
79 EmptySurfaceFactoryClient empty_client_; | 85 EmptySurfaceFactoryClient empty_client_; |
80 SurfaceFactory factory_; | 86 SurfaceFactory factory_; |
81 SurfaceAggregator aggregator_; | 87 SurfaceAggregator aggregator_; |
82 }; | 88 }; |
83 | 89 |
84 TEST_F(SurfaceAggregatorTest, ValidSurfaceNoFrame) { | 90 TEST_F(SurfaceAggregatorTest, ValidSurfaceNoFrame) { |
85 LocalFrameId local_frame_id(7, base::UnguessableToken::Create()); | 91 LocalFrameId local_frame_id(7, base::UnguessableToken::Create()); |
86 SurfaceId one_id(kArbitraryFrameSinkId, local_frame_id); | 92 SurfaceId one_id(kArbitraryRootFrameSinkId, local_frame_id); |
87 factory_.Create(local_frame_id); | 93 factory_.SubmitCompositorFrame(local_frame_id, CompositorFrame(), |
94 SurfaceFactory::DrawCallback()); | |
88 | 95 |
89 CompositorFrame frame = aggregator_.Aggregate(one_id); | 96 CompositorFrame frame = aggregator_.Aggregate(one_id); |
90 EXPECT_TRUE(frame.render_pass_list.empty()); | 97 EXPECT_TRUE(frame.render_pass_list.empty()); |
91 | |
92 factory_.Destroy(local_frame_id); | |
93 } | 98 } |
94 | 99 |
95 class SurfaceAggregatorValidSurfaceTest : public SurfaceAggregatorTest { | 100 class SurfaceAggregatorValidSurfaceTest : public SurfaceAggregatorTest { |
96 public: | 101 public: |
97 explicit SurfaceAggregatorValidSurfaceTest(bool use_damage_rect) | 102 explicit SurfaceAggregatorValidSurfaceTest(bool use_damage_rect) |
98 : SurfaceAggregatorTest(use_damage_rect), | 103 : SurfaceAggregatorTest(use_damage_rect), |
99 child_factory_(kArbitraryChildFrameSinkId, | 104 child_factory_(kArbitraryChildFrameSinkId, |
100 &manager_, | 105 &manager_, |
101 &empty_child_client_) {} | 106 &empty_child_client_) {} |
102 SurfaceAggregatorValidSurfaceTest() | 107 SurfaceAggregatorValidSurfaceTest() |
103 : SurfaceAggregatorValidSurfaceTest(false) {} | 108 : SurfaceAggregatorValidSurfaceTest(false) {} |
104 | 109 |
105 void SetUp() override { | 110 void SetUp() override { |
106 SurfaceAggregatorTest::SetUp(); | 111 SurfaceAggregatorTest::SetUp(); |
107 root_local_frame_id_ = allocator_.GenerateId(); | 112 root_local_frame_id_ = allocator_.GenerateId(); |
108 factory_.Create(root_local_frame_id_); | |
109 root_surface_ = manager_.GetSurfaceForId( | 113 root_surface_ = manager_.GetSurfaceForId( |
110 SurfaceId(factory_.frame_sink_id(), root_local_frame_id_)); | 114 SurfaceId(factory_.frame_sink_id(), root_local_frame_id_)); |
111 } | 115 } |
112 | 116 |
113 void TearDown() override { | 117 void TearDown() override { |
114 factory_.Destroy(root_local_frame_id_); | |
115 SurfaceAggregatorTest::TearDown(); | 118 SurfaceAggregatorTest::TearDown(); |
119 child_factory_.EvictSurface(); | |
danakj
2016/11/15 00:43:41
nitto
Saman Sami
2016/11/15 21:12:19
Done.
| |
116 } | 120 } |
117 | 121 |
118 void AggregateAndVerify(test::Pass* expected_passes, | 122 void AggregateAndVerify(test::Pass* expected_passes, |
119 size_t expected_pass_count, | 123 size_t expected_pass_count, |
120 SurfaceId* surface_ids, | 124 SurfaceId* surface_ids, |
121 size_t expected_surface_count) { | 125 size_t expected_surface_count) { |
122 CompositorFrame aggregated_frame = aggregator_.Aggregate( | 126 CompositorFrame aggregated_frame = aggregator_.Aggregate( |
123 SurfaceId(factory_.frame_sink_id(), root_local_frame_id_)); | 127 SurfaceId(factory_.frame_sink_id(), root_local_frame_id_)); |
124 | 128 |
125 TestPassesMatchExpectations(expected_passes, expected_pass_count, | 129 TestPassesMatchExpectations(expected_passes, expected_pass_count, |
(...skipping 27 matching lines...) Expand all Loading... | |
153 void SubmitCompositorFrame(SurfaceFactory* factory, | 157 void SubmitCompositorFrame(SurfaceFactory* factory, |
154 test::Pass* passes, | 158 test::Pass* passes, |
155 size_t pass_count, | 159 size_t pass_count, |
156 const LocalFrameId& local_frame_id) { | 160 const LocalFrameId& local_frame_id) { |
157 RenderPassList pass_list; | 161 RenderPassList pass_list; |
158 AddPasses(&pass_list, gfx::Rect(SurfaceSize()), passes, pass_count); | 162 AddPasses(&pass_list, gfx::Rect(SurfaceSize()), passes, pass_count); |
159 SubmitPassListAsFrame(factory, local_frame_id, &pass_list); | 163 SubmitPassListAsFrame(factory, local_frame_id, &pass_list); |
160 } | 164 } |
161 | 165 |
162 void QueuePassAsFrame(std::unique_ptr<RenderPass> pass, | 166 void QueuePassAsFrame(std::unique_ptr<RenderPass> pass, |
163 const LocalFrameId& local_frame_id) { | 167 const LocalFrameId& local_frame_id, |
168 SurfaceFactory* factory) { | |
164 CompositorFrame child_frame; | 169 CompositorFrame child_frame; |
165 child_frame.render_pass_list.push_back(std::move(pass)); | 170 child_frame.render_pass_list.push_back(std::move(pass)); |
166 | 171 |
167 factory_.SubmitCompositorFrame(local_frame_id, std::move(child_frame), | 172 factory->SubmitCompositorFrame(local_frame_id, std::move(child_frame), |
168 SurfaceFactory::DrawCallback()); | 173 SurfaceFactory::DrawCallback()); |
169 } | 174 } |
170 | 175 |
171 protected: | 176 protected: |
172 LocalFrameId root_local_frame_id_; | 177 LocalFrameId root_local_frame_id_; |
173 Surface* root_surface_; | 178 Surface* root_surface_; |
174 SurfaceIdAllocator allocator_; | 179 SurfaceIdAllocator allocator_; |
175 EmptySurfaceFactoryClient empty_child_client_; | 180 EmptySurfaceFactoryClient empty_child_client_; |
176 SurfaceFactory child_factory_; | 181 SurfaceFactory child_factory_; |
177 SurfaceIdAllocator child_allocator_; | 182 SurfaceIdAllocator child_allocator_; |
(...skipping 13 matching lines...) Expand all Loading... | |
191 SurfaceId ids[] = {root_surface_id}; | 196 SurfaceId ids[] = {root_surface_id}; |
192 | 197 |
193 AggregateAndVerify(passes, arraysize(passes), ids, arraysize(ids)); | 198 AggregateAndVerify(passes, arraysize(passes), ids, arraysize(ids)); |
194 | 199 |
195 // Check that WillDrawSurface was called. | 200 // Check that WillDrawSurface was called. |
196 EXPECT_EQ(gfx::Rect(SurfaceSize()), empty_client_.last_damage_rect_); | 201 EXPECT_EQ(gfx::Rect(SurfaceSize()), empty_client_.last_damage_rect_); |
197 EXPECT_EQ(root_local_frame_id_, empty_client_.last_local_frame_id_); | 202 EXPECT_EQ(root_local_frame_id_, empty_client_.last_local_frame_id_); |
198 } | 203 } |
199 | 204 |
200 TEST_F(SurfaceAggregatorValidSurfaceTest, OpacityCopied) { | 205 TEST_F(SurfaceAggregatorValidSurfaceTest, OpacityCopied) { |
206 SurfaceFactory embedded_factory(kArbitraryChildFrameSinkId, &manager_, | |
207 &empty_client_); | |
201 LocalFrameId embedded_local_frame_id = allocator_.GenerateId(); | 208 LocalFrameId embedded_local_frame_id = allocator_.GenerateId(); |
202 SurfaceId embedded_surface_id(factory_.frame_sink_id(), | 209 SurfaceId embedded_surface_id(embedded_factory.frame_sink_id(), |
203 embedded_local_frame_id); | 210 embedded_local_frame_id); |
204 factory_.Create(embedded_local_frame_id); | |
205 | 211 |
206 test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), | 212 test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), |
207 test::Quad::SolidColorQuad(SK_ColorBLUE)}; | 213 test::Quad::SolidColorQuad(SK_ColorBLUE)}; |
208 test::Pass embedded_passes[] = { | 214 test::Pass embedded_passes[] = { |
209 test::Pass(embedded_quads, arraysize(embedded_quads))}; | 215 test::Pass(embedded_quads, arraysize(embedded_quads))}; |
210 | 216 |
211 SubmitCompositorFrame(&factory_, embedded_passes, arraysize(embedded_passes), | 217 SubmitCompositorFrame(&embedded_factory, embedded_passes, |
212 embedded_local_frame_id); | 218 arraysize(embedded_passes), embedded_local_frame_id); |
213 | 219 |
214 test::Quad quads[] = {test::Quad::SurfaceQuad(embedded_surface_id, .5f)}; | 220 test::Quad quads[] = {test::Quad::SurfaceQuad(embedded_surface_id, .5f)}; |
215 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; | 221 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; |
216 | 222 |
217 SubmitCompositorFrame(&factory_, passes, arraysize(passes), | 223 SubmitCompositorFrame(&factory_, passes, arraysize(passes), |
218 root_local_frame_id_); | 224 root_local_frame_id_); |
219 | 225 |
220 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id_); | 226 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id_); |
221 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); | 227 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); |
222 | 228 |
223 RenderPassList& render_pass_list(aggregated_frame.render_pass_list); | 229 RenderPassList& render_pass_list(aggregated_frame.render_pass_list); |
224 ASSERT_EQ(2u, render_pass_list.size()); | 230 ASSERT_EQ(2u, render_pass_list.size()); |
225 SharedQuadStateList& shared_quad_state_list( | 231 SharedQuadStateList& shared_quad_state_list( |
226 render_pass_list[0]->shared_quad_state_list); | 232 render_pass_list[0]->shared_quad_state_list); |
227 ASSERT_EQ(2u, shared_quad_state_list.size()); | 233 ASSERT_EQ(2u, shared_quad_state_list.size()); |
228 EXPECT_EQ(1.f, shared_quad_state_list.ElementAt(0)->opacity); | 234 EXPECT_EQ(1.f, shared_quad_state_list.ElementAt(0)->opacity); |
229 EXPECT_EQ(1.f, shared_quad_state_list.ElementAt(1)->opacity); | 235 EXPECT_EQ(1.f, shared_quad_state_list.ElementAt(1)->opacity); |
230 | 236 |
231 SharedQuadStateList& shared_quad_state_list2( | 237 SharedQuadStateList& shared_quad_state_list2( |
232 render_pass_list[1]->shared_quad_state_list); | 238 render_pass_list[1]->shared_quad_state_list); |
233 ASSERT_EQ(1u, shared_quad_state_list2.size()); | 239 ASSERT_EQ(1u, shared_quad_state_list2.size()); |
234 EXPECT_EQ(.5f, shared_quad_state_list2.ElementAt(0)->opacity); | 240 EXPECT_EQ(.5f, shared_quad_state_list2.ElementAt(0)->opacity); |
235 | 241 |
236 factory_.Destroy(embedded_local_frame_id); | 242 embedded_factory.EvictSurface(); |
237 } | 243 } |
238 | 244 |
239 TEST_F(SurfaceAggregatorValidSurfaceTest, MultiPassSimpleFrame) { | 245 TEST_F(SurfaceAggregatorValidSurfaceTest, MultiPassSimpleFrame) { |
240 test::Quad quads[][2] = {{test::Quad::SolidColorQuad(SK_ColorWHITE), | 246 test::Quad quads[][2] = {{test::Quad::SolidColorQuad(SK_ColorWHITE), |
241 test::Quad::SolidColorQuad(SK_ColorLTGRAY)}, | 247 test::Quad::SolidColorQuad(SK_ColorLTGRAY)}, |
242 {test::Quad::SolidColorQuad(SK_ColorGRAY), | 248 {test::Quad::SolidColorQuad(SK_ColorGRAY), |
243 test::Quad::SolidColorQuad(SK_ColorDKGRAY)}}; | 249 test::Quad::SolidColorQuad(SK_ColorDKGRAY)}}; |
244 test::Pass passes[] = { | 250 test::Pass passes[] = { |
245 test::Pass(quads[0], arraysize(quads[0]), RenderPassId(1, 1)), | 251 test::Pass(quads[0], arraysize(quads[0]), RenderPassId(1, 1)), |
246 test::Pass(quads[1], arraysize(quads[1]), RenderPassId(1, 2))}; | 252 test::Pass(quads[1], arraysize(quads[1]), RenderPassId(1, 2))}; |
247 | 253 |
248 SubmitCompositorFrame(&factory_, passes, arraysize(passes), | 254 SubmitCompositorFrame(&factory_, passes, arraysize(passes), |
249 root_local_frame_id_); | 255 root_local_frame_id_); |
250 | 256 |
251 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id_); | 257 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id_); |
252 SurfaceId ids[] = {root_surface_id}; | 258 SurfaceId ids[] = {root_surface_id}; |
253 | 259 |
254 AggregateAndVerify(passes, arraysize(passes), ids, arraysize(ids)); | 260 AggregateAndVerify(passes, arraysize(passes), ids, arraysize(ids)); |
255 } | 261 } |
256 | 262 |
257 // This tests very simple embedding. root_surface has a frame containing a few | 263 // This tests very simple embedding. root_surface has a frame containing a few |
258 // solid color quads and a surface quad referencing embedded_surface. | 264 // solid color quads and a surface quad referencing embedded_surface. |
259 // embedded_surface has a frame containing only a solid color quad. The solid | 265 // embedded_surface has a frame containing only a solid color quad. The solid |
260 // color quad should be aggregated into the final frame. | 266 // color quad should be aggregated into the final frame. |
261 TEST_F(SurfaceAggregatorValidSurfaceTest, SimpleSurfaceReference) { | 267 TEST_F(SurfaceAggregatorValidSurfaceTest, SimpleSurfaceReference) { |
268 SurfaceFactory embedded_factory(kArbitraryChildFrameSinkId, &manager_, | |
269 &empty_client_); | |
262 LocalFrameId embedded_local_frame_id = allocator_.GenerateId(); | 270 LocalFrameId embedded_local_frame_id = allocator_.GenerateId(); |
263 SurfaceId embedded_surface_id(factory_.frame_sink_id(), | 271 SurfaceId embedded_surface_id(embedded_factory.frame_sink_id(), |
264 embedded_local_frame_id); | 272 embedded_local_frame_id); |
265 factory_.Create(embedded_local_frame_id); | |
266 | 273 |
267 test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)}; | 274 test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)}; |
268 test::Pass embedded_passes[] = { | 275 test::Pass embedded_passes[] = { |
269 test::Pass(embedded_quads, arraysize(embedded_quads))}; | 276 test::Pass(embedded_quads, arraysize(embedded_quads))}; |
270 | 277 |
271 SubmitCompositorFrame(&factory_, embedded_passes, arraysize(embedded_passes), | 278 SubmitCompositorFrame(&embedded_factory, embedded_passes, |
272 embedded_local_frame_id); | 279 arraysize(embedded_passes), embedded_local_frame_id); |
273 | 280 |
274 test::Quad root_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE), | 281 test::Quad root_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE), |
275 test::Quad::SurfaceQuad(embedded_surface_id, 1.f), | 282 test::Quad::SurfaceQuad(embedded_surface_id, 1.f), |
276 test::Quad::SolidColorQuad(SK_ColorBLACK)}; | 283 test::Quad::SolidColorQuad(SK_ColorBLACK)}; |
277 test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))}; | 284 test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))}; |
278 | 285 |
279 SubmitCompositorFrame(&factory_, root_passes, arraysize(root_passes), | 286 SubmitCompositorFrame(&factory_, root_passes, arraysize(root_passes), |
280 root_local_frame_id_); | 287 root_local_frame_id_); |
281 | 288 |
282 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE), | 289 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE), |
283 test::Quad::SolidColorQuad(SK_ColorGREEN), | 290 test::Quad::SolidColorQuad(SK_ColorGREEN), |
284 test::Quad::SolidColorQuad(SK_ColorBLACK)}; | 291 test::Quad::SolidColorQuad(SK_ColorBLACK)}; |
285 test::Pass expected_passes[] = { | 292 test::Pass expected_passes[] = { |
286 test::Pass(expected_quads, arraysize(expected_quads))}; | 293 test::Pass(expected_quads, arraysize(expected_quads))}; |
287 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id_); | 294 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id_); |
288 SurfaceId ids[] = {root_surface_id, embedded_surface_id}; | 295 SurfaceId ids[] = {root_surface_id, embedded_surface_id}; |
289 AggregateAndVerify( | 296 AggregateAndVerify( |
290 expected_passes, arraysize(expected_passes), ids, arraysize(ids)); | 297 expected_passes, arraysize(expected_passes), ids, arraysize(ids)); |
291 | 298 |
292 factory_.Destroy(embedded_local_frame_id); | 299 embedded_factory.EvictSurface(); |
293 } | 300 } |
294 | 301 |
295 TEST_F(SurfaceAggregatorValidSurfaceTest, CopyRequest) { | 302 TEST_F(SurfaceAggregatorValidSurfaceTest, CopyRequest) { |
303 SurfaceFactory embedded_factory(kArbitraryChildFrameSinkId, &manager_, | |
304 &empty_client_); | |
296 LocalFrameId embedded_local_frame_id = allocator_.GenerateId(); | 305 LocalFrameId embedded_local_frame_id = allocator_.GenerateId(); |
297 SurfaceId embedded_surface_id(factory_.frame_sink_id(), | 306 SurfaceId embedded_surface_id(embedded_factory.frame_sink_id(), |
298 embedded_local_frame_id); | 307 embedded_local_frame_id); |
299 factory_.Create(embedded_local_frame_id); | |
300 | 308 |
301 test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)}; | 309 test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)}; |
302 test::Pass embedded_passes[] = { | 310 test::Pass embedded_passes[] = { |
303 test::Pass(embedded_quads, arraysize(embedded_quads))}; | 311 test::Pass(embedded_quads, arraysize(embedded_quads))}; |
304 | 312 |
305 SubmitCompositorFrame(&factory_, embedded_passes, arraysize(embedded_passes), | 313 SubmitCompositorFrame(&embedded_factory, embedded_passes, |
306 embedded_local_frame_id); | 314 arraysize(embedded_passes), embedded_local_frame_id); |
307 std::unique_ptr<CopyOutputRequest> copy_request( | 315 std::unique_ptr<CopyOutputRequest> copy_request( |
308 CopyOutputRequest::CreateEmptyRequest()); | 316 CopyOutputRequest::CreateEmptyRequest()); |
309 CopyOutputRequest* copy_request_ptr = copy_request.get(); | 317 CopyOutputRequest* copy_request_ptr = copy_request.get(); |
310 factory_.RequestCopyOfSurface(embedded_local_frame_id, | 318 embedded_factory.RequestCopyOfSurface(std::move(copy_request)); |
311 std::move(copy_request)); | |
312 | 319 |
313 test::Quad root_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE), | 320 test::Quad root_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE), |
314 test::Quad::SurfaceQuad(embedded_surface_id, 1.f), | 321 test::Quad::SurfaceQuad(embedded_surface_id, 1.f), |
315 test::Quad::SolidColorQuad(SK_ColorBLACK)}; | 322 test::Quad::SolidColorQuad(SK_ColorBLACK)}; |
316 test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))}; | 323 test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))}; |
317 | 324 |
318 SubmitCompositorFrame(&factory_, root_passes, arraysize(root_passes), | 325 SubmitCompositorFrame(&factory_, root_passes, arraysize(root_passes), |
319 root_local_frame_id_); | 326 root_local_frame_id_); |
320 | 327 |
321 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id_); | 328 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id_); |
(...skipping 15 matching lines...) Expand all Loading... | |
337 | 344 |
338 SurfaceId surface_ids[] = {root_surface_id, embedded_surface_id}; | 345 SurfaceId surface_ids[] = {root_surface_id, embedded_surface_id}; |
339 EXPECT_EQ(arraysize(surface_ids), | 346 EXPECT_EQ(arraysize(surface_ids), |
340 aggregator_.previous_contained_surfaces().size()); | 347 aggregator_.previous_contained_surfaces().size()); |
341 for (size_t i = 0; i < arraysize(surface_ids); i++) { | 348 for (size_t i = 0; i < arraysize(surface_ids); i++) { |
342 EXPECT_TRUE( | 349 EXPECT_TRUE( |
343 aggregator_.previous_contained_surfaces().find(surface_ids[i]) != | 350 aggregator_.previous_contained_surfaces().find(surface_ids[i]) != |
344 aggregator_.previous_contained_surfaces().end()); | 351 aggregator_.previous_contained_surfaces().end()); |
345 } | 352 } |
346 | 353 |
347 factory_.Destroy(embedded_local_frame_id); | 354 embedded_factory.EvictSurface(); |
348 } | 355 } |
349 | 356 |
350 // Root surface may contain copy requests. | 357 // Root surface may contain copy requests. |
351 TEST_F(SurfaceAggregatorValidSurfaceTest, RootCopyRequest) { | 358 TEST_F(SurfaceAggregatorValidSurfaceTest, RootCopyRequest) { |
359 SurfaceFactory embedded_factory(kArbitraryChildFrameSinkId, &manager_, | |
360 &empty_client_); | |
352 LocalFrameId embedded_local_frame_id = allocator_.GenerateId(); | 361 LocalFrameId embedded_local_frame_id = allocator_.GenerateId(); |
353 SurfaceId embedded_surface_id(factory_.frame_sink_id(), | 362 SurfaceId embedded_surface_id(embedded_factory.frame_sink_id(), |
354 embedded_local_frame_id); | 363 embedded_local_frame_id); |
355 factory_.Create(embedded_local_frame_id); | |
356 | 364 |
357 test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)}; | 365 test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)}; |
358 test::Pass embedded_passes[] = { | 366 test::Pass embedded_passes[] = { |
359 test::Pass(embedded_quads, arraysize(embedded_quads))}; | 367 test::Pass(embedded_quads, arraysize(embedded_quads))}; |
360 | 368 |
361 SubmitCompositorFrame(&factory_, embedded_passes, arraysize(embedded_passes), | 369 SubmitCompositorFrame(&embedded_factory, embedded_passes, |
362 embedded_local_frame_id); | 370 arraysize(embedded_passes), embedded_local_frame_id); |
363 std::unique_ptr<CopyOutputRequest> copy_request( | 371 std::unique_ptr<CopyOutputRequest> copy_request( |
364 CopyOutputRequest::CreateEmptyRequest()); | 372 CopyOutputRequest::CreateEmptyRequest()); |
365 CopyOutputRequest* copy_request_ptr = copy_request.get(); | 373 CopyOutputRequest* copy_request_ptr = copy_request.get(); |
366 std::unique_ptr<CopyOutputRequest> copy_request2( | 374 std::unique_ptr<CopyOutputRequest> copy_request2( |
367 CopyOutputRequest::CreateEmptyRequest()); | 375 CopyOutputRequest::CreateEmptyRequest()); |
368 CopyOutputRequest* copy_request2_ptr = copy_request2.get(); | 376 CopyOutputRequest* copy_request2_ptr = copy_request2.get(); |
369 | 377 |
370 test::Quad root_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE), | 378 test::Quad root_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE), |
371 test::Quad::SurfaceQuad(embedded_surface_id, 1.f), | 379 test::Quad::SurfaceQuad(embedded_surface_id, 1.f), |
372 test::Quad::SolidColorQuad(SK_ColorBLACK)}; | 380 test::Quad::SolidColorQuad(SK_ColorBLACK)}; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
415 } | 423 } |
416 | 424 |
417 // Ensure copy requests have been removed from root surface. | 425 // Ensure copy requests have been removed from root surface. |
418 const CompositorFrame& original_frame = | 426 const CompositorFrame& original_frame = |
419 manager_.GetSurfaceForId(root_surface_id)->GetEligibleFrame(); | 427 manager_.GetSurfaceForId(root_surface_id)->GetEligibleFrame(); |
420 const RenderPassList& original_pass_list = original_frame.render_pass_list; | 428 const RenderPassList& original_pass_list = original_frame.render_pass_list; |
421 ASSERT_EQ(2u, original_pass_list.size()); | 429 ASSERT_EQ(2u, original_pass_list.size()); |
422 DCHECK(original_pass_list[0]->copy_requests.empty()); | 430 DCHECK(original_pass_list[0]->copy_requests.empty()); |
423 DCHECK(original_pass_list[1]->copy_requests.empty()); | 431 DCHECK(original_pass_list[1]->copy_requests.empty()); |
424 | 432 |
425 factory_.Destroy(embedded_local_frame_id); | 433 embedded_factory.EvictSurface(); |
426 } | 434 } |
427 | 435 |
428 TEST_F(SurfaceAggregatorValidSurfaceTest, UnreferencedSurface) { | 436 TEST_F(SurfaceAggregatorValidSurfaceTest, UnreferencedSurface) { |
437 SurfaceFactory embedded_factory(kArbitraryChildFrameSinkId, &manager_, | |
438 &empty_client_); | |
439 SurfaceFactory parent_factory(kArbitraryRootFrameSinkId, &manager_, | |
440 &empty_client_); | |
429 LocalFrameId embedded_local_frame_id = allocator_.GenerateId(); | 441 LocalFrameId embedded_local_frame_id = allocator_.GenerateId(); |
430 SurfaceId embedded_surface_id(factory_.frame_sink_id(), | 442 SurfaceId embedded_surface_id(embedded_factory.frame_sink_id(), |
431 embedded_local_frame_id); | 443 embedded_local_frame_id); |
432 SurfaceId nonexistent_surface_id(factory_.frame_sink_id(), | 444 SurfaceId nonexistent_surface_id(factory_.frame_sink_id(), |
433 allocator_.GenerateId()); | 445 allocator_.GenerateId()); |
434 factory_.Create(embedded_local_frame_id); | |
435 | 446 |
436 test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)}; | 447 test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)}; |
437 test::Pass embedded_passes[] = { | 448 test::Pass embedded_passes[] = { |
438 test::Pass(embedded_quads, arraysize(embedded_quads))}; | 449 test::Pass(embedded_quads, arraysize(embedded_quads))}; |
439 | 450 |
440 SubmitCompositorFrame(&factory_, embedded_passes, arraysize(embedded_passes), | 451 SubmitCompositorFrame(&embedded_factory, embedded_passes, |
441 embedded_local_frame_id); | 452 arraysize(embedded_passes), embedded_local_frame_id); |
442 std::unique_ptr<CopyOutputRequest> copy_request( | 453 std::unique_ptr<CopyOutputRequest> copy_request( |
443 CopyOutputRequest::CreateEmptyRequest()); | 454 CopyOutputRequest::CreateEmptyRequest()); |
444 CopyOutputRequest* copy_request_ptr = copy_request.get(); | 455 CopyOutputRequest* copy_request_ptr = copy_request.get(); |
445 factory_.RequestCopyOfSurface(embedded_local_frame_id, | 456 embedded_factory.RequestCopyOfSurface(std::move(copy_request)); |
446 std::move(copy_request)); | |
447 | 457 |
448 LocalFrameId parent_local_frame_id = allocator_.GenerateId(); | 458 LocalFrameId parent_local_frame_id = allocator_.GenerateId(); |
449 SurfaceId parent_surface_id(factory_.frame_sink_id(), parent_local_frame_id); | 459 SurfaceId parent_surface_id(parent_factory.frame_sink_id(), |
450 factory_.Create(parent_local_frame_id); | 460 parent_local_frame_id); |
451 | 461 |
452 test::Quad parent_quads[] = { | 462 test::Quad parent_quads[] = { |
453 test::Quad::SolidColorQuad(SK_ColorWHITE), | 463 test::Quad::SolidColorQuad(SK_ColorWHITE), |
454 test::Quad::SurfaceQuad(embedded_surface_id, 1.f), | 464 test::Quad::SurfaceQuad(embedded_surface_id, 1.f), |
455 test::Quad::SolidColorQuad(SK_ColorBLACK)}; | 465 test::Quad::SolidColorQuad(SK_ColorBLACK)}; |
456 test::Pass parent_passes[] = { | 466 test::Pass parent_passes[] = { |
457 test::Pass(parent_quads, arraysize(parent_quads))}; | 467 test::Pass(parent_quads, arraysize(parent_quads))}; |
458 | 468 |
459 { | 469 { |
460 CompositorFrame frame; | 470 CompositorFrame frame; |
461 | 471 |
462 AddPasses(&frame.render_pass_list, gfx::Rect(SurfaceSize()), parent_passes, | 472 AddPasses(&frame.render_pass_list, gfx::Rect(SurfaceSize()), parent_passes, |
463 arraysize(parent_passes)); | 473 arraysize(parent_passes)); |
464 | 474 |
465 frame.metadata.referenced_surfaces.push_back(embedded_surface_id); | 475 frame.metadata.referenced_surfaces.push_back(embedded_surface_id); |
466 | 476 |
467 factory_.SubmitCompositorFrame(parent_local_frame_id, std::move(frame), | 477 parent_factory.SubmitCompositorFrame(parent_local_frame_id, |
468 SurfaceFactory::DrawCallback()); | 478 std::move(frame), |
479 SurfaceFactory::DrawCallback()); | |
469 } | 480 } |
470 | 481 |
471 test::Quad root_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE), | 482 test::Quad root_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE), |
472 test::Quad::SolidColorQuad(SK_ColorBLACK)}; | 483 test::Quad::SolidColorQuad(SK_ColorBLACK)}; |
473 test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))}; | 484 test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))}; |
474 | 485 |
475 { | 486 { |
476 CompositorFrame frame; | 487 CompositorFrame frame; |
477 AddPasses(&frame.render_pass_list, gfx::Rect(SurfaceSize()), root_passes, | 488 AddPasses(&frame.render_pass_list, gfx::Rect(SurfaceSize()), root_passes, |
478 arraysize(root_passes)); | 489 arraysize(root_passes)); |
(...skipping 28 matching lines...) Expand all Loading... | |
507 SurfaceId(factory_.frame_sink_id(), root_local_frame_id_), | 518 SurfaceId(factory_.frame_sink_id(), root_local_frame_id_), |
508 parent_surface_id, embedded_surface_id, nonexistent_surface_id}; | 519 parent_surface_id, embedded_surface_id, nonexistent_surface_id}; |
509 EXPECT_EQ(arraysize(surface_ids), | 520 EXPECT_EQ(arraysize(surface_ids), |
510 aggregator_.previous_contained_surfaces().size()); | 521 aggregator_.previous_contained_surfaces().size()); |
511 for (size_t i = 0; i < arraysize(surface_ids); i++) { | 522 for (size_t i = 0; i < arraysize(surface_ids); i++) { |
512 EXPECT_TRUE( | 523 EXPECT_TRUE( |
513 aggregator_.previous_contained_surfaces().find(surface_ids[i]) != | 524 aggregator_.previous_contained_surfaces().find(surface_ids[i]) != |
514 aggregator_.previous_contained_surfaces().end()); | 525 aggregator_.previous_contained_surfaces().end()); |
515 } | 526 } |
516 | 527 |
517 factory_.Destroy(parent_local_frame_id); | 528 embedded_factory.EvictSurface(); |
518 factory_.Destroy(embedded_local_frame_id); | 529 parent_factory.EvictSurface(); |
519 } | 530 } |
520 | 531 |
521 // This tests referencing a surface that has multiple render passes. | 532 // This tests referencing a surface that has multiple render passes. |
522 TEST_F(SurfaceAggregatorValidSurfaceTest, MultiPassSurfaceReference) { | 533 TEST_F(SurfaceAggregatorValidSurfaceTest, MultiPassSurfaceReference) { |
523 LocalFrameId embedded_local_frame_id = child_allocator_.GenerateId(); | 534 LocalFrameId embedded_local_frame_id = child_allocator_.GenerateId(); |
524 SurfaceId embedded_surface_id(child_factory_.frame_sink_id(), | 535 SurfaceId embedded_surface_id(child_factory_.frame_sink_id(), |
525 embedded_local_frame_id); | 536 embedded_local_frame_id); |
526 child_factory_.Create(embedded_local_frame_id); | |
527 | 537 |
528 RenderPassId pass_ids[] = {RenderPassId(1, 1), RenderPassId(1, 2), | 538 RenderPassId pass_ids[] = {RenderPassId(1, 1), RenderPassId(1, 2), |
529 RenderPassId(1, 3)}; | 539 RenderPassId(1, 3)}; |
530 | 540 |
531 test::Quad embedded_quads[][2] = { | 541 test::Quad embedded_quads[][2] = { |
532 {test::Quad::SolidColorQuad(1), test::Quad::SolidColorQuad(2)}, | 542 {test::Quad::SolidColorQuad(1), test::Quad::SolidColorQuad(2)}, |
533 {test::Quad::SolidColorQuad(3), test::Quad::RenderPassQuad(pass_ids[0])}, | 543 {test::Quad::SolidColorQuad(3), test::Quad::RenderPassQuad(pass_ids[0])}, |
534 {test::Quad::SolidColorQuad(4), test::Quad::RenderPassQuad(pass_ids[1])}}; | 544 {test::Quad::SolidColorQuad(4), test::Quad::RenderPassQuad(pass_ids[1])}}; |
535 test::Pass embedded_passes[] = { | 545 test::Pass embedded_passes[] = { |
536 test::Pass(embedded_quads[0], arraysize(embedded_quads[0]), pass_ids[0]), | 546 test::Pass(embedded_quads[0], arraysize(embedded_quads[0]), pass_ids[0]), |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
647 // The last quad in the last pass will reference the second pass from the | 657 // The last quad in the last pass will reference the second pass from the |
648 // root surface, which after aggregating is the fourth pass in the overall | 658 // root surface, which after aggregating is the fourth pass in the overall |
649 // list. | 659 // list. |
650 ASSERT_EQ(DrawQuad::RENDER_PASS, | 660 ASSERT_EQ(DrawQuad::RENDER_PASS, |
651 fifth_pass_quad_list.ElementAt(1)->material); | 661 fifth_pass_quad_list.ElementAt(1)->material); |
652 const RenderPassDrawQuad* fifth_pass_render_pass_draw_quad = | 662 const RenderPassDrawQuad* fifth_pass_render_pass_draw_quad = |
653 RenderPassDrawQuad::MaterialCast(fifth_pass_quad_list.ElementAt(1)); | 663 RenderPassDrawQuad::MaterialCast(fifth_pass_quad_list.ElementAt(1)); |
654 EXPECT_EQ(actual_pass_ids[3], | 664 EXPECT_EQ(actual_pass_ids[3], |
655 fifth_pass_render_pass_draw_quad->render_pass_id); | 665 fifth_pass_render_pass_draw_quad->render_pass_id); |
656 } | 666 } |
657 child_factory_.Destroy(embedded_local_frame_id); | |
658 } | 667 } |
659 | 668 |
660 // Tests an invalid surface reference in a frame. The surface quad should just | 669 // Tests an invalid surface reference in a frame. The surface quad should just |
661 // be dropped. | 670 // be dropped. |
662 TEST_F(SurfaceAggregatorValidSurfaceTest, InvalidSurfaceReference) { | 671 TEST_F(SurfaceAggregatorValidSurfaceTest, InvalidSurfaceReference) { |
663 test::Quad quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), | 672 test::Quad quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), |
664 test::Quad::SurfaceQuad(InvalidSurfaceId(), 1.f), | 673 test::Quad::SurfaceQuad(InvalidSurfaceId(), 1.f), |
665 test::Quad::SolidColorQuad(SK_ColorBLUE)}; | 674 test::Quad::SolidColorQuad(SK_ColorBLUE)}; |
666 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; | 675 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; |
667 | 676 |
(...skipping 10 matching lines...) Expand all Loading... | |
678 AggregateAndVerify( | 687 AggregateAndVerify( |
679 expected_passes, arraysize(expected_passes), ids, arraysize(ids)); | 688 expected_passes, arraysize(expected_passes), ids, arraysize(ids)); |
680 } | 689 } |
681 | 690 |
682 // Tests a reference to a valid surface with no submitted frame. This quad | 691 // Tests a reference to a valid surface with no submitted frame. This quad |
683 // should also just be dropped. | 692 // should also just be dropped. |
684 TEST_F(SurfaceAggregatorValidSurfaceTest, ValidSurfaceReferenceWithNoFrame) { | 693 TEST_F(SurfaceAggregatorValidSurfaceTest, ValidSurfaceReferenceWithNoFrame) { |
685 LocalFrameId empty_local_frame_id = allocator_.GenerateId(); | 694 LocalFrameId empty_local_frame_id = allocator_.GenerateId(); |
686 SurfaceId surface_with_no_frame_id(factory_.frame_sink_id(), | 695 SurfaceId surface_with_no_frame_id(factory_.frame_sink_id(), |
687 empty_local_frame_id); | 696 empty_local_frame_id); |
688 factory_.Create(empty_local_frame_id); | |
689 | 697 |
690 test::Quad quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), | 698 test::Quad quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), |
691 test::Quad::SurfaceQuad(surface_with_no_frame_id, 1.f), | 699 test::Quad::SurfaceQuad(surface_with_no_frame_id, 1.f), |
692 test::Quad::SolidColorQuad(SK_ColorBLUE)}; | 700 test::Quad::SolidColorQuad(SK_ColorBLUE)}; |
693 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; | 701 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; |
694 | 702 |
695 SubmitCompositorFrame(&factory_, passes, arraysize(passes), | 703 SubmitCompositorFrame(&factory_, passes, arraysize(passes), |
696 root_local_frame_id_); | 704 root_local_frame_id_); |
697 | 705 |
698 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), | 706 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), |
699 test::Quad::SolidColorQuad(SK_ColorBLUE)}; | 707 test::Quad::SolidColorQuad(SK_ColorBLUE)}; |
700 test::Pass expected_passes[] = { | 708 test::Pass expected_passes[] = { |
701 test::Pass(expected_quads, arraysize(expected_quads))}; | 709 test::Pass(expected_quads, arraysize(expected_quads))}; |
702 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id_); | 710 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id_); |
703 SurfaceId ids[] = {root_surface_id, surface_with_no_frame_id}; | 711 SurfaceId ids[] = {root_surface_id, surface_with_no_frame_id}; |
704 AggregateAndVerify( | 712 AggregateAndVerify( |
705 expected_passes, arraysize(expected_passes), ids, arraysize(ids)); | 713 expected_passes, arraysize(expected_passes), ids, arraysize(ids)); |
706 factory_.Destroy(empty_local_frame_id); | |
707 } | 714 } |
708 | 715 |
709 // Tests a surface quad referencing itself, generating a trivial cycle. | 716 // Tests a surface quad referencing itself, generating a trivial cycle. |
710 // The quad creating the cycle should be dropped from the final frame. | 717 // The quad creating the cycle should be dropped from the final frame. |
711 TEST_F(SurfaceAggregatorValidSurfaceTest, SimpleCyclicalReference) { | 718 TEST_F(SurfaceAggregatorValidSurfaceTest, SimpleCyclicalReference) { |
712 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id_); | 719 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id_); |
713 test::Quad quads[] = {test::Quad::SurfaceQuad(root_surface_id, 1.f), | 720 test::Quad quads[] = {test::Quad::SurfaceQuad(root_surface_id, 1.f), |
714 test::Quad::SolidColorQuad(SK_ColorYELLOW)}; | 721 test::Quad::SolidColorQuad(SK_ColorYELLOW)}; |
715 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; | 722 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; |
716 | 723 |
717 SubmitCompositorFrame(&factory_, passes, arraysize(passes), | 724 SubmitCompositorFrame(&factory_, passes, arraysize(passes), |
718 root_local_frame_id_); | 725 root_local_frame_id_); |
719 | 726 |
720 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorYELLOW)}; | 727 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorYELLOW)}; |
721 test::Pass expected_passes[] = { | 728 test::Pass expected_passes[] = { |
722 test::Pass(expected_quads, arraysize(expected_quads))}; | 729 test::Pass(expected_quads, arraysize(expected_quads))}; |
723 SurfaceId ids[] = {root_surface_id}; | 730 SurfaceId ids[] = {root_surface_id}; |
724 AggregateAndVerify( | 731 AggregateAndVerify( |
725 expected_passes, arraysize(expected_passes), ids, arraysize(ids)); | 732 expected_passes, arraysize(expected_passes), ids, arraysize(ids)); |
726 } | 733 } |
727 | 734 |
728 // Tests a more complex cycle with one intermediate surface. | 735 // Tests a more complex cycle with one intermediate surface. |
729 TEST_F(SurfaceAggregatorValidSurfaceTest, TwoSurfaceCyclicalReference) { | 736 TEST_F(SurfaceAggregatorValidSurfaceTest, TwoSurfaceCyclicalReference) { |
730 LocalFrameId child_local_frame_id = allocator_.GenerateId(); | 737 LocalFrameId child_local_frame_id = allocator_.GenerateId(); |
731 SurfaceId child_surface_id(factory_.frame_sink_id(), child_local_frame_id); | 738 SurfaceId child_surface_id(child_factory_.frame_sink_id(), |
732 factory_.Create(child_local_frame_id); | 739 child_local_frame_id); |
733 | 740 |
734 test::Quad parent_quads[] = {test::Quad::SolidColorQuad(SK_ColorBLUE), | 741 test::Quad parent_quads[] = {test::Quad::SolidColorQuad(SK_ColorBLUE), |
735 test::Quad::SurfaceQuad(child_surface_id, 1.f), | 742 test::Quad::SurfaceQuad(child_surface_id, 1.f), |
736 test::Quad::SolidColorQuad(SK_ColorCYAN)}; | 743 test::Quad::SolidColorQuad(SK_ColorCYAN)}; |
737 test::Pass parent_passes[] = { | 744 test::Pass parent_passes[] = { |
738 test::Pass(parent_quads, arraysize(parent_quads))}; | 745 test::Pass(parent_quads, arraysize(parent_quads))}; |
739 | 746 |
740 SubmitCompositorFrame(&factory_, parent_passes, arraysize(parent_passes), | 747 SubmitCompositorFrame(&factory_, parent_passes, arraysize(parent_passes), |
741 root_local_frame_id_); | 748 root_local_frame_id_); |
742 | 749 |
743 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id_); | 750 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id_); |
744 test::Quad child_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), | 751 test::Quad child_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), |
745 test::Quad::SurfaceQuad(root_surface_id, 1.f), | 752 test::Quad::SurfaceQuad(root_surface_id, 1.f), |
746 test::Quad::SolidColorQuad(SK_ColorMAGENTA)}; | 753 test::Quad::SolidColorQuad(SK_ColorMAGENTA)}; |
747 test::Pass child_passes[] = {test::Pass(child_quads, arraysize(child_quads))}; | 754 test::Pass child_passes[] = {test::Pass(child_quads, arraysize(child_quads))}; |
748 | 755 |
749 SubmitCompositorFrame(&factory_, child_passes, arraysize(child_passes), | 756 SubmitCompositorFrame(&child_factory_, child_passes, arraysize(child_passes), |
750 child_local_frame_id); | 757 child_local_frame_id); |
751 | 758 |
752 // The child surface's reference to the root_surface_ will be dropped, so | 759 // The child surface's reference to the root_surface_ will be dropped, so |
753 // we'll end up with: | 760 // we'll end up with: |
754 // SK_ColorBLUE from the parent | 761 // SK_ColorBLUE from the parent |
755 // SK_ColorGREEN from the child | 762 // SK_ColorGREEN from the child |
756 // SK_ColorMAGENTA from the child | 763 // SK_ColorMAGENTA from the child |
757 // SK_ColorCYAN from the parent | 764 // SK_ColorCYAN from the parent |
758 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorBLUE), | 765 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorBLUE), |
759 test::Quad::SolidColorQuad(SK_ColorGREEN), | 766 test::Quad::SolidColorQuad(SK_ColorGREEN), |
760 test::Quad::SolidColorQuad(SK_ColorMAGENTA), | 767 test::Quad::SolidColorQuad(SK_ColorMAGENTA), |
761 test::Quad::SolidColorQuad(SK_ColorCYAN)}; | 768 test::Quad::SolidColorQuad(SK_ColorCYAN)}; |
762 test::Pass expected_passes[] = { | 769 test::Pass expected_passes[] = { |
763 test::Pass(expected_quads, arraysize(expected_quads))}; | 770 test::Pass(expected_quads, arraysize(expected_quads))}; |
764 SurfaceId ids[] = {root_surface_id, child_surface_id}; | 771 SurfaceId ids[] = {root_surface_id, child_surface_id}; |
765 AggregateAndVerify( | 772 AggregateAndVerify( |
766 expected_passes, arraysize(expected_passes), ids, arraysize(ids)); | 773 expected_passes, arraysize(expected_passes), ids, arraysize(ids)); |
767 factory_.Destroy(child_local_frame_id); | |
768 } | 774 } |
769 | 775 |
770 // Tests that we map render pass IDs from different surfaces into a unified | 776 // Tests that we map render pass IDs from different surfaces into a unified |
771 // namespace and update RenderPassDrawQuad's id references to match. | 777 // namespace and update RenderPassDrawQuad's id references to match. |
772 TEST_F(SurfaceAggregatorValidSurfaceTest, RenderPassIdMapping) { | 778 TEST_F(SurfaceAggregatorValidSurfaceTest, RenderPassIdMapping) { |
773 LocalFrameId child_local_frame_id = allocator_.GenerateId(); | 779 LocalFrameId child_local_frame_id = allocator_.GenerateId(); |
774 SurfaceId child_surface_id(factory_.frame_sink_id(), child_local_frame_id); | 780 SurfaceId child_surface_id(child_factory_.frame_sink_id(), |
775 factory_.Create(child_local_frame_id); | 781 child_local_frame_id); |
776 | 782 |
777 RenderPassId child_pass_id[] = {RenderPassId(1, 1), RenderPassId(1, 2)}; | 783 RenderPassId child_pass_id[] = {RenderPassId(1, 1), RenderPassId(1, 2)}; |
778 test::Quad child_quad[][1] = {{test::Quad::SolidColorQuad(SK_ColorGREEN)}, | 784 test::Quad child_quad[][1] = {{test::Quad::SolidColorQuad(SK_ColorGREEN)}, |
779 {test::Quad::RenderPassQuad(child_pass_id[0])}}; | 785 {test::Quad::RenderPassQuad(child_pass_id[0])}}; |
780 test::Pass surface_passes[] = { | 786 test::Pass surface_passes[] = { |
781 test::Pass(child_quad[0], arraysize(child_quad[0]), child_pass_id[0]), | 787 test::Pass(child_quad[0], arraysize(child_quad[0]), child_pass_id[0]), |
782 test::Pass(child_quad[1], arraysize(child_quad[1]), child_pass_id[1])}; | 788 test::Pass(child_quad[1], arraysize(child_quad[1]), child_pass_id[1])}; |
783 | 789 |
784 SubmitCompositorFrame(&factory_, surface_passes, arraysize(surface_passes), | 790 SubmitCompositorFrame(&child_factory_, surface_passes, |
785 child_local_frame_id); | 791 arraysize(surface_passes), child_local_frame_id); |
786 | 792 |
787 // Pass IDs from the parent surface may collide with ones from the child. | 793 // Pass IDs from the parent surface may collide with ones from the child. |
788 RenderPassId parent_pass_id[] = {RenderPassId(2, 1), RenderPassId(1, 2)}; | 794 RenderPassId parent_pass_id[] = {RenderPassId(2, 1), RenderPassId(1, 2)}; |
789 test::Quad parent_quad[][1] = { | 795 test::Quad parent_quad[][1] = { |
790 {test::Quad::SurfaceQuad(child_surface_id, 1.f)}, | 796 {test::Quad::SurfaceQuad(child_surface_id, 1.f)}, |
791 {test::Quad::RenderPassQuad(parent_pass_id[0])}}; | 797 {test::Quad::RenderPassQuad(parent_pass_id[0])}}; |
792 test::Pass parent_passes[] = { | 798 test::Pass parent_passes[] = { |
793 test::Pass(parent_quad[0], arraysize(parent_quad[0]), parent_pass_id[0]), | 799 test::Pass(parent_quad[0], arraysize(parent_quad[0]), parent_pass_id[0]), |
794 test::Pass(parent_quad[1], arraysize(parent_quad[1]), parent_pass_id[1])}; | 800 test::Pass(parent_quad[1], arraysize(parent_quad[1]), parent_pass_id[1])}; |
795 | 801 |
(...skipping 23 matching lines...) Expand all Loading... | |
819 aggregated_pass_list[2]->quad_list.front()}; | 825 aggregated_pass_list[2]->quad_list.front()}; |
820 ASSERT_EQ(render_pass_quads[0]->material, DrawQuad::RENDER_PASS); | 826 ASSERT_EQ(render_pass_quads[0]->material, DrawQuad::RENDER_PASS); |
821 EXPECT_EQ( | 827 EXPECT_EQ( |
822 actual_pass_ids[0], | 828 actual_pass_ids[0], |
823 RenderPassDrawQuad::MaterialCast(render_pass_quads[0])->render_pass_id); | 829 RenderPassDrawQuad::MaterialCast(render_pass_quads[0])->render_pass_id); |
824 | 830 |
825 ASSERT_EQ(render_pass_quads[1]->material, DrawQuad::RENDER_PASS); | 831 ASSERT_EQ(render_pass_quads[1]->material, DrawQuad::RENDER_PASS); |
826 EXPECT_EQ( | 832 EXPECT_EQ( |
827 actual_pass_ids[1], | 833 actual_pass_ids[1], |
828 RenderPassDrawQuad::MaterialCast(render_pass_quads[1])->render_pass_id); | 834 RenderPassDrawQuad::MaterialCast(render_pass_quads[1])->render_pass_id); |
829 factory_.Destroy(child_local_frame_id); | |
830 } | 835 } |
831 | 836 |
832 void AddSolidColorQuadWithBlendMode(const gfx::Size& size, | 837 void AddSolidColorQuadWithBlendMode(const gfx::Size& size, |
833 RenderPass* pass, | 838 RenderPass* pass, |
834 const SkXfermode::Mode blend_mode) { | 839 const SkXfermode::Mode blend_mode) { |
835 const gfx::Transform layer_to_target_transform; | 840 const gfx::Transform layer_to_target_transform; |
836 const gfx::Size layer_bounds(size); | 841 const gfx::Size layer_bounds(size); |
837 const gfx::Rect visible_layer_rect(size); | 842 const gfx::Rect visible_layer_rect(size); |
838 const gfx::Rect clip_rect(size); | 843 const gfx::Rect clip_rect(size); |
839 | 844 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
882 TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateSharedQuadStateProperties) { | 887 TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateSharedQuadStateProperties) { |
883 const SkXfermode::Mode blend_modes[] = {SkXfermode::kClear_Mode, // 0 | 888 const SkXfermode::Mode blend_modes[] = {SkXfermode::kClear_Mode, // 0 |
884 SkXfermode::kSrc_Mode, // 1 | 889 SkXfermode::kSrc_Mode, // 1 |
885 SkXfermode::kDst_Mode, // 2 | 890 SkXfermode::kDst_Mode, // 2 |
886 SkXfermode::kSrcOver_Mode, // 3 | 891 SkXfermode::kSrcOver_Mode, // 3 |
887 SkXfermode::kDstOver_Mode, // 4 | 892 SkXfermode::kDstOver_Mode, // 4 |
888 SkXfermode::kSrcIn_Mode, // 5 | 893 SkXfermode::kSrcIn_Mode, // 5 |
889 SkXfermode::kDstIn_Mode, // 6 | 894 SkXfermode::kDstIn_Mode, // 6 |
890 }; | 895 }; |
891 | 896 |
897 SurfaceFactory grandchild_factory(FrameSinkId(2, 2), &manager_, | |
898 &empty_client_); | |
899 SurfaceFactory child_one_factory(FrameSinkId(3, 3), &manager_, | |
900 &empty_client_); | |
901 SurfaceFactory child_two_factory(FrameSinkId(4, 4), &manager_, | |
902 &empty_client_); | |
892 RenderPassId pass_id(1, 1); | 903 RenderPassId pass_id(1, 1); |
893 LocalFrameId grandchild_local_frame_id = allocator_.GenerateId(); | 904 LocalFrameId grandchild_local_frame_id = allocator_.GenerateId(); |
894 SurfaceId grandchild_surface_id(factory_.frame_sink_id(), | 905 SurfaceId grandchild_surface_id(grandchild_factory.frame_sink_id(), |
895 grandchild_local_frame_id); | 906 grandchild_local_frame_id); |
896 factory_.Create(grandchild_local_frame_id); | 907 grandchild_factory.SubmitCompositorFrame(grandchild_local_frame_id, |
908 CompositorFrame(), | |
909 SurfaceFactory::DrawCallback()); | |
897 std::unique_ptr<RenderPass> grandchild_pass = RenderPass::Create(); | 910 std::unique_ptr<RenderPass> grandchild_pass = RenderPass::Create(); |
898 gfx::Rect output_rect(SurfaceSize()); | 911 gfx::Rect output_rect(SurfaceSize()); |
899 gfx::Rect damage_rect(SurfaceSize()); | 912 gfx::Rect damage_rect(SurfaceSize()); |
900 gfx::Transform transform_to_root_target; | 913 gfx::Transform transform_to_root_target; |
901 grandchild_pass->SetNew( | 914 grandchild_pass->SetNew( |
902 pass_id, output_rect, damage_rect, transform_to_root_target); | 915 pass_id, output_rect, damage_rect, transform_to_root_target); |
903 AddSolidColorQuadWithBlendMode( | 916 AddSolidColorQuadWithBlendMode( |
904 SurfaceSize(), grandchild_pass.get(), blend_modes[2]); | 917 SurfaceSize(), grandchild_pass.get(), blend_modes[2]); |
905 QueuePassAsFrame(std::move(grandchild_pass), grandchild_local_frame_id); | 918 QueuePassAsFrame(std::move(grandchild_pass), grandchild_local_frame_id, |
919 &grandchild_factory); | |
906 | 920 |
907 LocalFrameId child_one_local_frame_id = allocator_.GenerateId(); | 921 LocalFrameId child_one_local_frame_id = allocator_.GenerateId(); |
908 SurfaceId child_one_surface_id(factory_.frame_sink_id(), | 922 SurfaceId child_one_surface_id(child_one_factory.frame_sink_id(), |
909 child_one_local_frame_id); | 923 child_one_local_frame_id); |
910 factory_.Create(child_one_local_frame_id); | 924 child_one_factory.SubmitCompositorFrame(child_one_local_frame_id, |
925 CompositorFrame(), | |
926 SurfaceFactory::DrawCallback()); | |
911 | 927 |
912 std::unique_ptr<RenderPass> child_one_pass = RenderPass::Create(); | 928 std::unique_ptr<RenderPass> child_one_pass = RenderPass::Create(); |
913 child_one_pass->SetNew( | 929 child_one_pass->SetNew( |
914 pass_id, output_rect, damage_rect, transform_to_root_target); | 930 pass_id, output_rect, damage_rect, transform_to_root_target); |
915 AddSolidColorQuadWithBlendMode( | 931 AddSolidColorQuadWithBlendMode( |
916 SurfaceSize(), child_one_pass.get(), blend_modes[1]); | 932 SurfaceSize(), child_one_pass.get(), blend_modes[1]); |
917 SurfaceDrawQuad* grandchild_surface_quad = | 933 SurfaceDrawQuad* grandchild_surface_quad = |
918 child_one_pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); | 934 child_one_pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); |
919 grandchild_surface_quad->SetNew(child_one_pass->shared_quad_state_list.back(), | 935 grandchild_surface_quad->SetNew(child_one_pass->shared_quad_state_list.back(), |
920 gfx::Rect(SurfaceSize()), | 936 gfx::Rect(SurfaceSize()), |
921 gfx::Rect(SurfaceSize()), | 937 gfx::Rect(SurfaceSize()), |
922 grandchild_surface_id); | 938 grandchild_surface_id); |
923 AddSolidColorQuadWithBlendMode( | 939 AddSolidColorQuadWithBlendMode( |
924 SurfaceSize(), child_one_pass.get(), blend_modes[3]); | 940 SurfaceSize(), child_one_pass.get(), blend_modes[3]); |
925 QueuePassAsFrame(std::move(child_one_pass), child_one_local_frame_id); | 941 QueuePassAsFrame(std::move(child_one_pass), child_one_local_frame_id, |
942 &child_one_factory); | |
926 | 943 |
927 LocalFrameId child_two_local_frame_id = allocator_.GenerateId(); | 944 LocalFrameId child_two_local_frame_id = allocator_.GenerateId(); |
928 SurfaceId child_two_surface_id(factory_.frame_sink_id(), | 945 SurfaceId child_two_surface_id(child_two_factory.frame_sink_id(), |
929 child_two_local_frame_id); | 946 child_two_local_frame_id); |
930 factory_.Create(child_two_local_frame_id); | 947 child_two_factory.SubmitCompositorFrame(child_two_local_frame_id, |
948 CompositorFrame(), | |
949 SurfaceFactory::DrawCallback()); | |
931 | 950 |
932 std::unique_ptr<RenderPass> child_two_pass = RenderPass::Create(); | 951 std::unique_ptr<RenderPass> child_two_pass = RenderPass::Create(); |
933 child_two_pass->SetNew( | 952 child_two_pass->SetNew( |
934 pass_id, output_rect, damage_rect, transform_to_root_target); | 953 pass_id, output_rect, damage_rect, transform_to_root_target); |
935 AddSolidColorQuadWithBlendMode( | 954 AddSolidColorQuadWithBlendMode( |
936 SurfaceSize(), child_two_pass.get(), blend_modes[5]); | 955 SurfaceSize(), child_two_pass.get(), blend_modes[5]); |
937 QueuePassAsFrame(std::move(child_two_pass), child_two_local_frame_id); | 956 QueuePassAsFrame(std::move(child_two_pass), child_two_local_frame_id, |
957 &child_two_factory); | |
938 | 958 |
939 std::unique_ptr<RenderPass> root_pass = RenderPass::Create(); | 959 std::unique_ptr<RenderPass> root_pass = RenderPass::Create(); |
940 root_pass->SetNew( | 960 root_pass->SetNew( |
941 pass_id, output_rect, damage_rect, transform_to_root_target); | 961 pass_id, output_rect, damage_rect, transform_to_root_target); |
942 | 962 |
943 AddSolidColorQuadWithBlendMode( | 963 AddSolidColorQuadWithBlendMode( |
944 SurfaceSize(), root_pass.get(), blend_modes[0]); | 964 SurfaceSize(), root_pass.get(), blend_modes[0]); |
945 SurfaceDrawQuad* child_one_surface_quad = | 965 SurfaceDrawQuad* child_one_surface_quad = |
946 root_pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); | 966 root_pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); |
947 child_one_surface_quad->SetNew(root_pass->shared_quad_state_list.back(), | 967 child_one_surface_quad->SetNew(root_pass->shared_quad_state_list.back(), |
948 gfx::Rect(SurfaceSize()), | 968 gfx::Rect(SurfaceSize()), |
949 gfx::Rect(SurfaceSize()), | 969 gfx::Rect(SurfaceSize()), |
950 child_one_surface_id); | 970 child_one_surface_id); |
951 AddSolidColorQuadWithBlendMode( | 971 AddSolidColorQuadWithBlendMode( |
952 SurfaceSize(), root_pass.get(), blend_modes[4]); | 972 SurfaceSize(), root_pass.get(), blend_modes[4]); |
953 SurfaceDrawQuad* child_two_surface_quad = | 973 SurfaceDrawQuad* child_two_surface_quad = |
954 root_pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); | 974 root_pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); |
955 child_two_surface_quad->SetNew(root_pass->shared_quad_state_list.back(), | 975 child_two_surface_quad->SetNew(root_pass->shared_quad_state_list.back(), |
956 gfx::Rect(SurfaceSize()), | 976 gfx::Rect(SurfaceSize()), |
957 gfx::Rect(SurfaceSize()), | 977 gfx::Rect(SurfaceSize()), |
958 child_two_surface_id); | 978 child_two_surface_id); |
959 AddSolidColorQuadWithBlendMode( | 979 AddSolidColorQuadWithBlendMode( |
960 SurfaceSize(), root_pass.get(), blend_modes[6]); | 980 SurfaceSize(), root_pass.get(), blend_modes[6]); |
961 | 981 |
962 QueuePassAsFrame(std::move(root_pass), root_local_frame_id_); | 982 QueuePassAsFrame(std::move(root_pass), root_local_frame_id_, &factory_); |
963 | 983 |
964 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id_); | 984 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id_); |
965 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); | 985 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); |
966 | 986 |
967 const RenderPassList& aggregated_pass_list = | 987 const RenderPassList& aggregated_pass_list = |
968 aggregated_frame.render_pass_list; | 988 aggregated_frame.render_pass_list; |
969 | 989 |
970 ASSERT_EQ(1u, aggregated_pass_list.size()); | 990 ASSERT_EQ(1u, aggregated_pass_list.size()); |
971 | 991 |
972 const QuadList& aggregated_quad_list = aggregated_pass_list[0]->quad_list; | 992 const QuadList& aggregated_quad_list = aggregated_pass_list[0]->quad_list; |
973 | 993 |
974 ASSERT_EQ(7u, aggregated_quad_list.size()); | 994 ASSERT_EQ(7u, aggregated_quad_list.size()); |
975 | 995 |
976 for (auto iter = aggregated_quad_list.cbegin(); | 996 for (auto iter = aggregated_quad_list.cbegin(); |
977 iter != aggregated_quad_list.cend(); | 997 iter != aggregated_quad_list.cend(); |
978 ++iter) { | 998 ++iter) { |
979 EXPECT_EQ(blend_modes[iter.index()], iter->shared_quad_state->blend_mode) | 999 EXPECT_EQ(blend_modes[iter.index()], iter->shared_quad_state->blend_mode) |
980 << iter.index(); | 1000 << iter.index(); |
981 } | 1001 } |
982 factory_.Destroy(child_one_local_frame_id); | 1002 |
983 factory_.Destroy(child_two_local_frame_id); | 1003 grandchild_factory.EvictSurface(); |
984 factory_.Destroy(grandchild_local_frame_id); | 1004 child_one_factory.EvictSurface(); |
1005 child_two_factory.EvictSurface(); | |
985 } | 1006 } |
986 | 1007 |
987 // This tests that when aggregating a frame with multiple render passes that we | 1008 // This tests that when aggregating a frame with multiple render passes that we |
988 // map the transforms for the root pass but do not modify the transform on child | 1009 // map the transforms for the root pass but do not modify the transform on child |
989 // passes. | 1010 // passes. |
990 // | 1011 // |
991 // The root surface has one pass with a surface quad transformed by +10 in the y | 1012 // The root surface has one pass with a surface quad transformed by +10 in the y |
992 // direction. | 1013 // direction. |
993 // | 1014 // |
994 // The middle surface has one pass with a surface quad scaled by 2 in the x | 1015 // The middle surface has one pass with a surface quad scaled by 2 in the x |
995 // and 3 in the y directions. | 1016 // and 3 in the y directions. |
996 // | 1017 // |
997 // The child surface has two passes. The first pass has a quad with a transform | 1018 // The child surface has two passes. The first pass has a quad with a transform |
998 // of +5 in the x direction. The second pass has a reference to the first pass' | 1019 // of +5 in the x direction. The second pass has a reference to the first pass' |
999 // pass id and a transform of +8 in the x direction. | 1020 // pass id and a transform of +8 in the x direction. |
1000 // | 1021 // |
1001 // After aggregation, the child surface's root pass quad should have all | 1022 // After aggregation, the child surface's root pass quad should have all |
1002 // transforms concatenated for a total transform of +23 x, +10 y. The | 1023 // transforms concatenated for a total transform of +23 x, +10 y. The |
1003 // contributing render pass' transform in the aggregate frame should not be | 1024 // contributing render pass' transform in the aggregate frame should not be |
1004 // affected. | 1025 // affected. |
1005 TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateMultiplePassWithTransform) { | 1026 TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateMultiplePassWithTransform) { |
1027 SurfaceFactory middle_factory(kArbitraryMiddleFrameSinkId, &manager_, | |
1028 &empty_client_); | |
1006 // Innermost child surface. | 1029 // Innermost child surface. |
1007 LocalFrameId child_local_frame_id = allocator_.GenerateId(); | 1030 LocalFrameId child_local_frame_id = allocator_.GenerateId(); |
1008 SurfaceId child_surface_id(factory_.frame_sink_id(), child_local_frame_id); | 1031 SurfaceId child_surface_id(child_factory_.frame_sink_id(), |
1009 factory_.Create(child_local_frame_id); | 1032 child_local_frame_id); |
1010 { | 1033 { |
1011 RenderPassId child_pass_id[] = {RenderPassId(1, 1), RenderPassId(1, 2)}; | 1034 RenderPassId child_pass_id[] = {RenderPassId(1, 1), RenderPassId(1, 2)}; |
1012 test::Quad child_quads[][1] = { | 1035 test::Quad child_quads[][1] = { |
1013 {test::Quad::SolidColorQuad(SK_ColorGREEN)}, | 1036 {test::Quad::SolidColorQuad(SK_ColorGREEN)}, |
1014 {test::Quad::RenderPassQuad(child_pass_id[0])}, | 1037 {test::Quad::RenderPassQuad(child_pass_id[0])}, |
1015 }; | 1038 }; |
1016 test::Pass child_passes[] = { | 1039 test::Pass child_passes[] = { |
1017 test::Pass(child_quads[0], arraysize(child_quads[0]), child_pass_id[0]), | 1040 test::Pass(child_quads[0], arraysize(child_quads[0]), child_pass_id[0]), |
1018 test::Pass(child_quads[1], arraysize(child_quads[1]), | 1041 test::Pass(child_quads[1], arraysize(child_quads[1]), |
1019 child_pass_id[1])}; | 1042 child_pass_id[1])}; |
1020 | 1043 |
1021 CompositorFrame child_frame; | 1044 CompositorFrame child_frame; |
1022 AddPasses(&child_frame.render_pass_list, gfx::Rect(SurfaceSize()), | 1045 AddPasses(&child_frame.render_pass_list, gfx::Rect(SurfaceSize()), |
1023 child_passes, arraysize(child_passes)); | 1046 child_passes, arraysize(child_passes)); |
1024 | 1047 |
1025 RenderPass* child_nonroot_pass = child_frame.render_pass_list[0].get(); | 1048 RenderPass* child_nonroot_pass = child_frame.render_pass_list[0].get(); |
1026 child_nonroot_pass->transform_to_root_target.Translate(8, 0); | 1049 child_nonroot_pass->transform_to_root_target.Translate(8, 0); |
1027 SharedQuadState* child_nonroot_pass_sqs = | 1050 SharedQuadState* child_nonroot_pass_sqs = |
1028 child_nonroot_pass->shared_quad_state_list.front(); | 1051 child_nonroot_pass->shared_quad_state_list.front(); |
1029 child_nonroot_pass_sqs->quad_to_target_transform.Translate(5, 0); | 1052 child_nonroot_pass_sqs->quad_to_target_transform.Translate(5, 0); |
1030 | 1053 |
1031 RenderPass* child_root_pass = child_frame.render_pass_list[1].get(); | 1054 RenderPass* child_root_pass = child_frame.render_pass_list[1].get(); |
1032 SharedQuadState* child_root_pass_sqs = | 1055 SharedQuadState* child_root_pass_sqs = |
1033 child_root_pass->shared_quad_state_list.front(); | 1056 child_root_pass->shared_quad_state_list.front(); |
1034 child_root_pass_sqs->quad_to_target_transform.Translate(8, 0); | 1057 child_root_pass_sqs->quad_to_target_transform.Translate(8, 0); |
1035 child_root_pass_sqs->is_clipped = true; | 1058 child_root_pass_sqs->is_clipped = true; |
1036 child_root_pass_sqs->clip_rect = gfx::Rect(0, 0, 5, 5); | 1059 child_root_pass_sqs->clip_rect = gfx::Rect(0, 0, 5, 5); |
1037 | 1060 |
1038 factory_.SubmitCompositorFrame(child_local_frame_id, std::move(child_frame), | 1061 child_factory_.SubmitCompositorFrame(child_local_frame_id, |
1039 SurfaceFactory::DrawCallback()); | 1062 std::move(child_frame), |
1063 SurfaceFactory::DrawCallback()); | |
1040 } | 1064 } |
1041 | 1065 |
1042 // Middle child surface. | 1066 // Middle child surface. |
1043 LocalFrameId middle_local_frame_id = allocator_.GenerateId(); | 1067 LocalFrameId middle_local_frame_id = allocator_.GenerateId(); |
1044 SurfaceId middle_surface_id(factory_.frame_sink_id(), middle_local_frame_id); | 1068 SurfaceId middle_surface_id(middle_factory.frame_sink_id(), |
1045 factory_.Create(middle_local_frame_id); | 1069 middle_local_frame_id); |
1046 { | 1070 { |
1047 test::Quad middle_quads[] = { | 1071 test::Quad middle_quads[] = { |
1048 test::Quad::SurfaceQuad(child_surface_id, 1.f)}; | 1072 test::Quad::SurfaceQuad(child_surface_id, 1.f)}; |
1049 test::Pass middle_passes[] = { | 1073 test::Pass middle_passes[] = { |
1050 test::Pass(middle_quads, arraysize(middle_quads)), | 1074 test::Pass(middle_quads, arraysize(middle_quads)), |
1051 }; | 1075 }; |
1052 | 1076 |
1053 CompositorFrame middle_frame; | 1077 CompositorFrame middle_frame; |
1054 AddPasses(&middle_frame.render_pass_list, gfx::Rect(SurfaceSize()), | 1078 AddPasses(&middle_frame.render_pass_list, gfx::Rect(SurfaceSize()), |
1055 middle_passes, arraysize(middle_passes)); | 1079 middle_passes, arraysize(middle_passes)); |
1056 | 1080 |
1057 RenderPass* middle_root_pass = middle_frame.render_pass_list[0].get(); | 1081 RenderPass* middle_root_pass = middle_frame.render_pass_list[0].get(); |
1058 middle_root_pass->quad_list.ElementAt(0)->visible_rect = | 1082 middle_root_pass->quad_list.ElementAt(0)->visible_rect = |
1059 gfx::Rect(0, 1, 100, 7); | 1083 gfx::Rect(0, 1, 100, 7); |
1060 SharedQuadState* middle_root_pass_sqs = | 1084 SharedQuadState* middle_root_pass_sqs = |
1061 middle_root_pass->shared_quad_state_list.front(); | 1085 middle_root_pass->shared_quad_state_list.front(); |
1062 middle_root_pass_sqs->quad_to_target_transform.Scale(2, 3); | 1086 middle_root_pass_sqs->quad_to_target_transform.Scale(2, 3); |
1063 | 1087 |
1064 factory_.SubmitCompositorFrame(middle_local_frame_id, | 1088 middle_factory.SubmitCompositorFrame(middle_local_frame_id, |
1065 std::move(middle_frame), | 1089 std::move(middle_frame), |
1066 SurfaceFactory::DrawCallback()); | 1090 SurfaceFactory::DrawCallback()); |
1067 } | 1091 } |
1068 | 1092 |
1069 // Root surface. | 1093 // Root surface. |
1070 test::Quad secondary_quads[] = { | 1094 test::Quad secondary_quads[] = { |
1071 test::Quad::SolidColorQuad(1), | 1095 test::Quad::SolidColorQuad(1), |
1072 test::Quad::SurfaceQuad(middle_surface_id, 1.f)}; | 1096 test::Quad::SurfaceQuad(middle_surface_id, 1.f)}; |
1073 test::Quad root_quads[] = {test::Quad::SolidColorQuad(1)}; | 1097 test::Quad root_quads[] = {test::Quad::SolidColorQuad(1)}; |
1074 test::Pass root_passes[] = { | 1098 test::Pass root_passes[] = { |
1075 test::Pass(secondary_quads, arraysize(secondary_quads)), | 1099 test::Pass(secondary_quads, arraysize(secondary_quads)), |
1076 test::Pass(root_quads, arraysize(root_quads))}; | 1100 test::Pass(root_quads, arraysize(root_quads))}; |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1159 aggregated_pass_list[1]->shared_quad_state_list.ElementAt(1)->is_clipped); | 1183 aggregated_pass_list[1]->shared_quad_state_list.ElementAt(1)->is_clipped); |
1160 | 1184 |
1161 // The second quad in the root pass is aggregated from the child, so its | 1185 // The second quad in the root pass is aggregated from the child, so its |
1162 // clip rect must be transformed by the child's translation/scale and | 1186 // clip rect must be transformed by the child's translation/scale and |
1163 // clipped be the visible_rects for both children. | 1187 // clipped be the visible_rects for both children. |
1164 EXPECT_EQ(gfx::Rect(0, 13, 8, 12).ToString(), | 1188 EXPECT_EQ(gfx::Rect(0, 13, 8, 12).ToString(), |
1165 aggregated_pass_list[1] | 1189 aggregated_pass_list[1] |
1166 ->shared_quad_state_list.ElementAt(1) | 1190 ->shared_quad_state_list.ElementAt(1) |
1167 ->clip_rect.ToString()); | 1191 ->clip_rect.ToString()); |
1168 | 1192 |
1169 factory_.Destroy(middle_local_frame_id); | 1193 middle_factory.EvictSurface(); |
1170 factory_.Destroy(child_local_frame_id); | |
1171 } | 1194 } |
1172 | 1195 |
1173 // Tests that damage rects are aggregated correctly when surfaces change. | 1196 // Tests that damage rects are aggregated correctly when surfaces change. |
1174 TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateDamageRect) { | 1197 TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateDamageRect) { |
1198 SurfaceFactory parent_factory(kArbitraryMiddleFrameSinkId, &manager_, | |
1199 &empty_client_); | |
1175 test::Quad child_quads[] = {test::Quad::RenderPassQuad(RenderPassId(1, 1))}; | 1200 test::Quad child_quads[] = {test::Quad::RenderPassQuad(RenderPassId(1, 1))}; |
1176 test::Pass child_passes[] = { | 1201 test::Pass child_passes[] = { |
1177 test::Pass(child_quads, arraysize(child_quads), RenderPassId(1, 1))}; | 1202 test::Pass(child_quads, arraysize(child_quads), RenderPassId(1, 1))}; |
1178 | 1203 |
1179 CompositorFrame child_frame; | 1204 CompositorFrame child_frame; |
1180 AddPasses(&child_frame.render_pass_list, gfx::Rect(SurfaceSize()), | 1205 AddPasses(&child_frame.render_pass_list, gfx::Rect(SurfaceSize()), |
1181 child_passes, arraysize(child_passes)); | 1206 child_passes, arraysize(child_passes)); |
1182 | 1207 |
1183 RenderPass* child_root_pass = child_frame.render_pass_list[0].get(); | 1208 RenderPass* child_root_pass = child_frame.render_pass_list[0].get(); |
1184 SharedQuadState* child_root_pass_sqs = | 1209 SharedQuadState* child_root_pass_sqs = |
1185 child_root_pass->shared_quad_state_list.front(); | 1210 child_root_pass->shared_quad_state_list.front(); |
1186 child_root_pass_sqs->quad_to_target_transform.Translate(8, 0); | 1211 child_root_pass_sqs->quad_to_target_transform.Translate(8, 0); |
1187 | 1212 |
1188 LocalFrameId child_local_frame_id = allocator_.GenerateId(); | 1213 LocalFrameId child_local_frame_id = allocator_.GenerateId(); |
1189 SurfaceId child_surface_id(factory_.frame_sink_id(), child_local_frame_id); | 1214 SurfaceId child_surface_id(child_factory_.frame_sink_id(), |
1190 factory_.Create(child_local_frame_id); | 1215 child_local_frame_id); |
1191 factory_.SubmitCompositorFrame(child_local_frame_id, std::move(child_frame), | 1216 child_factory_.SubmitCompositorFrame(child_local_frame_id, |
1192 SurfaceFactory::DrawCallback()); | 1217 std::move(child_frame), |
1218 SurfaceFactory::DrawCallback()); | |
1193 | 1219 |
1194 test::Quad parent_surface_quads[] = { | 1220 test::Quad parent_surface_quads[] = { |
1195 test::Quad::SurfaceQuad(child_surface_id, 1.f)}; | 1221 test::Quad::SurfaceQuad(child_surface_id, 1.f)}; |
1196 test::Pass parent_surface_passes[] = { | 1222 test::Pass parent_surface_passes[] = { |
1197 test::Pass(parent_surface_quads, arraysize(parent_surface_quads), | 1223 test::Pass(parent_surface_quads, arraysize(parent_surface_quads), |
1198 RenderPassId(1, 1))}; | 1224 RenderPassId(1, 1))}; |
1199 | 1225 |
1200 // Parent surface is only used to test if the transform is applied correctly | 1226 // Parent surface is only used to test if the transform is applied correctly |
1201 // to the child surface's damage. | 1227 // to the child surface's damage. |
1202 CompositorFrame parent_surface_frame; | 1228 CompositorFrame parent_surface_frame; |
1203 AddPasses(&parent_surface_frame.render_pass_list, gfx::Rect(SurfaceSize()), | 1229 AddPasses(&parent_surface_frame.render_pass_list, gfx::Rect(SurfaceSize()), |
1204 parent_surface_passes, arraysize(parent_surface_passes)); | 1230 parent_surface_passes, arraysize(parent_surface_passes)); |
1205 | 1231 |
1206 LocalFrameId parent_local_frame_id = allocator_.GenerateId(); | 1232 LocalFrameId parent_local_frame_id = allocator_.GenerateId(); |
1207 SurfaceId parent_surface_id(factory_.frame_sink_id(), parent_local_frame_id); | 1233 SurfaceId parent_surface_id(parent_factory.frame_sink_id(), |
1208 factory_.Create(parent_local_frame_id); | 1234 parent_local_frame_id); |
1209 factory_.SubmitCompositorFrame(parent_local_frame_id, | 1235 parent_factory.SubmitCompositorFrame(parent_local_frame_id, |
1210 std::move(parent_surface_frame), | 1236 std::move(parent_surface_frame), |
1211 SurfaceFactory::DrawCallback()); | 1237 SurfaceFactory::DrawCallback()); |
1212 | 1238 |
1213 test::Quad root_surface_quads[] = { | 1239 test::Quad root_surface_quads[] = { |
1214 test::Quad::SurfaceQuad(parent_surface_id, 1.f)}; | 1240 test::Quad::SurfaceQuad(parent_surface_id, 1.f)}; |
1215 test::Quad root_render_pass_quads[] = { | 1241 test::Quad root_render_pass_quads[] = { |
1216 test::Quad::RenderPassQuad(RenderPassId(1, 1))}; | 1242 test::Quad::RenderPassQuad(RenderPassId(1, 1))}; |
1217 | 1243 |
1218 test::Pass root_passes[] = { | 1244 test::Pass root_passes[] = { |
1219 test::Pass(root_surface_quads, arraysize(root_surface_quads), | 1245 test::Pass(root_surface_quads, arraysize(root_surface_quads), |
1220 RenderPassId(1, 1)), | 1246 RenderPassId(1, 1)), |
1221 test::Pass(root_render_pass_quads, arraysize(root_render_pass_quads), | 1247 test::Pass(root_render_pass_quads, arraysize(root_render_pass_quads), |
(...skipping 28 matching lines...) Expand all Loading... | |
1250 CompositorFrame child_frame; | 1276 CompositorFrame child_frame; |
1251 AddPasses(&child_frame.render_pass_list, gfx::Rect(SurfaceSize()), | 1277 AddPasses(&child_frame.render_pass_list, gfx::Rect(SurfaceSize()), |
1252 child_passes, arraysize(child_passes)); | 1278 child_passes, arraysize(child_passes)); |
1253 | 1279 |
1254 RenderPass* child_root_pass = child_frame.render_pass_list[0].get(); | 1280 RenderPass* child_root_pass = child_frame.render_pass_list[0].get(); |
1255 SharedQuadState* child_root_pass_sqs = | 1281 SharedQuadState* child_root_pass_sqs = |
1256 child_root_pass->shared_quad_state_list.front(); | 1282 child_root_pass->shared_quad_state_list.front(); |
1257 child_root_pass_sqs->quad_to_target_transform.Translate(8, 0); | 1283 child_root_pass_sqs->quad_to_target_transform.Translate(8, 0); |
1258 child_root_pass->damage_rect = gfx::Rect(10, 10, 10, 10); | 1284 child_root_pass->damage_rect = gfx::Rect(10, 10, 10, 10); |
1259 | 1285 |
1260 factory_.SubmitCompositorFrame(child_local_frame_id, std::move(child_frame), | 1286 child_factory_.SubmitCompositorFrame(child_local_frame_id, |
1261 SurfaceFactory::DrawCallback()); | 1287 std::move(child_frame), |
1288 SurfaceFactory::DrawCallback()); | |
1262 | 1289 |
1263 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id_); | 1290 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id_); |
1264 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); | 1291 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); |
1265 | 1292 |
1266 const RenderPassList& aggregated_pass_list = | 1293 const RenderPassList& aggregated_pass_list = |
1267 aggregated_frame.render_pass_list; | 1294 aggregated_frame.render_pass_list; |
1268 | 1295 |
1269 ASSERT_EQ(2u, aggregated_pass_list.size()); | 1296 ASSERT_EQ(2u, aggregated_pass_list.size()); |
1270 | 1297 |
1271 // Outer surface didn't change, so transformed inner damage rect should be | 1298 // Outer surface didn't change, so transformed inner damage rect should be |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1336 | 1363 |
1337 const RenderPassList& aggregated_pass_list = | 1364 const RenderPassList& aggregated_pass_list = |
1338 aggregated_frame.render_pass_list; | 1365 aggregated_frame.render_pass_list; |
1339 | 1366 |
1340 ASSERT_EQ(2u, aggregated_pass_list.size()); | 1367 ASSERT_EQ(2u, aggregated_pass_list.size()); |
1341 | 1368 |
1342 EXPECT_TRUE(aggregated_pass_list[1]->damage_rect.Contains( | 1369 EXPECT_TRUE(aggregated_pass_list[1]->damage_rect.Contains( |
1343 gfx::Rect(SurfaceSize()))); | 1370 gfx::Rect(SurfaceSize()))); |
1344 } | 1371 } |
1345 | 1372 |
1346 factory_.Destroy(child_local_frame_id); | 1373 parent_factory.EvictSurface(); |
1347 } | 1374 } |
1348 | 1375 |
1349 // Check that damage is correctly calculated for surfaces with | 1376 // Check that damage is correctly calculated for surfaces. |
1350 // SetPreviousFrameSurface. | |
1351 TEST_F(SurfaceAggregatorValidSurfaceTest, SwitchSurfaceDamage) { | 1377 TEST_F(SurfaceAggregatorValidSurfaceTest, SwitchSurfaceDamage) { |
1352 test::Quad root_render_pass_quads[] = {test::Quad::SolidColorQuad(1)}; | 1378 test::Quad root_render_pass_quads[] = {test::Quad::SolidColorQuad(1)}; |
1353 | 1379 |
1354 test::Pass root_passes[] = {test::Pass(root_render_pass_quads, | 1380 test::Pass root_passes[] = {test::Pass(root_render_pass_quads, |
1355 arraysize(root_render_pass_quads), | 1381 arraysize(root_render_pass_quads), |
1356 RenderPassId(2, 1))}; | 1382 RenderPassId(2, 1))}; |
1357 | 1383 |
1358 CompositorFrame root_frame; | 1384 CompositorFrame root_frame; |
1359 AddPasses(&root_frame.render_pass_list, gfx::Rect(SurfaceSize()), root_passes, | 1385 AddPasses(&root_frame.render_pass_list, gfx::Rect(SurfaceSize()), root_passes, |
1360 arraysize(root_passes)); | 1386 arraysize(root_passes)); |
(...skipping 26 matching lines...) Expand all Loading... | |
1387 test::Pass root_passes[] = {test::Pass(root_render_pass_quads, | 1413 test::Pass root_passes[] = {test::Pass(root_render_pass_quads, |
1388 arraysize(root_render_pass_quads), | 1414 arraysize(root_render_pass_quads), |
1389 RenderPassId(2, 1))}; | 1415 RenderPassId(2, 1))}; |
1390 | 1416 |
1391 CompositorFrame root_frame; | 1417 CompositorFrame root_frame; |
1392 AddPasses(&root_frame.render_pass_list, gfx::Rect(SurfaceSize()), | 1418 AddPasses(&root_frame.render_pass_list, gfx::Rect(SurfaceSize()), |
1393 root_passes, arraysize(root_passes)); | 1419 root_passes, arraysize(root_passes)); |
1394 | 1420 |
1395 root_frame.render_pass_list[0]->damage_rect = gfx::Rect(1, 2, 3, 4); | 1421 root_frame.render_pass_list[0]->damage_rect = gfx::Rect(1, 2, 3, 4); |
1396 | 1422 |
1397 factory_.Create(second_root_local_frame_id); | |
1398 factory_.SubmitCompositorFrame(second_root_local_frame_id, | 1423 factory_.SubmitCompositorFrame(second_root_local_frame_id, |
1399 std::move(root_frame), | 1424 std::move(root_frame), |
1400 SurfaceFactory::DrawCallback()); | 1425 SurfaceFactory::DrawCallback()); |
1401 factory_.SetPreviousFrameSurface(second_root_local_frame_id, | |
1402 root_local_frame_id_); | |
1403 } | 1426 } |
1404 { | 1427 { |
1405 CompositorFrame aggregated_frame = | 1428 CompositorFrame aggregated_frame = |
1406 aggregator_.Aggregate(second_root_surface_id); | 1429 aggregator_.Aggregate(second_root_surface_id); |
1407 | 1430 |
1408 const RenderPassList& aggregated_pass_list = | 1431 const RenderPassList& aggregated_pass_list = |
1409 aggregated_frame.render_pass_list; | 1432 aggregated_frame.render_pass_list; |
1410 | 1433 |
1411 ASSERT_EQ(1u, aggregated_pass_list.size()); | 1434 ASSERT_EQ(1u, aggregated_pass_list.size()); |
1412 | 1435 |
1413 // Frame from SetPreviousFrameSurface was aggregated last, so damage rect | |
1414 // from new surface should be used. | |
1415 EXPECT_EQ(gfx::Rect(1, 2, 3, 4), aggregated_pass_list[0]->damage_rect); | 1436 EXPECT_EQ(gfx::Rect(1, 2, 3, 4), aggregated_pass_list[0]->damage_rect); |
1416 } | 1437 } |
1417 { | 1438 { |
1418 CompositorFrame aggregated_frame = | 1439 CompositorFrame aggregated_frame = |
1419 aggregator_.Aggregate(second_root_surface_id); | 1440 aggregator_.Aggregate(second_root_surface_id); |
1420 | 1441 |
1421 const RenderPassList& aggregated_pass_list = | 1442 const RenderPassList& aggregated_pass_list = |
1422 aggregated_frame.render_pass_list; | 1443 aggregated_frame.render_pass_list; |
1423 | 1444 |
1424 ASSERT_EQ(1u, aggregated_pass_list.size()); | 1445 ASSERT_EQ(1u, aggregated_pass_list.size()); |
1425 | 1446 |
1426 // No new frame, so no new damage. | 1447 // No new frame, so no new damage. |
1427 EXPECT_TRUE(aggregated_pass_list[0]->damage_rect.IsEmpty()); | 1448 EXPECT_TRUE(aggregated_pass_list[0]->damage_rect.IsEmpty()); |
1428 } | 1449 } |
1429 factory_.Destroy(second_root_local_frame_id); | |
1430 } | 1450 } |
1431 | 1451 |
1432 class SurfaceAggregatorPartialSwapTest | 1452 class SurfaceAggregatorPartialSwapTest |
1433 : public SurfaceAggregatorValidSurfaceTest { | 1453 : public SurfaceAggregatorValidSurfaceTest { |
1434 public: | 1454 public: |
1435 SurfaceAggregatorPartialSwapTest() | 1455 SurfaceAggregatorPartialSwapTest() |
1436 : SurfaceAggregatorValidSurfaceTest(true) {} | 1456 : SurfaceAggregatorValidSurfaceTest(true) {} |
1437 }; | 1457 }; |
1438 | 1458 |
1439 // Tests that quads outside the damage rect are ignored. | 1459 // Tests that quads outside the damage rect are ignored. |
1440 TEST_F(SurfaceAggregatorPartialSwapTest, IgnoreOutside) { | 1460 TEST_F(SurfaceAggregatorPartialSwapTest, IgnoreOutside) { |
1441 LocalFrameId child_local_frame_id = allocator_.GenerateId(); | 1461 LocalFrameId child_local_frame_id = allocator_.GenerateId(); |
1442 SurfaceId child_surface_id(factory_.frame_sink_id(), child_local_frame_id); | 1462 SurfaceId child_surface_id(child_factory_.frame_sink_id(), |
1443 factory_.Create(child_local_frame_id); | 1463 child_local_frame_id); |
1444 // The child surface has three quads, one with a visible rect of 13,13 4x4 and | 1464 // The child surface has three quads, one with a visible rect of 13,13 4x4 and |
1445 // the other other with a visible rect of 10,10 2x2 (relative to root target | 1465 // the other other with a visible rect of 10,10 2x2 (relative to root target |
1446 // space), and one with a non-invertible transform. | 1466 // space), and one with a non-invertible transform. |
1447 { | 1467 { |
1448 RenderPassId child_pass_id = RenderPassId(1, 1); | 1468 RenderPassId child_pass_id = RenderPassId(1, 1); |
1449 test::Quad child_quads1[] = {test::Quad::RenderPassQuad(child_pass_id)}; | 1469 test::Quad child_quads1[] = {test::Quad::RenderPassQuad(child_pass_id)}; |
1450 test::Quad child_quads2[] = {test::Quad::RenderPassQuad(child_pass_id)}; | 1470 test::Quad child_quads2[] = {test::Quad::RenderPassQuad(child_pass_id)}; |
1451 test::Quad child_quads3[] = {test::Quad::RenderPassQuad(child_pass_id)}; | 1471 test::Quad child_quads3[] = {test::Quad::RenderPassQuad(child_pass_id)}; |
1452 test::Pass child_passes[] = { | 1472 test::Pass child_passes[] = { |
1453 test::Pass(child_quads1, arraysize(child_quads1), child_pass_id), | 1473 test::Pass(child_quads1, arraysize(child_quads1), child_pass_id), |
(...skipping 16 matching lines...) Expand all Loading... | |
1470 | 1490 |
1471 SharedQuadState* child_noninvertible_sqs = | 1491 SharedQuadState* child_noninvertible_sqs = |
1472 child_pass_list[2]->shared_quad_state_list.ElementAt(0u); | 1492 child_pass_list[2]->shared_quad_state_list.ElementAt(0u); |
1473 child_noninvertible_sqs->quad_to_target_transform.matrix().setDouble(0, 0, | 1493 child_noninvertible_sqs->quad_to_target_transform.matrix().setDouble(0, 0, |
1474 0.0); | 1494 0.0); |
1475 EXPECT_FALSE( | 1495 EXPECT_FALSE( |
1476 child_noninvertible_sqs->quad_to_target_transform.IsInvertible()); | 1496 child_noninvertible_sqs->quad_to_target_transform.IsInvertible()); |
1477 child_pass_list[2]->quad_list.ElementAt(0)->visible_rect = | 1497 child_pass_list[2]->quad_list.ElementAt(0)->visible_rect = |
1478 gfx::Rect(0, 0, 2, 2); | 1498 gfx::Rect(0, 0, 2, 2); |
1479 | 1499 |
1480 SubmitPassListAsFrame(&factory_, child_local_frame_id, &child_pass_list); | 1500 SubmitPassListAsFrame(&child_factory_, child_local_frame_id, |
1501 &child_pass_list); | |
1481 } | 1502 } |
1482 | 1503 |
1483 { | 1504 { |
1484 test::Quad root_quads[] = {test::Quad::SurfaceQuad(child_surface_id, 1.f)}; | 1505 test::Quad root_quads[] = {test::Quad::SurfaceQuad(child_surface_id, 1.f)}; |
1485 | 1506 |
1486 test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))}; | 1507 test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))}; |
1487 | 1508 |
1488 RenderPassList root_pass_list; | 1509 RenderPassList root_pass_list; |
1489 AddPasses(&root_pass_list, gfx::Rect(SurfaceSize()), root_passes, | 1510 AddPasses(&root_pass_list, gfx::Rect(SurfaceSize()), root_passes, |
1490 arraysize(root_passes)); | 1511 arraysize(root_passes)); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1568 child_sqs->quad_to_target_transform.Scale(2, 2); | 1589 child_sqs->quad_to_target_transform.Scale(2, 2); |
1569 | 1590 |
1570 child_pass_list[1]->quad_list.ElementAt(0)->visible_rect = | 1591 child_pass_list[1]->quad_list.ElementAt(0)->visible_rect = |
1571 gfx::Rect(0, 0, 2, 2); | 1592 gfx::Rect(0, 0, 2, 2); |
1572 | 1593 |
1573 RenderPass* child_root_pass = child_pass_list[1].get(); | 1594 RenderPass* child_root_pass = child_pass_list[1].get(); |
1574 | 1595 |
1575 child_root_pass->copy_requests.push_back( | 1596 child_root_pass->copy_requests.push_back( |
1576 CopyOutputRequest::CreateEmptyRequest()); | 1597 CopyOutputRequest::CreateEmptyRequest()); |
1577 child_root_pass->damage_rect = gfx::Rect(); | 1598 child_root_pass->damage_rect = gfx::Rect(); |
1578 SubmitPassListAsFrame(&factory_, child_local_frame_id, &child_pass_list); | 1599 SubmitPassListAsFrame(&child_factory_, child_local_frame_id, |
1600 &child_pass_list); | |
1579 } | 1601 } |
1580 | 1602 |
1581 { | 1603 { |
1582 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); | 1604 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); |
1583 | 1605 |
1584 const RenderPassList& aggregated_pass_list = | 1606 const RenderPassList& aggregated_pass_list = |
1585 aggregated_frame.render_pass_list; | 1607 aggregated_frame.render_pass_list; |
1586 | 1608 |
1587 // Output frame should have no damage, but all quads included. | 1609 // Output frame should have no damage, but all quads included. |
1588 ASSERT_EQ(3u, aggregated_pass_list.size()); | 1610 ASSERT_EQ(3u, aggregated_pass_list.size()); |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1695 EXPECT_EQ(0u, aggregated_pass_list[0]->quad_list.size()); | 1717 EXPECT_EQ(0u, aggregated_pass_list[0]->quad_list.size()); |
1696 EXPECT_EQ(gfx::Rect(SurfaceSize()), aggregated_pass_list[1]->damage_rect); | 1718 EXPECT_EQ(gfx::Rect(SurfaceSize()), aggregated_pass_list[1]->damage_rect); |
1697 EXPECT_EQ(1u, aggregated_pass_list[1]->quad_list.size()); | 1719 EXPECT_EQ(1u, aggregated_pass_list[1]->quad_list.size()); |
1698 | 1720 |
1699 // First render pass draw quad is outside damage rect, so shouldn't be | 1721 // First render pass draw quad is outside damage rect, so shouldn't be |
1700 // drawn. SurfaceDrawQuad is after background filter, so corresponding | 1722 // drawn. SurfaceDrawQuad is after background filter, so corresponding |
1701 // RenderPassDrawQuad should be drawn. | 1723 // RenderPassDrawQuad should be drawn. |
1702 EXPECT_EQ(gfx::Rect(10, 10, 2, 2), aggregated_pass_list[2]->damage_rect); | 1724 EXPECT_EQ(gfx::Rect(10, 10, 2, 2), aggregated_pass_list[2]->damage_rect); |
1703 EXPECT_EQ(1u, aggregated_pass_list[2]->quad_list.size()); | 1725 EXPECT_EQ(1u, aggregated_pass_list[2]->quad_list.size()); |
1704 } | 1726 } |
1705 | |
1706 factory_.Destroy(child_local_frame_id); | |
1707 } | 1727 } |
1708 | 1728 |
1709 class SurfaceAggregatorWithResourcesTest : public testing::Test { | 1729 class SurfaceAggregatorWithResourcesTest : public testing::Test { |
1710 public: | 1730 public: |
1711 void SetUp() override { | 1731 void SetUp() override { |
1712 shared_bitmap_manager_.reset(new TestSharedBitmapManager); | 1732 shared_bitmap_manager_.reset(new TestSharedBitmapManager); |
1713 resource_provider_ = | 1733 resource_provider_ = |
1714 FakeResourceProvider::Create(nullptr, shared_bitmap_manager_.get()); | 1734 FakeResourceProvider::Create(nullptr, shared_bitmap_manager_.get()); |
1715 | 1735 |
1716 aggregator_.reset( | 1736 aggregator_.reset( |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1788 uv_bottom_right, background_color, vertex_opacity, flipped, | 1808 uv_bottom_right, background_color, vertex_opacity, flipped, |
1789 nearest_neighbor, secure_output_only); | 1809 nearest_neighbor, secure_output_only); |
1790 } | 1810 } |
1791 frame.render_pass_list.push_back(std::move(pass)); | 1811 frame.render_pass_list.push_back(std::move(pass)); |
1792 factory->SubmitCompositorFrame(surface_id.local_frame_id(), std::move(frame), | 1812 factory->SubmitCompositorFrame(surface_id.local_frame_id(), std::move(frame), |
1793 SurfaceFactory::DrawCallback()); | 1813 SurfaceFactory::DrawCallback()); |
1794 } | 1814 } |
1795 | 1815 |
1796 TEST_F(SurfaceAggregatorWithResourcesTest, TakeResourcesOneSurface) { | 1816 TEST_F(SurfaceAggregatorWithResourcesTest, TakeResourcesOneSurface) { |
1797 ResourceTrackingSurfaceFactoryClient client; | 1817 ResourceTrackingSurfaceFactoryClient client; |
1798 SurfaceFactory factory(kArbitraryFrameSinkId, &manager_, &client); | 1818 SurfaceFactory factory(kArbitraryRootFrameSinkId, &manager_, &client); |
1799 LocalFrameId local_frame_id(7u, base::UnguessableToken::Create()); | 1819 LocalFrameId local_frame_id(7u, base::UnguessableToken::Create()); |
1800 SurfaceId surface_id(kArbitraryFrameSinkId, local_frame_id); | 1820 SurfaceId surface_id(factory.frame_sink_id(), local_frame_id); |
1801 factory.Create(local_frame_id); | |
1802 | 1821 |
1803 ResourceId ids[] = {11, 12, 13}; | 1822 ResourceId ids[] = {11, 12, 13}; |
1804 SubmitCompositorFrameWithResources(ids, arraysize(ids), true, SurfaceId(), | 1823 SubmitCompositorFrameWithResources(ids, arraysize(ids), true, SurfaceId(), |
1805 &factory, surface_id); | 1824 &factory, surface_id); |
1806 | 1825 |
1807 CompositorFrame frame = aggregator_->Aggregate(surface_id); | 1826 CompositorFrame frame = aggregator_->Aggregate(surface_id); |
1808 | 1827 |
1809 // Nothing should be available to be returned yet. | 1828 // Nothing should be available to be returned yet. |
1810 EXPECT_TRUE(client.returned_resources().empty()); | 1829 EXPECT_TRUE(client.returned_resources().empty()); |
1811 | 1830 |
1812 SubmitCompositorFrameWithResources(NULL, 0u, true, SurfaceId(), &factory, | 1831 SubmitCompositorFrameWithResources(NULL, 0u, true, SurfaceId(), &factory, |
1813 surface_id); | 1832 surface_id); |
1814 | 1833 |
1815 frame = aggregator_->Aggregate(surface_id); | 1834 frame = aggregator_->Aggregate(surface_id); |
1816 | 1835 |
1817 ASSERT_EQ(3u, client.returned_resources().size()); | 1836 ASSERT_EQ(3u, client.returned_resources().size()); |
1818 ResourceId returned_ids[3]; | 1837 ResourceId returned_ids[3]; |
1819 for (size_t i = 0; i < 3; ++i) { | 1838 for (size_t i = 0; i < 3; ++i) { |
1820 returned_ids[i] = client.returned_resources()[i].id; | 1839 returned_ids[i] = client.returned_resources()[i].id; |
1821 } | 1840 } |
1822 EXPECT_THAT(returned_ids, | 1841 EXPECT_THAT(returned_ids, |
1823 testing::WhenSorted(testing::ElementsAreArray(ids))); | 1842 testing::WhenSorted(testing::ElementsAreArray(ids))); |
1824 factory.Destroy(local_frame_id); | 1843 |
1844 factory.EvictSurface(); | |
1825 } | 1845 } |
1826 | 1846 |
1827 TEST_F(SurfaceAggregatorWithResourcesTest, TakeInvalidResources) { | 1847 TEST_F(SurfaceAggregatorWithResourcesTest, TakeInvalidResources) { |
1828 ResourceTrackingSurfaceFactoryClient client; | 1848 ResourceTrackingSurfaceFactoryClient client; |
1829 SurfaceFactory factory(kArbitraryFrameSinkId, &manager_, &client); | 1849 SurfaceFactory factory(kArbitraryRootFrameSinkId, &manager_, &client); |
1830 LocalFrameId local_frame_id(7u, base::UnguessableToken::Create()); | 1850 LocalFrameId local_frame_id(7u, base::UnguessableToken::Create()); |
1831 SurfaceId surface_id(kArbitraryFrameSinkId, local_frame_id); | 1851 SurfaceId surface_id(factory.frame_sink_id(), local_frame_id); |
1832 factory.Create(local_frame_id); | |
1833 | 1852 |
1834 CompositorFrame frame; | 1853 CompositorFrame frame; |
1835 std::unique_ptr<RenderPass> pass = RenderPass::Create(); | 1854 std::unique_ptr<RenderPass> pass = RenderPass::Create(); |
1836 pass->id = RenderPassId(1, 1); | 1855 pass->id = RenderPassId(1, 1); |
1837 TransferableResource resource; | 1856 TransferableResource resource; |
1838 resource.id = 11; | 1857 resource.id = 11; |
1839 // ResourceProvider is software but resource is not, so it should be | 1858 // ResourceProvider is software but resource is not, so it should be |
1840 // ignored. | 1859 // ignored. |
1841 resource.is_software = false; | 1860 resource.is_software = false; |
1842 frame.resource_list.push_back(resource); | 1861 frame.resource_list.push_back(resource); |
1843 frame.render_pass_list.push_back(std::move(pass)); | 1862 frame.render_pass_list.push_back(std::move(pass)); |
1844 factory.SubmitCompositorFrame(local_frame_id, std::move(frame), | 1863 factory.SubmitCompositorFrame(local_frame_id, std::move(frame), |
1845 SurfaceFactory::DrawCallback()); | 1864 SurfaceFactory::DrawCallback()); |
1846 | 1865 |
1847 CompositorFrame returned_frame = aggregator_->Aggregate(surface_id); | 1866 CompositorFrame returned_frame = aggregator_->Aggregate(surface_id); |
1848 | 1867 |
1849 // Nothing should be available to be returned yet. | 1868 // Nothing should be available to be returned yet. |
1850 EXPECT_TRUE(client.returned_resources().empty()); | 1869 EXPECT_TRUE(client.returned_resources().empty()); |
1851 | 1870 |
1852 SubmitCompositorFrameWithResources(NULL, 0, true, SurfaceId(), &factory, | 1871 SubmitCompositorFrameWithResources(NULL, 0, true, SurfaceId(), &factory, |
1853 surface_id); | 1872 surface_id); |
1854 ASSERT_EQ(1u, client.returned_resources().size()); | 1873 ASSERT_EQ(1u, client.returned_resources().size()); |
1855 EXPECT_EQ(11u, client.returned_resources()[0].id); | 1874 EXPECT_EQ(11u, client.returned_resources()[0].id); |
1856 | 1875 |
1857 factory.Destroy(local_frame_id); | 1876 factory.EvictSurface(); |
1858 } | 1877 } |
1859 | 1878 |
1860 TEST_F(SurfaceAggregatorWithResourcesTest, TwoSurfaces) { | 1879 TEST_F(SurfaceAggregatorWithResourcesTest, TwoSurfaces) { |
1861 ResourceTrackingSurfaceFactoryClient client; | 1880 ResourceTrackingSurfaceFactoryClient client; |
1862 SurfaceFactory factory(kArbitraryFrameSinkId, &manager_, &client); | 1881 SurfaceFactory factory1(FrameSinkId(1, 1), &manager_, &client); |
1882 SurfaceFactory factory2(FrameSinkId(2, 2), &manager_, &client); | |
1863 LocalFrameId local_frame1_id(7u, base::UnguessableToken::Create()); | 1883 LocalFrameId local_frame1_id(7u, base::UnguessableToken::Create()); |
1864 SurfaceId surface1_id(kArbitraryFrameSinkId, local_frame1_id); | 1884 SurfaceId surface1_id(factory1.frame_sink_id(), local_frame1_id); |
1865 factory.Create(local_frame1_id); | |
1866 | 1885 |
1867 LocalFrameId local_frame2_id(8u, base::UnguessableToken::Create()); | 1886 LocalFrameId local_frame2_id(8u, base::UnguessableToken::Create()); |
1868 SurfaceId surface2_id(kArbitraryFrameSinkId, local_frame2_id); | 1887 SurfaceId surface2_id(factory2.frame_sink_id(), local_frame2_id); |
1869 factory.Create(local_frame2_id); | |
1870 | 1888 |
1871 ResourceId ids[] = {11, 12, 13}; | 1889 ResourceId ids[] = {11, 12, 13}; |
1872 SubmitCompositorFrameWithResources(ids, arraysize(ids), true, SurfaceId(), | 1890 SubmitCompositorFrameWithResources(ids, arraysize(ids), true, SurfaceId(), |
1873 &factory, surface1_id); | 1891 &factory1, surface1_id); |
1874 ResourceId ids2[] = {14, 15, 16}; | 1892 ResourceId ids2[] = {14, 15, 16}; |
1875 SubmitCompositorFrameWithResources(ids2, arraysize(ids2), true, SurfaceId(), | 1893 SubmitCompositorFrameWithResources(ids2, arraysize(ids2), true, SurfaceId(), |
1876 &factory, surface2_id); | 1894 &factory2, surface2_id); |
1877 | 1895 |
1878 CompositorFrame frame = aggregator_->Aggregate(surface1_id); | 1896 CompositorFrame frame = aggregator_->Aggregate(surface1_id); |
1879 | 1897 |
1880 SubmitCompositorFrameWithResources(NULL, 0, true, SurfaceId(), &factory, | 1898 SubmitCompositorFrameWithResources(NULL, 0, true, SurfaceId(), &factory1, |
1881 surface1_id); | 1899 surface1_id); |
1882 | 1900 |
1883 // Nothing should be available to be returned yet. | 1901 // Nothing should be available to be returned yet. |
1884 EXPECT_TRUE(client.returned_resources().empty()); | 1902 EXPECT_TRUE(client.returned_resources().empty()); |
1885 | 1903 |
1886 frame = aggregator_->Aggregate(surface2_id); | 1904 frame = aggregator_->Aggregate(surface2_id); |
1887 | 1905 |
1888 // surface1_id wasn't referenced, so its resources should be returned. | 1906 // surface1_id wasn't referenced, so its resources should be returned. |
1889 ASSERT_EQ(3u, client.returned_resources().size()); | 1907 ASSERT_EQ(3u, client.returned_resources().size()); |
1890 ResourceId returned_ids[3]; | 1908 ResourceId returned_ids[3]; |
1891 for (size_t i = 0; i < 3; ++i) { | 1909 for (size_t i = 0; i < 3; ++i) { |
1892 returned_ids[i] = client.returned_resources()[i].id; | 1910 returned_ids[i] = client.returned_resources()[i].id; |
1893 } | 1911 } |
1894 EXPECT_THAT(returned_ids, | 1912 EXPECT_THAT(returned_ids, |
1895 testing::WhenSorted(testing::ElementsAreArray(ids))); | 1913 testing::WhenSorted(testing::ElementsAreArray(ids))); |
1896 EXPECT_EQ(3u, resource_provider_->num_resources()); | 1914 EXPECT_EQ(3u, resource_provider_->num_resources()); |
1897 factory.Destroy(local_frame1_id); | 1915 |
1898 factory.Destroy(local_frame2_id); | 1916 factory1.EvictSurface(); |
1917 factory2.EvictSurface(); | |
1899 } | 1918 } |
1900 | 1919 |
1901 // Ensure that aggregator completely ignores Surfaces that reference invalid | 1920 // Ensure that aggregator completely ignores Surfaces that reference invalid |
1902 // resources. | 1921 // resources. |
1903 TEST_F(SurfaceAggregatorWithResourcesTest, InvalidChildSurface) { | 1922 TEST_F(SurfaceAggregatorWithResourcesTest, InvalidChildSurface) { |
1904 ResourceTrackingSurfaceFactoryClient client; | 1923 ResourceTrackingSurfaceFactoryClient client; |
1905 SurfaceFactory factory(kArbitraryFrameSinkId, &manager_, &client); | 1924 SurfaceFactory root_factory(kArbitraryRootFrameSinkId, &manager_, &client); |
1925 SurfaceFactory middle_factory(kArbitraryMiddleFrameSinkId, &manager_, | |
1926 &client); | |
1927 SurfaceFactory child_factory(kArbitraryChildFrameSinkId, &manager_, &client); | |
1906 LocalFrameId root_local_frame_id(7u, kArbitraryToken); | 1928 LocalFrameId root_local_frame_id(7u, kArbitraryToken); |
1907 SurfaceId root_surface_id(kArbitraryFrameSinkId, root_local_frame_id); | 1929 SurfaceId root_surface_id(root_factory.frame_sink_id(), root_local_frame_id); |
1908 factory.Create(root_local_frame_id); | |
1909 LocalFrameId middle_local_frame_id(8u, kArbitraryToken); | 1930 LocalFrameId middle_local_frame_id(8u, kArbitraryToken); |
1910 SurfaceId middle_surface_id(kArbitraryFrameSinkId, middle_local_frame_id); | 1931 SurfaceId middle_surface_id(middle_factory.frame_sink_id(), |
1911 factory.Create(middle_local_frame_id); | 1932 middle_local_frame_id); |
1912 LocalFrameId child_local_frame_id(9u, kArbitraryToken); | 1933 LocalFrameId child_local_frame_id(9u, kArbitraryToken); |
1913 SurfaceId child_surface_id(kArbitraryFrameSinkId, child_local_frame_id); | 1934 SurfaceId child_surface_id(child_factory.frame_sink_id(), |
1914 factory.Create(child_local_frame_id); | 1935 child_local_frame_id); |
1915 | 1936 |
1916 ResourceId ids[] = {14, 15, 16}; | 1937 ResourceId ids[] = {14, 15, 16}; |
1917 SubmitCompositorFrameWithResources(ids, arraysize(ids), true, SurfaceId(), | 1938 SubmitCompositorFrameWithResources(ids, arraysize(ids), true, SurfaceId(), |
1918 &factory, child_surface_id); | 1939 &child_factory, child_surface_id); |
1919 | 1940 |
1920 ResourceId ids2[] = {17, 18, 19}; | 1941 ResourceId ids2[] = {17, 18, 19}; |
1921 SubmitCompositorFrameWithResources(ids2, arraysize(ids2), false, | 1942 SubmitCompositorFrameWithResources(ids2, arraysize(ids2), false, |
1922 child_surface_id, &factory, | 1943 child_surface_id, &middle_factory, |
1923 middle_surface_id); | 1944 middle_surface_id); |
1924 | 1945 |
1925 ResourceId ids3[] = {20, 21, 22}; | 1946 ResourceId ids3[] = {20, 21, 22}; |
1926 SubmitCompositorFrameWithResources(ids3, arraysize(ids3), true, | 1947 SubmitCompositorFrameWithResources(ids3, arraysize(ids3), true, |
1927 middle_surface_id, &factory, | 1948 middle_surface_id, &root_factory, |
1928 root_surface_id); | 1949 root_surface_id); |
1929 | 1950 |
1930 CompositorFrame frame; | 1951 CompositorFrame frame; |
1931 frame = aggregator_->Aggregate(root_surface_id); | 1952 frame = aggregator_->Aggregate(root_surface_id); |
1932 | 1953 |
1933 RenderPassList* pass_list = &frame.render_pass_list; | 1954 RenderPassList* pass_list = &frame.render_pass_list; |
1934 ASSERT_EQ(1u, pass_list->size()); | 1955 ASSERT_EQ(1u, pass_list->size()); |
1935 EXPECT_EQ(1u, pass_list->back()->shared_quad_state_list.size()); | 1956 EXPECT_EQ(1u, pass_list->back()->shared_quad_state_list.size()); |
1936 EXPECT_EQ(3u, pass_list->back()->quad_list.size()); | 1957 EXPECT_EQ(3u, pass_list->back()->quad_list.size()); |
1937 SubmitCompositorFrameWithResources(ids2, arraysize(ids), true, | 1958 SubmitCompositorFrameWithResources(ids2, arraysize(ids), true, |
1938 child_surface_id, &factory, | 1959 child_surface_id, &middle_factory, |
1939 middle_surface_id); | 1960 middle_surface_id); |
1940 | 1961 |
1941 frame = aggregator_->Aggregate(root_surface_id); | 1962 frame = aggregator_->Aggregate(root_surface_id); |
1942 | 1963 |
1943 pass_list = &frame.render_pass_list; | 1964 pass_list = &frame.render_pass_list; |
1944 ASSERT_EQ(1u, pass_list->size()); | 1965 ASSERT_EQ(1u, pass_list->size()); |
1945 EXPECT_EQ(3u, pass_list->back()->shared_quad_state_list.size()); | 1966 EXPECT_EQ(3u, pass_list->back()->shared_quad_state_list.size()); |
1946 EXPECT_EQ(9u, pass_list->back()->quad_list.size()); | 1967 EXPECT_EQ(9u, pass_list->back()->quad_list.size()); |
1947 | 1968 |
1948 factory.Destroy(root_local_frame_id); | 1969 root_factory.EvictSurface(); |
1949 factory.Destroy(child_local_frame_id); | 1970 middle_factory.EvictSurface(); |
1950 factory.Destroy(middle_local_frame_id); | 1971 child_factory.EvictSurface(); |
1951 } | 1972 } |
1952 | 1973 |
1953 TEST_F(SurfaceAggregatorWithResourcesTest, SecureOutputTexture) { | 1974 TEST_F(SurfaceAggregatorWithResourcesTest, SecureOutputTexture) { |
1954 ResourceTrackingSurfaceFactoryClient client; | 1975 ResourceTrackingSurfaceFactoryClient client; |
1955 SurfaceFactory factory(kArbitraryFrameSinkId, &manager_, &client); | 1976 SurfaceFactory factory1(FrameSinkId(1, 1), &manager_, &client); |
1977 SurfaceFactory factory2(FrameSinkId(2, 2), &manager_, &client); | |
1956 LocalFrameId local_frame1_id(7u, base::UnguessableToken::Create()); | 1978 LocalFrameId local_frame1_id(7u, base::UnguessableToken::Create()); |
1957 SurfaceId surface1_id(kArbitraryFrameSinkId, local_frame1_id); | 1979 SurfaceId surface1_id(factory1.frame_sink_id(), local_frame1_id); |
1958 factory.Create(local_frame1_id); | |
1959 | 1980 |
1960 LocalFrameId local_frame2_id(8u, base::UnguessableToken::Create()); | 1981 LocalFrameId local_frame2_id(8u, base::UnguessableToken::Create()); |
1961 SurfaceId surface2_id(kArbitraryFrameSinkId, local_frame2_id); | 1982 SurfaceId surface2_id(factory2.frame_sink_id(), local_frame2_id); |
1962 factory.Create(local_frame2_id); | |
1963 | 1983 |
1964 ResourceId ids[] = {11, 12, 13}; | 1984 ResourceId ids[] = {11, 12, 13}; |
1965 SubmitCompositorFrameWithResources(ids, arraysize(ids), true, SurfaceId(), | 1985 SubmitCompositorFrameWithResources(ids, arraysize(ids), true, SurfaceId(), |
1966 &factory, surface1_id); | 1986 &factory1, surface1_id); |
1967 | 1987 |
1968 CompositorFrame frame = aggregator_->Aggregate(surface1_id); | 1988 CompositorFrame frame = aggregator_->Aggregate(surface1_id); |
1969 | 1989 |
1970 RenderPass* render_pass = frame.render_pass_list.back().get(); | 1990 RenderPass* render_pass = frame.render_pass_list.back().get(); |
1971 | 1991 |
1972 EXPECT_EQ(DrawQuad::TEXTURE_CONTENT, render_pass->quad_list.back()->material); | 1992 EXPECT_EQ(DrawQuad::TEXTURE_CONTENT, render_pass->quad_list.back()->material); |
1973 | 1993 |
1974 { | 1994 { |
1975 std::unique_ptr<RenderPass> pass = RenderPass::Create(); | 1995 std::unique_ptr<RenderPass> pass = RenderPass::Create(); |
1976 pass->id = RenderPassId(1, 1); | 1996 pass->id = RenderPassId(1, 1); |
1977 SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState(); | 1997 SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState(); |
1978 sqs->opacity = 1.f; | 1998 sqs->opacity = 1.f; |
1979 SurfaceDrawQuad* surface_quad = | 1999 SurfaceDrawQuad* surface_quad = |
1980 pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); | 2000 pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); |
2001 | |
1981 surface_quad->SetNew(sqs, gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1), | 2002 surface_quad->SetNew(sqs, gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1), |
1982 surface1_id); | 2003 surface1_id); |
1983 pass->copy_requests.push_back(CopyOutputRequest::CreateEmptyRequest()); | 2004 pass->copy_requests.push_back(CopyOutputRequest::CreateEmptyRequest()); |
1984 | 2005 |
1985 CompositorFrame frame; | 2006 CompositorFrame frame; |
1986 frame.render_pass_list.push_back(std::move(pass)); | 2007 frame.render_pass_list.push_back(std::move(pass)); |
1987 | 2008 |
1988 factory.SubmitCompositorFrame(local_frame2_id, std::move(frame), | 2009 factory2.SubmitCompositorFrame(local_frame2_id, std::move(frame), |
1989 SurfaceFactory::DrawCallback()); | 2010 SurfaceFactory::DrawCallback()); |
1990 } | 2011 } |
1991 | 2012 |
1992 frame = aggregator_->Aggregate(surface2_id); | 2013 frame = aggregator_->Aggregate(surface2_id); |
1993 EXPECT_EQ(1u, frame.render_pass_list.size()); | 2014 EXPECT_EQ(1u, frame.render_pass_list.size()); |
1994 render_pass = frame.render_pass_list.front().get(); | 2015 render_pass = frame.render_pass_list.front().get(); |
1995 | 2016 |
1996 // Parent has copy request, so texture should not be drawn. | 2017 // Parent has copy request, so texture should not be drawn. |
1997 EXPECT_EQ(DrawQuad::SOLID_COLOR, render_pass->quad_list.back()->material); | 2018 EXPECT_EQ(DrawQuad::SOLID_COLOR, render_pass->quad_list.back()->material); |
1998 | 2019 |
1999 frame = aggregator_->Aggregate(surface2_id); | 2020 frame = aggregator_->Aggregate(surface2_id); |
2000 EXPECT_EQ(1u, frame.render_pass_list.size()); | 2021 EXPECT_EQ(1u, frame.render_pass_list.size()); |
2001 render_pass = frame.render_pass_list.front().get(); | 2022 render_pass = frame.render_pass_list.front().get(); |
2002 | 2023 |
2003 // Copy request has been executed earlier, so texture should be drawn. | 2024 // Copy request has been executed earlier, so texture should be drawn. |
2004 EXPECT_EQ(DrawQuad::TEXTURE_CONTENT, | 2025 EXPECT_EQ(DrawQuad::TEXTURE_CONTENT, |
2005 render_pass->quad_list.front()->material); | 2026 render_pass->quad_list.front()->material); |
2006 | 2027 |
2007 aggregator_->set_output_is_secure(false); | 2028 aggregator_->set_output_is_secure(false); |
2008 | 2029 |
2009 frame = aggregator_->Aggregate(surface2_id); | 2030 frame = aggregator_->Aggregate(surface2_id); |
2010 render_pass = frame.render_pass_list.back().get(); | 2031 render_pass = frame.render_pass_list.back().get(); |
2011 | 2032 |
2012 // Output is insecure, so texture should be drawn. | 2033 // Output is insecure, so texture should be drawn. |
2013 EXPECT_EQ(DrawQuad::SOLID_COLOR, render_pass->quad_list.back()->material); | 2034 EXPECT_EQ(DrawQuad::SOLID_COLOR, render_pass->quad_list.back()->material); |
2014 | 2035 |
2015 factory.Destroy(local_frame1_id); | 2036 factory1.EvictSurface(); |
2016 factory.Destroy(local_frame2_id); | 2037 factory2.EvictSurface(); |
2017 } | 2038 } |
2018 | 2039 |
2019 } // namespace | 2040 } // namespace |
2020 } // namespace cc | 2041 } // namespace cc |
2021 | 2042 |
OLD | NEW |