| 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/output/delegated_frame_data.h" | 6 #include "cc/output/delegated_frame_data.h" |
| 7 #include "cc/quads/render_pass.h" | 7 #include "cc/quads/render_pass.h" |
| 8 #include "cc/quads/render_pass_draw_quad.h" | 8 #include "cc/quads/render_pass_draw_quad.h" |
| 9 #include "cc/quads/solid_color_draw_quad.h" | 9 #include "cc/quads/solid_color_draw_quad.h" |
| 10 #include "cc/quads/surface_draw_quad.h" | 10 #include "cc/quads/surface_draw_quad.h" |
| 11 #include "cc/surfaces/surface.h" | 11 #include "cc/surfaces/surface.h" |
| 12 #include "cc/surfaces/surface_aggregator.h" | 12 #include "cc/surfaces/surface_aggregator.h" |
| 13 #include "cc/surfaces/surface_aggregator_test_helpers.h" | 13 #include "cc/surfaces/surface_aggregator_test_helpers.h" |
| 14 #include "cc/surfaces/surface_manager.h" | 14 #include "cc/surfaces/surface_manager.h" |
| 15 #include "cc/test/render_pass_test_common.h" | 15 #include "cc/test/render_pass_test_common.h" |
| 16 #include "cc/test/render_pass_test_utils.h" | 16 #include "cc/test/render_pass_test_utils.h" |
| 17 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| 18 #include "third_party/skia/include/core/SkColor.h" | 18 #include "third_party/skia/include/core/SkColor.h" |
| 19 | 19 |
| 20 namespace cc { | 20 namespace cc { |
| 21 namespace { | 21 namespace { |
| 22 const int kInvalidSurfaceId = -1; | 22 |
| 23 SurfaceId InvalidSurfaceId() { |
| 24 static SurfaceId invalid; |
| 25 invalid.id = -1; |
| 26 return invalid; |
| 27 } |
| 23 | 28 |
| 24 class SurfaceAggregatorTest : public testing::Test { | 29 class SurfaceAggregatorTest : public testing::Test { |
| 25 public: | 30 public: |
| 26 SurfaceAggregatorTest() : aggregator_(&manager_) {} | 31 SurfaceAggregatorTest() : aggregator_(&manager_) {} |
| 27 | 32 |
| 28 protected: | 33 protected: |
| 29 SurfaceManager manager_; | 34 SurfaceManager manager_; |
| 30 SurfaceAggregator aggregator_; | 35 SurfaceAggregator aggregator_; |
| 31 }; | 36 }; |
| 32 | 37 |
| 33 TEST_F(SurfaceAggregatorTest, InvalidSurfaceId) { | 38 TEST_F(SurfaceAggregatorTest, InvalidSurfaceId) { |
| 34 scoped_ptr<CompositorFrame> frame = aggregator_.Aggregate(kInvalidSurfaceId); | 39 scoped_ptr<CompositorFrame> frame = aggregator_.Aggregate(InvalidSurfaceId()); |
| 35 EXPECT_FALSE(frame); | 40 EXPECT_FALSE(frame); |
| 36 } | 41 } |
| 37 | 42 |
| 38 TEST_F(SurfaceAggregatorTest, ValidSurfaceNoFrame) { | 43 TEST_F(SurfaceAggregatorTest, ValidSurfaceNoFrame) { |
| 39 Surface one(&manager_, NULL, gfx::Size(5, 5)); | 44 Surface one(&manager_, NULL, gfx::Size(5, 5)); |
| 40 scoped_ptr<CompositorFrame> frame = aggregator_.Aggregate(one.surface_id()); | 45 scoped_ptr<CompositorFrame> frame = aggregator_.Aggregate(one.surface_id()); |
| 41 EXPECT_FALSE(frame); | 46 EXPECT_FALSE(frame); |
| 42 } | 47 } |
| 43 | 48 |
| 44 class SurfaceAggregatorValidSurfaceTest : public SurfaceAggregatorTest { | 49 class SurfaceAggregatorValidSurfaceTest : public SurfaceAggregatorTest { |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 RenderPassDrawQuad::MaterialCast(fifth_pass_quad_list.at(1u)); | 256 RenderPassDrawQuad::MaterialCast(fifth_pass_quad_list.at(1u)); |
| 252 EXPECT_EQ(actual_pass_ids[3], | 257 EXPECT_EQ(actual_pass_ids[3], |
| 253 fifth_pass_render_pass_draw_quad->render_pass_id); | 258 fifth_pass_render_pass_draw_quad->render_pass_id); |
| 254 } | 259 } |
| 255 } | 260 } |
| 256 | 261 |
| 257 // Tests an invalid surface reference in a frame. The surface quad should just | 262 // Tests an invalid surface reference in a frame. The surface quad should just |
| 258 // be dropped. | 263 // be dropped. |
| 259 TEST_F(SurfaceAggregatorValidSurfaceTest, InvalidSurfaceReference) { | 264 TEST_F(SurfaceAggregatorValidSurfaceTest, InvalidSurfaceReference) { |
| 260 test::Quad quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), | 265 test::Quad quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), |
| 261 test::Quad::SurfaceQuad(kInvalidSurfaceId), | 266 test::Quad::SurfaceQuad(InvalidSurfaceId()), |
| 262 test::Quad::SolidColorQuad(SK_ColorBLUE)}; | 267 test::Quad::SolidColorQuad(SK_ColorBLUE)}; |
| 263 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; | 268 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; |
| 264 | 269 |
| 265 SubmitFrame(passes, arraysize(passes), &root_surface_); | 270 SubmitFrame(passes, arraysize(passes), &root_surface_); |
| 266 | 271 |
| 267 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), | 272 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), |
| 268 test::Quad::SolidColorQuad(SK_ColorBLUE)}; | 273 test::Quad::SolidColorQuad(SK_ColorBLUE)}; |
| 269 test::Pass expected_passes[] = { | 274 test::Pass expected_passes[] = { |
| 270 test::Pass(expected_quads, arraysize(expected_quads))}; | 275 test::Pass(expected_quads, arraysize(expected_quads))}; |
| 271 AggregateAndVerify(expected_passes, arraysize(expected_passes)); | 276 AggregateAndVerify(expected_passes, arraysize(expected_passes)); |
| (...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 693 DrawQuad* quad = aggregated_pass_list[1]->quad_list.at(i); | 698 DrawQuad* quad = aggregated_pass_list[1]->quad_list.at(i); |
| 694 EXPECT_EQ(expected_root_pass_quad_transforms[i].ToString(), | 699 EXPECT_EQ(expected_root_pass_quad_transforms[i].ToString(), |
| 695 quad->quadTransform().ToString()) | 700 quad->quadTransform().ToString()) |
| 696 << i; | 701 << i; |
| 697 } | 702 } |
| 698 } | 703 } |
| 699 | 704 |
| 700 } // namespace | 705 } // namespace |
| 701 } // namespace cc | 706 } // namespace cc |
| 702 | 707 |
| OLD | NEW |