| 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/output/compositor_frame.h" | 5 #include "cc/output/compositor_frame.h" |
| 6 #include "cc/quads/render_pass.h" | 6 #include "cc/quads/render_pass.h" |
| 7 #include "cc/quads/solid_color_draw_quad.h" | 7 #include "cc/quads/solid_color_draw_quad.h" |
| 8 #include "cc/quads/surface_draw_quad.h" | 8 #include "cc/quads/surface_draw_quad.h" |
| 9 #include "cc/surfaces/surface.h" | 9 #include "cc/surfaces/surface.h" |
| 10 #include "cc/surfaces/surface_aggregator.h" | 10 #include "cc/surfaces/surface_aggregator.h" |
| 11 #include "cc/surfaces/surface_factory.h" | 11 #include "cc/surfaces/surface_factory.h" |
| 12 #include "cc/surfaces/surface_factory_client.h" | 12 #include "cc/surfaces/surface_factory_client.h" |
| 13 #include "cc/surfaces/surface_id_allocator.h" | 13 #include "cc/surfaces/surface_id_allocator.h" |
| 14 #include "cc/surfaces/surface_manager.h" | 14 #include "cc/surfaces/surface_manager.h" |
| 15 #include "cc/test/pixel_comparator.h" | 15 #include "cc/test/pixel_comparator.h" |
| 16 #include "cc/test/pixel_test.h" | 16 #include "cc/test/pixel_test.h" |
| 17 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| 18 | 18 |
| 19 #if !defined(OS_ANDROID) | 19 #if !defined(OS_ANDROID) |
| 20 | 20 |
| 21 namespace cc { | 21 namespace cc { |
| 22 namespace { | 22 namespace { |
| 23 | 23 |
| 24 class EmptySurfaceFactoryClient : public SurfaceFactoryClient { | 24 class EmptySurfaceFactoryClient : public SurfaceFactoryClient { |
| 25 public: | 25 public: |
| 26 void ReturnResources(const ReturnedResourceArray& resources) override {} | 26 void ReturnResources(const ReturnedResourceArray& resources) override {} |
| 27 void SetBeginFrameSource(BeginFrameSource* begin_frame_source) override {} |
| 28 }; |
| 29 |
| 30 class EmptySurfaceAggregatorClient : public SurfaceAggregatorClient { |
| 31 public: |
| 32 void AddSurface(Surface* surface) override {} |
| 33 void RemoveSurface(Surface* surface) override {} |
| 27 }; | 34 }; |
| 28 | 35 |
| 29 class SurfacesPixelTest : public RendererPixelTest<GLRenderer> { | 36 class SurfacesPixelTest : public RendererPixelTest<GLRenderer> { |
| 30 public: | 37 public: |
| 31 SurfacesPixelTest() : allocator_(1u), factory_(&manager_, &client_) {} | 38 SurfacesPixelTest() : allocator_(1u), factory_(&manager_, &client_) {} |
| 32 | 39 |
| 33 protected: | 40 protected: |
| 34 SurfaceManager manager_; | 41 SurfaceManager manager_; |
| 35 SurfaceIdAllocator allocator_; | 42 SurfaceIdAllocator allocator_; |
| 36 EmptySurfaceFactoryClient client_; | 43 EmptySurfaceFactoryClient client_; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 delegated_frame_data->render_pass_list.push_back(pass.Pass()); | 83 delegated_frame_data->render_pass_list.push_back(pass.Pass()); |
| 77 | 84 |
| 78 scoped_ptr<CompositorFrame> root_frame(new CompositorFrame); | 85 scoped_ptr<CompositorFrame> root_frame(new CompositorFrame); |
| 79 root_frame->delegated_frame_data = delegated_frame_data.Pass(); | 86 root_frame->delegated_frame_data = delegated_frame_data.Pass(); |
| 80 | 87 |
| 81 SurfaceId root_surface_id = allocator_.GenerateId(); | 88 SurfaceId root_surface_id = allocator_.GenerateId(); |
| 82 factory_.Create(root_surface_id); | 89 factory_.Create(root_surface_id); |
| 83 factory_.SubmitCompositorFrame(root_surface_id, root_frame.Pass(), | 90 factory_.SubmitCompositorFrame(root_surface_id, root_frame.Pass(), |
| 84 SurfaceFactory::DrawCallback()); | 91 SurfaceFactory::DrawCallback()); |
| 85 | 92 |
| 86 SurfaceAggregator aggregator(&manager_, resource_provider_.get(), true); | 93 EmptySurfaceAggregatorClient surface_aggregator_client; |
| 94 SurfaceAggregator aggregator(&surface_aggregator_client, &manager_, |
| 95 resource_provider_.get(), true); |
| 87 scoped_ptr<CompositorFrame> aggregated_frame = | 96 scoped_ptr<CompositorFrame> aggregated_frame = |
| 88 aggregator.Aggregate(root_surface_id); | 97 aggregator.Aggregate(root_surface_id); |
| 89 factory_.Destroy(root_surface_id); | 98 factory_.Destroy(root_surface_id); |
| 90 | 99 |
| 91 bool discard_alpha = false; | 100 bool discard_alpha = false; |
| 92 ExactPixelComparator pixel_comparator(discard_alpha); | 101 ExactPixelComparator pixel_comparator(discard_alpha); |
| 93 RenderPassList* pass_list = | 102 RenderPassList* pass_list = |
| 94 &aggregated_frame->delegated_frame_data->render_pass_list; | 103 &aggregated_frame->delegated_frame_data->render_pass_list; |
| 95 EXPECT_TRUE(RunPixelTest(pass_list, | 104 EXPECT_TRUE(RunPixelTest(pass_list, |
| 96 base::FilePath(FILE_PATH_LITERAL("green.png")), | 105 base::FilePath(FILE_PATH_LITERAL("green.png")), |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 scoped_ptr<DelegatedFrameData> delegated_frame_data(new DelegatedFrameData); | 169 scoped_ptr<DelegatedFrameData> delegated_frame_data(new DelegatedFrameData); |
| 161 delegated_frame_data->render_pass_list.push_back(pass.Pass()); | 170 delegated_frame_data->render_pass_list.push_back(pass.Pass()); |
| 162 | 171 |
| 163 scoped_ptr<CompositorFrame> child_frame(new CompositorFrame); | 172 scoped_ptr<CompositorFrame> child_frame(new CompositorFrame); |
| 164 child_frame->delegated_frame_data = delegated_frame_data.Pass(); | 173 child_frame->delegated_frame_data = delegated_frame_data.Pass(); |
| 165 | 174 |
| 166 factory_.SubmitCompositorFrame(child_surface_id, child_frame.Pass(), | 175 factory_.SubmitCompositorFrame(child_surface_id, child_frame.Pass(), |
| 167 SurfaceFactory::DrawCallback()); | 176 SurfaceFactory::DrawCallback()); |
| 168 } | 177 } |
| 169 | 178 |
| 170 SurfaceAggregator aggregator(&manager_, resource_provider_.get(), true); | 179 EmptySurfaceAggregatorClient surface_aggregator_client; |
| 180 SurfaceAggregator aggregator(&surface_aggregator_client, &manager_, |
| 181 resource_provider_.get(), true); |
| 171 scoped_ptr<CompositorFrame> aggregated_frame = | 182 scoped_ptr<CompositorFrame> aggregated_frame = |
| 172 aggregator.Aggregate(root_surface_id); | 183 aggregator.Aggregate(root_surface_id); |
| 173 | 184 |
| 174 bool discard_alpha = false; | 185 bool discard_alpha = false; |
| 175 ExactPixelComparator pixel_comparator(discard_alpha); | 186 ExactPixelComparator pixel_comparator(discard_alpha); |
| 176 RenderPassList* pass_list = | 187 RenderPassList* pass_list = |
| 177 &aggregated_frame->delegated_frame_data->render_pass_list; | 188 &aggregated_frame->delegated_frame_data->render_pass_list; |
| 178 EXPECT_TRUE(RunPixelTest(pass_list, | 189 EXPECT_TRUE(RunPixelTest(pass_list, |
| 179 base::FilePath(FILE_PATH_LITERAL("blue_yellow.png")), | 190 base::FilePath(FILE_PATH_LITERAL("blue_yellow.png")), |
| 180 pixel_comparator)); | 191 pixel_comparator)); |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 scoped_ptr<DelegatedFrameData> delegated_frame_data(new DelegatedFrameData); | 314 scoped_ptr<DelegatedFrameData> delegated_frame_data(new DelegatedFrameData); |
| 304 delegated_frame_data->render_pass_list.push_back(pass.Pass()); | 315 delegated_frame_data->render_pass_list.push_back(pass.Pass()); |
| 305 | 316 |
| 306 scoped_ptr<CompositorFrame> child_frame(new CompositorFrame); | 317 scoped_ptr<CompositorFrame> child_frame(new CompositorFrame); |
| 307 child_frame->delegated_frame_data = delegated_frame_data.Pass(); | 318 child_frame->delegated_frame_data = delegated_frame_data.Pass(); |
| 308 | 319 |
| 309 factory_.SubmitCompositorFrame(right_child_id, child_frame.Pass(), | 320 factory_.SubmitCompositorFrame(right_child_id, child_frame.Pass(), |
| 310 SurfaceFactory::DrawCallback()); | 321 SurfaceFactory::DrawCallback()); |
| 311 } | 322 } |
| 312 | 323 |
| 313 SurfaceAggregator aggregator(&manager_, resource_provider_.get(), true); | 324 EmptySurfaceAggregatorClient surface_aggregator_client; |
| 325 SurfaceAggregator aggregator(&surface_aggregator_client, &manager_, |
| 326 resource_provider_.get(), true); |
| 314 scoped_ptr<CompositorFrame> aggregated_frame = | 327 scoped_ptr<CompositorFrame> aggregated_frame = |
| 315 aggregator.Aggregate(root_surface_id); | 328 aggregator.Aggregate(root_surface_id); |
| 316 | 329 |
| 317 bool discard_alpha = false; | 330 bool discard_alpha = false; |
| 318 ExactPixelComparator pixel_comparator(discard_alpha); | 331 ExactPixelComparator pixel_comparator(discard_alpha); |
| 319 RenderPassList* pass_list = | 332 RenderPassList* pass_list = |
| 320 &aggregated_frame->delegated_frame_data->render_pass_list; | 333 &aggregated_frame->delegated_frame_data->render_pass_list; |
| 321 EXPECT_TRUE(RunPixelTest( | 334 EXPECT_TRUE(RunPixelTest( |
| 322 pass_list, | 335 pass_list, |
| 323 base::FilePath(FILE_PATH_LITERAL("four_blue_green_checkers.png")), | 336 base::FilePath(FILE_PATH_LITERAL("four_blue_green_checkers.png")), |
| 324 pixel_comparator)); | 337 pixel_comparator)); |
| 325 | 338 |
| 326 factory_.Destroy(root_surface_id); | 339 factory_.Destroy(root_surface_id); |
| 327 factory_.Destroy(left_child_id); | 340 factory_.Destroy(left_child_id); |
| 328 factory_.Destroy(right_child_id); | 341 factory_.Destroy(right_child_id); |
| 329 } | 342 } |
| 330 | 343 |
| 331 } // namespace | 344 } // namespace |
| 332 } // namespace cc | 345 } // namespace cc |
| 333 | 346 |
| 334 #endif // !defined(OS_ANDROID) | 347 #endif // !defined(OS_ANDROID) |
| OLD | NEW |