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