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