Chromium Code Reviews| 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 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 253 | 253 |
| 254 SubmitCompositorFrame(&factory_, passes, arraysize(passes), | 254 SubmitCompositorFrame(&factory_, passes, arraysize(passes), |
| 255 root_local_frame_id_); | 255 root_local_frame_id_); |
| 256 | 256 |
| 257 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id_); | 257 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id_); |
| 258 SurfaceId ids[] = {root_surface_id}; | 258 SurfaceId ids[] = {root_surface_id}; |
| 259 | 259 |
| 260 AggregateAndVerify(passes, arraysize(passes), ids, arraysize(ids)); | 260 AggregateAndVerify(passes, arraysize(passes), ids, arraysize(ids)); |
| 261 } | 261 } |
| 262 | 262 |
| 263 // Ensure that the render pass ID map properly keeps and deletes entries. | |
| 264 TEST_F(SurfaceAggregatorValidSurfaceTest, MultiPassDeallocation) { | |
| 265 test::Quad quads[][2] = {{test::Quad::SolidColorQuad(SK_ColorWHITE), | |
| 266 test::Quad::SolidColorQuad(SK_ColorLTGRAY)}, | |
| 267 {test::Quad::SolidColorQuad(SK_ColorGRAY), | |
| 268 test::Quad::SolidColorQuad(SK_ColorDKGRAY)}}; | |
| 269 test::Pass passes[] = { | |
| 270 test::Pass(quads[0], arraysize(quads[0]), RenderPassId(1, 2)), | |
| 271 test::Pass(quads[1], arraysize(quads[1]), RenderPassId(1, 1))}; | |
| 272 | |
| 273 SubmitCompositorFrame(&factory_, passes, arraysize(passes), | |
| 274 root_local_frame_id_); | |
| 275 | |
| 276 SurfaceId surface_id(factory_.frame_sink_id(), root_local_frame_id_); | |
| 277 | |
| 278 CompositorFrame aggregated_frame; | |
| 279 aggregated_frame = aggregator_.Aggregate(surface_id); | |
| 280 EXPECT_EQ(RenderPassId(1, 2), aggregated_frame.render_pass_list[0]->id); | |
|
danakj
2016/12/02 22:17:53
instead of hardcoding the result can u just store
| |
| 281 EXPECT_EQ(RenderPassId(1, 1), aggregated_frame.render_pass_list[1]->id); | |
| 282 | |
| 283 // Aggregated RenderPassIds should remain the same between frames. | |
| 284 aggregated_frame = aggregator_.Aggregate(surface_id); | |
| 285 EXPECT_EQ(RenderPassId(1, 2), aggregated_frame.render_pass_list[0]->id); | |
| 286 EXPECT_EQ(RenderPassId(1, 1), aggregated_frame.render_pass_list[1]->id); | |
| 287 | |
| 288 test::Pass passes2[] = { | |
| 289 test::Pass(quads[0], arraysize(quads[0]), RenderPassId(1, 3)), | |
| 290 test::Pass(quads[1], arraysize(quads[1]), RenderPassId(1, 1))}; | |
| 291 | |
| 292 SubmitCompositorFrame(&factory_, passes2, arraysize(passes2), | |
| 293 root_local_frame_id_); | |
| 294 | |
| 295 // The RenderPass that still exists should keep the same ID. | |
| 296 aggregated_frame = aggregator_.Aggregate(surface_id); | |
| 297 EXPECT_EQ(RenderPassId(1, 3), aggregated_frame.render_pass_list[0]->id); | |
|
danakj
2016/12/02 22:17:53
and then check this is a new thing with NE compare
| |
| 298 EXPECT_EQ(RenderPassId(1, 1), aggregated_frame.render_pass_list[1]->id); | |
| 299 | |
| 300 SubmitCompositorFrame(&factory_, passes, arraysize(passes), | |
| 301 root_local_frame_id_); | |
| 302 | |
| 303 // RenderPassId(1, 2) didn't exist in the previous frame, so it should be | |
| 304 // mapped to a new ID. | |
| 305 aggregated_frame = aggregator_.Aggregate(surface_id); | |
| 306 EXPECT_EQ(RenderPassId(1, 4), aggregated_frame.render_pass_list[0]->id); | |
|
danakj
2016/12/02 22:17:53
same same?
| |
| 307 EXPECT_EQ(RenderPassId(1, 1), aggregated_frame.render_pass_list[1]->id); | |
| 308 } | |
| 309 | |
| 263 // This tests very simple embedding. root_surface has a frame containing a few | 310 // This tests very simple embedding. root_surface has a frame containing a few |
| 264 // solid color quads and a surface quad referencing embedded_surface. | 311 // solid color quads and a surface quad referencing embedded_surface. |
| 265 // embedded_surface has a frame containing only a solid color quad. The solid | 312 // embedded_surface has a frame containing only a solid color quad. The solid |
| 266 // color quad should be aggregated into the final frame. | 313 // color quad should be aggregated into the final frame. |
| 267 TEST_F(SurfaceAggregatorValidSurfaceTest, SimpleSurfaceReference) { | 314 TEST_F(SurfaceAggregatorValidSurfaceTest, SimpleSurfaceReference) { |
| 268 SurfaceFactory embedded_factory(kArbitraryChildFrameSinkId, &manager_, | 315 SurfaceFactory embedded_factory(kArbitraryChildFrameSinkId, &manager_, |
| 269 &empty_client_); | 316 &empty_client_); |
| 270 LocalFrameId embedded_local_frame_id = allocator_.GenerateId(); | 317 LocalFrameId embedded_local_frame_id = allocator_.GenerateId(); |
| 271 SurfaceId embedded_surface_id(embedded_factory.frame_sink_id(), | 318 SurfaceId embedded_surface_id(embedded_factory.frame_sink_id(), |
| 272 embedded_local_frame_id); | 319 embedded_local_frame_id); |
| (...skipping 1761 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2034 // Output is insecure, so texture should be drawn. | 2081 // Output is insecure, so texture should be drawn. |
| 2035 EXPECT_EQ(DrawQuad::SOLID_COLOR, render_pass->quad_list.back()->material); | 2082 EXPECT_EQ(DrawQuad::SOLID_COLOR, render_pass->quad_list.back()->material); |
| 2036 | 2083 |
| 2037 factory1.EvictSurface(); | 2084 factory1.EvictSurface(); |
| 2038 factory2.EvictSurface(); | 2085 factory2.EvictSurface(); |
| 2039 } | 2086 } |
| 2040 | 2087 |
| 2041 } // namespace | 2088 } // namespace |
| 2042 } // namespace cc | 2089 } // namespace cc |
| 2043 | 2090 |
| OLD | NEW |