| 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> |
| 11 | 11 |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/memory/ptr_util.h" | 13 #include "base/memory/ptr_util.h" |
| 14 #include "cc/output/compositor_frame.h" | 14 #include "cc/output/compositor_frame.h" |
| 15 #include "cc/quads/render_pass.h" | 15 #include "cc/quads/render_pass.h" |
| 16 #include "cc/quads/render_pass_draw_quad.h" | 16 #include "cc/quads/render_pass_draw_quad.h" |
| 17 #include "cc/quads/solid_color_draw_quad.h" | 17 #include "cc/quads/solid_color_draw_quad.h" |
| 18 #include "cc/quads/surface_draw_quad.h" | 18 #include "cc/quads/surface_draw_quad.h" |
| 19 #include "cc/quads/texture_draw_quad.h" | 19 #include "cc/quads/texture_draw_quad.h" |
| 20 #include "cc/resources/shared_bitmap_manager.h" | 20 #include "cc/resources/shared_bitmap_manager.h" |
| 21 #include "cc/surfaces/compositor_frame_sink_support.h" |
| 21 #include "cc/surfaces/local_surface_id_allocator.h" | 22 #include "cc/surfaces/local_surface_id_allocator.h" |
| 22 #include "cc/surfaces/surface.h" | 23 #include "cc/surfaces/surface.h" |
| 23 #include "cc/surfaces/surface_factory.h" | |
| 24 #include "cc/surfaces/surface_factory_client.h" | |
| 25 #include "cc/surfaces/surface_manager.h" | 24 #include "cc/surfaces/surface_manager.h" |
| 26 #include "cc/test/fake_resource_provider.h" | 25 #include "cc/test/fake_resource_provider.h" |
| 27 #include "cc/test/render_pass_test_utils.h" | 26 #include "cc/test/render_pass_test_utils.h" |
| 28 #include "cc/test/surface_aggregator_test_helpers.h" | 27 #include "cc/test/surface_aggregator_test_helpers.h" |
| 29 #include "cc/test/test_shared_bitmap_manager.h" | 28 #include "cc/test/test_shared_bitmap_manager.h" |
| 30 #include "testing/gmock/include/gmock/gmock.h" | 29 #include "testing/gmock/include/gmock/gmock.h" |
| 31 #include "testing/gtest/include/gtest/gtest.h" | 30 #include "testing/gtest/include/gtest/gtest.h" |
| 32 #include "third_party/skia/include/core/SkColor.h" | 31 #include "third_party/skia/include/core/SkColor.h" |
| 33 | 32 |
| 34 namespace cc { | 33 namespace cc { |
| 35 namespace { | 34 namespace { |
| 36 | 35 |
| 37 constexpr FrameSinkId kArbitraryRootFrameSinkId(1, 1); | 36 constexpr FrameSinkId kArbitraryRootFrameSinkId(1, 1); |
| 38 constexpr FrameSinkId kArbitraryChildFrameSinkId1(2, 2); | 37 constexpr FrameSinkId kArbitraryFrameSinkId1(2, 2); |
| 39 constexpr FrameSinkId kArbitraryChildFrameSinkId2(3, 3); | 38 constexpr FrameSinkId kArbitraryFrameSinkId2(3, 3); |
| 40 constexpr FrameSinkId kArbitraryMiddleFrameSinkId(4, 4); | 39 constexpr FrameSinkId kArbitraryMiddleFrameSinkId(4, 4); |
| 40 constexpr FrameSinkId kArbitraryReservedFrameSinkId(5, 5); |
| 41 constexpr FrameSinkId kArbitraryFrameSinkId3(6, 6); |
| 41 const base::UnguessableToken kArbitraryToken = base::UnguessableToken::Create(); | 42 const base::UnguessableToken kArbitraryToken = base::UnguessableToken::Create(); |
| 43 constexpr bool is_root = true; |
| 44 constexpr bool is_root_child = false; |
| 45 constexpr bool handles_frame_sink_id_invalidation = true; |
| 46 constexpr bool needs_sync_points = false; |
| 42 | 47 |
| 43 SurfaceId InvalidSurfaceId() { | 48 SurfaceId InvalidSurfaceId() { |
| 44 static SurfaceId invalid(FrameSinkId(), | 49 static SurfaceId invalid(FrameSinkId(), |
| 45 LocalSurfaceId(0xdeadbeef, kArbitraryToken)); | 50 LocalSurfaceId(0xdeadbeef, kArbitraryToken)); |
| 46 return invalid; | 51 return invalid; |
| 47 } | 52 } |
| 48 | 53 |
| 49 gfx::Size SurfaceSize() { | 54 gfx::Size SurfaceSize() { |
| 50 static gfx::Size size(100, 100); | 55 static gfx::Size size(100, 100); |
| 51 return size; | 56 return size; |
| 52 } | 57 } |
| 53 | 58 |
| 54 class EmptySurfaceFactoryClient : public SurfaceFactoryClient { | |
| 55 public: | |
| 56 void ReturnResources(const ReturnedResourceArray& resources) override {} | |
| 57 | |
| 58 void WillDrawSurface(const LocalSurfaceId& id, | |
| 59 const gfx::Rect& damage_rect) override { | |
| 60 last_local_surface_id_ = id; | |
| 61 last_damage_rect_ = damage_rect; | |
| 62 } | |
| 63 | |
| 64 void SetBeginFrameSource(BeginFrameSource* begin_frame_source) override {} | |
| 65 | |
| 66 gfx::Rect last_damage_rect_; | |
| 67 LocalSurfaceId last_local_surface_id_; | |
| 68 }; | |
| 69 | |
| 70 class SurfaceAggregatorTest : public testing::Test { | 59 class SurfaceAggregatorTest : public testing::Test { |
| 71 public: | 60 public: |
| 72 explicit SurfaceAggregatorTest(bool use_damage_rect) | 61 explicit SurfaceAggregatorTest(bool use_damage_rect) |
| 73 : factory_(kArbitraryRootFrameSinkId, &manager_, &empty_client_), | 62 : support_(nullptr, |
| 63 &manager_, |
| 64 kArbitraryRootFrameSinkId, |
| 65 is_root, |
| 66 handles_frame_sink_id_invalidation, |
| 67 needs_sync_points), |
| 74 aggregator_(&manager_, NULL, use_damage_rect) {} | 68 aggregator_(&manager_, NULL, use_damage_rect) {} |
| 75 | 69 |
| 76 SurfaceAggregatorTest() : SurfaceAggregatorTest(false) {} | 70 SurfaceAggregatorTest() : SurfaceAggregatorTest(false) {} |
| 77 | 71 |
| 78 void TearDown() override { | 72 void TearDown() override { |
| 79 factory_.EvictSurface(); | 73 support_.EvictFrame(); |
| 80 testing::Test::TearDown(); | 74 testing::Test::TearDown(); |
| 81 } | 75 } |
| 82 | 76 |
| 83 protected: | 77 protected: |
| 84 SurfaceManager manager_; | 78 SurfaceManager manager_; |
| 85 EmptySurfaceFactoryClient empty_client_; | 79 CompositorFrameSinkSupport support_; |
| 86 SurfaceFactory factory_; | |
| 87 SurfaceAggregator aggregator_; | 80 SurfaceAggregator aggregator_; |
| 88 }; | 81 }; |
| 89 | 82 |
| 90 TEST_F(SurfaceAggregatorTest, ValidSurfaceNoFrame) { | 83 TEST_F(SurfaceAggregatorTest, ValidSurfaceNoFrame) { |
| 91 LocalSurfaceId local_surface_id(7, base::UnguessableToken::Create()); | 84 LocalSurfaceId local_surface_id(7, base::UnguessableToken::Create()); |
| 92 SurfaceId one_id(kArbitraryRootFrameSinkId, local_surface_id); | 85 SurfaceId one_id(kArbitraryRootFrameSinkId, local_surface_id); |
| 93 factory_.SubmitCompositorFrame(local_surface_id, CompositorFrame(), | 86 support_.SubmitCompositorFrame(local_surface_id, CompositorFrame()); |
| 94 SurfaceFactory::DrawCallback()); | |
| 95 | 87 |
| 96 CompositorFrame frame = aggregator_.Aggregate(one_id); | 88 CompositorFrame frame = aggregator_.Aggregate(one_id); |
| 97 EXPECT_TRUE(frame.render_pass_list.empty()); | 89 EXPECT_TRUE(frame.render_pass_list.empty()); |
| 98 } | 90 } |
| 99 | 91 |
| 100 class SurfaceAggregatorValidSurfaceTest : public SurfaceAggregatorTest { | 92 class SurfaceAggregatorValidSurfaceTest : public SurfaceAggregatorTest { |
| 101 public: | 93 public: |
| 102 explicit SurfaceAggregatorValidSurfaceTest(bool use_damage_rect) | 94 explicit SurfaceAggregatorValidSurfaceTest(bool use_damage_rect) |
| 103 : SurfaceAggregatorTest(use_damage_rect), | 95 : SurfaceAggregatorTest(use_damage_rect), |
| 104 child_factory_(kArbitraryChildFrameSinkId1, | 96 child_support_(nullptr, |
| 105 &manager_, | 97 &manager_, |
| 106 &empty_child_client_) {} | 98 kArbitraryReservedFrameSinkId, |
| 99 is_root_child, |
| 100 handles_frame_sink_id_invalidation, |
| 101 needs_sync_points) {} |
| 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_surface_id_ = allocator_.GenerateId(); | 107 root_local_surface_id_ = allocator_.GenerateId(); |
| 113 root_surface_ = manager_.GetSurfaceForId( | 108 root_surface_ = manager_.GetSurfaceForId( |
| 114 SurfaceId(factory_.frame_sink_id(), root_local_surface_id_)); | 109 SurfaceId(support_.frame_sink_id(), root_local_surface_id_)); |
| 115 } | 110 } |
| 116 | 111 |
| 117 void TearDown() override { | 112 void TearDown() override { |
| 118 child_factory_.EvictSurface(); | 113 child_support_.EvictFrame(); |
| 119 SurfaceAggregatorTest::TearDown(); | 114 SurfaceAggregatorTest::TearDown(); |
| 120 } | 115 } |
| 121 | 116 |
| 122 void AggregateAndVerify(test::Pass* expected_passes, | 117 void AggregateAndVerify(test::Pass* expected_passes, |
| 123 size_t expected_pass_count, | 118 size_t expected_pass_count, |
| 124 SurfaceId* surface_ids, | 119 SurfaceId* surface_ids, |
| 125 size_t expected_surface_count) { | 120 size_t expected_surface_count) { |
| 126 CompositorFrame aggregated_frame = aggregator_.Aggregate( | 121 CompositorFrame aggregated_frame = aggregator_.Aggregate( |
| 127 SurfaceId(factory_.frame_sink_id(), root_local_surface_id_)); | 122 SurfaceId(support_.frame_sink_id(), root_local_surface_id_)); |
| 128 | 123 |
| 129 TestPassesMatchExpectations(expected_passes, expected_pass_count, | 124 TestPassesMatchExpectations(expected_passes, expected_pass_count, |
| 130 &aggregated_frame.render_pass_list); | 125 &aggregated_frame.render_pass_list); |
| 131 | 126 |
| 132 // Ensure no duplicate pass ids output. | 127 // Ensure no duplicate pass ids output. |
| 133 std::set<int> used_passes; | 128 std::set<int> used_passes; |
| 134 for (const auto& pass : aggregated_frame.render_pass_list) { | 129 for (const auto& pass : aggregated_frame.render_pass_list) { |
| 135 EXPECT_TRUE(used_passes.insert(pass->id).second); | 130 EXPECT_TRUE(used_passes.insert(pass->id).second); |
| 136 } | 131 } |
| 137 | 132 |
| 138 EXPECT_EQ(expected_surface_count, | 133 EXPECT_EQ(expected_surface_count, |
| 139 aggregator_.previous_contained_surfaces().size()); | 134 aggregator_.previous_contained_surfaces().size()); |
| 140 for (size_t i = 0; i < expected_surface_count; i++) { | 135 for (size_t i = 0; i < expected_surface_count; i++) { |
| 141 EXPECT_TRUE( | 136 EXPECT_TRUE( |
| 142 aggregator_.previous_contained_surfaces().find(surface_ids[i]) != | 137 aggregator_.previous_contained_surfaces().find(surface_ids[i]) != |
| 143 aggregator_.previous_contained_surfaces().end()); | 138 aggregator_.previous_contained_surfaces().end()); |
| 144 } | 139 } |
| 145 } | 140 } |
| 146 | 141 |
| 147 void SubmitPassListAsFrame(SurfaceFactory* factory, | 142 void SubmitPassListAsFrame(CompositorFrameSinkSupport* support, |
| 148 const LocalSurfaceId& local_surface_id, | 143 const LocalSurfaceId& local_surface_id, |
| 149 RenderPassList* pass_list) { | 144 RenderPassList* pass_list) { |
| 150 CompositorFrame frame; | 145 CompositorFrame frame; |
| 151 pass_list->swap(frame.render_pass_list); | 146 pass_list->swap(frame.render_pass_list); |
| 152 | 147 |
| 153 factory->SubmitCompositorFrame(local_surface_id, std::move(frame), | 148 support->SubmitCompositorFrame(local_surface_id, std::move(frame)); |
| 154 SurfaceFactory::DrawCallback()); | |
| 155 } | 149 } |
| 156 | 150 |
| 157 void SubmitCompositorFrame(SurfaceFactory* factory, | 151 void SubmitCompositorFrame(CompositorFrameSinkSupport* support, |
| 158 test::Pass* passes, | 152 test::Pass* passes, |
| 159 size_t pass_count, | 153 size_t pass_count, |
| 160 const LocalSurfaceId& local_surface_id) { | 154 const LocalSurfaceId& local_surface_id) { |
| 161 RenderPassList pass_list; | 155 RenderPassList pass_list; |
| 162 AddPasses(&pass_list, gfx::Rect(SurfaceSize()), passes, pass_count); | 156 AddPasses(&pass_list, gfx::Rect(SurfaceSize()), passes, pass_count); |
| 163 SubmitPassListAsFrame(factory, local_surface_id, &pass_list); | 157 SubmitPassListAsFrame(support, local_surface_id, &pass_list); |
| 164 } | 158 } |
| 165 | 159 |
| 166 void QueuePassAsFrame(std::unique_ptr<RenderPass> pass, | 160 void QueuePassAsFrame(std::unique_ptr<RenderPass> pass, |
| 167 const LocalSurfaceId& local_surface_id, | 161 const LocalSurfaceId& local_surface_id, |
| 168 SurfaceFactory* factory) { | 162 CompositorFrameSinkSupport* support) { |
| 169 CompositorFrame child_frame; | 163 CompositorFrame child_frame; |
| 170 child_frame.render_pass_list.push_back(std::move(pass)); | 164 child_frame.render_pass_list.push_back(std::move(pass)); |
| 171 | 165 |
| 172 factory->SubmitCompositorFrame(local_surface_id, std::move(child_frame), | 166 support->SubmitCompositorFrame(local_surface_id, std::move(child_frame)); |
| 173 SurfaceFactory::DrawCallback()); | |
| 174 } | 167 } |
| 175 | 168 |
| 176 protected: | 169 protected: |
| 177 LocalSurfaceId root_local_surface_id_; | 170 LocalSurfaceId root_local_surface_id_; |
| 178 Surface* root_surface_; | 171 Surface* root_surface_; |
| 179 LocalSurfaceIdAllocator allocator_; | 172 LocalSurfaceIdAllocator allocator_; |
| 180 EmptySurfaceFactoryClient empty_child_client_; | 173 CompositorFrameSinkSupport child_support_; |
| 181 SurfaceFactory child_factory_; | |
| 182 LocalSurfaceIdAllocator child_allocator_; | 174 LocalSurfaceIdAllocator child_allocator_; |
| 183 }; | 175 }; |
| 184 | 176 |
| 185 // Tests that a very simple frame containing only two solid color quads makes it | 177 // Tests that a very simple frame containing only two solid color quads makes it |
| 186 // through the aggregator correctly. | 178 // through the aggregator correctly. |
| 187 TEST_F(SurfaceAggregatorValidSurfaceTest, SimpleFrame) { | 179 TEST_F(SurfaceAggregatorValidSurfaceTest, SimpleFrame) { |
| 188 test::Quad quads[] = {test::Quad::SolidColorQuad(SK_ColorRED), | 180 test::Quad quads[] = {test::Quad::SolidColorQuad(SK_ColorRED), |
| 189 test::Quad::SolidColorQuad(SK_ColorBLUE)}; | 181 test::Quad::SolidColorQuad(SK_ColorBLUE)}; |
| 190 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; | 182 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; |
| 191 | 183 |
| 192 SubmitCompositorFrame(&factory_, passes, arraysize(passes), | 184 SubmitCompositorFrame(&support_, passes, arraysize(passes), |
| 193 root_local_surface_id_); | 185 root_local_surface_id_); |
| 194 | 186 |
| 195 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_surface_id_); | 187 SurfaceId root_surface_id(support_.frame_sink_id(), root_local_surface_id_); |
| 196 SurfaceId ids[] = {root_surface_id}; | 188 SurfaceId ids[] = {root_surface_id}; |
| 197 | 189 |
| 198 AggregateAndVerify(passes, arraysize(passes), ids, arraysize(ids)); | 190 AggregateAndVerify(passes, arraysize(passes), ids, arraysize(ids)); |
| 199 | 191 |
| 200 // Check that WillDrawSurface was called. | 192 // Check that WillDrawSurface was called. |
| 201 EXPECT_EQ(gfx::Rect(SurfaceSize()), empty_client_.last_damage_rect_); | 193 EXPECT_EQ(gfx::Rect(SurfaceSize()), support_.last_damage_rect()); |
| 202 EXPECT_EQ(root_local_surface_id_, empty_client_.last_local_surface_id_); | 194 EXPECT_EQ(root_local_surface_id_, support_.last_local_surface_id()); |
| 203 } | 195 } |
| 204 | 196 |
| 205 TEST_F(SurfaceAggregatorValidSurfaceTest, OpacityCopied) { | 197 TEST_F(SurfaceAggregatorValidSurfaceTest, OpacityCopied) { |
| 206 SurfaceFactory embedded_factory(kArbitraryChildFrameSinkId1, &manager_, | 198 CompositorFrameSinkSupport embedded_support( |
| 207 &empty_client_); | 199 nullptr, &manager_, kArbitraryFrameSinkId1, is_root, |
| 200 handles_frame_sink_id_invalidation, needs_sync_points); |
| 208 LocalSurfaceId embedded_local_surface_id = allocator_.GenerateId(); | 201 LocalSurfaceId embedded_local_surface_id = allocator_.GenerateId(); |
| 209 SurfaceId embedded_surface_id(embedded_factory.frame_sink_id(), | 202 SurfaceId embedded_surface_id(embedded_support.frame_sink_id(), |
| 210 embedded_local_surface_id); | 203 embedded_local_surface_id); |
| 211 | 204 |
| 212 test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), | 205 test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), |
| 213 test::Quad::SolidColorQuad(SK_ColorBLUE)}; | 206 test::Quad::SolidColorQuad(SK_ColorBLUE)}; |
| 214 test::Pass embedded_passes[] = { | 207 test::Pass embedded_passes[] = { |
| 215 test::Pass(embedded_quads, arraysize(embedded_quads))}; | 208 test::Pass(embedded_quads, arraysize(embedded_quads))}; |
| 216 | 209 |
| 217 SubmitCompositorFrame(&embedded_factory, embedded_passes, | 210 SubmitCompositorFrame(&embedded_support, embedded_passes, |
| 218 arraysize(embedded_passes), embedded_local_surface_id); | 211 arraysize(embedded_passes), embedded_local_surface_id); |
| 219 | 212 |
| 220 test::Quad quads[] = { | 213 test::Quad quads[] = { |
| 221 test::Quad::SurfaceQuad(embedded_surface_id, InvalidSurfaceId(), .5f)}; | 214 test::Quad::SurfaceQuad(embedded_surface_id, InvalidSurfaceId(), .5f)}; |
| 222 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; | 215 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; |
| 223 | 216 |
| 224 SubmitCompositorFrame(&factory_, passes, arraysize(passes), | 217 SubmitCompositorFrame(&support_, passes, arraysize(passes), |
| 225 root_local_surface_id_); | 218 root_local_surface_id_); |
| 226 | 219 |
| 227 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_surface_id_); | 220 SurfaceId root_surface_id(support_.frame_sink_id(), root_local_surface_id_); |
| 228 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); | 221 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); |
| 229 | 222 |
| 230 RenderPassList& render_pass_list(aggregated_frame.render_pass_list); | 223 RenderPassList& render_pass_list(aggregated_frame.render_pass_list); |
| 231 ASSERT_EQ(2u, render_pass_list.size()); | 224 ASSERT_EQ(2u, render_pass_list.size()); |
| 232 SharedQuadStateList& shared_quad_state_list( | 225 SharedQuadStateList& shared_quad_state_list( |
| 233 render_pass_list[0]->shared_quad_state_list); | 226 render_pass_list[0]->shared_quad_state_list); |
| 234 ASSERT_EQ(2u, shared_quad_state_list.size()); | 227 ASSERT_EQ(2u, shared_quad_state_list.size()); |
| 235 EXPECT_EQ(1.f, shared_quad_state_list.ElementAt(0)->opacity); | 228 EXPECT_EQ(1.f, shared_quad_state_list.ElementAt(0)->opacity); |
| 236 EXPECT_EQ(1.f, shared_quad_state_list.ElementAt(1)->opacity); | 229 EXPECT_EQ(1.f, shared_quad_state_list.ElementAt(1)->opacity); |
| 237 | 230 |
| 238 SharedQuadStateList& shared_quad_state_list2( | 231 SharedQuadStateList& shared_quad_state_list2( |
| 239 render_pass_list[1]->shared_quad_state_list); | 232 render_pass_list[1]->shared_quad_state_list); |
| 240 ASSERT_EQ(1u, shared_quad_state_list2.size()); | 233 ASSERT_EQ(1u, shared_quad_state_list2.size()); |
| 241 EXPECT_EQ(.5f, shared_quad_state_list2.ElementAt(0)->opacity); | 234 EXPECT_EQ(.5f, shared_quad_state_list2.ElementAt(0)->opacity); |
| 242 | 235 |
| 243 embedded_factory.EvictSurface(); | 236 embedded_support.EvictFrame(); |
| 244 } | 237 } |
| 245 | 238 |
| 246 TEST_F(SurfaceAggregatorValidSurfaceTest, MultiPassSimpleFrame) { | 239 TEST_F(SurfaceAggregatorValidSurfaceTest, MultiPassSimpleFrame) { |
| 247 test::Quad quads[][2] = {{test::Quad::SolidColorQuad(SK_ColorWHITE), | 240 test::Quad quads[][2] = {{test::Quad::SolidColorQuad(SK_ColorWHITE), |
| 248 test::Quad::SolidColorQuad(SK_ColorLTGRAY)}, | 241 test::Quad::SolidColorQuad(SK_ColorLTGRAY)}, |
| 249 {test::Quad::SolidColorQuad(SK_ColorGRAY), | 242 {test::Quad::SolidColorQuad(SK_ColorGRAY), |
| 250 test::Quad::SolidColorQuad(SK_ColorDKGRAY)}}; | 243 test::Quad::SolidColorQuad(SK_ColorDKGRAY)}}; |
| 251 test::Pass passes[] = {test::Pass(quads[0], arraysize(quads[0]), 1), | 244 test::Pass passes[] = {test::Pass(quads[0], arraysize(quads[0]), 1), |
| 252 test::Pass(quads[1], arraysize(quads[1]), 2)}; | 245 test::Pass(quads[1], arraysize(quads[1]), 2)}; |
| 253 | 246 |
| 254 SubmitCompositorFrame(&factory_, passes, arraysize(passes), | 247 SubmitCompositorFrame(&support_, passes, arraysize(passes), |
| 255 root_local_surface_id_); | 248 root_local_surface_id_); |
| 256 | 249 |
| 257 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_surface_id_); | 250 SurfaceId root_surface_id(support_.frame_sink_id(), root_local_surface_id_); |
| 258 SurfaceId ids[] = {root_surface_id}; | 251 SurfaceId ids[] = {root_surface_id}; |
| 259 | 252 |
| 260 AggregateAndVerify(passes, arraysize(passes), ids, arraysize(ids)); | 253 AggregateAndVerify(passes, arraysize(passes), ids, arraysize(ids)); |
| 261 } | 254 } |
| 262 | 255 |
| 263 // Ensure that the render pass ID map properly keeps and deletes entries. | 256 // Ensure that the render pass ID map properly keeps and deletes entries. |
| 264 TEST_F(SurfaceAggregatorValidSurfaceTest, MultiPassDeallocation) { | 257 TEST_F(SurfaceAggregatorValidSurfaceTest, MultiPassDeallocation) { |
| 265 test::Quad quads[][2] = {{test::Quad::SolidColorQuad(SK_ColorWHITE), | 258 test::Quad quads[][2] = {{test::Quad::SolidColorQuad(SK_ColorWHITE), |
| 266 test::Quad::SolidColorQuad(SK_ColorLTGRAY)}, | 259 test::Quad::SolidColorQuad(SK_ColorLTGRAY)}, |
| 267 {test::Quad::SolidColorQuad(SK_ColorGRAY), | 260 {test::Quad::SolidColorQuad(SK_ColorGRAY), |
| 268 test::Quad::SolidColorQuad(SK_ColorDKGRAY)}}; | 261 test::Quad::SolidColorQuad(SK_ColorDKGRAY)}}; |
| 269 test::Pass passes[] = {test::Pass(quads[0], arraysize(quads[0]), 2), | 262 test::Pass passes[] = {test::Pass(quads[0], arraysize(quads[0]), 2), |
| 270 test::Pass(quads[1], arraysize(quads[1]), 1)}; | 263 test::Pass(quads[1], arraysize(quads[1]), 1)}; |
| 271 | 264 |
| 272 SubmitCompositorFrame(&factory_, passes, arraysize(passes), | 265 SubmitCompositorFrame(&support_, passes, arraysize(passes), |
| 273 root_local_surface_id_); | 266 root_local_surface_id_); |
| 274 | 267 |
| 275 SurfaceId surface_id(factory_.frame_sink_id(), root_local_surface_id_); | 268 SurfaceId surface_id(support_.frame_sink_id(), root_local_surface_id_); |
| 276 | 269 |
| 277 CompositorFrame aggregated_frame; | 270 CompositorFrame aggregated_frame; |
| 278 aggregated_frame = aggregator_.Aggregate(surface_id); | 271 aggregated_frame = aggregator_.Aggregate(surface_id); |
| 279 auto id0 = aggregated_frame.render_pass_list[0]->id; | 272 auto id0 = aggregated_frame.render_pass_list[0]->id; |
| 280 auto id1 = aggregated_frame.render_pass_list[1]->id; | 273 auto id1 = aggregated_frame.render_pass_list[1]->id; |
| 281 EXPECT_NE(id1, id0); | 274 EXPECT_NE(id1, id0); |
| 282 | 275 |
| 283 // Aggregated RenderPass ids should remain the same between frames. | 276 // Aggregated RenderPass ids should remain the same between frames. |
| 284 aggregated_frame = aggregator_.Aggregate(surface_id); | 277 aggregated_frame = aggregator_.Aggregate(surface_id); |
| 285 EXPECT_EQ(id0, aggregated_frame.render_pass_list[0]->id); | 278 EXPECT_EQ(id0, aggregated_frame.render_pass_list[0]->id); |
| 286 EXPECT_EQ(id1, aggregated_frame.render_pass_list[1]->id); | 279 EXPECT_EQ(id1, aggregated_frame.render_pass_list[1]->id); |
| 287 | 280 |
| 288 test::Pass passes2[] = {test::Pass(quads[0], arraysize(quads[0]), 3), | 281 test::Pass passes2[] = {test::Pass(quads[0], arraysize(quads[0]), 3), |
| 289 test::Pass(quads[1], arraysize(quads[1]), 1)}; | 282 test::Pass(quads[1], arraysize(quads[1]), 1)}; |
| 290 | 283 |
| 291 SubmitCompositorFrame(&factory_, passes2, arraysize(passes2), | 284 SubmitCompositorFrame(&support_, passes2, arraysize(passes2), |
| 292 root_local_surface_id_); | 285 root_local_surface_id_); |
| 293 | 286 |
| 294 // The RenderPass that still exists should keep the same ID. | 287 // The RenderPass that still exists should keep the same ID. |
| 295 aggregated_frame = aggregator_.Aggregate(surface_id); | 288 aggregated_frame = aggregator_.Aggregate(surface_id); |
| 296 auto id2 = aggregated_frame.render_pass_list[0]->id; | 289 auto id2 = aggregated_frame.render_pass_list[0]->id; |
| 297 EXPECT_NE(id2, id1); | 290 EXPECT_NE(id2, id1); |
| 298 EXPECT_NE(id2, id0); | 291 EXPECT_NE(id2, id0); |
| 299 EXPECT_EQ(id1, aggregated_frame.render_pass_list[1]->id); | 292 EXPECT_EQ(id1, aggregated_frame.render_pass_list[1]->id); |
| 300 | 293 |
| 301 SubmitCompositorFrame(&factory_, passes, arraysize(passes), | 294 SubmitCompositorFrame(&support_, passes, arraysize(passes), |
| 302 root_local_surface_id_); | 295 root_local_surface_id_); |
| 303 | 296 |
| 304 // |id1| didn't exist in the previous frame, so it should be | 297 // |id1| didn't exist in the previous frame, so it should be |
| 305 // mapped to a new ID. | 298 // mapped to a new ID. |
| 306 aggregated_frame = aggregator_.Aggregate(surface_id); | 299 aggregated_frame = aggregator_.Aggregate(surface_id); |
| 307 auto id3 = aggregated_frame.render_pass_list[0]->id; | 300 auto id3 = aggregated_frame.render_pass_list[0]->id; |
| 308 EXPECT_NE(id3, id2); | 301 EXPECT_NE(id3, id2); |
| 309 EXPECT_NE(id3, id1); | 302 EXPECT_NE(id3, id1); |
| 310 EXPECT_NE(id3, id0); | 303 EXPECT_NE(id3, id0); |
| 311 EXPECT_EQ(id1, aggregated_frame.render_pass_list[1]->id); | 304 EXPECT_EQ(id1, aggregated_frame.render_pass_list[1]->id); |
| 312 } | 305 } |
| 313 | 306 |
| 314 // This tests very simple embedding. root_surface has a frame containing a few | 307 // This tests very simple embedding. root_surface has a frame containing a few |
| 315 // solid color quads and a surface quad referencing embedded_surface. | 308 // solid color quads and a surface quad referencing embedded_surface. |
| 316 // embedded_surface has a frame containing only a solid color quad. The solid | 309 // embedded_surface has a frame containing only a solid color quad. The solid |
| 317 // color quad should be aggregated into the final frame. | 310 // color quad should be aggregated into the final frame. |
| 318 TEST_F(SurfaceAggregatorValidSurfaceTest, SimpleSurfaceReference) { | 311 TEST_F(SurfaceAggregatorValidSurfaceTest, SimpleSurfaceReference) { |
| 319 SurfaceFactory embedded_factory(kArbitraryChildFrameSinkId1, &manager_, | 312 CompositorFrameSinkSupport embedded_support( |
| 320 &empty_client_); | 313 nullptr, &manager_, kArbitraryFrameSinkId1, is_root, |
| 314 handles_frame_sink_id_invalidation, needs_sync_points); |
| 321 LocalSurfaceId embedded_local_surface_id = allocator_.GenerateId(); | 315 LocalSurfaceId embedded_local_surface_id = allocator_.GenerateId(); |
| 322 SurfaceId embedded_surface_id(embedded_factory.frame_sink_id(), | 316 SurfaceId embedded_surface_id(embedded_support.frame_sink_id(), |
| 323 embedded_local_surface_id); | 317 embedded_local_surface_id); |
| 324 | 318 |
| 325 test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)}; | 319 test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)}; |
| 326 test::Pass embedded_passes[] = { | 320 test::Pass embedded_passes[] = { |
| 327 test::Pass(embedded_quads, arraysize(embedded_quads))}; | 321 test::Pass(embedded_quads, arraysize(embedded_quads))}; |
| 328 | 322 |
| 329 SubmitCompositorFrame(&embedded_factory, embedded_passes, | 323 SubmitCompositorFrame(&embedded_support, embedded_passes, |
| 330 arraysize(embedded_passes), embedded_local_surface_id); | 324 arraysize(embedded_passes), embedded_local_surface_id); |
| 331 | 325 |
| 332 test::Quad root_quads[] = { | 326 test::Quad root_quads[] = { |
| 333 test::Quad::SolidColorQuad(SK_ColorWHITE), | 327 test::Quad::SolidColorQuad(SK_ColorWHITE), |
| 334 test::Quad::SurfaceQuad(embedded_surface_id, InvalidSurfaceId(), 1.f), | 328 test::Quad::SurfaceQuad(embedded_surface_id, InvalidSurfaceId(), 1.f), |
| 335 test::Quad::SolidColorQuad(SK_ColorBLACK)}; | 329 test::Quad::SolidColorQuad(SK_ColorBLACK)}; |
| 336 test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))}; | 330 test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))}; |
| 337 | 331 |
| 338 SubmitCompositorFrame(&factory_, root_passes, arraysize(root_passes), | 332 SubmitCompositorFrame(&support_, root_passes, arraysize(root_passes), |
| 339 root_local_surface_id_); | 333 root_local_surface_id_); |
| 340 | 334 |
| 341 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE), | 335 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE), |
| 342 test::Quad::SolidColorQuad(SK_ColorGREEN), | 336 test::Quad::SolidColorQuad(SK_ColorGREEN), |
| 343 test::Quad::SolidColorQuad(SK_ColorBLACK)}; | 337 test::Quad::SolidColorQuad(SK_ColorBLACK)}; |
| 344 test::Pass expected_passes[] = { | 338 test::Pass expected_passes[] = { |
| 345 test::Pass(expected_quads, arraysize(expected_quads))}; | 339 test::Pass(expected_quads, arraysize(expected_quads))}; |
| 346 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_surface_id_); | 340 SurfaceId root_surface_id(support_.frame_sink_id(), root_local_surface_id_); |
| 347 SurfaceId ids[] = {root_surface_id, embedded_surface_id}; | 341 SurfaceId ids[] = {root_surface_id, embedded_surface_id}; |
| 348 AggregateAndVerify( | 342 AggregateAndVerify( |
| 349 expected_passes, arraysize(expected_passes), ids, arraysize(ids)); | 343 expected_passes, arraysize(expected_passes), ids, arraysize(ids)); |
| 350 | 344 |
| 351 embedded_factory.EvictSurface(); | 345 embedded_support.EvictFrame(); |
| 352 } | 346 } |
| 353 | 347 |
| 354 // This test verifies that in the absence of a primary Surface, | 348 // This test verifies that in the absence of a primary Surface, |
| 355 // SurfaceAggregator will embed a fallback Surface, if available. If the primary | 349 // SurfaceAggregator will embed a fallback Surface, if available. If the primary |
| 356 // Surface is available, though, the fallback will not be used. | 350 // Surface is available, though, the fallback will not be used. |
| 357 TEST_F(SurfaceAggregatorValidSurfaceTest, FallbackSurfaceReference) { | 351 TEST_F(SurfaceAggregatorValidSurfaceTest, FallbackSurfaceReference) { |
| 358 SurfaceFactory primary_child_factory(kArbitraryChildFrameSinkId1, &manager_, | 352 CompositorFrameSinkSupport primary_child_support( |
| 359 &empty_client_); | 353 nullptr, &manager_, kArbitraryFrameSinkId1, is_root_child, |
| 354 handles_frame_sink_id_invalidation, needs_sync_points); |
| 360 LocalSurfaceId primary_child_local_surface_id = allocator_.GenerateId(); | 355 LocalSurfaceId primary_child_local_surface_id = allocator_.GenerateId(); |
| 361 SurfaceId primary_child_surface_id(primary_child_factory.frame_sink_id(), | 356 SurfaceId primary_child_surface_id(primary_child_support.frame_sink_id(), |
| 362 primary_child_local_surface_id); | 357 primary_child_local_surface_id); |
| 363 | 358 |
| 364 SurfaceFactory fallback_child_factory(kArbitraryChildFrameSinkId2, &manager_, | 359 CompositorFrameSinkSupport fallback_child_support( |
| 365 &empty_client_); | 360 nullptr, &manager_, kArbitraryFrameSinkId2, is_root_child, |
| 361 handles_frame_sink_id_invalidation, needs_sync_points); |
| 366 LocalSurfaceId fallback_child_local_surface_id = allocator_.GenerateId(); | 362 LocalSurfaceId fallback_child_local_surface_id = allocator_.GenerateId(); |
| 367 SurfaceId fallback_child_surface_id(fallback_child_factory.frame_sink_id(), | 363 SurfaceId fallback_child_surface_id(fallback_child_support.frame_sink_id(), |
| 368 fallback_child_local_surface_id); | 364 fallback_child_local_surface_id); |
| 369 | 365 |
| 370 test::Quad fallback_child_quads[] = {test::Quad::SolidColorQuad(SK_ColorRED)}; | 366 test::Quad fallback_child_quads[] = {test::Quad::SolidColorQuad(SK_ColorRED)}; |
| 371 test::Pass fallback_child_passes[] = { | 367 test::Pass fallback_child_passes[] = { |
| 372 test::Pass(fallback_child_quads, arraysize(fallback_child_quads))}; | 368 test::Pass(fallback_child_quads, arraysize(fallback_child_quads))}; |
| 373 | 369 |
| 374 // Submit a CompositorFrame to the fallback Surface containing a red | 370 // Submit a CompositorFrame to the fallback Surface containing a red |
| 375 // SolidColorDrawQuad. | 371 // SolidColorDrawQuad. |
| 376 SubmitCompositorFrame(&fallback_child_factory, fallback_child_passes, | 372 SubmitCompositorFrame(&fallback_child_support, fallback_child_passes, |
| 377 arraysize(fallback_child_passes), | 373 arraysize(fallback_child_passes), |
| 378 fallback_child_local_surface_id); | 374 fallback_child_local_surface_id); |
| 379 | 375 |
| 380 // Try to embed |primary_child_surface_id| and if unavailabe, embed | 376 // Try to embed |primary_child_surface_id| and if unavailabe, embed |
| 381 // |fallback_child_surface_id|. | 377 // |fallback_child_surface_id|. |
| 382 test::Quad root_quads[] = {test::Quad::SurfaceQuad( | 378 test::Quad root_quads[] = {test::Quad::SurfaceQuad( |
| 383 primary_child_surface_id, fallback_child_surface_id, 1.f)}; | 379 primary_child_surface_id, fallback_child_surface_id, 1.f)}; |
| 384 test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))}; | 380 test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))}; |
| 385 | 381 |
| 386 SubmitCompositorFrame(&factory_, root_passes, arraysize(root_passes), | 382 SubmitCompositorFrame(&support_, root_passes, arraysize(root_passes), |
| 387 root_local_surface_id_); | 383 root_local_surface_id_); |
| 388 | 384 |
| 389 // There is no CompositorFrame submitted to |primary_child_surface_id| and so | 385 // There is no CompositorFrame submitted to |primary_child_surface_id| and so |
| 390 // |fallback_child_surface_id| will be embedded and we should see a red | 386 // |fallback_child_surface_id| will be embedded and we should see a red |
| 391 // SolidColorDrawQuad. | 387 // SolidColorDrawQuad. |
| 392 test::Quad expected_quads1[] = {test::Quad::SolidColorQuad(SK_ColorRED)}; | 388 test::Quad expected_quads1[] = {test::Quad::SolidColorQuad(SK_ColorRED)}; |
| 393 test::Pass expected_passes1[] = { | 389 test::Pass expected_passes1[] = { |
| 394 test::Pass(expected_quads1, arraysize(expected_quads1))}; | 390 test::Pass(expected_quads1, arraysize(expected_quads1))}; |
| 395 | 391 |
| 396 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_surface_id_); | 392 SurfaceId root_surface_id(support_.frame_sink_id(), root_local_surface_id_); |
| 397 SurfaceId ids[] = {root_surface_id, primary_child_surface_id, | 393 SurfaceId ids[] = {root_surface_id, primary_child_surface_id, |
| 398 fallback_child_surface_id}; | 394 fallback_child_surface_id}; |
| 399 AggregateAndVerify(expected_passes1, arraysize(expected_passes1), ids, | 395 AggregateAndVerify(expected_passes1, arraysize(expected_passes1), ids, |
| 400 arraysize(ids)); | 396 arraysize(ids)); |
| 401 | 397 |
| 402 test::Quad primary_child_quads[] = { | 398 test::Quad primary_child_quads[] = { |
| 403 test::Quad::SolidColorQuad(SK_ColorGREEN)}; | 399 test::Quad::SolidColorQuad(SK_ColorGREEN)}; |
| 404 test::Pass primary_child_passes[] = { | 400 test::Pass primary_child_passes[] = { |
| 405 test::Pass(primary_child_quads, arraysize(primary_child_quads))}; | 401 test::Pass(primary_child_quads, arraysize(primary_child_quads))}; |
| 406 | 402 |
| 407 // Submit a CompositorFrame to the primary Surface containing a green | 403 // Submit a CompositorFrame to the primary Surface containing a green |
| 408 // SolidColorDrawQuad. | 404 // SolidColorDrawQuad. |
| 409 SubmitCompositorFrame(&primary_child_factory, primary_child_passes, | 405 SubmitCompositorFrame(&primary_child_support, primary_child_passes, |
| 410 arraysize(primary_child_passes), | 406 arraysize(primary_child_passes), |
| 411 primary_child_local_surface_id); | 407 primary_child_local_surface_id); |
| 412 | 408 |
| 413 // Now that the primary Surface has a CompositorFrame, we expect | 409 // Now that the primary Surface has a CompositorFrame, we expect |
| 414 // SurfaceAggregator to embed the primary Surface, and drop the fallback | 410 // SurfaceAggregator to embed the primary Surface, and drop the fallback |
| 415 // Surface. | 411 // Surface. |
| 416 test::Quad expected_quads2[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)}; | 412 test::Quad expected_quads2[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)}; |
| 417 test::Pass expected_passes2[] = { | 413 test::Pass expected_passes2[] = { |
| 418 test::Pass(expected_quads2, arraysize(expected_quads2))}; | 414 test::Pass(expected_quads2, arraysize(expected_quads2))}; |
| 419 AggregateAndVerify(expected_passes2, arraysize(expected_passes2), ids, | 415 AggregateAndVerify(expected_passes2, arraysize(expected_passes2), ids, |
| 420 arraysize(ids)); | 416 arraysize(ids)); |
| 421 | 417 |
| 422 primary_child_factory.EvictSurface(); | 418 primary_child_support.EvictFrame(); |
| 423 fallback_child_factory.EvictSurface(); | 419 fallback_child_support.EvictFrame(); |
| 424 } | 420 } |
| 425 | 421 |
| 426 // This test verifies that in the presence of both primary Surface and fallback | 422 // This test verifies that in the presence of both primary Surface and fallback |
| 427 // Surface, the fallback will not be used. | 423 // Surface, the fallback will not be used. |
| 428 TEST_F(SurfaceAggregatorValidSurfaceTest, FallbackSurfaceReferenceWithPrimary) { | 424 TEST_F(SurfaceAggregatorValidSurfaceTest, FallbackSurfaceReferenceWithPrimary) { |
| 429 SurfaceFactory primary_child_factory(kArbitraryChildFrameSinkId1, &manager_, | 425 CompositorFrameSinkSupport primary_child_support( |
| 430 &empty_client_); | 426 nullptr, &manager_, kArbitraryFrameSinkId1, is_root_child, |
| 427 handles_frame_sink_id_invalidation, needs_sync_points); |
| 431 LocalSurfaceId primary_child_local_surface_id = allocator_.GenerateId(); | 428 LocalSurfaceId primary_child_local_surface_id = allocator_.GenerateId(); |
| 432 SurfaceId primary_child_surface_id(primary_child_factory.frame_sink_id(), | 429 SurfaceId primary_child_surface_id(primary_child_support.frame_sink_id(), |
| 433 primary_child_local_surface_id); | 430 primary_child_local_surface_id); |
| 434 test::Quad primary_child_quads[] = { | 431 test::Quad primary_child_quads[] = { |
| 435 test::Quad::SolidColorQuad(SK_ColorGREEN)}; | 432 test::Quad::SolidColorQuad(SK_ColorGREEN)}; |
| 436 test::Pass primary_child_passes[] = { | 433 test::Pass primary_child_passes[] = { |
| 437 test::Pass(primary_child_quads, arraysize(primary_child_quads))}; | 434 test::Pass(primary_child_quads, arraysize(primary_child_quads))}; |
| 438 | 435 |
| 439 // Submit a CompositorFrame to the primary Surface containing a green | 436 // Submit a CompositorFrame to the primary Surface containing a green |
| 440 // SolidColorDrawQuad. | 437 // SolidColorDrawQuad. |
| 441 SubmitCompositorFrame(&primary_child_factory, primary_child_passes, | 438 SubmitCompositorFrame(&primary_child_support, primary_child_passes, |
| 442 arraysize(primary_child_passes), | 439 arraysize(primary_child_passes), |
| 443 primary_child_local_surface_id); | 440 primary_child_local_surface_id); |
| 444 | 441 |
| 445 SurfaceFactory fallback_child_factory(kArbitraryChildFrameSinkId2, &manager_, | 442 CompositorFrameSinkSupport fallback_child_support( |
| 446 &empty_client_); | 443 nullptr, &manager_, kArbitraryFrameSinkId2, is_root_child, |
| 444 handles_frame_sink_id_invalidation, needs_sync_points); |
| 447 LocalSurfaceId fallback_child_local_surface_id = allocator_.GenerateId(); | 445 LocalSurfaceId fallback_child_local_surface_id = allocator_.GenerateId(); |
| 448 SurfaceId fallback_child_surface_id(fallback_child_factory.frame_sink_id(), | 446 SurfaceId fallback_child_surface_id(fallback_child_support.frame_sink_id(), |
| 449 fallback_child_local_surface_id); | 447 fallback_child_local_surface_id); |
| 450 | 448 |
| 451 test::Quad fallback_child_quads[] = {test::Quad::SolidColorQuad(SK_ColorRED)}; | 449 test::Quad fallback_child_quads[] = {test::Quad::SolidColorQuad(SK_ColorRED)}; |
| 452 test::Pass fallback_child_passes[] = { | 450 test::Pass fallback_child_passes[] = { |
| 453 test::Pass(fallback_child_quads, arraysize(fallback_child_quads))}; | 451 test::Pass(fallback_child_quads, arraysize(fallback_child_quads))}; |
| 454 | 452 |
| 455 // Submit a CompositorFrame to the fallback Surface containing a red | 453 // Submit a CompositorFrame to the fallback Surface containing a red |
| 456 // SolidColorDrawQuad. | 454 // SolidColorDrawQuad. |
| 457 SubmitCompositorFrame(&fallback_child_factory, fallback_child_passes, | 455 SubmitCompositorFrame(&fallback_child_support, fallback_child_passes, |
| 458 arraysize(fallback_child_passes), | 456 arraysize(fallback_child_passes), |
| 459 fallback_child_local_surface_id); | 457 fallback_child_local_surface_id); |
| 460 | 458 |
| 461 // Try to embed |primary_child_surface_id| and if unavailabe, embed | 459 // Try to embed |primary_child_surface_id| and if unavailabe, embed |
| 462 // |fallback_child_surface_id|. | 460 // |fallback_child_surface_id|. |
| 463 test::Quad root_quads[] = {test::Quad::SurfaceQuad( | 461 test::Quad root_quads[] = {test::Quad::SurfaceQuad( |
| 464 primary_child_surface_id, fallback_child_surface_id, 1.f)}; | 462 primary_child_surface_id, fallback_child_surface_id, 1.f)}; |
| 465 test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))}; | 463 test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))}; |
| 466 | 464 |
| 467 SubmitCompositorFrame(&factory_, root_passes, arraysize(root_passes), | 465 SubmitCompositorFrame(&support_, root_passes, arraysize(root_passes), |
| 468 root_local_surface_id_); | 466 root_local_surface_id_); |
| 469 | 467 |
| 470 // The CompositorFrame is submitted to |primary_child_surface_id|, so | 468 // The CompositorFrame is submitted to |primary_child_surface_id|, so |
| 471 // |fallback_child_surface_id| will not be used and we should see a green | 469 // |fallback_child_surface_id| will not be used and we should see a green |
| 472 // SolidColorDrawQuad. | 470 // SolidColorDrawQuad. |
| 473 test::Quad expected_quads1[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)}; | 471 test::Quad expected_quads1[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)}; |
| 474 test::Pass expected_passes1[] = { | 472 test::Pass expected_passes1[] = { |
| 475 test::Pass(expected_quads1, arraysize(expected_quads1))}; | 473 test::Pass(expected_quads1, arraysize(expected_quads1))}; |
| 476 | 474 |
| 477 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_surface_id_); | 475 SurfaceId root_surface_id(support_.frame_sink_id(), root_local_surface_id_); |
| 478 SurfaceId ids[] = {root_surface_id, primary_child_surface_id, | 476 SurfaceId ids[] = {root_surface_id, primary_child_surface_id, |
| 479 fallback_child_surface_id}; | 477 fallback_child_surface_id}; |
| 480 AggregateAndVerify(expected_passes1, arraysize(expected_passes1), ids, | 478 AggregateAndVerify(expected_passes1, arraysize(expected_passes1), ids, |
| 481 arraysize(ids)); | 479 arraysize(ids)); |
| 482 | 480 |
| 483 primary_child_factory.EvictSurface(); | 481 primary_child_support.EvictFrame(); |
| 484 fallback_child_factory.EvictSurface(); | 482 fallback_child_support.EvictFrame(); |
| 485 } | 483 } |
| 486 | 484 |
| 487 TEST_F(SurfaceAggregatorValidSurfaceTest, CopyRequest) { | 485 TEST_F(SurfaceAggregatorValidSurfaceTest, CopyRequest) { |
| 488 SurfaceFactory embedded_factory(kArbitraryChildFrameSinkId1, &manager_, | 486 CompositorFrameSinkSupport embedded_support( |
| 489 &empty_client_); | 487 nullptr, &manager_, kArbitraryFrameSinkId1, is_root_child, |
| 488 handles_frame_sink_id_invalidation, needs_sync_points); |
| 490 LocalSurfaceId embedded_local_surface_id = allocator_.GenerateId(); | 489 LocalSurfaceId embedded_local_surface_id = allocator_.GenerateId(); |
| 491 SurfaceId embedded_surface_id(embedded_factory.frame_sink_id(), | 490 SurfaceId embedded_surface_id(embedded_support.frame_sink_id(), |
| 492 embedded_local_surface_id); | 491 embedded_local_surface_id); |
| 493 | 492 |
| 494 test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)}; | 493 test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)}; |
| 495 test::Pass embedded_passes[] = { | 494 test::Pass embedded_passes[] = { |
| 496 test::Pass(embedded_quads, arraysize(embedded_quads))}; | 495 test::Pass(embedded_quads, arraysize(embedded_quads))}; |
| 497 | 496 |
| 498 SubmitCompositorFrame(&embedded_factory, embedded_passes, | 497 SubmitCompositorFrame(&embedded_support, embedded_passes, |
| 499 arraysize(embedded_passes), embedded_local_surface_id); | 498 arraysize(embedded_passes), embedded_local_surface_id); |
| 500 std::unique_ptr<CopyOutputRequest> copy_request( | 499 std::unique_ptr<CopyOutputRequest> copy_request( |
| 501 CopyOutputRequest::CreateEmptyRequest()); | 500 CopyOutputRequest::CreateEmptyRequest()); |
| 502 CopyOutputRequest* copy_request_ptr = copy_request.get(); | 501 CopyOutputRequest* copy_request_ptr = copy_request.get(); |
| 503 embedded_factory.RequestCopyOfSurface(std::move(copy_request)); | 502 embedded_support.RequestCopyOfSurface(std::move(copy_request)); |
| 504 | 503 |
| 505 test::Quad root_quads[] = { | 504 test::Quad root_quads[] = { |
| 506 test::Quad::SolidColorQuad(SK_ColorWHITE), | 505 test::Quad::SolidColorQuad(SK_ColorWHITE), |
| 507 test::Quad::SurfaceQuad(embedded_surface_id, InvalidSurfaceId(), 1.f), | 506 test::Quad::SurfaceQuad(embedded_surface_id, InvalidSurfaceId(), 1.f), |
| 508 test::Quad::SolidColorQuad(SK_ColorBLACK)}; | 507 test::Quad::SolidColorQuad(SK_ColorBLACK)}; |
| 509 test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))}; | 508 test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))}; |
| 510 | 509 |
| 511 SubmitCompositorFrame(&factory_, root_passes, arraysize(root_passes), | 510 SubmitCompositorFrame(&support_, root_passes, arraysize(root_passes), |
| 512 root_local_surface_id_); | 511 root_local_surface_id_); |
| 513 | 512 |
| 514 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_surface_id_); | 513 SurfaceId root_surface_id(support_.frame_sink_id(), root_local_surface_id_); |
| 515 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); | 514 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); |
| 516 | 515 |
| 517 test::Quad expected_quads[] = { | 516 test::Quad expected_quads[] = { |
| 518 test::Quad::SolidColorQuad(SK_ColorWHITE), | 517 test::Quad::SolidColorQuad(SK_ColorWHITE), |
| 519 test::Quad::RenderPassQuad(aggregated_frame.render_pass_list[0]->id), | 518 test::Quad::RenderPassQuad(aggregated_frame.render_pass_list[0]->id), |
| 520 test::Quad::SolidColorQuad(SK_ColorBLACK)}; | 519 test::Quad::SolidColorQuad(SK_ColorBLACK)}; |
| 521 test::Pass expected_passes[] = { | 520 test::Pass expected_passes[] = { |
| 522 test::Pass(embedded_quads, arraysize(embedded_quads)), | 521 test::Pass(embedded_quads, arraysize(embedded_quads)), |
| 523 test::Pass(expected_quads, arraysize(expected_quads))}; | 522 test::Pass(expected_quads, arraysize(expected_quads))}; |
| 524 TestPassesMatchExpectations(expected_passes, arraysize(expected_passes), | 523 TestPassesMatchExpectations(expected_passes, arraysize(expected_passes), |
| 525 &aggregated_frame.render_pass_list); | 524 &aggregated_frame.render_pass_list); |
| 526 ASSERT_EQ(2u, aggregated_frame.render_pass_list.size()); | 525 ASSERT_EQ(2u, aggregated_frame.render_pass_list.size()); |
| 527 ASSERT_EQ(1u, aggregated_frame.render_pass_list[0]->copy_requests.size()); | 526 ASSERT_EQ(1u, aggregated_frame.render_pass_list[0]->copy_requests.size()); |
| 528 DCHECK_EQ(copy_request_ptr, | 527 DCHECK_EQ(copy_request_ptr, |
| 529 aggregated_frame.render_pass_list[0]->copy_requests[0].get()); | 528 aggregated_frame.render_pass_list[0]->copy_requests[0].get()); |
| 530 | 529 |
| 531 SurfaceId surface_ids[] = {root_surface_id, embedded_surface_id}; | 530 SurfaceId surface_ids[] = {root_surface_id, embedded_surface_id}; |
| 532 EXPECT_EQ(arraysize(surface_ids), | 531 EXPECT_EQ(arraysize(surface_ids), |
| 533 aggregator_.previous_contained_surfaces().size()); | 532 aggregator_.previous_contained_surfaces().size()); |
| 534 for (size_t i = 0; i < arraysize(surface_ids); i++) { | 533 for (size_t i = 0; i < arraysize(surface_ids); i++) { |
| 535 EXPECT_TRUE( | 534 EXPECT_TRUE( |
| 536 aggregator_.previous_contained_surfaces().find(surface_ids[i]) != | 535 aggregator_.previous_contained_surfaces().find(surface_ids[i]) != |
| 537 aggregator_.previous_contained_surfaces().end()); | 536 aggregator_.previous_contained_surfaces().end()); |
| 538 } | 537 } |
| 539 | 538 |
| 540 embedded_factory.EvictSurface(); | 539 embedded_support.EvictFrame(); |
| 541 } | 540 } |
| 542 | 541 |
| 543 // Root surface may contain copy requests. | 542 // Root surface may contain copy requests. |
| 544 TEST_F(SurfaceAggregatorValidSurfaceTest, RootCopyRequest) { | 543 TEST_F(SurfaceAggregatorValidSurfaceTest, RootCopyRequest) { |
| 545 SurfaceFactory embedded_factory(kArbitraryChildFrameSinkId1, &manager_, | 544 CompositorFrameSinkSupport embedded_support( |
| 546 &empty_client_); | 545 nullptr, &manager_, kArbitraryFrameSinkId2, is_root_child, |
| 546 handles_frame_sink_id_invalidation, needs_sync_points); |
| 547 LocalSurfaceId embedded_local_surface_id = allocator_.GenerateId(); | 547 LocalSurfaceId embedded_local_surface_id = allocator_.GenerateId(); |
| 548 SurfaceId embedded_surface_id(embedded_factory.frame_sink_id(), | 548 SurfaceId embedded_surface_id(embedded_support.frame_sink_id(), |
| 549 embedded_local_surface_id); | 549 embedded_local_surface_id); |
| 550 | 550 |
| 551 test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)}; | 551 test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)}; |
| 552 test::Pass embedded_passes[] = { | 552 test::Pass embedded_passes[] = { |
| 553 test::Pass(embedded_quads, arraysize(embedded_quads))}; | 553 test::Pass(embedded_quads, arraysize(embedded_quads))}; |
| 554 | 554 |
| 555 SubmitCompositorFrame(&embedded_factory, embedded_passes, | 555 SubmitCompositorFrame(&embedded_support, embedded_passes, |
| 556 arraysize(embedded_passes), embedded_local_surface_id); | 556 arraysize(embedded_passes), embedded_local_surface_id); |
| 557 std::unique_ptr<CopyOutputRequest> copy_request( | 557 std::unique_ptr<CopyOutputRequest> copy_request( |
| 558 CopyOutputRequest::CreateEmptyRequest()); | 558 CopyOutputRequest::CreateEmptyRequest()); |
| 559 CopyOutputRequest* copy_request_ptr = copy_request.get(); | 559 CopyOutputRequest* copy_request_ptr = copy_request.get(); |
| 560 std::unique_ptr<CopyOutputRequest> copy_request2( | 560 std::unique_ptr<CopyOutputRequest> copy_request2( |
| 561 CopyOutputRequest::CreateEmptyRequest()); | 561 CopyOutputRequest::CreateEmptyRequest()); |
| 562 CopyOutputRequest* copy_request2_ptr = copy_request2.get(); | 562 CopyOutputRequest* copy_request2_ptr = copy_request2.get(); |
| 563 | 563 |
| 564 test::Quad root_quads[] = { | 564 test::Quad root_quads[] = { |
| 565 test::Quad::SolidColorQuad(SK_ColorWHITE), | 565 test::Quad::SolidColorQuad(SK_ColorWHITE), |
| 566 test::Quad::SurfaceQuad(embedded_surface_id, InvalidSurfaceId(), 1.f), | 566 test::Quad::SurfaceQuad(embedded_surface_id, InvalidSurfaceId(), 1.f), |
| 567 test::Quad::SolidColorQuad(SK_ColorBLACK)}; | 567 test::Quad::SolidColorQuad(SK_ColorBLACK)}; |
| 568 test::Quad root_quads2[] = {test::Quad::SolidColorQuad(SK_ColorRED)}; | 568 test::Quad root_quads2[] = {test::Quad::SolidColorQuad(SK_ColorRED)}; |
| 569 test::Pass root_passes[] = { | 569 test::Pass root_passes[] = { |
| 570 test::Pass(root_quads, arraysize(root_quads), 1), | 570 test::Pass(root_quads, arraysize(root_quads), 1), |
| 571 test::Pass(root_quads2, arraysize(root_quads2), 2)}; | 571 test::Pass(root_quads2, arraysize(root_quads2), 2)}; |
| 572 { | 572 { |
| 573 CompositorFrame frame; | 573 CompositorFrame frame; |
| 574 AddPasses(&frame.render_pass_list, gfx::Rect(SurfaceSize()), root_passes, | 574 AddPasses(&frame.render_pass_list, gfx::Rect(SurfaceSize()), root_passes, |
| 575 arraysize(root_passes)); | 575 arraysize(root_passes)); |
| 576 frame.render_pass_list[0]->copy_requests.push_back(std::move(copy_request)); | 576 frame.render_pass_list[0]->copy_requests.push_back(std::move(copy_request)); |
| 577 frame.render_pass_list[1]->copy_requests.push_back( | 577 frame.render_pass_list[1]->copy_requests.push_back( |
| 578 std::move(copy_request2)); | 578 std::move(copy_request2)); |
| 579 | 579 |
| 580 factory_.SubmitCompositorFrame(root_local_surface_id_, std::move(frame), | 580 support_.SubmitCompositorFrame(root_local_surface_id_, std::move(frame)); |
| 581 SurfaceFactory::DrawCallback()); | |
| 582 } | 581 } |
| 583 | 582 |
| 584 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_surface_id_); | 583 SurfaceId root_surface_id(support_.frame_sink_id(), root_local_surface_id_); |
| 585 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); | 584 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); |
| 586 | 585 |
| 587 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE), | 586 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE), |
| 588 test::Quad::SolidColorQuad(SK_ColorGREEN), | 587 test::Quad::SolidColorQuad(SK_ColorGREEN), |
| 589 test::Quad::SolidColorQuad(SK_ColorBLACK)}; | 588 test::Quad::SolidColorQuad(SK_ColorBLACK)}; |
| 590 test::Pass expected_passes[] = { | 589 test::Pass expected_passes[] = { |
| 591 test::Pass(expected_quads, arraysize(expected_quads)), | 590 test::Pass(expected_quads, arraysize(expected_quads)), |
| 592 test::Pass(root_quads2, arraysize(root_quads2))}; | 591 test::Pass(root_quads2, arraysize(root_quads2))}; |
| 593 TestPassesMatchExpectations(expected_passes, arraysize(expected_passes), | 592 TestPassesMatchExpectations(expected_passes, arraysize(expected_passes), |
| 594 &aggregated_frame.render_pass_list); | 593 &aggregated_frame.render_pass_list); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 610 } | 609 } |
| 611 | 610 |
| 612 // Ensure copy requests have been removed from root surface. | 611 // Ensure copy requests have been removed from root surface. |
| 613 const CompositorFrame& original_frame = | 612 const CompositorFrame& original_frame = |
| 614 manager_.GetSurfaceForId(root_surface_id)->GetActiveFrame(); | 613 manager_.GetSurfaceForId(root_surface_id)->GetActiveFrame(); |
| 615 const RenderPassList& original_pass_list = original_frame.render_pass_list; | 614 const RenderPassList& original_pass_list = original_frame.render_pass_list; |
| 616 ASSERT_EQ(2u, original_pass_list.size()); | 615 ASSERT_EQ(2u, original_pass_list.size()); |
| 617 DCHECK(original_pass_list[0]->copy_requests.empty()); | 616 DCHECK(original_pass_list[0]->copy_requests.empty()); |
| 618 DCHECK(original_pass_list[1]->copy_requests.empty()); | 617 DCHECK(original_pass_list[1]->copy_requests.empty()); |
| 619 | 618 |
| 620 embedded_factory.EvictSurface(); | 619 embedded_support.EvictFrame(); |
| 621 } | 620 } |
| 622 | 621 |
| 623 TEST_F(SurfaceAggregatorValidSurfaceTest, UnreferencedSurface) { | 622 TEST_F(SurfaceAggregatorValidSurfaceTest, UnreferencedSurface) { |
| 624 SurfaceFactory embedded_factory(kArbitraryChildFrameSinkId1, &manager_, | 623 CompositorFrameSinkSupport embedded_support( |
| 625 &empty_client_); | 624 nullptr, &manager_, kArbitraryFrameSinkId1, is_root_child, |
| 626 SurfaceFactory parent_factory(kArbitraryRootFrameSinkId, &manager_, | 625 handles_frame_sink_id_invalidation, needs_sync_points); |
| 627 &empty_client_); | 626 CompositorFrameSinkSupport parent_support( |
| 627 nullptr, &manager_, kArbitraryFrameSinkId2, is_root, |
| 628 handles_frame_sink_id_invalidation, needs_sync_points); |
| 628 LocalSurfaceId embedded_local_surface_id = allocator_.GenerateId(); | 629 LocalSurfaceId embedded_local_surface_id = allocator_.GenerateId(); |
| 629 SurfaceId embedded_surface_id(embedded_factory.frame_sink_id(), | 630 SurfaceId embedded_surface_id(embedded_support.frame_sink_id(), |
| 630 embedded_local_surface_id); | 631 embedded_local_surface_id); |
| 631 SurfaceId nonexistent_surface_id(factory_.frame_sink_id(), | 632 SurfaceId nonexistent_surface_id(support_.frame_sink_id(), |
| 632 allocator_.GenerateId()); | 633 allocator_.GenerateId()); |
| 633 | 634 |
| 634 test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)}; | 635 test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)}; |
| 635 test::Pass embedded_passes[] = { | 636 test::Pass embedded_passes[] = { |
| 636 test::Pass(embedded_quads, arraysize(embedded_quads))}; | 637 test::Pass(embedded_quads, arraysize(embedded_quads))}; |
| 637 | 638 |
| 638 SubmitCompositorFrame(&embedded_factory, embedded_passes, | 639 SubmitCompositorFrame(&embedded_support, embedded_passes, |
| 639 arraysize(embedded_passes), embedded_local_surface_id); | 640 arraysize(embedded_passes), embedded_local_surface_id); |
| 640 std::unique_ptr<CopyOutputRequest> copy_request( | 641 std::unique_ptr<CopyOutputRequest> copy_request( |
| 641 CopyOutputRequest::CreateEmptyRequest()); | 642 CopyOutputRequest::CreateEmptyRequest()); |
| 642 CopyOutputRequest* copy_request_ptr = copy_request.get(); | 643 CopyOutputRequest* copy_request_ptr = copy_request.get(); |
| 643 embedded_factory.RequestCopyOfSurface(std::move(copy_request)); | 644 embedded_support.RequestCopyOfSurface(std::move(copy_request)); |
| 644 | 645 |
| 645 LocalSurfaceId parent_local_surface_id = allocator_.GenerateId(); | 646 LocalSurfaceId parent_local_surface_id = allocator_.GenerateId(); |
| 646 SurfaceId parent_surface_id(parent_factory.frame_sink_id(), | 647 SurfaceId parent_surface_id(parent_support.frame_sink_id(), |
| 647 parent_local_surface_id); | 648 parent_local_surface_id); |
| 648 | 649 |
| 649 test::Quad parent_quads[] = { | 650 test::Quad parent_quads[] = { |
| 650 test::Quad::SolidColorQuad(SK_ColorGRAY), | 651 test::Quad::SolidColorQuad(SK_ColorGRAY), |
| 651 test::Quad::SurfaceQuad(embedded_surface_id, InvalidSurfaceId(), 1.f), | 652 test::Quad::SurfaceQuad(embedded_surface_id, InvalidSurfaceId(), 1.f), |
| 652 test::Quad::SolidColorQuad(SK_ColorLTGRAY)}; | 653 test::Quad::SolidColorQuad(SK_ColorLTGRAY)}; |
| 653 test::Pass parent_passes[] = { | 654 test::Pass parent_passes[] = { |
| 654 test::Pass(parent_quads, arraysize(parent_quads))}; | 655 test::Pass(parent_quads, arraysize(parent_quads))}; |
| 655 | 656 |
| 656 { | 657 { |
| 657 CompositorFrame frame; | 658 CompositorFrame frame; |
| 658 | 659 |
| 659 AddPasses(&frame.render_pass_list, gfx::Rect(SurfaceSize()), parent_passes, | 660 AddPasses(&frame.render_pass_list, gfx::Rect(SurfaceSize()), parent_passes, |
| 660 arraysize(parent_passes)); | 661 arraysize(parent_passes)); |
| 661 | 662 |
| 662 frame.metadata.referenced_surfaces.push_back(embedded_surface_id); | 663 frame.metadata.referenced_surfaces.push_back(embedded_surface_id); |
| 663 | 664 |
| 664 parent_factory.SubmitCompositorFrame(parent_local_surface_id, | 665 parent_support.SubmitCompositorFrame(parent_local_surface_id, |
| 665 std::move(frame), | 666 std::move(frame)); |
| 666 SurfaceFactory::DrawCallback()); | |
| 667 } | 667 } |
| 668 | 668 |
| 669 test::Quad root_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE), | 669 test::Quad root_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE), |
| 670 test::Quad::SolidColorQuad(SK_ColorBLACK)}; | 670 test::Quad::SolidColorQuad(SK_ColorBLACK)}; |
| 671 test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))}; | 671 test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))}; |
| 672 | 672 |
| 673 { | 673 { |
| 674 CompositorFrame frame; | 674 CompositorFrame frame; |
| 675 AddPasses(&frame.render_pass_list, gfx::Rect(SurfaceSize()), root_passes, | 675 AddPasses(&frame.render_pass_list, gfx::Rect(SurfaceSize()), root_passes, |
| 676 arraysize(root_passes)); | 676 arraysize(root_passes)); |
| 677 | 677 |
| 678 frame.metadata.referenced_surfaces.push_back(parent_surface_id); | 678 frame.metadata.referenced_surfaces.push_back(parent_surface_id); |
| 679 // Reference to Surface ID of a Surface that doesn't exist should be | 679 // Reference to Surface ID of a Surface that doesn't exist should be |
| 680 // included in previous_contained_surfaces, but otherwise ignored. | 680 // included in previous_contained_surfaces, but otherwise ignored. |
| 681 frame.metadata.referenced_surfaces.push_back(nonexistent_surface_id); | 681 frame.metadata.referenced_surfaces.push_back(nonexistent_surface_id); |
| 682 | 682 |
| 683 factory_.SubmitCompositorFrame(root_local_surface_id_, std::move(frame), | 683 support_.SubmitCompositorFrame(root_local_surface_id_, std::move(frame)); |
| 684 SurfaceFactory::DrawCallback()); | |
| 685 } | 684 } |
| 686 | 685 |
| 687 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_surface_id_); | 686 SurfaceId root_surface_id(support_.frame_sink_id(), root_local_surface_id_); |
| 688 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); | 687 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); |
| 689 | 688 |
| 690 // First pass should come from surface that had a copy request but was not | 689 // First pass should come from surface that had a copy request but was not |
| 691 // referenced directly. The second pass comes from the root surface. | 690 // referenced directly. The second pass comes from the root surface. |
| 692 // parent_quad should be ignored because it is neither referenced through a | 691 // parent_quad should be ignored because it is neither referenced through a |
| 693 // SurfaceDrawQuad nor has a copy request on it. | 692 // SurfaceDrawQuad nor has a copy request on it. |
| 694 test::Pass expected_passes[] = { | 693 test::Pass expected_passes[] = { |
| 695 test::Pass(embedded_quads, arraysize(embedded_quads)), | 694 test::Pass(embedded_quads, arraysize(embedded_quads)), |
| 696 test::Pass(root_quads, arraysize(root_quads))}; | 695 test::Pass(root_quads, arraysize(root_quads))}; |
| 697 TestPassesMatchExpectations(expected_passes, arraysize(expected_passes), | 696 TestPassesMatchExpectations(expected_passes, arraysize(expected_passes), |
| 698 &aggregated_frame.render_pass_list); | 697 &aggregated_frame.render_pass_list); |
| 699 ASSERT_EQ(2u, aggregated_frame.render_pass_list.size()); | 698 ASSERT_EQ(2u, aggregated_frame.render_pass_list.size()); |
| 700 ASSERT_EQ(1u, aggregated_frame.render_pass_list[0]->copy_requests.size()); | 699 ASSERT_EQ(1u, aggregated_frame.render_pass_list[0]->copy_requests.size()); |
| 701 DCHECK_EQ(copy_request_ptr, | 700 DCHECK_EQ(copy_request_ptr, |
| 702 aggregated_frame.render_pass_list[0]->copy_requests[0].get()); | 701 aggregated_frame.render_pass_list[0]->copy_requests[0].get()); |
| 703 | 702 |
| 704 SurfaceId surface_ids[] = { | 703 SurfaceId surface_ids[] = { |
| 705 SurfaceId(factory_.frame_sink_id(), root_local_surface_id_), | 704 SurfaceId(support_.frame_sink_id(), root_local_surface_id_), |
| 706 parent_surface_id, embedded_surface_id, nonexistent_surface_id}; | 705 parent_surface_id, embedded_surface_id, nonexistent_surface_id}; |
| 707 EXPECT_EQ(arraysize(surface_ids), | 706 EXPECT_EQ(arraysize(surface_ids), |
| 708 aggregator_.previous_contained_surfaces().size()); | 707 aggregator_.previous_contained_surfaces().size()); |
| 709 for (size_t i = 0; i < arraysize(surface_ids); i++) { | 708 for (size_t i = 0; i < arraysize(surface_ids); i++) { |
| 710 EXPECT_TRUE( | 709 EXPECT_TRUE( |
| 711 aggregator_.previous_contained_surfaces().find(surface_ids[i]) != | 710 aggregator_.previous_contained_surfaces().find(surface_ids[i]) != |
| 712 aggregator_.previous_contained_surfaces().end()); | 711 aggregator_.previous_contained_surfaces().end()); |
| 713 } | 712 } |
| 714 | 713 |
| 715 embedded_factory.EvictSurface(); | 714 embedded_support.EvictFrame(); |
| 716 parent_factory.EvictSurface(); | 715 parent_support.EvictFrame(); |
| 717 } | 716 } |
| 718 | 717 |
| 719 // This tests referencing a surface that has multiple render passes. | 718 // This tests referencing a surface that has multiple render passes. |
| 720 TEST_F(SurfaceAggregatorValidSurfaceTest, MultiPassSurfaceReference) { | 719 TEST_F(SurfaceAggregatorValidSurfaceTest, MultiPassSurfaceReference) { |
| 721 LocalSurfaceId embedded_local_surface_id = child_allocator_.GenerateId(); | 720 LocalSurfaceId embedded_local_surface_id = child_allocator_.GenerateId(); |
| 722 SurfaceId embedded_surface_id(child_factory_.frame_sink_id(), | 721 SurfaceId embedded_surface_id(child_support_.frame_sink_id(), |
| 723 embedded_local_surface_id); | 722 embedded_local_surface_id); |
| 724 | 723 |
| 725 int pass_ids[] = {1, 2, 3}; | 724 int pass_ids[] = {1, 2, 3}; |
| 726 | 725 |
| 727 test::Quad embedded_quads[][2] = { | 726 test::Quad embedded_quads[][2] = { |
| 728 {test::Quad::SolidColorQuad(1), test::Quad::SolidColorQuad(2)}, | 727 {test::Quad::SolidColorQuad(1), test::Quad::SolidColorQuad(2)}, |
| 729 {test::Quad::SolidColorQuad(3), test::Quad::RenderPassQuad(pass_ids[0])}, | 728 {test::Quad::SolidColorQuad(3), test::Quad::RenderPassQuad(pass_ids[0])}, |
| 730 {test::Quad::SolidColorQuad(4), test::Quad::RenderPassQuad(pass_ids[1])}}; | 729 {test::Quad::SolidColorQuad(4), test::Quad::RenderPassQuad(pass_ids[1])}}; |
| 731 test::Pass embedded_passes[] = { | 730 test::Pass embedded_passes[] = { |
| 732 test::Pass(embedded_quads[0], arraysize(embedded_quads[0]), pass_ids[0]), | 731 test::Pass(embedded_quads[0], arraysize(embedded_quads[0]), pass_ids[0]), |
| 733 test::Pass(embedded_quads[1], arraysize(embedded_quads[1]), pass_ids[1]), | 732 test::Pass(embedded_quads[1], arraysize(embedded_quads[1]), pass_ids[1]), |
| 734 test::Pass(embedded_quads[2], arraysize(embedded_quads[2]), pass_ids[2])}; | 733 test::Pass(embedded_quads[2], arraysize(embedded_quads[2]), pass_ids[2])}; |
| 735 | 734 |
| 736 SubmitCompositorFrame(&child_factory_, embedded_passes, | 735 SubmitCompositorFrame(&child_support_, embedded_passes, |
| 737 arraysize(embedded_passes), embedded_local_surface_id); | 736 arraysize(embedded_passes), embedded_local_surface_id); |
| 738 | 737 |
| 739 test::Quad root_quads[][2] = { | 738 test::Quad root_quads[][2] = { |
| 740 {test::Quad::SolidColorQuad(5), test::Quad::SolidColorQuad(6)}, | 739 {test::Quad::SolidColorQuad(5), test::Quad::SolidColorQuad(6)}, |
| 741 {test::Quad::SurfaceQuad(embedded_surface_id, InvalidSurfaceId(), 1.f), | 740 {test::Quad::SurfaceQuad(embedded_surface_id, InvalidSurfaceId(), 1.f), |
| 742 test::Quad::RenderPassQuad(pass_ids[0])}, | 741 test::Quad::RenderPassQuad(pass_ids[0])}, |
| 743 {test::Quad::SolidColorQuad(7), test::Quad::RenderPassQuad(pass_ids[1])}}; | 742 {test::Quad::SolidColorQuad(7), test::Quad::RenderPassQuad(pass_ids[1])}}; |
| 744 test::Pass root_passes[] = { | 743 test::Pass root_passes[] = { |
| 745 test::Pass(root_quads[0], arraysize(root_quads[0]), pass_ids[0]), | 744 test::Pass(root_quads[0], arraysize(root_quads[0]), pass_ids[0]), |
| 746 test::Pass(root_quads[1], arraysize(root_quads[1]), pass_ids[1]), | 745 test::Pass(root_quads[1], arraysize(root_quads[1]), pass_ids[1]), |
| 747 test::Pass(root_quads[2], arraysize(root_quads[2]), pass_ids[2])}; | 746 test::Pass(root_quads[2], arraysize(root_quads[2]), pass_ids[2])}; |
| 748 | 747 |
| 749 SubmitCompositorFrame(&factory_, root_passes, arraysize(root_passes), | 748 SubmitCompositorFrame(&support_, root_passes, arraysize(root_passes), |
| 750 root_local_surface_id_); | 749 root_local_surface_id_); |
| 751 | 750 |
| 752 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_surface_id_); | 751 SurfaceId root_surface_id(support_.frame_sink_id(), root_local_surface_id_); |
| 753 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); | 752 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); |
| 754 | 753 |
| 755 const RenderPassList& aggregated_pass_list = | 754 const RenderPassList& aggregated_pass_list = |
| 756 aggregated_frame.render_pass_list; | 755 aggregated_frame.render_pass_list; |
| 757 | 756 |
| 758 ASSERT_EQ(5u, aggregated_pass_list.size()); | 757 ASSERT_EQ(5u, aggregated_pass_list.size()); |
| 759 int actual_pass_ids[] = { | 758 int actual_pass_ids[] = { |
| 760 aggregated_pass_list[0]->id, aggregated_pass_list[1]->id, | 759 aggregated_pass_list[0]->id, aggregated_pass_list[1]->id, |
| 761 aggregated_pass_list[2]->id, aggregated_pass_list[3]->id, | 760 aggregated_pass_list[2]->id, aggregated_pass_list[3]->id, |
| 762 aggregated_pass_list[4]->id}; | 761 aggregated_pass_list[4]->id}; |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 854 | 853 |
| 855 // Tests an invalid surface reference in a frame. The surface quad should just | 854 // Tests an invalid surface reference in a frame. The surface quad should just |
| 856 // be dropped. | 855 // be dropped. |
| 857 TEST_F(SurfaceAggregatorValidSurfaceTest, InvalidSurfaceReference) { | 856 TEST_F(SurfaceAggregatorValidSurfaceTest, InvalidSurfaceReference) { |
| 858 test::Quad quads[] = { | 857 test::Quad quads[] = { |
| 859 test::Quad::SolidColorQuad(SK_ColorGREEN), | 858 test::Quad::SolidColorQuad(SK_ColorGREEN), |
| 860 test::Quad::SurfaceQuad(InvalidSurfaceId(), InvalidSurfaceId(), 1.f), | 859 test::Quad::SurfaceQuad(InvalidSurfaceId(), InvalidSurfaceId(), 1.f), |
| 861 test::Quad::SolidColorQuad(SK_ColorBLUE)}; | 860 test::Quad::SolidColorQuad(SK_ColorBLUE)}; |
| 862 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; | 861 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; |
| 863 | 862 |
| 864 SubmitCompositorFrame(&factory_, passes, arraysize(passes), | 863 SubmitCompositorFrame(&support_, passes, arraysize(passes), |
| 865 root_local_surface_id_); | 864 root_local_surface_id_); |
| 866 | 865 |
| 867 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), | 866 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), |
| 868 test::Quad::SolidColorQuad(SK_ColorBLUE)}; | 867 test::Quad::SolidColorQuad(SK_ColorBLUE)}; |
| 869 test::Pass expected_passes[] = { | 868 test::Pass expected_passes[] = { |
| 870 test::Pass(expected_quads, arraysize(expected_quads))}; | 869 test::Pass(expected_quads, arraysize(expected_quads))}; |
| 871 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_surface_id_); | 870 SurfaceId root_surface_id(support_.frame_sink_id(), root_local_surface_id_); |
| 872 SurfaceId ids[] = {root_surface_id, InvalidSurfaceId()}; | 871 SurfaceId ids[] = {root_surface_id, InvalidSurfaceId()}; |
| 873 | 872 |
| 874 AggregateAndVerify( | 873 AggregateAndVerify( |
| 875 expected_passes, arraysize(expected_passes), ids, arraysize(ids)); | 874 expected_passes, arraysize(expected_passes), ids, arraysize(ids)); |
| 876 } | 875 } |
| 877 | 876 |
| 878 // Tests a reference to a valid surface with no submitted frame. This quad | 877 // Tests a reference to a valid surface with no submitted frame. This quad |
| 879 // should also just be dropped. | 878 // should also just be dropped. |
| 880 TEST_F(SurfaceAggregatorValidSurfaceTest, ValidSurfaceReferenceWithNoFrame) { | 879 TEST_F(SurfaceAggregatorValidSurfaceTest, ValidSurfaceReferenceWithNoFrame) { |
| 881 LocalSurfaceId empty_local_surface_id = allocator_.GenerateId(); | 880 LocalSurfaceId empty_local_surface_id = allocator_.GenerateId(); |
| 882 SurfaceId surface_with_no_frame_id(factory_.frame_sink_id(), | 881 SurfaceId surface_with_no_frame_id(support_.frame_sink_id(), |
| 883 empty_local_surface_id); | 882 empty_local_surface_id); |
| 884 | 883 |
| 885 test::Quad quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), | 884 test::Quad quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), |
| 886 test::Quad::SurfaceQuad(surface_with_no_frame_id, | 885 test::Quad::SurfaceQuad(surface_with_no_frame_id, |
| 887 InvalidSurfaceId(), 1.f), | 886 InvalidSurfaceId(), 1.f), |
| 888 test::Quad::SolidColorQuad(SK_ColorBLUE)}; | 887 test::Quad::SolidColorQuad(SK_ColorBLUE)}; |
| 889 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; | 888 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; |
| 890 | 889 |
| 891 SubmitCompositorFrame(&factory_, passes, arraysize(passes), | 890 SubmitCompositorFrame(&support_, passes, arraysize(passes), |
| 892 root_local_surface_id_); | 891 root_local_surface_id_); |
| 893 | 892 |
| 894 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), | 893 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), |
| 895 test::Quad::SolidColorQuad(SK_ColorBLUE)}; | 894 test::Quad::SolidColorQuad(SK_ColorBLUE)}; |
| 896 test::Pass expected_passes[] = { | 895 test::Pass expected_passes[] = { |
| 897 test::Pass(expected_quads, arraysize(expected_quads))}; | 896 test::Pass(expected_quads, arraysize(expected_quads))}; |
| 898 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_surface_id_); | 897 SurfaceId root_surface_id(support_.frame_sink_id(), root_local_surface_id_); |
| 899 SurfaceId ids[] = {root_surface_id, surface_with_no_frame_id}; | 898 SurfaceId ids[] = {root_surface_id, surface_with_no_frame_id}; |
| 900 AggregateAndVerify( | 899 AggregateAndVerify( |
| 901 expected_passes, arraysize(expected_passes), ids, arraysize(ids)); | 900 expected_passes, arraysize(expected_passes), ids, arraysize(ids)); |
| 902 } | 901 } |
| 903 | 902 |
| 904 // Tests a surface quad referencing itself, generating a trivial cycle. | 903 // Tests a surface quad referencing itself, generating a trivial cycle. |
| 905 // The quad creating the cycle should be dropped from the final frame. | 904 // The quad creating the cycle should be dropped from the final frame. |
| 906 TEST_F(SurfaceAggregatorValidSurfaceTest, SimpleCyclicalReference) { | 905 TEST_F(SurfaceAggregatorValidSurfaceTest, SimpleCyclicalReference) { |
| 907 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_surface_id_); | 906 SurfaceId root_surface_id(support_.frame_sink_id(), root_local_surface_id_); |
| 908 test::Quad quads[] = { | 907 test::Quad quads[] = { |
| 909 test::Quad::SurfaceQuad(root_surface_id, InvalidSurfaceId(), 1.f), | 908 test::Quad::SurfaceQuad(root_surface_id, InvalidSurfaceId(), 1.f), |
| 910 test::Quad::SolidColorQuad(SK_ColorYELLOW)}; | 909 test::Quad::SolidColorQuad(SK_ColorYELLOW)}; |
| 911 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; | 910 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; |
| 912 | 911 |
| 913 SubmitCompositorFrame(&factory_, passes, arraysize(passes), | 912 SubmitCompositorFrame(&support_, passes, arraysize(passes), |
| 914 root_local_surface_id_); | 913 root_local_surface_id_); |
| 915 | 914 |
| 916 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorYELLOW)}; | 915 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorYELLOW)}; |
| 917 test::Pass expected_passes[] = { | 916 test::Pass expected_passes[] = { |
| 918 test::Pass(expected_quads, arraysize(expected_quads))}; | 917 test::Pass(expected_quads, arraysize(expected_quads))}; |
| 919 SurfaceId ids[] = {root_surface_id}; | 918 SurfaceId ids[] = {root_surface_id}; |
| 920 AggregateAndVerify( | 919 AggregateAndVerify( |
| 921 expected_passes, arraysize(expected_passes), ids, arraysize(ids)); | 920 expected_passes, arraysize(expected_passes), ids, arraysize(ids)); |
| 922 } | 921 } |
| 923 | 922 |
| 924 // Tests a more complex cycle with one intermediate surface. | 923 // Tests a more complex cycle with one intermediate surface. |
| 925 TEST_F(SurfaceAggregatorValidSurfaceTest, TwoSurfaceCyclicalReference) { | 924 TEST_F(SurfaceAggregatorValidSurfaceTest, TwoSurfaceCyclicalReference) { |
| 926 LocalSurfaceId child_local_surface_id = allocator_.GenerateId(); | 925 LocalSurfaceId child_local_surface_id = allocator_.GenerateId(); |
| 927 SurfaceId child_surface_id(child_factory_.frame_sink_id(), | 926 SurfaceId child_surface_id(child_support_.frame_sink_id(), |
| 928 child_local_surface_id); | 927 child_local_surface_id); |
| 929 | 928 |
| 930 test::Quad parent_quads[] = { | 929 test::Quad parent_quads[] = { |
| 931 test::Quad::SolidColorQuad(SK_ColorBLUE), | 930 test::Quad::SolidColorQuad(SK_ColorBLUE), |
| 932 test::Quad::SurfaceQuad(child_surface_id, InvalidSurfaceId(), 1.f), | 931 test::Quad::SurfaceQuad(child_surface_id, InvalidSurfaceId(), 1.f), |
| 933 test::Quad::SolidColorQuad(SK_ColorCYAN)}; | 932 test::Quad::SolidColorQuad(SK_ColorCYAN)}; |
| 934 test::Pass parent_passes[] = { | 933 test::Pass parent_passes[] = { |
| 935 test::Pass(parent_quads, arraysize(parent_quads))}; | 934 test::Pass(parent_quads, arraysize(parent_quads))}; |
| 936 | 935 |
| 937 SubmitCompositorFrame(&factory_, parent_passes, arraysize(parent_passes), | 936 SubmitCompositorFrame(&support_, parent_passes, arraysize(parent_passes), |
| 938 root_local_surface_id_); | 937 root_local_surface_id_); |
| 939 | 938 |
| 940 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_surface_id_); | 939 SurfaceId root_surface_id(support_.frame_sink_id(), root_local_surface_id_); |
| 941 test::Quad child_quads[] = { | 940 test::Quad child_quads[] = { |
| 942 test::Quad::SolidColorQuad(SK_ColorGREEN), | 941 test::Quad::SolidColorQuad(SK_ColorGREEN), |
| 943 test::Quad::SurfaceQuad(root_surface_id, InvalidSurfaceId(), 1.f), | 942 test::Quad::SurfaceQuad(root_surface_id, InvalidSurfaceId(), 1.f), |
| 944 test::Quad::SolidColorQuad(SK_ColorMAGENTA)}; | 943 test::Quad::SolidColorQuad(SK_ColorMAGENTA)}; |
| 945 test::Pass child_passes[] = {test::Pass(child_quads, arraysize(child_quads))}; | 944 test::Pass child_passes[] = {test::Pass(child_quads, arraysize(child_quads))}; |
| 946 | 945 |
| 947 SubmitCompositorFrame(&child_factory_, child_passes, arraysize(child_passes), | 946 SubmitCompositorFrame(&child_support_, child_passes, arraysize(child_passes), |
| 948 child_local_surface_id); | 947 child_local_surface_id); |
| 949 | 948 |
| 950 // The child surface's reference to the root_surface_ will be dropped, so | 949 // The child surface's reference to the root_surface_ will be dropped, so |
| 951 // we'll end up with: | 950 // we'll end up with: |
| 952 // SK_ColorBLUE from the parent | 951 // SK_ColorBLUE from the parent |
| 953 // SK_ColorGREEN from the child | 952 // SK_ColorGREEN from the child |
| 954 // SK_ColorMAGENTA from the child | 953 // SK_ColorMAGENTA from the child |
| 955 // SK_ColorCYAN from the parent | 954 // SK_ColorCYAN from the parent |
| 956 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorBLUE), | 955 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorBLUE), |
| 957 test::Quad::SolidColorQuad(SK_ColorGREEN), | 956 test::Quad::SolidColorQuad(SK_ColorGREEN), |
| 958 test::Quad::SolidColorQuad(SK_ColorMAGENTA), | 957 test::Quad::SolidColorQuad(SK_ColorMAGENTA), |
| 959 test::Quad::SolidColorQuad(SK_ColorCYAN)}; | 958 test::Quad::SolidColorQuad(SK_ColorCYAN)}; |
| 960 test::Pass expected_passes[] = { | 959 test::Pass expected_passes[] = { |
| 961 test::Pass(expected_quads, arraysize(expected_quads))}; | 960 test::Pass(expected_quads, arraysize(expected_quads))}; |
| 962 SurfaceId ids[] = {root_surface_id, child_surface_id}; | 961 SurfaceId ids[] = {root_surface_id, child_surface_id}; |
| 963 AggregateAndVerify( | 962 AggregateAndVerify( |
| 964 expected_passes, arraysize(expected_passes), ids, arraysize(ids)); | 963 expected_passes, arraysize(expected_passes), ids, arraysize(ids)); |
| 965 } | 964 } |
| 966 | 965 |
| 967 // Tests that we map render pass IDs from different surfaces into a unified | 966 // Tests that we map render pass IDs from different surfaces into a unified |
| 968 // namespace and update RenderPassDrawQuad's id references to match. | 967 // namespace and update RenderPassDrawQuad's id references to match. |
| 969 TEST_F(SurfaceAggregatorValidSurfaceTest, RenderPassIdMapping) { | 968 TEST_F(SurfaceAggregatorValidSurfaceTest, RenderPassIdMapping) { |
| 970 LocalSurfaceId child_local_surface_id = allocator_.GenerateId(); | 969 LocalSurfaceId child_local_surface_id = allocator_.GenerateId(); |
| 971 SurfaceId child_surface_id(child_factory_.frame_sink_id(), | 970 SurfaceId child_surface_id(child_support_.frame_sink_id(), |
| 972 child_local_surface_id); | 971 child_local_surface_id); |
| 973 | 972 |
| 974 int child_pass_id[] = {1, 2}; | 973 int child_pass_id[] = {1, 2}; |
| 975 test::Quad child_quad[][1] = {{test::Quad::SolidColorQuad(SK_ColorGREEN)}, | 974 test::Quad child_quad[][1] = {{test::Quad::SolidColorQuad(SK_ColorGREEN)}, |
| 976 {test::Quad::RenderPassQuad(child_pass_id[0])}}; | 975 {test::Quad::RenderPassQuad(child_pass_id[0])}}; |
| 977 test::Pass surface_passes[] = { | 976 test::Pass surface_passes[] = { |
| 978 test::Pass(child_quad[0], arraysize(child_quad[0]), child_pass_id[0]), | 977 test::Pass(child_quad[0], arraysize(child_quad[0]), child_pass_id[0]), |
| 979 test::Pass(child_quad[1], arraysize(child_quad[1]), child_pass_id[1])}; | 978 test::Pass(child_quad[1], arraysize(child_quad[1]), child_pass_id[1])}; |
| 980 | 979 |
| 981 SubmitCompositorFrame(&child_factory_, surface_passes, | 980 SubmitCompositorFrame(&child_support_, surface_passes, |
| 982 arraysize(surface_passes), child_local_surface_id); | 981 arraysize(surface_passes), child_local_surface_id); |
| 983 | 982 |
| 984 // Pass IDs from the parent surface may collide with ones from the child. | 983 // Pass IDs from the parent surface may collide with ones from the child. |
| 985 int parent_pass_id[] = {3, 2}; | 984 int parent_pass_id[] = {3, 2}; |
| 986 test::Quad parent_quad[][1] = { | 985 test::Quad parent_quad[][1] = { |
| 987 {test::Quad::SurfaceQuad(child_surface_id, InvalidSurfaceId(), 1.f)}, | 986 {test::Quad::SurfaceQuad(child_surface_id, InvalidSurfaceId(), 1.f)}, |
| 988 {test::Quad::RenderPassQuad(parent_pass_id[0])}}; | 987 {test::Quad::RenderPassQuad(parent_pass_id[0])}}; |
| 989 test::Pass parent_passes[] = { | 988 test::Pass parent_passes[] = { |
| 990 test::Pass(parent_quad[0], arraysize(parent_quad[0]), parent_pass_id[0]), | 989 test::Pass(parent_quad[0], arraysize(parent_quad[0]), parent_pass_id[0]), |
| 991 test::Pass(parent_quad[1], arraysize(parent_quad[1]), parent_pass_id[1])}; | 990 test::Pass(parent_quad[1], arraysize(parent_quad[1]), parent_pass_id[1])}; |
| 992 | 991 |
| 993 SubmitCompositorFrame(&factory_, parent_passes, arraysize(parent_passes), | 992 SubmitCompositorFrame(&support_, parent_passes, arraysize(parent_passes), |
| 994 root_local_surface_id_); | 993 root_local_surface_id_); |
| 995 | 994 |
| 996 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_surface_id_); | 995 SurfaceId root_surface_id(support_.frame_sink_id(), root_local_surface_id_); |
| 997 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); | 996 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); |
| 998 | 997 |
| 999 const RenderPassList& aggregated_pass_list = | 998 const RenderPassList& aggregated_pass_list = |
| 1000 aggregated_frame.render_pass_list; | 999 aggregated_frame.render_pass_list; |
| 1001 | 1000 |
| 1002 ASSERT_EQ(3u, aggregated_pass_list.size()); | 1001 ASSERT_EQ(3u, aggregated_pass_list.size()); |
| 1003 int actual_pass_ids[] = {aggregated_pass_list[0]->id, | 1002 int actual_pass_ids[] = {aggregated_pass_list[0]->id, |
| 1004 aggregated_pass_list[1]->id, | 1003 aggregated_pass_list[1]->id, |
| 1005 aggregated_pass_list[2]->id}; | 1004 aggregated_pass_list[2]->id}; |
| 1006 // Make sure the aggregated frame's pass IDs are all unique. | 1005 // Make sure the aggregated frame's pass IDs are all unique. |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1078 TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateSharedQuadStateProperties) { | 1077 TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateSharedQuadStateProperties) { |
| 1079 const SkBlendMode blend_modes[] = { | 1078 const SkBlendMode blend_modes[] = { |
| 1080 SkBlendMode::kClear, // 0 | 1079 SkBlendMode::kClear, // 0 |
| 1081 SkBlendMode::kSrc, // 1 | 1080 SkBlendMode::kSrc, // 1 |
| 1082 SkBlendMode::kDst, // 2 | 1081 SkBlendMode::kDst, // 2 |
| 1083 SkBlendMode::kSrcOver, // 3 | 1082 SkBlendMode::kSrcOver, // 3 |
| 1084 SkBlendMode::kDstOver, // 4 | 1083 SkBlendMode::kDstOver, // 4 |
| 1085 SkBlendMode::kSrcIn, // 5 | 1084 SkBlendMode::kSrcIn, // 5 |
| 1086 SkBlendMode::kDstIn, // 6 | 1085 SkBlendMode::kDstIn, // 6 |
| 1087 }; | 1086 }; |
| 1088 | 1087 CompositorFrameSinkSupport grandchild_support( |
| 1089 SurfaceFactory grandchild_factory(FrameSinkId(2, 2), &manager_, | 1088 nullptr, &manager_, kArbitraryFrameSinkId1, is_root_child, |
| 1090 &empty_client_); | 1089 handles_frame_sink_id_invalidation, needs_sync_points); |
| 1091 SurfaceFactory child_one_factory(FrameSinkId(3, 3), &manager_, | 1090 CompositorFrameSinkSupport child_one_support( |
| 1092 &empty_client_); | 1091 nullptr, &manager_, kArbitraryFrameSinkId2, is_root_child, |
| 1093 SurfaceFactory child_two_factory(FrameSinkId(4, 4), &manager_, | 1092 handles_frame_sink_id_invalidation, needs_sync_points); |
| 1094 &empty_client_); | 1093 CompositorFrameSinkSupport child_two_support( |
| 1094 nullptr, &manager_, kArbitraryFrameSinkId3, is_root_child, |
| 1095 handles_frame_sink_id_invalidation, needs_sync_points); |
| 1095 int pass_id = 1; | 1096 int pass_id = 1; |
| 1096 LocalSurfaceId grandchild_local_surface_id = allocator_.GenerateId(); | 1097 LocalSurfaceId grandchild_local_surface_id = allocator_.GenerateId(); |
| 1097 SurfaceId grandchild_surface_id(grandchild_factory.frame_sink_id(), | 1098 SurfaceId grandchild_surface_id(grandchild_support.frame_sink_id(), |
| 1098 grandchild_local_surface_id); | 1099 grandchild_local_surface_id); |
| 1099 grandchild_factory.SubmitCompositorFrame(grandchild_local_surface_id, | 1100 grandchild_support.SubmitCompositorFrame(grandchild_local_surface_id, |
| 1100 CompositorFrame(), | 1101 CompositorFrame()); |
| 1101 SurfaceFactory::DrawCallback()); | |
| 1102 std::unique_ptr<RenderPass> grandchild_pass = RenderPass::Create(); | 1102 std::unique_ptr<RenderPass> grandchild_pass = RenderPass::Create(); |
| 1103 gfx::Rect output_rect(SurfaceSize()); | 1103 gfx::Rect output_rect(SurfaceSize()); |
| 1104 gfx::Rect damage_rect(SurfaceSize()); | 1104 gfx::Rect damage_rect(SurfaceSize()); |
| 1105 gfx::Transform transform_to_root_target; | 1105 gfx::Transform transform_to_root_target; |
| 1106 grandchild_pass->SetNew(pass_id, output_rect, damage_rect, | 1106 grandchild_pass->SetNew(pass_id, output_rect, damage_rect, |
| 1107 transform_to_root_target); | 1107 transform_to_root_target); |
| 1108 AddSolidColorQuadWithBlendMode( | 1108 AddSolidColorQuadWithBlendMode( |
| 1109 SurfaceSize(), grandchild_pass.get(), blend_modes[2]); | 1109 SurfaceSize(), grandchild_pass.get(), blend_modes[2]); |
| 1110 QueuePassAsFrame(std::move(grandchild_pass), grandchild_local_surface_id, | 1110 QueuePassAsFrame(std::move(grandchild_pass), grandchild_local_surface_id, |
| 1111 &grandchild_factory); | 1111 &grandchild_support); |
| 1112 | 1112 |
| 1113 LocalSurfaceId child_one_local_surface_id = allocator_.GenerateId(); | 1113 LocalSurfaceId child_one_local_surface_id = allocator_.GenerateId(); |
| 1114 SurfaceId child_one_surface_id(child_one_factory.frame_sink_id(), | 1114 SurfaceId child_one_surface_id(child_one_support.frame_sink_id(), |
| 1115 child_one_local_surface_id); | 1115 child_one_local_surface_id); |
| 1116 child_one_factory.SubmitCompositorFrame(child_one_local_surface_id, | 1116 child_one_support.SubmitCompositorFrame(child_one_local_surface_id, |
| 1117 CompositorFrame(), | 1117 CompositorFrame()); |
| 1118 SurfaceFactory::DrawCallback()); | |
| 1119 | 1118 |
| 1120 std::unique_ptr<RenderPass> child_one_pass = RenderPass::Create(); | 1119 std::unique_ptr<RenderPass> child_one_pass = RenderPass::Create(); |
| 1121 child_one_pass->SetNew(pass_id, output_rect, damage_rect, | 1120 child_one_pass->SetNew(pass_id, output_rect, damage_rect, |
| 1122 transform_to_root_target); | 1121 transform_to_root_target); |
| 1123 AddSolidColorQuadWithBlendMode( | 1122 AddSolidColorQuadWithBlendMode( |
| 1124 SurfaceSize(), child_one_pass.get(), blend_modes[1]); | 1123 SurfaceSize(), child_one_pass.get(), blend_modes[1]); |
| 1125 SurfaceDrawQuad* grandchild_surface_quad = | 1124 SurfaceDrawQuad* grandchild_surface_quad = |
| 1126 child_one_pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); | 1125 child_one_pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); |
| 1127 grandchild_surface_quad->SetNew( | 1126 grandchild_surface_quad->SetNew( |
| 1128 child_one_pass->shared_quad_state_list.back(), gfx::Rect(SurfaceSize()), | 1127 child_one_pass->shared_quad_state_list.back(), gfx::Rect(SurfaceSize()), |
| 1129 gfx::Rect(SurfaceSize()), grandchild_surface_id, | 1128 gfx::Rect(SurfaceSize()), grandchild_surface_id, |
| 1130 SurfaceDrawQuadType::PRIMARY, nullptr); | 1129 SurfaceDrawQuadType::PRIMARY, nullptr); |
| 1131 AddSolidColorQuadWithBlendMode( | 1130 AddSolidColorQuadWithBlendMode( |
| 1132 SurfaceSize(), child_one_pass.get(), blend_modes[3]); | 1131 SurfaceSize(), child_one_pass.get(), blend_modes[3]); |
| 1133 QueuePassAsFrame(std::move(child_one_pass), child_one_local_surface_id, | 1132 QueuePassAsFrame(std::move(child_one_pass), child_one_local_surface_id, |
| 1134 &child_one_factory); | 1133 &child_one_support); |
| 1135 | 1134 |
| 1136 LocalSurfaceId child_two_local_surface_id = allocator_.GenerateId(); | 1135 LocalSurfaceId child_two_local_surface_id = allocator_.GenerateId(); |
| 1137 SurfaceId child_two_surface_id(child_two_factory.frame_sink_id(), | 1136 SurfaceId child_two_surface_id(child_two_support.frame_sink_id(), |
| 1138 child_two_local_surface_id); | 1137 child_two_local_surface_id); |
| 1139 child_two_factory.SubmitCompositorFrame(child_two_local_surface_id, | 1138 child_two_support.SubmitCompositorFrame(child_two_local_surface_id, |
| 1140 CompositorFrame(), | 1139 CompositorFrame()); |
| 1141 SurfaceFactory::DrawCallback()); | |
| 1142 | 1140 |
| 1143 std::unique_ptr<RenderPass> child_two_pass = RenderPass::Create(); | 1141 std::unique_ptr<RenderPass> child_two_pass = RenderPass::Create(); |
| 1144 child_two_pass->SetNew(pass_id, output_rect, damage_rect, | 1142 child_two_pass->SetNew(pass_id, output_rect, damage_rect, |
| 1145 transform_to_root_target); | 1143 transform_to_root_target); |
| 1146 AddSolidColorQuadWithBlendMode( | 1144 AddSolidColorQuadWithBlendMode( |
| 1147 SurfaceSize(), child_two_pass.get(), blend_modes[5]); | 1145 SurfaceSize(), child_two_pass.get(), blend_modes[5]); |
| 1148 QueuePassAsFrame(std::move(child_two_pass), child_two_local_surface_id, | 1146 QueuePassAsFrame(std::move(child_two_pass), child_two_local_surface_id, |
| 1149 &child_two_factory); | 1147 &child_two_support); |
| 1150 | 1148 |
| 1151 std::unique_ptr<RenderPass> root_pass = RenderPass::Create(); | 1149 std::unique_ptr<RenderPass> root_pass = RenderPass::Create(); |
| 1152 root_pass->SetNew(pass_id, output_rect, damage_rect, | 1150 root_pass->SetNew(pass_id, output_rect, damage_rect, |
| 1153 transform_to_root_target); | 1151 transform_to_root_target); |
| 1154 | 1152 |
| 1155 AddSolidColorQuadWithBlendMode( | 1153 AddSolidColorQuadWithBlendMode( |
| 1156 SurfaceSize(), root_pass.get(), blend_modes[0]); | 1154 SurfaceSize(), root_pass.get(), blend_modes[0]); |
| 1157 SurfaceDrawQuad* child_one_surface_quad = | 1155 SurfaceDrawQuad* child_one_surface_quad = |
| 1158 root_pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); | 1156 root_pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); |
| 1159 child_one_surface_quad->SetNew(root_pass->shared_quad_state_list.back(), | 1157 child_one_surface_quad->SetNew(root_pass->shared_quad_state_list.back(), |
| 1160 gfx::Rect(SurfaceSize()), | 1158 gfx::Rect(SurfaceSize()), |
| 1161 gfx::Rect(SurfaceSize()), child_one_surface_id, | 1159 gfx::Rect(SurfaceSize()), child_one_surface_id, |
| 1162 SurfaceDrawQuadType::PRIMARY, nullptr); | 1160 SurfaceDrawQuadType::PRIMARY, nullptr); |
| 1163 AddSolidColorQuadWithBlendMode( | 1161 AddSolidColorQuadWithBlendMode( |
| 1164 SurfaceSize(), root_pass.get(), blend_modes[4]); | 1162 SurfaceSize(), root_pass.get(), blend_modes[4]); |
| 1165 SurfaceDrawQuad* child_two_surface_quad = | 1163 SurfaceDrawQuad* child_two_surface_quad = |
| 1166 root_pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); | 1164 root_pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); |
| 1167 child_two_surface_quad->SetNew(root_pass->shared_quad_state_list.back(), | 1165 child_two_surface_quad->SetNew(root_pass->shared_quad_state_list.back(), |
| 1168 gfx::Rect(SurfaceSize()), | 1166 gfx::Rect(SurfaceSize()), |
| 1169 gfx::Rect(SurfaceSize()), child_two_surface_id, | 1167 gfx::Rect(SurfaceSize()), child_two_surface_id, |
| 1170 SurfaceDrawQuadType::PRIMARY, nullptr); | 1168 SurfaceDrawQuadType::PRIMARY, nullptr); |
| 1171 AddSolidColorQuadWithBlendMode( | 1169 AddSolidColorQuadWithBlendMode( |
| 1172 SurfaceSize(), root_pass.get(), blend_modes[6]); | 1170 SurfaceSize(), root_pass.get(), blend_modes[6]); |
| 1173 | 1171 |
| 1174 QueuePassAsFrame(std::move(root_pass), root_local_surface_id_, &factory_); | 1172 QueuePassAsFrame(std::move(root_pass), root_local_surface_id_, &support_); |
| 1175 | 1173 |
| 1176 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_surface_id_); | 1174 SurfaceId root_surface_id(support_.frame_sink_id(), root_local_surface_id_); |
| 1177 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); | 1175 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); |
| 1178 | 1176 |
| 1179 const RenderPassList& aggregated_pass_list = | 1177 const RenderPassList& aggregated_pass_list = |
| 1180 aggregated_frame.render_pass_list; | 1178 aggregated_frame.render_pass_list; |
| 1181 | 1179 |
| 1182 ASSERT_EQ(1u, aggregated_pass_list.size()); | 1180 ASSERT_EQ(1u, aggregated_pass_list.size()); |
| 1183 | 1181 |
| 1184 const QuadList& aggregated_quad_list = aggregated_pass_list[0]->quad_list; | 1182 const QuadList& aggregated_quad_list = aggregated_pass_list[0]->quad_list; |
| 1185 | 1183 |
| 1186 ASSERT_EQ(7u, aggregated_quad_list.size()); | 1184 ASSERT_EQ(7u, aggregated_quad_list.size()); |
| 1187 | 1185 |
| 1188 for (auto iter = aggregated_quad_list.cbegin(); | 1186 for (auto iter = aggregated_quad_list.cbegin(); |
| 1189 iter != aggregated_quad_list.cend(); | 1187 iter != aggregated_quad_list.cend(); |
| 1190 ++iter) { | 1188 ++iter) { |
| 1191 EXPECT_EQ(blend_modes[iter.index()], iter->shared_quad_state->blend_mode) | 1189 EXPECT_EQ(blend_modes[iter.index()], iter->shared_quad_state->blend_mode) |
| 1192 << iter.index(); | 1190 << iter.index(); |
| 1193 } | 1191 } |
| 1194 | 1192 |
| 1195 grandchild_factory.EvictSurface(); | 1193 grandchild_support.EvictFrame(); |
| 1196 child_one_factory.EvictSurface(); | 1194 child_one_support.EvictFrame(); |
| 1197 child_two_factory.EvictSurface(); | 1195 child_two_support.EvictFrame(); |
| 1198 } | 1196 } |
| 1199 | 1197 |
| 1200 // This tests that when aggregating a frame with multiple render passes that we | 1198 // This tests that when aggregating a frame with multiple render passes that we |
| 1201 // map the transforms for the root pass but do not modify the transform on child | 1199 // map the transforms for the root pass but do not modify the transform on child |
| 1202 // passes. | 1200 // passes. |
| 1203 // | 1201 // |
| 1204 // The root surface has one pass with a surface quad transformed by +10 in the y | 1202 // The root surface has one pass with a surface quad transformed by +10 in the y |
| 1205 // direction. | 1203 // direction. |
| 1206 // | 1204 // |
| 1207 // The middle surface has one pass with a surface quad scaled by 2 in the x | 1205 // The middle surface has one pass with a surface quad scaled by 2 in the x |
| 1208 // and 3 in the y directions. | 1206 // and 3 in the y directions. |
| 1209 // | 1207 // |
| 1210 // The child surface has two passes. The first pass has a quad with a transform | 1208 // The child surface has two passes. The first pass has a quad with a transform |
| 1211 // of +5 in the x direction. The second pass has a reference to the first pass' | 1209 // of +5 in the x direction. The second pass has a reference to the first pass' |
| 1212 // pass id and a transform of +8 in the x direction. | 1210 // pass id and a transform of +8 in the x direction. |
| 1213 // | 1211 // |
| 1214 // After aggregation, the child surface's root pass quad should have all | 1212 // After aggregation, the child surface's root pass quad should have all |
| 1215 // transforms concatenated for a total transform of +23 x, +10 y. The | 1213 // transforms concatenated for a total transform of +23 x, +10 y. The |
| 1216 // contributing render pass' transform in the aggregate frame should not be | 1214 // contributing render pass' transform in the aggregate frame should not be |
| 1217 // affected. | 1215 // affected. |
| 1218 TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateMultiplePassWithTransform) { | 1216 TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateMultiplePassWithTransform) { |
| 1219 SurfaceFactory middle_factory(kArbitraryMiddleFrameSinkId, &manager_, | 1217 CompositorFrameSinkSupport middle_support( |
| 1220 &empty_client_); | 1218 nullptr, &manager_, kArbitraryMiddleFrameSinkId, is_root_child, |
| 1219 handles_frame_sink_id_invalidation, needs_sync_points); |
| 1221 // Innermost child surface. | 1220 // Innermost child surface. |
| 1222 LocalSurfaceId child_local_surface_id = allocator_.GenerateId(); | 1221 LocalSurfaceId child_local_surface_id = allocator_.GenerateId(); |
| 1223 SurfaceId child_surface_id(child_factory_.frame_sink_id(), | 1222 SurfaceId child_surface_id(child_support_.frame_sink_id(), |
| 1224 child_local_surface_id); | 1223 child_local_surface_id); |
| 1225 { | 1224 { |
| 1226 int child_pass_id[] = {1, 2}; | 1225 int child_pass_id[] = {1, 2}; |
| 1227 test::Quad child_quads[][1] = { | 1226 test::Quad child_quads[][1] = { |
| 1228 {test::Quad::SolidColorQuad(SK_ColorGREEN)}, | 1227 {test::Quad::SolidColorQuad(SK_ColorGREEN)}, |
| 1229 {test::Quad::RenderPassQuad(child_pass_id[0])}, | 1228 {test::Quad::RenderPassQuad(child_pass_id[0])}, |
| 1230 }; | 1229 }; |
| 1231 test::Pass child_passes[] = { | 1230 test::Pass child_passes[] = { |
| 1232 test::Pass(child_quads[0], arraysize(child_quads[0]), child_pass_id[0]), | 1231 test::Pass(child_quads[0], arraysize(child_quads[0]), child_pass_id[0]), |
| 1233 test::Pass(child_quads[1], arraysize(child_quads[1]), | 1232 test::Pass(child_quads[1], arraysize(child_quads[1]), |
| 1234 child_pass_id[1])}; | 1233 child_pass_id[1])}; |
| 1235 | 1234 |
| 1236 CompositorFrame child_frame; | 1235 CompositorFrame child_frame; |
| 1237 AddPasses(&child_frame.render_pass_list, gfx::Rect(SurfaceSize()), | 1236 AddPasses(&child_frame.render_pass_list, gfx::Rect(SurfaceSize()), |
| 1238 child_passes, arraysize(child_passes)); | 1237 child_passes, arraysize(child_passes)); |
| 1239 | 1238 |
| 1240 RenderPass* child_nonroot_pass = child_frame.render_pass_list[0].get(); | 1239 RenderPass* child_nonroot_pass = child_frame.render_pass_list[0].get(); |
| 1241 child_nonroot_pass->transform_to_root_target.Translate(8, 0); | 1240 child_nonroot_pass->transform_to_root_target.Translate(8, 0); |
| 1242 SharedQuadState* child_nonroot_pass_sqs = | 1241 SharedQuadState* child_nonroot_pass_sqs = |
| 1243 child_nonroot_pass->shared_quad_state_list.front(); | 1242 child_nonroot_pass->shared_quad_state_list.front(); |
| 1244 child_nonroot_pass_sqs->quad_to_target_transform.Translate(5, 0); | 1243 child_nonroot_pass_sqs->quad_to_target_transform.Translate(5, 0); |
| 1245 | 1244 |
| 1246 RenderPass* child_root_pass = child_frame.render_pass_list[1].get(); | 1245 RenderPass* child_root_pass = child_frame.render_pass_list[1].get(); |
| 1247 SharedQuadState* child_root_pass_sqs = | 1246 SharedQuadState* child_root_pass_sqs = |
| 1248 child_root_pass->shared_quad_state_list.front(); | 1247 child_root_pass->shared_quad_state_list.front(); |
| 1249 child_root_pass_sqs->quad_to_target_transform.Translate(8, 0); | 1248 child_root_pass_sqs->quad_to_target_transform.Translate(8, 0); |
| 1250 child_root_pass_sqs->is_clipped = true; | 1249 child_root_pass_sqs->is_clipped = true; |
| 1251 child_root_pass_sqs->clip_rect = gfx::Rect(0, 0, 5, 5); | 1250 child_root_pass_sqs->clip_rect = gfx::Rect(0, 0, 5, 5); |
| 1252 | 1251 |
| 1253 child_factory_.SubmitCompositorFrame(child_local_surface_id, | 1252 child_support_.SubmitCompositorFrame(child_local_surface_id, |
| 1254 std::move(child_frame), | 1253 std::move(child_frame)); |
| 1255 SurfaceFactory::DrawCallback()); | |
| 1256 } | 1254 } |
| 1257 | 1255 |
| 1258 // Middle child surface. | 1256 // Middle child surface. |
| 1259 LocalSurfaceId middle_local_surface_id = allocator_.GenerateId(); | 1257 LocalSurfaceId middle_local_surface_id = allocator_.GenerateId(); |
| 1260 SurfaceId middle_surface_id(middle_factory.frame_sink_id(), | 1258 SurfaceId middle_surface_id(middle_support.frame_sink_id(), |
| 1261 middle_local_surface_id); | 1259 middle_local_surface_id); |
| 1262 { | 1260 { |
| 1263 test::Quad middle_quads[] = { | 1261 test::Quad middle_quads[] = { |
| 1264 test::Quad::SurfaceQuad(child_surface_id, InvalidSurfaceId(), 1.f)}; | 1262 test::Quad::SurfaceQuad(child_surface_id, InvalidSurfaceId(), 1.f)}; |
| 1265 test::Pass middle_passes[] = { | 1263 test::Pass middle_passes[] = { |
| 1266 test::Pass(middle_quads, arraysize(middle_quads)), | 1264 test::Pass(middle_quads, arraysize(middle_quads)), |
| 1267 }; | 1265 }; |
| 1268 | 1266 |
| 1269 CompositorFrame middle_frame; | 1267 CompositorFrame middle_frame; |
| 1270 AddPasses(&middle_frame.render_pass_list, gfx::Rect(SurfaceSize()), | 1268 AddPasses(&middle_frame.render_pass_list, gfx::Rect(SurfaceSize()), |
| 1271 middle_passes, arraysize(middle_passes)); | 1269 middle_passes, arraysize(middle_passes)); |
| 1272 | 1270 |
| 1273 RenderPass* middle_root_pass = middle_frame.render_pass_list[0].get(); | 1271 RenderPass* middle_root_pass = middle_frame.render_pass_list[0].get(); |
| 1274 middle_root_pass->quad_list.ElementAt(0)->visible_rect = | 1272 middle_root_pass->quad_list.ElementAt(0)->visible_rect = |
| 1275 gfx::Rect(0, 1, 100, 7); | 1273 gfx::Rect(0, 1, 100, 7); |
| 1276 SharedQuadState* middle_root_pass_sqs = | 1274 SharedQuadState* middle_root_pass_sqs = |
| 1277 middle_root_pass->shared_quad_state_list.front(); | 1275 middle_root_pass->shared_quad_state_list.front(); |
| 1278 middle_root_pass_sqs->quad_to_target_transform.Scale(2, 3); | 1276 middle_root_pass_sqs->quad_to_target_transform.Scale(2, 3); |
| 1279 | 1277 |
| 1280 middle_factory.SubmitCompositorFrame(middle_local_surface_id, | 1278 middle_support.SubmitCompositorFrame(middle_local_surface_id, |
| 1281 std::move(middle_frame), | 1279 std::move(middle_frame)); |
| 1282 SurfaceFactory::DrawCallback()); | |
| 1283 } | 1280 } |
| 1284 | 1281 |
| 1285 // Root surface. | 1282 // Root surface. |
| 1286 test::Quad secondary_quads[] = { | 1283 test::Quad secondary_quads[] = { |
| 1287 test::Quad::SolidColorQuad(1), | 1284 test::Quad::SolidColorQuad(1), |
| 1288 test::Quad::SurfaceQuad(middle_surface_id, InvalidSurfaceId(), 1.f)}; | 1285 test::Quad::SurfaceQuad(middle_surface_id, InvalidSurfaceId(), 1.f)}; |
| 1289 test::Quad root_quads[] = {test::Quad::SolidColorQuad(1)}; | 1286 test::Quad root_quads[] = {test::Quad::SolidColorQuad(1)}; |
| 1290 test::Pass root_passes[] = { | 1287 test::Pass root_passes[] = { |
| 1291 test::Pass(secondary_quads, arraysize(secondary_quads)), | 1288 test::Pass(secondary_quads, arraysize(secondary_quads)), |
| 1292 test::Pass(root_quads, arraysize(root_quads))}; | 1289 test::Pass(root_quads, arraysize(root_quads))}; |
| 1293 | 1290 |
| 1294 CompositorFrame root_frame; | 1291 CompositorFrame root_frame; |
| 1295 AddPasses(&root_frame.render_pass_list, gfx::Rect(SurfaceSize()), root_passes, | 1292 AddPasses(&root_frame.render_pass_list, gfx::Rect(SurfaceSize()), root_passes, |
| 1296 arraysize(root_passes)); | 1293 arraysize(root_passes)); |
| 1297 | 1294 |
| 1298 root_frame.render_pass_list[0] | 1295 root_frame.render_pass_list[0] |
| 1299 ->shared_quad_state_list.front() | 1296 ->shared_quad_state_list.front() |
| 1300 ->quad_to_target_transform.Translate(0, 7); | 1297 ->quad_to_target_transform.Translate(0, 7); |
| 1301 root_frame.render_pass_list[0] | 1298 root_frame.render_pass_list[0] |
| 1302 ->shared_quad_state_list.ElementAt(1) | 1299 ->shared_quad_state_list.ElementAt(1) |
| 1303 ->quad_to_target_transform.Translate(0, 10); | 1300 ->quad_to_target_transform.Translate(0, 10); |
| 1304 root_frame.render_pass_list[0]->quad_list.ElementAt(1)->visible_rect = | 1301 root_frame.render_pass_list[0]->quad_list.ElementAt(1)->visible_rect = |
| 1305 gfx::Rect(0, 0, 8, 100); | 1302 gfx::Rect(0, 0, 8, 100); |
| 1306 | 1303 |
| 1307 root_frame.render_pass_list[0]->transform_to_root_target.Translate(10, 5); | 1304 root_frame.render_pass_list[0]->transform_to_root_target.Translate(10, 5); |
| 1308 | 1305 |
| 1309 factory_.SubmitCompositorFrame(root_local_surface_id_, std::move(root_frame), | 1306 support_.SubmitCompositorFrame(root_local_surface_id_, std::move(root_frame)); |
| 1310 SurfaceFactory::DrawCallback()); | |
| 1311 | 1307 |
| 1312 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_surface_id_); | 1308 SurfaceId root_surface_id(support_.frame_sink_id(), root_local_surface_id_); |
| 1313 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); | 1309 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); |
| 1314 | 1310 |
| 1315 const RenderPassList& aggregated_pass_list = | 1311 const RenderPassList& aggregated_pass_list = |
| 1316 aggregated_frame.render_pass_list; | 1312 aggregated_frame.render_pass_list; |
| 1317 | 1313 |
| 1318 ASSERT_EQ(3u, aggregated_pass_list.size()); | 1314 ASSERT_EQ(3u, aggregated_pass_list.size()); |
| 1319 | 1315 |
| 1320 ASSERT_EQ(1u, aggregated_pass_list[0]->shared_quad_state_list.size()); | 1316 ASSERT_EQ(1u, aggregated_pass_list[0]->shared_quad_state_list.size()); |
| 1321 | 1317 |
| 1322 // The first pass should have one shared quad state for the one solid color | 1318 // The first pass should have one shared quad state for the one solid color |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1375 aggregated_pass_list[1]->shared_quad_state_list.ElementAt(1)->is_clipped); | 1371 aggregated_pass_list[1]->shared_quad_state_list.ElementAt(1)->is_clipped); |
| 1376 | 1372 |
| 1377 // The second quad in the root pass is aggregated from the child, so its | 1373 // The second quad in the root pass is aggregated from the child, so its |
| 1378 // clip rect must be transformed by the child's translation/scale and | 1374 // clip rect must be transformed by the child's translation/scale and |
| 1379 // clipped be the visible_rects for both children. | 1375 // clipped be the visible_rects for both children. |
| 1380 EXPECT_EQ(gfx::Rect(0, 13, 8, 12).ToString(), | 1376 EXPECT_EQ(gfx::Rect(0, 13, 8, 12).ToString(), |
| 1381 aggregated_pass_list[1] | 1377 aggregated_pass_list[1] |
| 1382 ->shared_quad_state_list.ElementAt(1) | 1378 ->shared_quad_state_list.ElementAt(1) |
| 1383 ->clip_rect.ToString()); | 1379 ->clip_rect.ToString()); |
| 1384 | 1380 |
| 1385 middle_factory.EvictSurface(); | 1381 middle_support.EvictFrame(); |
| 1386 } | 1382 } |
| 1387 | 1383 |
| 1388 // Tests that damage rects are aggregated correctly when surfaces change. | 1384 // Tests that damage rects are aggregated correctly when surfaces change. |
| 1389 TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateDamageRect) { | 1385 TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateDamageRect) { |
| 1390 SurfaceFactory parent_factory(kArbitraryMiddleFrameSinkId, &manager_, | 1386 CompositorFrameSinkSupport parent_support( |
| 1391 &empty_client_); | 1387 nullptr, &manager_, kArbitraryMiddleFrameSinkId, is_root_child, |
| 1388 handles_frame_sink_id_invalidation, needs_sync_points); |
| 1392 test::Quad child_quads[] = {test::Quad::RenderPassQuad(1)}; | 1389 test::Quad child_quads[] = {test::Quad::RenderPassQuad(1)}; |
| 1393 test::Pass child_passes[] = { | 1390 test::Pass child_passes[] = { |
| 1394 test::Pass(child_quads, arraysize(child_quads), 1)}; | 1391 test::Pass(child_quads, arraysize(child_quads), 1)}; |
| 1395 | 1392 |
| 1396 CompositorFrame child_frame; | 1393 CompositorFrame child_frame; |
| 1397 AddPasses(&child_frame.render_pass_list, gfx::Rect(SurfaceSize()), | 1394 AddPasses(&child_frame.render_pass_list, gfx::Rect(SurfaceSize()), |
| 1398 child_passes, arraysize(child_passes)); | 1395 child_passes, arraysize(child_passes)); |
| 1399 | 1396 |
| 1400 RenderPass* child_root_pass = child_frame.render_pass_list[0].get(); | 1397 RenderPass* child_root_pass = child_frame.render_pass_list[0].get(); |
| 1401 SharedQuadState* child_root_pass_sqs = | 1398 SharedQuadState* child_root_pass_sqs = |
| 1402 child_root_pass->shared_quad_state_list.front(); | 1399 child_root_pass->shared_quad_state_list.front(); |
| 1403 child_root_pass_sqs->quad_to_target_transform.Translate(8, 0); | 1400 child_root_pass_sqs->quad_to_target_transform.Translate(8, 0); |
| 1404 | 1401 |
| 1405 LocalSurfaceId child_local_surface_id = allocator_.GenerateId(); | 1402 LocalSurfaceId child_local_surface_id = allocator_.GenerateId(); |
| 1406 SurfaceId child_surface_id(child_factory_.frame_sink_id(), | 1403 SurfaceId child_surface_id(child_support_.frame_sink_id(), |
| 1407 child_local_surface_id); | 1404 child_local_surface_id); |
| 1408 child_factory_.SubmitCompositorFrame(child_local_surface_id, | 1405 child_support_.SubmitCompositorFrame(child_local_surface_id, |
| 1409 std::move(child_frame), | 1406 std::move(child_frame)); |
| 1410 SurfaceFactory::DrawCallback()); | |
| 1411 | 1407 |
| 1412 test::Quad parent_surface_quads[] = { | 1408 test::Quad parent_surface_quads[] = { |
| 1413 test::Quad::SurfaceQuad(child_surface_id, InvalidSurfaceId(), 1.f)}; | 1409 test::Quad::SurfaceQuad(child_surface_id, InvalidSurfaceId(), 1.f)}; |
| 1414 test::Pass parent_surface_passes[] = { | 1410 test::Pass parent_surface_passes[] = { |
| 1415 test::Pass(parent_surface_quads, arraysize(parent_surface_quads), 1)}; | 1411 test::Pass(parent_surface_quads, arraysize(parent_surface_quads), 1)}; |
| 1416 | 1412 |
| 1417 // Parent surface is only used to test if the transform is applied correctly | 1413 // Parent surface is only used to test if the transform is applied correctly |
| 1418 // to the child surface's damage. | 1414 // to the child surface's damage. |
| 1419 CompositorFrame parent_surface_frame; | 1415 CompositorFrame parent_surface_frame; |
| 1420 AddPasses(&parent_surface_frame.render_pass_list, gfx::Rect(SurfaceSize()), | 1416 AddPasses(&parent_surface_frame.render_pass_list, gfx::Rect(SurfaceSize()), |
| 1421 parent_surface_passes, arraysize(parent_surface_passes)); | 1417 parent_surface_passes, arraysize(parent_surface_passes)); |
| 1422 | 1418 |
| 1423 LocalSurfaceId parent_local_surface_id = allocator_.GenerateId(); | 1419 LocalSurfaceId parent_local_surface_id = allocator_.GenerateId(); |
| 1424 SurfaceId parent_surface_id(parent_factory.frame_sink_id(), | 1420 SurfaceId parent_surface_id(parent_support.frame_sink_id(), |
| 1425 parent_local_surface_id); | 1421 parent_local_surface_id); |
| 1426 parent_factory.SubmitCompositorFrame(parent_local_surface_id, | 1422 parent_support.SubmitCompositorFrame(parent_local_surface_id, |
| 1427 std::move(parent_surface_frame), | 1423 std::move(parent_surface_frame)); |
| 1428 SurfaceFactory::DrawCallback()); | |
| 1429 | 1424 |
| 1430 test::Quad root_surface_quads[] = { | 1425 test::Quad root_surface_quads[] = { |
| 1431 test::Quad::SurfaceQuad(parent_surface_id, InvalidSurfaceId(), 1.f)}; | 1426 test::Quad::SurfaceQuad(parent_surface_id, InvalidSurfaceId(), 1.f)}; |
| 1432 test::Quad root_render_pass_quads[] = {test::Quad::RenderPassQuad(1)}; | 1427 test::Quad root_render_pass_quads[] = {test::Quad::RenderPassQuad(1)}; |
| 1433 | 1428 |
| 1434 test::Pass root_passes[] = { | 1429 test::Pass root_passes[] = { |
| 1435 test::Pass(root_surface_quads, arraysize(root_surface_quads), 1), | 1430 test::Pass(root_surface_quads, arraysize(root_surface_quads), 1), |
| 1436 test::Pass(root_render_pass_quads, arraysize(root_render_pass_quads), 2)}; | 1431 test::Pass(root_render_pass_quads, arraysize(root_render_pass_quads), 2)}; |
| 1437 | 1432 |
| 1438 CompositorFrame root_frame; | 1433 CompositorFrame root_frame; |
| 1439 AddPasses(&root_frame.render_pass_list, gfx::Rect(SurfaceSize()), root_passes, | 1434 AddPasses(&root_frame.render_pass_list, gfx::Rect(SurfaceSize()), root_passes, |
| 1440 arraysize(root_passes)); | 1435 arraysize(root_passes)); |
| 1441 | 1436 |
| 1442 root_frame.render_pass_list[0] | 1437 root_frame.render_pass_list[0] |
| 1443 ->shared_quad_state_list.front() | 1438 ->shared_quad_state_list.front() |
| 1444 ->quad_to_target_transform.Translate(0, 10); | 1439 ->quad_to_target_transform.Translate(0, 10); |
| 1445 root_frame.render_pass_list[0]->damage_rect = gfx::Rect(5, 5, 10, 10); | 1440 root_frame.render_pass_list[0]->damage_rect = gfx::Rect(5, 5, 10, 10); |
| 1446 root_frame.render_pass_list[1]->damage_rect = gfx::Rect(5, 5, 100, 100); | 1441 root_frame.render_pass_list[1]->damage_rect = gfx::Rect(5, 5, 100, 100); |
| 1447 | 1442 |
| 1448 factory_.SubmitCompositorFrame(root_local_surface_id_, std::move(root_frame), | 1443 support_.SubmitCompositorFrame(root_local_surface_id_, std::move(root_frame)); |
| 1449 SurfaceFactory::DrawCallback()); | |
| 1450 | 1444 |
| 1451 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_surface_id_); | 1445 SurfaceId root_surface_id(support_.frame_sink_id(), root_local_surface_id_); |
| 1452 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); | 1446 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); |
| 1453 | 1447 |
| 1454 const RenderPassList& aggregated_pass_list = | 1448 const RenderPassList& aggregated_pass_list = |
| 1455 aggregated_frame.render_pass_list; | 1449 aggregated_frame.render_pass_list; |
| 1456 | 1450 |
| 1457 ASSERT_EQ(2u, aggregated_pass_list.size()); | 1451 ASSERT_EQ(2u, aggregated_pass_list.size()); |
| 1458 | 1452 |
| 1459 // Damage rect for first aggregation should contain entire root surface. | 1453 // Damage rect for first aggregation should contain entire root surface. |
| 1460 EXPECT_TRUE( | 1454 EXPECT_TRUE( |
| 1461 aggregated_pass_list[1]->damage_rect.Contains(gfx::Rect(SurfaceSize()))); | 1455 aggregated_pass_list[1]->damage_rect.Contains(gfx::Rect(SurfaceSize()))); |
| 1462 | 1456 |
| 1463 { | 1457 { |
| 1464 CompositorFrame child_frame; | 1458 CompositorFrame child_frame; |
| 1465 AddPasses(&child_frame.render_pass_list, gfx::Rect(SurfaceSize()), | 1459 AddPasses(&child_frame.render_pass_list, gfx::Rect(SurfaceSize()), |
| 1466 child_passes, arraysize(child_passes)); | 1460 child_passes, arraysize(child_passes)); |
| 1467 | 1461 |
| 1468 RenderPass* child_root_pass = child_frame.render_pass_list[0].get(); | 1462 RenderPass* child_root_pass = child_frame.render_pass_list[0].get(); |
| 1469 SharedQuadState* child_root_pass_sqs = | 1463 SharedQuadState* child_root_pass_sqs = |
| 1470 child_root_pass->shared_quad_state_list.front(); | 1464 child_root_pass->shared_quad_state_list.front(); |
| 1471 child_root_pass_sqs->quad_to_target_transform.Translate(8, 0); | 1465 child_root_pass_sqs->quad_to_target_transform.Translate(8, 0); |
| 1472 child_root_pass->damage_rect = gfx::Rect(10, 10, 10, 10); | 1466 child_root_pass->damage_rect = gfx::Rect(10, 10, 10, 10); |
| 1473 | 1467 |
| 1474 child_factory_.SubmitCompositorFrame(child_local_surface_id, | 1468 child_support_.SubmitCompositorFrame(child_local_surface_id, |
| 1475 std::move(child_frame), | 1469 std::move(child_frame)); |
| 1476 SurfaceFactory::DrawCallback()); | |
| 1477 | 1470 |
| 1478 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_surface_id_); | 1471 SurfaceId root_surface_id(support_.frame_sink_id(), root_local_surface_id_); |
| 1479 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); | 1472 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); |
| 1480 | 1473 |
| 1481 const RenderPassList& aggregated_pass_list = | 1474 const RenderPassList& aggregated_pass_list = |
| 1482 aggregated_frame.render_pass_list; | 1475 aggregated_frame.render_pass_list; |
| 1483 | 1476 |
| 1484 ASSERT_EQ(2u, aggregated_pass_list.size()); | 1477 ASSERT_EQ(2u, aggregated_pass_list.size()); |
| 1485 | 1478 |
| 1486 // Outer surface didn't change, so transformed inner damage rect should be | 1479 // Outer surface didn't change, so transformed inner damage rect should be |
| 1487 // used. | 1480 // used. |
| 1488 EXPECT_EQ(gfx::Rect(10, 20, 10, 10).ToString(), | 1481 EXPECT_EQ(gfx::Rect(10, 20, 10, 10).ToString(), |
| 1489 aggregated_pass_list[1]->damage_rect.ToString()); | 1482 aggregated_pass_list[1]->damage_rect.ToString()); |
| 1490 } | 1483 } |
| 1491 | 1484 |
| 1492 { | 1485 { |
| 1493 CompositorFrame root_frame; | 1486 CompositorFrame root_frame; |
| 1494 AddPasses(&root_frame.render_pass_list, gfx::Rect(SurfaceSize()), | 1487 AddPasses(&root_frame.render_pass_list, gfx::Rect(SurfaceSize()), |
| 1495 root_passes, arraysize(root_passes)); | 1488 root_passes, arraysize(root_passes)); |
| 1496 | 1489 |
| 1497 root_frame.render_pass_list[0] | 1490 root_frame.render_pass_list[0] |
| 1498 ->shared_quad_state_list.front() | 1491 ->shared_quad_state_list.front() |
| 1499 ->quad_to_target_transform.Translate(0, 10); | 1492 ->quad_to_target_transform.Translate(0, 10); |
| 1500 root_frame.render_pass_list[0]->damage_rect = gfx::Rect(0, 0, 1, 1); | 1493 root_frame.render_pass_list[0]->damage_rect = gfx::Rect(0, 0, 1, 1); |
| 1501 | 1494 |
| 1502 factory_.SubmitCompositorFrame(root_local_surface_id_, | 1495 support_.SubmitCompositorFrame(root_local_surface_id_, |
| 1503 std::move(root_frame), | 1496 std::move(root_frame)); |
| 1504 SurfaceFactory::DrawCallback()); | |
| 1505 } | 1497 } |
| 1506 | 1498 |
| 1507 { | 1499 { |
| 1508 CompositorFrame root_frame; | 1500 CompositorFrame root_frame; |
| 1509 AddPasses(&root_frame.render_pass_list, gfx::Rect(SurfaceSize()), | 1501 AddPasses(&root_frame.render_pass_list, gfx::Rect(SurfaceSize()), |
| 1510 root_passes, arraysize(root_passes)); | 1502 root_passes, arraysize(root_passes)); |
| 1511 | 1503 |
| 1512 root_frame.render_pass_list[0] | 1504 root_frame.render_pass_list[0] |
| 1513 ->shared_quad_state_list.front() | 1505 ->shared_quad_state_list.front() |
| 1514 ->quad_to_target_transform.Translate(0, 10); | 1506 ->quad_to_target_transform.Translate(0, 10); |
| 1515 root_frame.render_pass_list[0]->damage_rect = gfx::Rect(1, 1, 1, 1); | 1507 root_frame.render_pass_list[0]->damage_rect = gfx::Rect(1, 1, 1, 1); |
| 1516 | 1508 |
| 1517 factory_.SubmitCompositorFrame(root_local_surface_id_, | 1509 support_.SubmitCompositorFrame(root_local_surface_id_, |
| 1518 std::move(root_frame), | 1510 std::move(root_frame)); |
| 1519 SurfaceFactory::DrawCallback()); | |
| 1520 | 1511 |
| 1521 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_surface_id_); | 1512 SurfaceId root_surface_id(support_.frame_sink_id(), root_local_surface_id_); |
| 1522 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); | 1513 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); |
| 1523 | 1514 |
| 1524 const RenderPassList& aggregated_pass_list = | 1515 const RenderPassList& aggregated_pass_list = |
| 1525 aggregated_frame.render_pass_list; | 1516 aggregated_frame.render_pass_list; |
| 1526 | 1517 |
| 1527 ASSERT_EQ(2u, aggregated_pass_list.size()); | 1518 ASSERT_EQ(2u, aggregated_pass_list.size()); |
| 1528 | 1519 |
| 1529 // The root surface was enqueued without being aggregated once, so it should | 1520 // The root surface was enqueued without being aggregated once, so it should |
| 1530 // be treated as completely damaged. | 1521 // be treated as completely damaged. |
| 1531 EXPECT_TRUE(aggregated_pass_list[1]->damage_rect.Contains( | 1522 EXPECT_TRUE(aggregated_pass_list[1]->damage_rect.Contains( |
| 1532 gfx::Rect(SurfaceSize()))); | 1523 gfx::Rect(SurfaceSize()))); |
| 1533 } | 1524 } |
| 1534 | 1525 |
| 1535 // No Surface changed, so no damage should be given. | 1526 // No Surface changed, so no damage should be given. |
| 1536 { | 1527 { |
| 1537 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_surface_id_); | 1528 SurfaceId root_surface_id(support_.frame_sink_id(), root_local_surface_id_); |
| 1538 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); | 1529 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); |
| 1539 | 1530 |
| 1540 const RenderPassList& aggregated_pass_list = | 1531 const RenderPassList& aggregated_pass_list = |
| 1541 aggregated_frame.render_pass_list; | 1532 aggregated_frame.render_pass_list; |
| 1542 | 1533 |
| 1543 ASSERT_EQ(2u, aggregated_pass_list.size()); | 1534 ASSERT_EQ(2u, aggregated_pass_list.size()); |
| 1544 | 1535 |
| 1545 EXPECT_TRUE(aggregated_pass_list[1]->damage_rect.IsEmpty()); | 1536 EXPECT_TRUE(aggregated_pass_list[1]->damage_rect.IsEmpty()); |
| 1546 } | 1537 } |
| 1547 | 1538 |
| 1548 // SetFullDamageRectForSurface should cause the entire output to be | 1539 // SetFullDamageRectForSurface should cause the entire output to be |
| 1549 // marked as damaged. | 1540 // marked as damaged. |
| 1550 { | 1541 { |
| 1551 aggregator_.SetFullDamageForSurface(root_surface_id); | 1542 aggregator_.SetFullDamageForSurface(root_surface_id); |
| 1552 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); | 1543 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); |
| 1553 | 1544 |
| 1554 const RenderPassList& aggregated_pass_list = | 1545 const RenderPassList& aggregated_pass_list = |
| 1555 aggregated_frame.render_pass_list; | 1546 aggregated_frame.render_pass_list; |
| 1556 | 1547 |
| 1557 ASSERT_EQ(2u, aggregated_pass_list.size()); | 1548 ASSERT_EQ(2u, aggregated_pass_list.size()); |
| 1558 | 1549 |
| 1559 EXPECT_TRUE(aggregated_pass_list[1]->damage_rect.Contains( | 1550 EXPECT_TRUE(aggregated_pass_list[1]->damage_rect.Contains( |
| 1560 gfx::Rect(SurfaceSize()))); | 1551 gfx::Rect(SurfaceSize()))); |
| 1561 } | 1552 } |
| 1562 | 1553 |
| 1563 parent_factory.EvictSurface(); | 1554 parent_support.EvictFrame(); |
| 1564 } | 1555 } |
| 1565 | 1556 |
| 1566 // Check that damage is correctly calculated for surfaces. | 1557 // Check that damage is correctly calculated for surfaces. |
| 1567 TEST_F(SurfaceAggregatorValidSurfaceTest, SwitchSurfaceDamage) { | 1558 TEST_F(SurfaceAggregatorValidSurfaceTest, SwitchSurfaceDamage) { |
| 1568 test::Quad root_render_pass_quads[] = {test::Quad::SolidColorQuad(1)}; | 1559 test::Quad root_render_pass_quads[] = {test::Quad::SolidColorQuad(1)}; |
| 1569 | 1560 |
| 1570 test::Pass root_passes[] = { | 1561 test::Pass root_passes[] = { |
| 1571 test::Pass(root_render_pass_quads, arraysize(root_render_pass_quads), 2)}; | 1562 test::Pass(root_render_pass_quads, arraysize(root_render_pass_quads), 2)}; |
| 1572 | 1563 |
| 1573 CompositorFrame root_frame; | 1564 CompositorFrame root_frame; |
| 1574 AddPasses(&root_frame.render_pass_list, gfx::Rect(SurfaceSize()), root_passes, | 1565 AddPasses(&root_frame.render_pass_list, gfx::Rect(SurfaceSize()), root_passes, |
| 1575 arraysize(root_passes)); | 1566 arraysize(root_passes)); |
| 1576 | 1567 |
| 1577 root_frame.render_pass_list[0]->damage_rect = gfx::Rect(5, 5, 100, 100); | 1568 root_frame.render_pass_list[0]->damage_rect = gfx::Rect(5, 5, 100, 100); |
| 1578 | 1569 |
| 1579 factory_.SubmitCompositorFrame(root_local_surface_id_, std::move(root_frame), | 1570 support_.SubmitCompositorFrame(root_local_surface_id_, std::move(root_frame)); |
| 1580 SurfaceFactory::DrawCallback()); | |
| 1581 | 1571 |
| 1582 { | 1572 { |
| 1583 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_surface_id_); | 1573 SurfaceId root_surface_id(support_.frame_sink_id(), root_local_surface_id_); |
| 1584 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); | 1574 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); |
| 1585 | 1575 |
| 1586 const RenderPassList& aggregated_pass_list = | 1576 const RenderPassList& aggregated_pass_list = |
| 1587 aggregated_frame.render_pass_list; | 1577 aggregated_frame.render_pass_list; |
| 1588 | 1578 |
| 1589 ASSERT_EQ(1u, aggregated_pass_list.size()); | 1579 ASSERT_EQ(1u, aggregated_pass_list.size()); |
| 1590 | 1580 |
| 1591 // Damage rect for first aggregation should contain entire root surface. | 1581 // Damage rect for first aggregation should contain entire root surface. |
| 1592 EXPECT_TRUE(aggregated_pass_list[0]->damage_rect.Contains( | 1582 EXPECT_TRUE(aggregated_pass_list[0]->damage_rect.Contains( |
| 1593 gfx::Rect(SurfaceSize()))); | 1583 gfx::Rect(SurfaceSize()))); |
| 1594 } | 1584 } |
| 1595 | 1585 |
| 1596 LocalSurfaceId second_root_local_surface_id = allocator_.GenerateId(); | 1586 LocalSurfaceId second_root_local_surface_id = allocator_.GenerateId(); |
| 1597 SurfaceId second_root_surface_id(factory_.frame_sink_id(), | 1587 SurfaceId second_root_surface_id(support_.frame_sink_id(), |
| 1598 second_root_local_surface_id); | 1588 second_root_local_surface_id); |
| 1599 { | 1589 { |
| 1600 test::Quad root_render_pass_quads[] = {test::Quad::SolidColorQuad(1)}; | 1590 test::Quad root_render_pass_quads[] = {test::Quad::SolidColorQuad(1)}; |
| 1601 | 1591 |
| 1602 test::Pass root_passes[] = {test::Pass( | 1592 test::Pass root_passes[] = {test::Pass( |
| 1603 root_render_pass_quads, arraysize(root_render_pass_quads), 2)}; | 1593 root_render_pass_quads, arraysize(root_render_pass_quads), 2)}; |
| 1604 | 1594 |
| 1605 CompositorFrame root_frame; | 1595 CompositorFrame root_frame; |
| 1606 AddPasses(&root_frame.render_pass_list, gfx::Rect(SurfaceSize()), | 1596 AddPasses(&root_frame.render_pass_list, gfx::Rect(SurfaceSize()), |
| 1607 root_passes, arraysize(root_passes)); | 1597 root_passes, arraysize(root_passes)); |
| 1608 | 1598 |
| 1609 root_frame.render_pass_list[0]->damage_rect = gfx::Rect(1, 2, 3, 4); | 1599 root_frame.render_pass_list[0]->damage_rect = gfx::Rect(1, 2, 3, 4); |
| 1610 | 1600 |
| 1611 factory_.SubmitCompositorFrame(second_root_local_surface_id, | 1601 support_.SubmitCompositorFrame(second_root_local_surface_id, |
| 1612 std::move(root_frame), | 1602 std::move(root_frame)); |
| 1613 SurfaceFactory::DrawCallback()); | |
| 1614 } | 1603 } |
| 1615 { | 1604 { |
| 1616 CompositorFrame aggregated_frame = | 1605 CompositorFrame aggregated_frame = |
| 1617 aggregator_.Aggregate(second_root_surface_id); | 1606 aggregator_.Aggregate(second_root_surface_id); |
| 1618 | 1607 |
| 1619 const RenderPassList& aggregated_pass_list = | 1608 const RenderPassList& aggregated_pass_list = |
| 1620 aggregated_frame.render_pass_list; | 1609 aggregated_frame.render_pass_list; |
| 1621 | 1610 |
| 1622 ASSERT_EQ(1u, aggregated_pass_list.size()); | 1611 ASSERT_EQ(1u, aggregated_pass_list.size()); |
| 1623 | 1612 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1640 class SurfaceAggregatorPartialSwapTest | 1629 class SurfaceAggregatorPartialSwapTest |
| 1641 : public SurfaceAggregatorValidSurfaceTest { | 1630 : public SurfaceAggregatorValidSurfaceTest { |
| 1642 public: | 1631 public: |
| 1643 SurfaceAggregatorPartialSwapTest() | 1632 SurfaceAggregatorPartialSwapTest() |
| 1644 : SurfaceAggregatorValidSurfaceTest(true) {} | 1633 : SurfaceAggregatorValidSurfaceTest(true) {} |
| 1645 }; | 1634 }; |
| 1646 | 1635 |
| 1647 // Tests that quads outside the damage rect are ignored. | 1636 // Tests that quads outside the damage rect are ignored. |
| 1648 TEST_F(SurfaceAggregatorPartialSwapTest, IgnoreOutside) { | 1637 TEST_F(SurfaceAggregatorPartialSwapTest, IgnoreOutside) { |
| 1649 LocalSurfaceId child_local_surface_id = allocator_.GenerateId(); | 1638 LocalSurfaceId child_local_surface_id = allocator_.GenerateId(); |
| 1650 SurfaceId child_surface_id(child_factory_.frame_sink_id(), | 1639 SurfaceId child_surface_id(child_support_.frame_sink_id(), |
| 1651 child_local_surface_id); | 1640 child_local_surface_id); |
| 1652 // The child surface has three quads, one with a visible rect of 13,13 4x4 and | 1641 // The child surface has three quads, one with a visible rect of 13,13 4x4 and |
| 1653 // the other other with a visible rect of 10,10 2x2 (relative to root target | 1642 // the other other with a visible rect of 10,10 2x2 (relative to root target |
| 1654 // space), and one with a non-invertible transform. | 1643 // space), and one with a non-invertible transform. |
| 1655 { | 1644 { |
| 1656 int child_pass_id = 1; | 1645 int child_pass_id = 1; |
| 1657 test::Quad child_quads1[] = {test::Quad::RenderPassQuad(child_pass_id)}; | 1646 test::Quad child_quads1[] = {test::Quad::RenderPassQuad(child_pass_id)}; |
| 1658 test::Quad child_quads2[] = {test::Quad::RenderPassQuad(child_pass_id)}; | 1647 test::Quad child_quads2[] = {test::Quad::RenderPassQuad(child_pass_id)}; |
| 1659 test::Quad child_quads3[] = {test::Quad::RenderPassQuad(child_pass_id)}; | 1648 test::Quad child_quads3[] = {test::Quad::RenderPassQuad(child_pass_id)}; |
| 1660 test::Pass child_passes[] = { | 1649 test::Pass child_passes[] = { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1678 | 1667 |
| 1679 SharedQuadState* child_noninvertible_sqs = | 1668 SharedQuadState* child_noninvertible_sqs = |
| 1680 child_pass_list[2]->shared_quad_state_list.ElementAt(0u); | 1669 child_pass_list[2]->shared_quad_state_list.ElementAt(0u); |
| 1681 child_noninvertible_sqs->quad_to_target_transform.matrix().setDouble(0, 0, | 1670 child_noninvertible_sqs->quad_to_target_transform.matrix().setDouble(0, 0, |
| 1682 0.0); | 1671 0.0); |
| 1683 EXPECT_FALSE( | 1672 EXPECT_FALSE( |
| 1684 child_noninvertible_sqs->quad_to_target_transform.IsInvertible()); | 1673 child_noninvertible_sqs->quad_to_target_transform.IsInvertible()); |
| 1685 child_pass_list[2]->quad_list.ElementAt(0)->visible_rect = | 1674 child_pass_list[2]->quad_list.ElementAt(0)->visible_rect = |
| 1686 gfx::Rect(0, 0, 2, 2); | 1675 gfx::Rect(0, 0, 2, 2); |
| 1687 | 1676 |
| 1688 SubmitPassListAsFrame(&child_factory_, child_local_surface_id, | 1677 SubmitPassListAsFrame(&child_support_, child_local_surface_id, |
| 1689 &child_pass_list); | 1678 &child_pass_list); |
| 1690 } | 1679 } |
| 1691 | 1680 |
| 1692 { | 1681 { |
| 1693 test::Quad root_quads[] = { | 1682 test::Quad root_quads[] = { |
| 1694 test::Quad::SurfaceQuad(child_surface_id, InvalidSurfaceId(), 1.f)}; | 1683 test::Quad::SurfaceQuad(child_surface_id, InvalidSurfaceId(), 1.f)}; |
| 1695 | 1684 |
| 1696 test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))}; | 1685 test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))}; |
| 1697 | 1686 |
| 1698 RenderPassList root_pass_list; | 1687 RenderPassList root_pass_list; |
| 1699 AddPasses(&root_pass_list, gfx::Rect(SurfaceSize()), root_passes, | 1688 AddPasses(&root_pass_list, gfx::Rect(SurfaceSize()), root_passes, |
| 1700 arraysize(root_passes)); | 1689 arraysize(root_passes)); |
| 1701 | 1690 |
| 1702 RenderPass* root_pass = root_pass_list[0].get(); | 1691 RenderPass* root_pass = root_pass_list[0].get(); |
| 1703 root_pass->shared_quad_state_list.front() | 1692 root_pass->shared_quad_state_list.front() |
| 1704 ->quad_to_target_transform.Translate(10, 10); | 1693 ->quad_to_target_transform.Translate(10, 10); |
| 1705 root_pass->damage_rect = gfx::Rect(0, 0, 1, 1); | 1694 root_pass->damage_rect = gfx::Rect(0, 0, 1, 1); |
| 1706 | 1695 |
| 1707 SubmitPassListAsFrame(&factory_, root_local_surface_id_, &root_pass_list); | 1696 SubmitPassListAsFrame(&support_, root_local_surface_id_, &root_pass_list); |
| 1708 } | 1697 } |
| 1709 | 1698 |
| 1710 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_surface_id_); | 1699 SurfaceId root_surface_id(support_.frame_sink_id(), root_local_surface_id_); |
| 1711 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); | 1700 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); |
| 1712 | 1701 |
| 1713 const RenderPassList& aggregated_pass_list = | 1702 const RenderPassList& aggregated_pass_list = |
| 1714 aggregated_frame.render_pass_list; | 1703 aggregated_frame.render_pass_list; |
| 1715 | 1704 |
| 1716 ASSERT_EQ(3u, aggregated_pass_list.size()); | 1705 ASSERT_EQ(3u, aggregated_pass_list.size()); |
| 1717 | 1706 |
| 1718 // Damage rect for first aggregation should contain entire root surface. | 1707 // Damage rect for first aggregation should contain entire root surface. |
| 1719 EXPECT_EQ(gfx::Rect(SurfaceSize()), aggregated_pass_list[2]->damage_rect); | 1708 EXPECT_EQ(gfx::Rect(SurfaceSize()), aggregated_pass_list[2]->damage_rect); |
| 1720 EXPECT_EQ(1u, aggregated_pass_list[0]->quad_list.size()); | 1709 EXPECT_EQ(1u, aggregated_pass_list[0]->quad_list.size()); |
| 1721 EXPECT_EQ(1u, aggregated_pass_list[1]->quad_list.size()); | 1710 EXPECT_EQ(1u, aggregated_pass_list[1]->quad_list.size()); |
| 1722 EXPECT_EQ(1u, aggregated_pass_list[2]->quad_list.size()); | 1711 EXPECT_EQ(1u, aggregated_pass_list[2]->quad_list.size()); |
| 1723 | 1712 |
| 1724 // Create a root surface with a smaller damage rect. | 1713 // Create a root surface with a smaller damage rect. |
| 1725 { | 1714 { |
| 1726 test::Quad root_quads[] = { | 1715 test::Quad root_quads[] = { |
| 1727 test::Quad::SurfaceQuad(child_surface_id, InvalidSurfaceId(), 1.f)}; | 1716 test::Quad::SurfaceQuad(child_surface_id, InvalidSurfaceId(), 1.f)}; |
| 1728 | 1717 |
| 1729 test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))}; | 1718 test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))}; |
| 1730 | 1719 |
| 1731 RenderPassList root_pass_list; | 1720 RenderPassList root_pass_list; |
| 1732 AddPasses(&root_pass_list, gfx::Rect(SurfaceSize()), root_passes, | 1721 AddPasses(&root_pass_list, gfx::Rect(SurfaceSize()), root_passes, |
| 1733 arraysize(root_passes)); | 1722 arraysize(root_passes)); |
| 1734 | 1723 |
| 1735 RenderPass* root_pass = root_pass_list[0].get(); | 1724 RenderPass* root_pass = root_pass_list[0].get(); |
| 1736 root_pass->shared_quad_state_list.front() | 1725 root_pass->shared_quad_state_list.front() |
| 1737 ->quad_to_target_transform.Translate(10, 10); | 1726 ->quad_to_target_transform.Translate(10, 10); |
| 1738 root_pass->damage_rect = gfx::Rect(10, 10, 2, 2); | 1727 root_pass->damage_rect = gfx::Rect(10, 10, 2, 2); |
| 1739 SubmitPassListAsFrame(&factory_, root_local_surface_id_, &root_pass_list); | 1728 SubmitPassListAsFrame(&support_, root_local_surface_id_, &root_pass_list); |
| 1740 } | 1729 } |
| 1741 | 1730 |
| 1742 { | 1731 { |
| 1743 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); | 1732 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); |
| 1744 | 1733 |
| 1745 const RenderPassList& aggregated_pass_list = | 1734 const RenderPassList& aggregated_pass_list = |
| 1746 aggregated_frame.render_pass_list; | 1735 aggregated_frame.render_pass_list; |
| 1747 | 1736 |
| 1748 ASSERT_EQ(3u, aggregated_pass_list.size()); | 1737 ASSERT_EQ(3u, aggregated_pass_list.size()); |
| 1749 | 1738 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1779 child_sqs->quad_to_target_transform.Scale(2, 2); | 1768 child_sqs->quad_to_target_transform.Scale(2, 2); |
| 1780 | 1769 |
| 1781 child_pass_list[1]->quad_list.ElementAt(0)->visible_rect = | 1770 child_pass_list[1]->quad_list.ElementAt(0)->visible_rect = |
| 1782 gfx::Rect(0, 0, 2, 2); | 1771 gfx::Rect(0, 0, 2, 2); |
| 1783 | 1772 |
| 1784 RenderPass* child_root_pass = child_pass_list[1].get(); | 1773 RenderPass* child_root_pass = child_pass_list[1].get(); |
| 1785 | 1774 |
| 1786 child_root_pass->copy_requests.push_back( | 1775 child_root_pass->copy_requests.push_back( |
| 1787 CopyOutputRequest::CreateEmptyRequest()); | 1776 CopyOutputRequest::CreateEmptyRequest()); |
| 1788 child_root_pass->damage_rect = gfx::Rect(); | 1777 child_root_pass->damage_rect = gfx::Rect(); |
| 1789 SubmitPassListAsFrame(&child_factory_, child_local_surface_id, | 1778 SubmitPassListAsFrame(&child_support_, child_local_surface_id, |
| 1790 &child_pass_list); | 1779 &child_pass_list); |
| 1791 } | 1780 } |
| 1792 | 1781 |
| 1793 { | 1782 { |
| 1794 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); | 1783 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); |
| 1795 | 1784 |
| 1796 const RenderPassList& aggregated_pass_list = | 1785 const RenderPassList& aggregated_pass_list = |
| 1797 aggregated_frame.render_pass_list; | 1786 aggregated_frame.render_pass_list; |
| 1798 | 1787 |
| 1799 // Output frame should have no damage, but all quads included. | 1788 // Output frame should have no damage, but all quads included. |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1839 RenderPassList root_pass_list; | 1828 RenderPassList root_pass_list; |
| 1840 AddPasses(&root_pass_list, gfx::Rect(SurfaceSize()), root_passes, | 1829 AddPasses(&root_pass_list, gfx::Rect(SurfaceSize()), root_passes, |
| 1841 arraysize(root_passes)); | 1830 arraysize(root_passes)); |
| 1842 | 1831 |
| 1843 RenderPass* filter_pass = root_pass_list[1].get(); | 1832 RenderPass* filter_pass = root_pass_list[1].get(); |
| 1844 filter_pass->shared_quad_state_list.front() | 1833 filter_pass->shared_quad_state_list.front() |
| 1845 ->quad_to_target_transform.Translate(10, 10); | 1834 ->quad_to_target_transform.Translate(10, 10); |
| 1846 RenderPass* root_pass = root_pass_list[2].get(); | 1835 RenderPass* root_pass = root_pass_list[2].get(); |
| 1847 filter_pass->filters.Append(FilterOperation::CreateBlurFilter(2)); | 1836 filter_pass->filters.Append(FilterOperation::CreateBlurFilter(2)); |
| 1848 root_pass->damage_rect = gfx::Rect(10, 10, 2, 2); | 1837 root_pass->damage_rect = gfx::Rect(10, 10, 2, 2); |
| 1849 SubmitPassListAsFrame(&factory_, root_local_surface_id_, &root_pass_list); | 1838 SubmitPassListAsFrame(&support_, root_local_surface_id_, &root_pass_list); |
| 1850 } | 1839 } |
| 1851 | 1840 |
| 1852 { | 1841 { |
| 1853 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); | 1842 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); |
| 1854 | 1843 |
| 1855 const RenderPassList& aggregated_pass_list = | 1844 const RenderPassList& aggregated_pass_list = |
| 1856 aggregated_frame.render_pass_list; | 1845 aggregated_frame.render_pass_list; |
| 1857 | 1846 |
| 1858 ASSERT_EQ(4u, aggregated_pass_list.size()); | 1847 ASSERT_EQ(4u, aggregated_pass_list.size()); |
| 1859 | 1848 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1887 RenderPassList root_pass_list; | 1876 RenderPassList root_pass_list; |
| 1888 AddPasses(&root_pass_list, gfx::Rect(SurfaceSize()), root_passes, | 1877 AddPasses(&root_pass_list, gfx::Rect(SurfaceSize()), root_passes, |
| 1889 arraysize(root_passes)); | 1878 arraysize(root_passes)); |
| 1890 | 1879 |
| 1891 RenderPass* pass = root_pass_list[0].get(); | 1880 RenderPass* pass = root_pass_list[0].get(); |
| 1892 RenderPass* root_pass = root_pass_list[1].get(); | 1881 RenderPass* root_pass = root_pass_list[1].get(); |
| 1893 root_pass->shared_quad_state_list.ElementAt(1) | 1882 root_pass->shared_quad_state_list.ElementAt(1) |
| 1894 ->quad_to_target_transform.Translate(10, 10); | 1883 ->quad_to_target_transform.Translate(10, 10); |
| 1895 pass->background_filters.Append(FilterOperation::CreateBlurFilter(2)); | 1884 pass->background_filters.Append(FilterOperation::CreateBlurFilter(2)); |
| 1896 root_pass->damage_rect = gfx::Rect(10, 10, 2, 2); | 1885 root_pass->damage_rect = gfx::Rect(10, 10, 2, 2); |
| 1897 SubmitPassListAsFrame(&factory_, root_local_surface_id_, &root_pass_list); | 1886 SubmitPassListAsFrame(&support_, root_local_surface_id_, &root_pass_list); |
| 1898 } | 1887 } |
| 1899 | 1888 |
| 1900 { | 1889 { |
| 1901 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); | 1890 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); |
| 1902 | 1891 |
| 1903 const RenderPassList& aggregated_pass_list = | 1892 const RenderPassList& aggregated_pass_list = |
| 1904 aggregated_frame.render_pass_list; | 1893 aggregated_frame.render_pass_list; |
| 1905 | 1894 |
| 1906 ASSERT_EQ(3u, aggregated_pass_list.size()); | 1895 ASSERT_EQ(3u, aggregated_pass_list.size()); |
| 1907 | 1896 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1931 aggregator_->set_output_is_secure(true); | 1920 aggregator_->set_output_is_secure(true); |
| 1932 } | 1921 } |
| 1933 | 1922 |
| 1934 protected: | 1923 protected: |
| 1935 SurfaceManager manager_; | 1924 SurfaceManager manager_; |
| 1936 std::unique_ptr<SharedBitmapManager> shared_bitmap_manager_; | 1925 std::unique_ptr<SharedBitmapManager> shared_bitmap_manager_; |
| 1937 std::unique_ptr<ResourceProvider> resource_provider_; | 1926 std::unique_ptr<ResourceProvider> resource_provider_; |
| 1938 std::unique_ptr<SurfaceAggregator> aggregator_; | 1927 std::unique_ptr<SurfaceAggregator> aggregator_; |
| 1939 }; | 1928 }; |
| 1940 | 1929 |
| 1941 class ResourceTrackingSurfaceFactoryClient : public SurfaceFactoryClient { | |
| 1942 public: | |
| 1943 ResourceTrackingSurfaceFactoryClient() {} | |
| 1944 ~ResourceTrackingSurfaceFactoryClient() override {} | |
| 1945 | |
| 1946 void ReturnResources(const ReturnedResourceArray& resources) override { | |
| 1947 returned_resources_ = resources; | |
| 1948 } | |
| 1949 | |
| 1950 ReturnedResourceArray returned_resources() const { | |
| 1951 return returned_resources_; | |
| 1952 } | |
| 1953 | |
| 1954 void SetBeginFrameSource(BeginFrameSource* begin_frame_source) override {} | |
| 1955 | |
| 1956 private: | |
| 1957 ReturnedResourceArray returned_resources_; | |
| 1958 | |
| 1959 DISALLOW_COPY_AND_ASSIGN(ResourceTrackingSurfaceFactoryClient); | |
| 1960 }; | |
| 1961 | |
| 1962 void SubmitCompositorFrameWithResources(ResourceId* resource_ids, | 1930 void SubmitCompositorFrameWithResources(ResourceId* resource_ids, |
| 1963 size_t num_resource_ids, | 1931 size_t num_resource_ids, |
| 1964 bool valid, | 1932 bool valid, |
| 1965 SurfaceId child_id, | 1933 SurfaceId child_id, |
| 1966 SurfaceFactory* factory, | 1934 CompositorFrameSinkSupport* support, |
| 1967 SurfaceId surface_id) { | 1935 SurfaceId surface_id) { |
| 1968 CompositorFrame frame; | 1936 CompositorFrame frame; |
| 1969 std::unique_ptr<RenderPass> pass = RenderPass::Create(); | 1937 std::unique_ptr<RenderPass> pass = RenderPass::Create(); |
| 1970 pass->id = 1; | 1938 pass->id = 1; |
| 1971 SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState(); | 1939 SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState(); |
| 1972 sqs->opacity = 1.f; | 1940 sqs->opacity = 1.f; |
| 1973 if (child_id.is_valid()) { | 1941 if (child_id.is_valid()) { |
| 1974 SurfaceDrawQuad* surface_quad = | 1942 SurfaceDrawQuad* surface_quad = |
| 1975 pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); | 1943 pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); |
| 1976 surface_quad->SetNew(sqs, gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1), | 1944 surface_quad->SetNew(sqs, gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1), |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1995 const float vertex_opacity[4] = {0.f, 0.f, 1.f, 1.f}; | 1963 const float vertex_opacity[4] = {0.f, 0.f, 1.f, 1.f}; |
| 1996 bool flipped = false; | 1964 bool flipped = false; |
| 1997 bool nearest_neighbor = false; | 1965 bool nearest_neighbor = false; |
| 1998 bool secure_output_only = true; | 1966 bool secure_output_only = true; |
| 1999 quad->SetAll(sqs, rect, opaque_rect, visible_rect, needs_blending, | 1967 quad->SetAll(sqs, rect, opaque_rect, visible_rect, needs_blending, |
| 2000 resource_ids[i], gfx::Size(), premultiplied_alpha, uv_top_left, | 1968 resource_ids[i], gfx::Size(), premultiplied_alpha, uv_top_left, |
| 2001 uv_bottom_right, background_color, vertex_opacity, flipped, | 1969 uv_bottom_right, background_color, vertex_opacity, flipped, |
| 2002 nearest_neighbor, secure_output_only); | 1970 nearest_neighbor, secure_output_only); |
| 2003 } | 1971 } |
| 2004 frame.render_pass_list.push_back(std::move(pass)); | 1972 frame.render_pass_list.push_back(std::move(pass)); |
| 2005 factory->SubmitCompositorFrame(surface_id.local_surface_id(), | 1973 support->SubmitCompositorFrame(surface_id.local_surface_id(), |
| 2006 std::move(frame), | 1974 std::move(frame)); |
| 2007 SurfaceFactory::DrawCallback()); | |
| 2008 } | 1975 } |
| 2009 | 1976 |
| 2010 TEST_F(SurfaceAggregatorWithResourcesTest, TakeResourcesOneSurface) { | 1977 TEST_F(SurfaceAggregatorWithResourcesTest, TakeResourcesOneSurface) { |
| 2011 ResourceTrackingSurfaceFactoryClient client; | 1978 CompositorFrameSinkSupport support( |
| 2012 SurfaceFactory factory(kArbitraryRootFrameSinkId, &manager_, &client); | 1979 nullptr, &manager_, kArbitraryRootFrameSinkId, is_root, |
| 1980 handles_frame_sink_id_invalidation, needs_sync_points); |
| 2013 LocalSurfaceId local_surface_id(7u, base::UnguessableToken::Create()); | 1981 LocalSurfaceId local_surface_id(7u, base::UnguessableToken::Create()); |
| 2014 SurfaceId surface_id(factory.frame_sink_id(), local_surface_id); | 1982 SurfaceId surface_id(support.frame_sink_id(), local_surface_id); |
| 2015 | 1983 |
| 2016 ResourceId ids[] = {11, 12, 13}; | 1984 ResourceId ids[] = {11, 12, 13}; |
| 2017 SubmitCompositorFrameWithResources(ids, arraysize(ids), true, SurfaceId(), | 1985 SubmitCompositorFrameWithResources(ids, arraysize(ids), true, SurfaceId(), |
| 2018 &factory, surface_id); | 1986 &support, surface_id); |
| 2019 | 1987 |
| 2020 CompositorFrame frame = aggregator_->Aggregate(surface_id); | 1988 CompositorFrame frame = aggregator_->Aggregate(surface_id); |
| 2021 | 1989 |
| 2022 // Nothing should be available to be returned yet. | 1990 // Nothing should be available to be returned yet. |
| 2023 EXPECT_TRUE(client.returned_resources().empty()); | 1991 EXPECT_TRUE(support.LastReturnedResourcesForTesting().empty()); |
| 2024 | 1992 |
| 2025 SubmitCompositorFrameWithResources(NULL, 0u, true, SurfaceId(), &factory, | 1993 SubmitCompositorFrameWithResources(NULL, 0u, true, SurfaceId(), &support, |
| 2026 surface_id); | 1994 surface_id); |
| 2027 | 1995 |
| 2028 frame = aggregator_->Aggregate(surface_id); | 1996 frame = aggregator_->Aggregate(surface_id); |
| 2029 | 1997 |
| 2030 ASSERT_EQ(3u, client.returned_resources().size()); | 1998 ASSERT_EQ(3u, support.LastReturnedResourcesForTesting().size()); |
| 2031 ResourceId returned_ids[3]; | 1999 ResourceId returned_ids[3]; |
| 2032 for (size_t i = 0; i < 3; ++i) { | 2000 for (size_t i = 0; i < 3; ++i) { |
| 2033 returned_ids[i] = client.returned_resources()[i].id; | 2001 returned_ids[i] = support.LastReturnedResourcesForTesting()[i].id; |
| 2034 } | 2002 } |
| 2035 EXPECT_THAT(returned_ids, | 2003 EXPECT_THAT(returned_ids, |
| 2036 testing::WhenSorted(testing::ElementsAreArray(ids))); | 2004 testing::WhenSorted(testing::ElementsAreArray(ids))); |
| 2037 | 2005 |
| 2038 factory.EvictSurface(); | 2006 support.EvictFrame(); |
| 2039 } | 2007 } |
| 2040 | 2008 |
| 2041 TEST_F(SurfaceAggregatorWithResourcesTest, TakeInvalidResources) { | 2009 TEST_F(SurfaceAggregatorWithResourcesTest, TakeInvalidResources) { |
| 2042 ResourceTrackingSurfaceFactoryClient client; | 2010 CompositorFrameSinkSupport support( |
| 2043 SurfaceFactory factory(kArbitraryRootFrameSinkId, &manager_, &client); | 2011 nullptr, &manager_, kArbitraryRootFrameSinkId, is_root, |
| 2012 handles_frame_sink_id_invalidation, needs_sync_points); |
| 2044 LocalSurfaceId local_surface_id(7u, base::UnguessableToken::Create()); | 2013 LocalSurfaceId local_surface_id(7u, base::UnguessableToken::Create()); |
| 2045 SurfaceId surface_id(factory.frame_sink_id(), local_surface_id); | 2014 SurfaceId surface_id(support.frame_sink_id(), local_surface_id); |
| 2046 | 2015 |
| 2047 CompositorFrame frame; | 2016 CompositorFrame frame; |
| 2048 std::unique_ptr<RenderPass> pass = RenderPass::Create(); | 2017 std::unique_ptr<RenderPass> pass = RenderPass::Create(); |
| 2049 pass->id = 1; | 2018 pass->id = 1; |
| 2050 TransferableResource resource; | 2019 TransferableResource resource; |
| 2051 resource.id = 11; | 2020 resource.id = 11; |
| 2052 // ResourceProvider is software but resource is not, so it should be | 2021 // ResourceProvider is software but resource is not, so it should be |
| 2053 // ignored. | 2022 // ignored. |
| 2054 resource.is_software = false; | 2023 resource.is_software = false; |
| 2055 frame.resource_list.push_back(resource); | 2024 frame.resource_list.push_back(resource); |
| 2056 frame.render_pass_list.push_back(std::move(pass)); | 2025 frame.render_pass_list.push_back(std::move(pass)); |
| 2057 factory.SubmitCompositorFrame(local_surface_id, std::move(frame), | 2026 support.SubmitCompositorFrame(local_surface_id, std::move(frame)); |
| 2058 SurfaceFactory::DrawCallback()); | |
| 2059 | 2027 |
| 2060 CompositorFrame returned_frame = aggregator_->Aggregate(surface_id); | 2028 CompositorFrame returned_frame = aggregator_->Aggregate(surface_id); |
| 2061 | 2029 |
| 2062 // Nothing should be available to be returned yet. | 2030 // Nothing should be available to be returned yet. |
| 2063 EXPECT_TRUE(client.returned_resources().empty()); | 2031 EXPECT_TRUE(support.LastReturnedResourcesForTesting().empty()); |
| 2064 | 2032 |
| 2065 SubmitCompositorFrameWithResources(NULL, 0, true, SurfaceId(), &factory, | 2033 SubmitCompositorFrameWithResources(NULL, 0, true, SurfaceId(), &support, |
| 2066 surface_id); | 2034 surface_id); |
| 2067 ASSERT_EQ(1u, client.returned_resources().size()); | 2035 ASSERT_EQ(1u, support.LastReturnedResourcesForTesting().size()); |
| 2068 EXPECT_EQ(11u, client.returned_resources()[0].id); | 2036 EXPECT_EQ(11u, support.LastReturnedResourcesForTesting()[0].id); |
| 2069 | 2037 |
| 2070 factory.EvictSurface(); | 2038 support.EvictFrame(); |
| 2071 } | 2039 } |
| 2072 | 2040 |
| 2073 TEST_F(SurfaceAggregatorWithResourcesTest, TwoSurfaces) { | 2041 TEST_F(SurfaceAggregatorWithResourcesTest, TwoSurfaces) { |
| 2074 ResourceTrackingSurfaceFactoryClient client; | 2042 CompositorFrameSinkSupport support1( |
| 2075 SurfaceFactory factory1(FrameSinkId(1, 1), &manager_, &client); | 2043 nullptr, &manager_, FrameSinkId(1, 1), is_root_child, |
| 2076 SurfaceFactory factory2(FrameSinkId(2, 2), &manager_, &client); | 2044 handles_frame_sink_id_invalidation, needs_sync_points); |
| 2045 CompositorFrameSinkSupport support2( |
| 2046 nullptr, &manager_, FrameSinkId(2, 2), is_root_child, |
| 2047 handles_frame_sink_id_invalidation, needs_sync_points); |
| 2077 LocalSurfaceId local_frame1_id(7u, base::UnguessableToken::Create()); | 2048 LocalSurfaceId local_frame1_id(7u, base::UnguessableToken::Create()); |
| 2078 SurfaceId surface1_id(factory1.frame_sink_id(), local_frame1_id); | 2049 SurfaceId surface1_id(support1.frame_sink_id(), local_frame1_id); |
| 2079 | 2050 |
| 2080 LocalSurfaceId local_frame2_id(8u, base::UnguessableToken::Create()); | 2051 LocalSurfaceId local_frame2_id(8u, base::UnguessableToken::Create()); |
| 2081 SurfaceId surface2_id(factory2.frame_sink_id(), local_frame2_id); | 2052 SurfaceId surface2_id(support2.frame_sink_id(), local_frame2_id); |
| 2082 | 2053 |
| 2083 ResourceId ids[] = {11, 12, 13}; | 2054 ResourceId ids[] = {11, 12, 13}; |
| 2084 SubmitCompositorFrameWithResources(ids, arraysize(ids), true, SurfaceId(), | 2055 SubmitCompositorFrameWithResources(ids, arraysize(ids), true, SurfaceId(), |
| 2085 &factory1, surface1_id); | 2056 &support1, surface1_id); |
| 2086 ResourceId ids2[] = {14, 15, 16}; | 2057 ResourceId ids2[] = {14, 15, 16}; |
| 2087 SubmitCompositorFrameWithResources(ids2, arraysize(ids2), true, SurfaceId(), | 2058 SubmitCompositorFrameWithResources(ids2, arraysize(ids2), true, SurfaceId(), |
| 2088 &factory2, surface2_id); | 2059 &support2, surface2_id); |
| 2089 | 2060 |
| 2090 CompositorFrame frame = aggregator_->Aggregate(surface1_id); | 2061 CompositorFrame frame = aggregator_->Aggregate(surface1_id); |
| 2091 | 2062 |
| 2092 SubmitCompositorFrameWithResources(NULL, 0, true, SurfaceId(), &factory1, | 2063 SubmitCompositorFrameWithResources(NULL, 0, true, SurfaceId(), &support1, |
| 2093 surface1_id); | 2064 surface1_id); |
| 2094 | 2065 |
| 2095 // Nothing should be available to be returned yet. | 2066 // Nothing should be available to be returned yet. |
| 2096 EXPECT_TRUE(client.returned_resources().empty()); | 2067 EXPECT_TRUE(support1.LastReturnedResourcesForTesting().empty()); |
| 2068 EXPECT_TRUE(support2.LastReturnedResourcesForTesting().empty()); |
| 2097 | 2069 |
| 2098 frame = aggregator_->Aggregate(surface2_id); | 2070 frame = aggregator_->Aggregate(surface2_id); |
| 2099 | 2071 |
| 2100 // surface1_id wasn't referenced, so its resources should be returned. | 2072 // surface1_id wasn't referenced, so its resources should be returned. |
| 2101 ASSERT_EQ(3u, client.returned_resources().size()); | 2073 ASSERT_EQ(3u, support1.LastReturnedResourcesForTesting().size()); |
| 2074 ASSERT_TRUE(support2.LastReturnedResourcesForTesting().empty()); |
| 2102 ResourceId returned_ids[3]; | 2075 ResourceId returned_ids[3]; |
| 2103 for (size_t i = 0; i < 3; ++i) { | 2076 for (size_t i = 0; i < 3; ++i) { |
| 2104 returned_ids[i] = client.returned_resources()[i].id; | 2077 returned_ids[i] = support1.LastReturnedResourcesForTesting()[i].id; |
| 2105 } | 2078 } |
| 2106 EXPECT_THAT(returned_ids, | 2079 EXPECT_THAT(returned_ids, |
| 2107 testing::WhenSorted(testing::ElementsAreArray(ids))); | 2080 testing::WhenSorted(testing::ElementsAreArray(ids))); |
| 2108 EXPECT_EQ(3u, resource_provider_->num_resources()); | 2081 EXPECT_EQ(3u, resource_provider_->num_resources()); |
| 2109 | 2082 |
| 2110 factory1.EvictSurface(); | 2083 support1.EvictFrame(); |
| 2111 factory2.EvictSurface(); | 2084 support2.EvictFrame(); |
| 2112 } | 2085 } |
| 2113 | 2086 |
| 2114 // Ensure that aggregator completely ignores Surfaces that reference invalid | 2087 // Ensure that aggregator completely ignores Surfaces that reference invalid |
| 2115 // resources. | 2088 // resources. |
| 2116 TEST_F(SurfaceAggregatorWithResourcesTest, InvalidChildSurface) { | 2089 TEST_F(SurfaceAggregatorWithResourcesTest, InvalidChildSurface) { |
| 2117 ResourceTrackingSurfaceFactoryClient client; | 2090 CompositorFrameSinkSupport root_support( |
| 2118 SurfaceFactory root_factory(kArbitraryRootFrameSinkId, &manager_, &client); | 2091 nullptr, &manager_, kArbitraryRootFrameSinkId, is_root, |
| 2119 SurfaceFactory middle_factory(kArbitraryMiddleFrameSinkId, &manager_, | 2092 handles_frame_sink_id_invalidation, needs_sync_points); |
| 2120 &client); | 2093 CompositorFrameSinkSupport middle_support( |
| 2121 SurfaceFactory child_factory(kArbitraryChildFrameSinkId1, &manager_, &client); | 2094 nullptr, &manager_, kArbitraryMiddleFrameSinkId, is_root_child, |
| 2095 handles_frame_sink_id_invalidation, needs_sync_points); |
| 2096 CompositorFrameSinkSupport child_support( |
| 2097 nullptr, &manager_, kArbitraryFrameSinkId1, is_root_child, |
| 2098 handles_frame_sink_id_invalidation, needs_sync_points); |
| 2122 LocalSurfaceId root_local_surface_id(7u, kArbitraryToken); | 2099 LocalSurfaceId root_local_surface_id(7u, kArbitraryToken); |
| 2123 SurfaceId root_surface_id(root_factory.frame_sink_id(), | 2100 SurfaceId root_surface_id(root_support.frame_sink_id(), |
| 2124 root_local_surface_id); | 2101 root_local_surface_id); |
| 2125 LocalSurfaceId middle_local_surface_id(8u, kArbitraryToken); | 2102 LocalSurfaceId middle_local_surface_id(8u, kArbitraryToken); |
| 2126 SurfaceId middle_surface_id(middle_factory.frame_sink_id(), | 2103 SurfaceId middle_surface_id(middle_support.frame_sink_id(), |
| 2127 middle_local_surface_id); | 2104 middle_local_surface_id); |
| 2128 LocalSurfaceId child_local_surface_id(9u, kArbitraryToken); | 2105 LocalSurfaceId child_local_surface_id(9u, kArbitraryToken); |
| 2129 SurfaceId child_surface_id(child_factory.frame_sink_id(), | 2106 SurfaceId child_surface_id(child_support.frame_sink_id(), |
| 2130 child_local_surface_id); | 2107 child_local_surface_id); |
| 2131 | 2108 |
| 2132 ResourceId ids[] = {14, 15, 16}; | 2109 ResourceId ids[] = {14, 15, 16}; |
| 2133 SubmitCompositorFrameWithResources(ids, arraysize(ids), true, SurfaceId(), | 2110 SubmitCompositorFrameWithResources(ids, arraysize(ids), true, SurfaceId(), |
| 2134 &child_factory, child_surface_id); | 2111 &child_support, child_surface_id); |
| 2135 | 2112 |
| 2136 ResourceId ids2[] = {17, 18, 19}; | 2113 ResourceId ids2[] = {17, 18, 19}; |
| 2137 SubmitCompositorFrameWithResources(ids2, arraysize(ids2), false, | 2114 SubmitCompositorFrameWithResources(ids2, arraysize(ids2), false, |
| 2138 child_surface_id, &middle_factory, | 2115 child_surface_id, &middle_support, |
| 2139 middle_surface_id); | 2116 middle_surface_id); |
| 2140 | 2117 |
| 2141 ResourceId ids3[] = {20, 21, 22}; | 2118 ResourceId ids3[] = {20, 21, 22}; |
| 2142 SubmitCompositorFrameWithResources(ids3, arraysize(ids3), true, | 2119 SubmitCompositorFrameWithResources(ids3, arraysize(ids3), true, |
| 2143 middle_surface_id, &root_factory, | 2120 middle_surface_id, &root_support, |
| 2144 root_surface_id); | 2121 root_surface_id); |
| 2145 | 2122 |
| 2146 CompositorFrame frame; | 2123 CompositorFrame frame; |
| 2147 frame = aggregator_->Aggregate(root_surface_id); | 2124 frame = aggregator_->Aggregate(root_surface_id); |
| 2148 | 2125 |
| 2149 RenderPassList* pass_list = &frame.render_pass_list; | 2126 RenderPassList* pass_list = &frame.render_pass_list; |
| 2150 ASSERT_EQ(1u, pass_list->size()); | 2127 ASSERT_EQ(1u, pass_list->size()); |
| 2151 EXPECT_EQ(1u, pass_list->back()->shared_quad_state_list.size()); | 2128 EXPECT_EQ(1u, pass_list->back()->shared_quad_state_list.size()); |
| 2152 EXPECT_EQ(3u, pass_list->back()->quad_list.size()); | 2129 EXPECT_EQ(3u, pass_list->back()->quad_list.size()); |
| 2153 SubmitCompositorFrameWithResources(ids2, arraysize(ids), true, | 2130 SubmitCompositorFrameWithResources(ids2, arraysize(ids), true, |
| 2154 child_surface_id, &middle_factory, | 2131 child_surface_id, &middle_support, |
| 2155 middle_surface_id); | 2132 middle_surface_id); |
| 2156 | 2133 |
| 2157 frame = aggregator_->Aggregate(root_surface_id); | 2134 frame = aggregator_->Aggregate(root_surface_id); |
| 2158 | 2135 |
| 2159 pass_list = &frame.render_pass_list; | 2136 pass_list = &frame.render_pass_list; |
| 2160 ASSERT_EQ(1u, pass_list->size()); | 2137 ASSERT_EQ(1u, pass_list->size()); |
| 2161 EXPECT_EQ(3u, pass_list->back()->shared_quad_state_list.size()); | 2138 EXPECT_EQ(3u, pass_list->back()->shared_quad_state_list.size()); |
| 2162 EXPECT_EQ(9u, pass_list->back()->quad_list.size()); | 2139 EXPECT_EQ(9u, pass_list->back()->quad_list.size()); |
| 2163 | 2140 |
| 2164 root_factory.EvictSurface(); | 2141 root_support.EvictFrame(); |
| 2165 middle_factory.EvictSurface(); | 2142 middle_support.EvictFrame(); |
| 2166 child_factory.EvictSurface(); | 2143 child_support.EvictFrame(); |
| 2167 } | 2144 } |
| 2168 | 2145 |
| 2169 TEST_F(SurfaceAggregatorWithResourcesTest, SecureOutputTexture) { | 2146 TEST_F(SurfaceAggregatorWithResourcesTest, SecureOutputTexture) { |
| 2170 ResourceTrackingSurfaceFactoryClient client; | 2147 CompositorFrameSinkSupport support1( |
| 2171 SurfaceFactory factory1(FrameSinkId(1, 1), &manager_, &client); | 2148 nullptr, &manager_, FrameSinkId(1, 1), is_root_child, |
| 2172 SurfaceFactory factory2(FrameSinkId(2, 2), &manager_, &client); | 2149 handles_frame_sink_id_invalidation, needs_sync_points); |
| 2150 CompositorFrameSinkSupport support2( |
| 2151 nullptr, &manager_, FrameSinkId(2, 2), is_root_child, |
| 2152 handles_frame_sink_id_invalidation, needs_sync_points); |
| 2173 LocalSurfaceId local_frame1_id(7u, base::UnguessableToken::Create()); | 2153 LocalSurfaceId local_frame1_id(7u, base::UnguessableToken::Create()); |
| 2174 SurfaceId surface1_id(factory1.frame_sink_id(), local_frame1_id); | 2154 SurfaceId surface1_id(support1.frame_sink_id(), local_frame1_id); |
| 2175 | 2155 |
| 2176 LocalSurfaceId local_frame2_id(8u, base::UnguessableToken::Create()); | 2156 LocalSurfaceId local_frame2_id(8u, base::UnguessableToken::Create()); |
| 2177 SurfaceId surface2_id(factory2.frame_sink_id(), local_frame2_id); | 2157 SurfaceId surface2_id(support2.frame_sink_id(), local_frame2_id); |
| 2178 | 2158 |
| 2179 ResourceId ids[] = {11, 12, 13}; | 2159 ResourceId ids[] = {11, 12, 13}; |
| 2180 SubmitCompositorFrameWithResources(ids, arraysize(ids), true, SurfaceId(), | 2160 SubmitCompositorFrameWithResources(ids, arraysize(ids), true, SurfaceId(), |
| 2181 &factory1, surface1_id); | 2161 &support1, surface1_id); |
| 2182 | 2162 |
| 2183 CompositorFrame frame = aggregator_->Aggregate(surface1_id); | 2163 CompositorFrame frame = aggregator_->Aggregate(surface1_id); |
| 2184 | 2164 |
| 2185 RenderPass* render_pass = frame.render_pass_list.back().get(); | 2165 RenderPass* render_pass = frame.render_pass_list.back().get(); |
| 2186 | 2166 |
| 2187 EXPECT_EQ(DrawQuad::TEXTURE_CONTENT, render_pass->quad_list.back()->material); | 2167 EXPECT_EQ(DrawQuad::TEXTURE_CONTENT, render_pass->quad_list.back()->material); |
| 2188 | 2168 |
| 2189 { | 2169 { |
| 2190 std::unique_ptr<RenderPass> pass = RenderPass::Create(); | 2170 std::unique_ptr<RenderPass> pass = RenderPass::Create(); |
| 2191 pass->id = 1; | 2171 pass->id = 1; |
| 2192 SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState(); | 2172 SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState(); |
| 2193 sqs->opacity = 1.f; | 2173 sqs->opacity = 1.f; |
| 2194 SurfaceDrawQuad* surface_quad = | 2174 SurfaceDrawQuad* surface_quad = |
| 2195 pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); | 2175 pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); |
| 2196 | 2176 |
| 2197 surface_quad->SetNew(sqs, gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1), | 2177 surface_quad->SetNew(sqs, gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1), |
| 2198 surface1_id, SurfaceDrawQuadType::PRIMARY, nullptr); | 2178 surface1_id, SurfaceDrawQuadType::PRIMARY, nullptr); |
| 2199 pass->copy_requests.push_back(CopyOutputRequest::CreateEmptyRequest()); | 2179 pass->copy_requests.push_back(CopyOutputRequest::CreateEmptyRequest()); |
| 2200 | 2180 |
| 2201 CompositorFrame frame; | 2181 CompositorFrame frame; |
| 2202 frame.render_pass_list.push_back(std::move(pass)); | 2182 frame.render_pass_list.push_back(std::move(pass)); |
| 2203 | 2183 |
| 2204 factory2.SubmitCompositorFrame(local_frame2_id, std::move(frame), | 2184 support2.SubmitCompositorFrame(local_frame2_id, std::move(frame)); |
| 2205 SurfaceFactory::DrawCallback()); | |
| 2206 } | 2185 } |
| 2207 | 2186 |
| 2208 frame = aggregator_->Aggregate(surface2_id); | 2187 frame = aggregator_->Aggregate(surface2_id); |
| 2209 EXPECT_EQ(1u, frame.render_pass_list.size()); | 2188 EXPECT_EQ(1u, frame.render_pass_list.size()); |
| 2210 render_pass = frame.render_pass_list.front().get(); | 2189 render_pass = frame.render_pass_list.front().get(); |
| 2211 | 2190 |
| 2212 // Parent has copy request, so texture should not be drawn. | 2191 // Parent has copy request, so texture should not be drawn. |
| 2213 EXPECT_EQ(DrawQuad::SOLID_COLOR, render_pass->quad_list.back()->material); | 2192 EXPECT_EQ(DrawQuad::SOLID_COLOR, render_pass->quad_list.back()->material); |
| 2214 | 2193 |
| 2215 frame = aggregator_->Aggregate(surface2_id); | 2194 frame = aggregator_->Aggregate(surface2_id); |
| 2216 EXPECT_EQ(1u, frame.render_pass_list.size()); | 2195 EXPECT_EQ(1u, frame.render_pass_list.size()); |
| 2217 render_pass = frame.render_pass_list.front().get(); | 2196 render_pass = frame.render_pass_list.front().get(); |
| 2218 | 2197 |
| 2219 // Copy request has been executed earlier, so texture should be drawn. | 2198 // Copy request has been executed earlier, so texture should be drawn. |
| 2220 EXPECT_EQ(DrawQuad::TEXTURE_CONTENT, | 2199 EXPECT_EQ(DrawQuad::TEXTURE_CONTENT, |
| 2221 render_pass->quad_list.front()->material); | 2200 render_pass->quad_list.front()->material); |
| 2222 | 2201 |
| 2223 aggregator_->set_output_is_secure(false); | 2202 aggregator_->set_output_is_secure(false); |
| 2224 | 2203 |
| 2225 frame = aggregator_->Aggregate(surface2_id); | 2204 frame = aggregator_->Aggregate(surface2_id); |
| 2226 render_pass = frame.render_pass_list.back().get(); | 2205 render_pass = frame.render_pass_list.back().get(); |
| 2227 | 2206 |
| 2228 // Output is insecure, so texture should be drawn. | 2207 // Output is insecure, so texture should be drawn. |
| 2229 EXPECT_EQ(DrawQuad::SOLID_COLOR, render_pass->quad_list.back()->material); | 2208 EXPECT_EQ(DrawQuad::SOLID_COLOR, render_pass->quad_list.back()->material); |
| 2230 | 2209 |
| 2231 factory1.EvictSurface(); | 2210 support1.EvictFrame(); |
| 2232 factory2.EvictSurface(); | 2211 support2.EvictFrame(); |
| 2233 } | 2212 } |
| 2234 | 2213 |
| 2235 // Ensure that the render passes have correct color spaces. | 2214 // Ensure that the render passes have correct color spaces. |
| 2236 TEST_F(SurfaceAggregatorValidSurfaceTest, ColorSpaceTest) { | 2215 TEST_F(SurfaceAggregatorValidSurfaceTest, ColorSpaceTest) { |
| 2237 test::Quad quads[][2] = {{test::Quad::SolidColorQuad(SK_ColorWHITE), | 2216 test::Quad quads[][2] = {{test::Quad::SolidColorQuad(SK_ColorWHITE), |
| 2238 test::Quad::SolidColorQuad(SK_ColorLTGRAY)}, | 2217 test::Quad::SolidColorQuad(SK_ColorLTGRAY)}, |
| 2239 {test::Quad::SolidColorQuad(SK_ColorGRAY), | 2218 {test::Quad::SolidColorQuad(SK_ColorGRAY), |
| 2240 test::Quad::SolidColorQuad(SK_ColorDKGRAY)}}; | 2219 test::Quad::SolidColorQuad(SK_ColorDKGRAY)}}; |
| 2241 test::Pass passes[] = {test::Pass(quads[0], arraysize(quads[0]), 2), | 2220 test::Pass passes[] = {test::Pass(quads[0], arraysize(quads[0]), 2), |
| 2242 test::Pass(quads[1], arraysize(quads[1]), 1)}; | 2221 test::Pass(quads[1], arraysize(quads[1]), 1)}; |
| 2243 gfx::ColorSpace color_space1 = gfx::ColorSpace::CreateXYZD50(); | 2222 gfx::ColorSpace color_space1 = gfx::ColorSpace::CreateXYZD50(); |
| 2244 gfx::ColorSpace color_space2 = gfx::ColorSpace::CreateSRGB(); | 2223 gfx::ColorSpace color_space2 = gfx::ColorSpace::CreateSRGB(); |
| 2245 gfx::ColorSpace color_space3 = gfx::ColorSpace::CreateSCRGBLinear(); | 2224 gfx::ColorSpace color_space3 = gfx::ColorSpace::CreateSCRGBLinear(); |
| 2246 | 2225 |
| 2247 SubmitCompositorFrame(&factory_, passes, arraysize(passes), | 2226 SubmitCompositorFrame(&support_, passes, arraysize(passes), |
| 2248 root_local_surface_id_); | 2227 root_local_surface_id_); |
| 2249 | 2228 |
| 2250 SurfaceId surface_id(factory_.frame_sink_id(), root_local_surface_id_); | 2229 SurfaceId surface_id(support_.frame_sink_id(), root_local_surface_id_); |
| 2251 | 2230 |
| 2252 CompositorFrame aggregated_frame; | 2231 CompositorFrame aggregated_frame; |
| 2253 aggregator_.SetOutputColorSpace(color_space1, color_space1); | 2232 aggregator_.SetOutputColorSpace(color_space1, color_space1); |
| 2254 aggregated_frame = aggregator_.Aggregate(surface_id); | 2233 aggregated_frame = aggregator_.Aggregate(surface_id); |
| 2255 EXPECT_EQ(2u, aggregated_frame.render_pass_list.size()); | 2234 EXPECT_EQ(2u, aggregated_frame.render_pass_list.size()); |
| 2256 EXPECT_EQ(color_space1, aggregated_frame.render_pass_list[0]->color_space); | 2235 EXPECT_EQ(color_space1, aggregated_frame.render_pass_list[0]->color_space); |
| 2257 EXPECT_EQ(color_space1, aggregated_frame.render_pass_list[1]->color_space); | 2236 EXPECT_EQ(color_space1, aggregated_frame.render_pass_list[1]->color_space); |
| 2258 | 2237 |
| 2259 aggregator_.SetOutputColorSpace(color_space2, color_space2); | 2238 aggregator_.SetOutputColorSpace(color_space2, color_space2); |
| 2260 aggregated_frame = aggregator_.Aggregate(surface_id); | 2239 aggregated_frame = aggregator_.Aggregate(surface_id); |
| 2261 EXPECT_EQ(2u, aggregated_frame.render_pass_list.size()); | 2240 EXPECT_EQ(2u, aggregated_frame.render_pass_list.size()); |
| 2262 EXPECT_EQ(color_space2, aggregated_frame.render_pass_list[0]->color_space); | 2241 EXPECT_EQ(color_space2, aggregated_frame.render_pass_list[0]->color_space); |
| 2263 EXPECT_EQ(color_space2, aggregated_frame.render_pass_list[1]->color_space); | 2242 EXPECT_EQ(color_space2, aggregated_frame.render_pass_list[1]->color_space); |
| 2264 | 2243 |
| 2265 aggregator_.SetOutputColorSpace(color_space1, color_space3); | 2244 aggregator_.SetOutputColorSpace(color_space1, color_space3); |
| 2266 aggregated_frame = aggregator_.Aggregate(surface_id); | 2245 aggregated_frame = aggregator_.Aggregate(surface_id); |
| 2267 EXPECT_EQ(3u, aggregated_frame.render_pass_list.size()); | 2246 EXPECT_EQ(3u, aggregated_frame.render_pass_list.size()); |
| 2268 EXPECT_EQ(color_space1, aggregated_frame.render_pass_list[0]->color_space); | 2247 EXPECT_EQ(color_space1, aggregated_frame.render_pass_list[0]->color_space); |
| 2269 EXPECT_EQ(color_space1, aggregated_frame.render_pass_list[1]->color_space); | 2248 EXPECT_EQ(color_space1, aggregated_frame.render_pass_list[1]->color_space); |
| 2270 EXPECT_EQ(color_space3, aggregated_frame.render_pass_list[2]->color_space); | 2249 EXPECT_EQ(color_space3, aggregated_frame.render_pass_list[2]->color_space); |
| 2271 } | 2250 } |
| 2272 | 2251 |
| 2273 } // namespace | 2252 } // namespace |
| 2274 } // namespace cc | 2253 } // namespace cc |
| 2275 | 2254 |
| OLD | NEW |