| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/surfaces/surface_aggregator.h" | 5 #include "cc/surfaces/surface_aggregator.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 16 matching lines...) Expand all Loading... |
| 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 static constexpr FrameSinkId kArbitraryFrameSinkId(1, 1); | 37 static constexpr FrameSinkId kArbitraryRootFrameSinkId(1, 1); |
| 38 static constexpr FrameSinkId kArbitraryChildFrameSinkId(2, 2); | 38 static constexpr FrameSinkId kArbitraryChildFrameSinkId(2, 2); |
| 39 static constexpr FrameSinkId kArbitraryMiddleFrameSinkId(3, 3); |
| 39 static const base::UnguessableToken kArbitraryToken = | 40 static const base::UnguessableToken kArbitraryToken = |
| 40 base::UnguessableToken::Create(); | 41 base::UnguessableToken::Create(); |
| 41 | 42 |
| 42 SurfaceId InvalidSurfaceId() { | 43 SurfaceId InvalidSurfaceId() { |
| 43 static SurfaceId invalid(kArbitraryFrameSinkId, | 44 static SurfaceId invalid(kArbitraryRootFrameSinkId, |
| 44 LocalFrameId(0xdeadbeef, kArbitraryToken)); | 45 LocalFrameId(0xdeadbeef, kArbitraryToken)); |
| 45 return invalid; | 46 return invalid; |
| 46 } | 47 } |
| 47 | 48 |
| 48 gfx::Size SurfaceSize() { | 49 gfx::Size SurfaceSize() { |
| 49 static gfx::Size size(100, 100); | 50 static gfx::Size size(100, 100); |
| 50 return size; | 51 return size; |
| 51 } | 52 } |
| 52 | 53 |
| 53 class EmptySurfaceFactoryClient : public SurfaceFactoryClient { | 54 class EmptySurfaceFactoryClient : public SurfaceFactoryClient { |
| 54 public: | 55 public: |
| 55 void ReturnResources(const ReturnedResourceArray& resources) override {} | 56 void ReturnResources(const ReturnedResourceArray& resources) override {} |
| 56 | 57 |
| 57 void WillDrawSurface(const LocalFrameId& id, | 58 void WillDrawSurface(const LocalFrameId& id, |
| 58 const gfx::Rect& damage_rect) override { | 59 const gfx::Rect& damage_rect) override { |
| 59 last_local_frame_id_ = id; | 60 last_local_frame_id_ = id; |
| 60 last_damage_rect_ = damage_rect; | 61 last_damage_rect_ = damage_rect; |
| 61 } | 62 } |
| 62 | 63 |
| 63 void SetBeginFrameSource(BeginFrameSource* begin_frame_source) override {} | 64 void SetBeginFrameSource(BeginFrameSource* begin_frame_source) override {} |
| 64 | 65 |
| 65 gfx::Rect last_damage_rect_; | 66 gfx::Rect last_damage_rect_; |
| 66 LocalFrameId last_local_frame_id_; | 67 LocalFrameId last_local_frame_id_; |
| 67 }; | 68 }; |
| 68 | 69 |
| 69 class SurfaceAggregatorTest : public testing::Test { | 70 class SurfaceAggregatorTest : public testing::Test { |
| 70 public: | 71 public: |
| 71 explicit SurfaceAggregatorTest(bool use_damage_rect) | 72 explicit SurfaceAggregatorTest(bool use_damage_rect) |
| 72 : factory_(kArbitraryFrameSinkId, &manager_, &empty_client_), | 73 : factory_(kArbitraryRootFrameSinkId, &manager_, &empty_client_), |
| 73 aggregator_(&manager_, NULL, use_damage_rect) {} | 74 aggregator_(&manager_, NULL, use_damage_rect) {} |
| 74 | 75 |
| 75 SurfaceAggregatorTest() : SurfaceAggregatorTest(false) {} | 76 SurfaceAggregatorTest() : SurfaceAggregatorTest(false) {} |
| 76 | 77 |
| 78 void TearDown() override { |
| 79 factory_.EvictSurface(); |
| 80 testing::Test::TearDown(); |
| 81 } |
| 82 |
| 77 protected: | 83 protected: |
| 78 SurfaceManager manager_; | 84 SurfaceManager manager_; |
| 79 EmptySurfaceFactoryClient empty_client_; | 85 EmptySurfaceFactoryClient empty_client_; |
| 80 SurfaceFactory factory_; | 86 SurfaceFactory factory_; |
| 81 SurfaceAggregator aggregator_; | 87 SurfaceAggregator aggregator_; |
| 82 }; | 88 }; |
| 83 | 89 |
| 84 TEST_F(SurfaceAggregatorTest, ValidSurfaceNoFrame) { | 90 TEST_F(SurfaceAggregatorTest, ValidSurfaceNoFrame) { |
| 85 LocalFrameId local_frame_id(7, base::UnguessableToken::Create()); | 91 LocalFrameId local_frame_id(7, base::UnguessableToken::Create()); |
| 86 SurfaceId one_id(kArbitraryFrameSinkId, local_frame_id); | 92 SurfaceId one_id(kArbitraryRootFrameSinkId, local_frame_id); |
| 87 factory_.Create(local_frame_id); | 93 factory_.SubmitCompositorFrame(local_frame_id, CompositorFrame(), |
| 94 SurfaceFactory::DrawCallback()); |
| 88 | 95 |
| 89 CompositorFrame frame = aggregator_.Aggregate(one_id); | 96 CompositorFrame frame = aggregator_.Aggregate(one_id); |
| 90 EXPECT_TRUE(frame.render_pass_list.empty()); | 97 EXPECT_TRUE(frame.render_pass_list.empty()); |
| 91 | |
| 92 factory_.Destroy(local_frame_id); | |
| 93 } | 98 } |
| 94 | 99 |
| 95 class SurfaceAggregatorValidSurfaceTest : public SurfaceAggregatorTest { | 100 class SurfaceAggregatorValidSurfaceTest : public SurfaceAggregatorTest { |
| 96 public: | 101 public: |
| 97 explicit SurfaceAggregatorValidSurfaceTest(bool use_damage_rect) | 102 explicit SurfaceAggregatorValidSurfaceTest(bool use_damage_rect) |
| 98 : SurfaceAggregatorTest(use_damage_rect), | 103 : SurfaceAggregatorTest(use_damage_rect), |
| 99 child_factory_(kArbitraryChildFrameSinkId, | 104 child_factory_(kArbitraryChildFrameSinkId, |
| 100 &manager_, | 105 &manager_, |
| 101 &empty_child_client_) {} | 106 &empty_child_client_) {} |
| 102 SurfaceAggregatorValidSurfaceTest() | 107 SurfaceAggregatorValidSurfaceTest() |
| 103 : SurfaceAggregatorValidSurfaceTest(false) {} | 108 : SurfaceAggregatorValidSurfaceTest(false) {} |
| 104 | 109 |
| 105 void SetUp() override { | 110 void SetUp() override { |
| 106 SurfaceAggregatorTest::SetUp(); | 111 SurfaceAggregatorTest::SetUp(); |
| 107 root_local_frame_id_ = allocator_.GenerateId(); | 112 root_local_frame_id_ = allocator_.GenerateId(); |
| 108 factory_.Create(root_local_frame_id_); | |
| 109 root_surface_ = manager_.GetSurfaceForId( | 113 root_surface_ = manager_.GetSurfaceForId( |
| 110 SurfaceId(factory_.frame_sink_id(), root_local_frame_id_)); | 114 SurfaceId(factory_.frame_sink_id(), root_local_frame_id_)); |
| 111 } | 115 } |
| 112 | 116 |
| 113 void TearDown() override { | 117 void TearDown() override { |
| 114 factory_.Destroy(root_local_frame_id_); | 118 child_factory_.EvictSurface(); |
| 115 SurfaceAggregatorTest::TearDown(); | 119 SurfaceAggregatorTest::TearDown(); |
| 116 } | 120 } |
| 117 | 121 |
| 118 void AggregateAndVerify(test::Pass* expected_passes, | 122 void AggregateAndVerify(test::Pass* expected_passes, |
| 119 size_t expected_pass_count, | 123 size_t expected_pass_count, |
| 120 SurfaceId* surface_ids, | 124 SurfaceId* surface_ids, |
| 121 size_t expected_surface_count) { | 125 size_t expected_surface_count) { |
| 122 CompositorFrame aggregated_frame = aggregator_.Aggregate( | 126 CompositorFrame aggregated_frame = aggregator_.Aggregate( |
| 123 SurfaceId(factory_.frame_sink_id(), root_local_frame_id_)); | 127 SurfaceId(factory_.frame_sink_id(), root_local_frame_id_)); |
| 124 | 128 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 153 void SubmitCompositorFrame(SurfaceFactory* factory, | 157 void SubmitCompositorFrame(SurfaceFactory* factory, |
| 154 test::Pass* passes, | 158 test::Pass* passes, |
| 155 size_t pass_count, | 159 size_t pass_count, |
| 156 const LocalFrameId& local_frame_id) { | 160 const LocalFrameId& local_frame_id) { |
| 157 RenderPassList pass_list; | 161 RenderPassList pass_list; |
| 158 AddPasses(&pass_list, gfx::Rect(SurfaceSize()), passes, pass_count); | 162 AddPasses(&pass_list, gfx::Rect(SurfaceSize()), passes, pass_count); |
| 159 SubmitPassListAsFrame(factory, local_frame_id, &pass_list); | 163 SubmitPassListAsFrame(factory, local_frame_id, &pass_list); |
| 160 } | 164 } |
| 161 | 165 |
| 162 void QueuePassAsFrame(std::unique_ptr<RenderPass> pass, | 166 void QueuePassAsFrame(std::unique_ptr<RenderPass> pass, |
| 163 const LocalFrameId& local_frame_id) { | 167 const LocalFrameId& local_frame_id, |
| 168 SurfaceFactory* factory) { |
| 164 CompositorFrame child_frame; | 169 CompositorFrame child_frame; |
| 165 child_frame.render_pass_list.push_back(std::move(pass)); | 170 child_frame.render_pass_list.push_back(std::move(pass)); |
| 166 | 171 |
| 167 factory_.SubmitCompositorFrame(local_frame_id, std::move(child_frame), | 172 factory->SubmitCompositorFrame(local_frame_id, std::move(child_frame), |
| 168 SurfaceFactory::DrawCallback()); | 173 SurfaceFactory::DrawCallback()); |
| 169 } | 174 } |
| 170 | 175 |
| 171 protected: | 176 protected: |
| 172 LocalFrameId root_local_frame_id_; | 177 LocalFrameId root_local_frame_id_; |
| 173 Surface* root_surface_; | 178 Surface* root_surface_; |
| 174 SurfaceIdAllocator allocator_; | 179 SurfaceIdAllocator allocator_; |
| 175 EmptySurfaceFactoryClient empty_child_client_; | 180 EmptySurfaceFactoryClient empty_child_client_; |
| 176 SurfaceFactory child_factory_; | 181 SurfaceFactory child_factory_; |
| 177 SurfaceIdAllocator child_allocator_; | 182 SurfaceIdAllocator child_allocator_; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 191 SurfaceId ids[] = {root_surface_id}; | 196 SurfaceId ids[] = {root_surface_id}; |
| 192 | 197 |
| 193 AggregateAndVerify(passes, arraysize(passes), ids, arraysize(ids)); | 198 AggregateAndVerify(passes, arraysize(passes), ids, arraysize(ids)); |
| 194 | 199 |
| 195 // Check that WillDrawSurface was called. | 200 // Check that WillDrawSurface was called. |
| 196 EXPECT_EQ(gfx::Rect(SurfaceSize()), empty_client_.last_damage_rect_); | 201 EXPECT_EQ(gfx::Rect(SurfaceSize()), empty_client_.last_damage_rect_); |
| 197 EXPECT_EQ(root_local_frame_id_, empty_client_.last_local_frame_id_); | 202 EXPECT_EQ(root_local_frame_id_, empty_client_.last_local_frame_id_); |
| 198 } | 203 } |
| 199 | 204 |
| 200 TEST_F(SurfaceAggregatorValidSurfaceTest, OpacityCopied) { | 205 TEST_F(SurfaceAggregatorValidSurfaceTest, OpacityCopied) { |
| 206 SurfaceFactory embedded_factory(kArbitraryChildFrameSinkId, &manager_, |
| 207 &empty_client_); |
| 201 LocalFrameId embedded_local_frame_id = allocator_.GenerateId(); | 208 LocalFrameId embedded_local_frame_id = allocator_.GenerateId(); |
| 202 SurfaceId embedded_surface_id(factory_.frame_sink_id(), | 209 SurfaceId embedded_surface_id(embedded_factory.frame_sink_id(), |
| 203 embedded_local_frame_id); | 210 embedded_local_frame_id); |
| 204 factory_.Create(embedded_local_frame_id); | |
| 205 | 211 |
| 206 test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), | 212 test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), |
| 207 test::Quad::SolidColorQuad(SK_ColorBLUE)}; | 213 test::Quad::SolidColorQuad(SK_ColorBLUE)}; |
| 208 test::Pass embedded_passes[] = { | 214 test::Pass embedded_passes[] = { |
| 209 test::Pass(embedded_quads, arraysize(embedded_quads))}; | 215 test::Pass(embedded_quads, arraysize(embedded_quads))}; |
| 210 | 216 |
| 211 SubmitCompositorFrame(&factory_, embedded_passes, arraysize(embedded_passes), | 217 SubmitCompositorFrame(&embedded_factory, embedded_passes, |
| 212 embedded_local_frame_id); | 218 arraysize(embedded_passes), embedded_local_frame_id); |
| 213 | 219 |
| 214 test::Quad quads[] = {test::Quad::SurfaceQuad(embedded_surface_id, .5f)}; | 220 test::Quad quads[] = {test::Quad::SurfaceQuad(embedded_surface_id, .5f)}; |
| 215 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; | 221 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; |
| 216 | 222 |
| 217 SubmitCompositorFrame(&factory_, passes, arraysize(passes), | 223 SubmitCompositorFrame(&factory_, passes, arraysize(passes), |
| 218 root_local_frame_id_); | 224 root_local_frame_id_); |
| 219 | 225 |
| 220 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id_); | 226 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id_); |
| 221 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); | 227 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); |
| 222 | 228 |
| 223 RenderPassList& render_pass_list(aggregated_frame.render_pass_list); | 229 RenderPassList& render_pass_list(aggregated_frame.render_pass_list); |
| 224 ASSERT_EQ(2u, render_pass_list.size()); | 230 ASSERT_EQ(2u, render_pass_list.size()); |
| 225 SharedQuadStateList& shared_quad_state_list( | 231 SharedQuadStateList& shared_quad_state_list( |
| 226 render_pass_list[0]->shared_quad_state_list); | 232 render_pass_list[0]->shared_quad_state_list); |
| 227 ASSERT_EQ(2u, shared_quad_state_list.size()); | 233 ASSERT_EQ(2u, shared_quad_state_list.size()); |
| 228 EXPECT_EQ(1.f, shared_quad_state_list.ElementAt(0)->opacity); | 234 EXPECT_EQ(1.f, shared_quad_state_list.ElementAt(0)->opacity); |
| 229 EXPECT_EQ(1.f, shared_quad_state_list.ElementAt(1)->opacity); | 235 EXPECT_EQ(1.f, shared_quad_state_list.ElementAt(1)->opacity); |
| 230 | 236 |
| 231 SharedQuadStateList& shared_quad_state_list2( | 237 SharedQuadStateList& shared_quad_state_list2( |
| 232 render_pass_list[1]->shared_quad_state_list); | 238 render_pass_list[1]->shared_quad_state_list); |
| 233 ASSERT_EQ(1u, shared_quad_state_list2.size()); | 239 ASSERT_EQ(1u, shared_quad_state_list2.size()); |
| 234 EXPECT_EQ(.5f, shared_quad_state_list2.ElementAt(0)->opacity); | 240 EXPECT_EQ(.5f, shared_quad_state_list2.ElementAt(0)->opacity); |
| 235 | 241 |
| 236 factory_.Destroy(embedded_local_frame_id); | 242 embedded_factory.EvictSurface(); |
| 237 } | 243 } |
| 238 | 244 |
| 239 TEST_F(SurfaceAggregatorValidSurfaceTest, MultiPassSimpleFrame) { | 245 TEST_F(SurfaceAggregatorValidSurfaceTest, MultiPassSimpleFrame) { |
| 240 test::Quad quads[][2] = {{test::Quad::SolidColorQuad(SK_ColorWHITE), | 246 test::Quad quads[][2] = {{test::Quad::SolidColorQuad(SK_ColorWHITE), |
| 241 test::Quad::SolidColorQuad(SK_ColorLTGRAY)}, | 247 test::Quad::SolidColorQuad(SK_ColorLTGRAY)}, |
| 242 {test::Quad::SolidColorQuad(SK_ColorGRAY), | 248 {test::Quad::SolidColorQuad(SK_ColorGRAY), |
| 243 test::Quad::SolidColorQuad(SK_ColorDKGRAY)}}; | 249 test::Quad::SolidColorQuad(SK_ColorDKGRAY)}}; |
| 244 test::Pass passes[] = { | 250 test::Pass passes[] = { |
| 245 test::Pass(quads[0], arraysize(quads[0]), RenderPassId(1, 1)), | 251 test::Pass(quads[0], arraysize(quads[0]), RenderPassId(1, 1)), |
| 246 test::Pass(quads[1], arraysize(quads[1]), RenderPassId(1, 2))}; | 252 test::Pass(quads[1], arraysize(quads[1]), RenderPassId(1, 2))}; |
| 247 | 253 |
| 248 SubmitCompositorFrame(&factory_, passes, arraysize(passes), | 254 SubmitCompositorFrame(&factory_, passes, arraysize(passes), |
| 249 root_local_frame_id_); | 255 root_local_frame_id_); |
| 250 | 256 |
| 251 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id_); | 257 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id_); |
| 252 SurfaceId ids[] = {root_surface_id}; | 258 SurfaceId ids[] = {root_surface_id}; |
| 253 | 259 |
| 254 AggregateAndVerify(passes, arraysize(passes), ids, arraysize(ids)); | 260 AggregateAndVerify(passes, arraysize(passes), ids, arraysize(ids)); |
| 255 } | 261 } |
| 256 | 262 |
| 257 // This tests very simple embedding. root_surface has a frame containing a few | 263 // This tests very simple embedding. root_surface has a frame containing a few |
| 258 // solid color quads and a surface quad referencing embedded_surface. | 264 // solid color quads and a surface quad referencing embedded_surface. |
| 259 // embedded_surface has a frame containing only a solid color quad. The solid | 265 // embedded_surface has a frame containing only a solid color quad. The solid |
| 260 // color quad should be aggregated into the final frame. | 266 // color quad should be aggregated into the final frame. |
| 261 TEST_F(SurfaceAggregatorValidSurfaceTest, SimpleSurfaceReference) { | 267 TEST_F(SurfaceAggregatorValidSurfaceTest, SimpleSurfaceReference) { |
| 268 SurfaceFactory embedded_factory(kArbitraryChildFrameSinkId, &manager_, |
| 269 &empty_client_); |
| 262 LocalFrameId embedded_local_frame_id = allocator_.GenerateId(); | 270 LocalFrameId embedded_local_frame_id = allocator_.GenerateId(); |
| 263 SurfaceId embedded_surface_id(factory_.frame_sink_id(), | 271 SurfaceId embedded_surface_id(embedded_factory.frame_sink_id(), |
| 264 embedded_local_frame_id); | 272 embedded_local_frame_id); |
| 265 factory_.Create(embedded_local_frame_id); | |
| 266 | 273 |
| 267 test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)}; | 274 test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)}; |
| 268 test::Pass embedded_passes[] = { | 275 test::Pass embedded_passes[] = { |
| 269 test::Pass(embedded_quads, arraysize(embedded_quads))}; | 276 test::Pass(embedded_quads, arraysize(embedded_quads))}; |
| 270 | 277 |
| 271 SubmitCompositorFrame(&factory_, embedded_passes, arraysize(embedded_passes), | 278 SubmitCompositorFrame(&embedded_factory, embedded_passes, |
| 272 embedded_local_frame_id); | 279 arraysize(embedded_passes), embedded_local_frame_id); |
| 273 | 280 |
| 274 test::Quad root_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE), | 281 test::Quad root_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE), |
| 275 test::Quad::SurfaceQuad(embedded_surface_id, 1.f), | 282 test::Quad::SurfaceQuad(embedded_surface_id, 1.f), |
| 276 test::Quad::SolidColorQuad(SK_ColorBLACK)}; | 283 test::Quad::SolidColorQuad(SK_ColorBLACK)}; |
| 277 test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))}; | 284 test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))}; |
| 278 | 285 |
| 279 SubmitCompositorFrame(&factory_, root_passes, arraysize(root_passes), | 286 SubmitCompositorFrame(&factory_, root_passes, arraysize(root_passes), |
| 280 root_local_frame_id_); | 287 root_local_frame_id_); |
| 281 | 288 |
| 282 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE), | 289 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE), |
| 283 test::Quad::SolidColorQuad(SK_ColorGREEN), | 290 test::Quad::SolidColorQuad(SK_ColorGREEN), |
| 284 test::Quad::SolidColorQuad(SK_ColorBLACK)}; | 291 test::Quad::SolidColorQuad(SK_ColorBLACK)}; |
| 285 test::Pass expected_passes[] = { | 292 test::Pass expected_passes[] = { |
| 286 test::Pass(expected_quads, arraysize(expected_quads))}; | 293 test::Pass(expected_quads, arraysize(expected_quads))}; |
| 287 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id_); | 294 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id_); |
| 288 SurfaceId ids[] = {root_surface_id, embedded_surface_id}; | 295 SurfaceId ids[] = {root_surface_id, embedded_surface_id}; |
| 289 AggregateAndVerify( | 296 AggregateAndVerify( |
| 290 expected_passes, arraysize(expected_passes), ids, arraysize(ids)); | 297 expected_passes, arraysize(expected_passes), ids, arraysize(ids)); |
| 291 | 298 |
| 292 factory_.Destroy(embedded_local_frame_id); | 299 embedded_factory.EvictSurface(); |
| 293 } | 300 } |
| 294 | 301 |
| 295 TEST_F(SurfaceAggregatorValidSurfaceTest, CopyRequest) { | 302 TEST_F(SurfaceAggregatorValidSurfaceTest, CopyRequest) { |
| 303 SurfaceFactory embedded_factory(kArbitraryChildFrameSinkId, &manager_, |
| 304 &empty_client_); |
| 296 LocalFrameId embedded_local_frame_id = allocator_.GenerateId(); | 305 LocalFrameId embedded_local_frame_id = allocator_.GenerateId(); |
| 297 SurfaceId embedded_surface_id(factory_.frame_sink_id(), | 306 SurfaceId embedded_surface_id(embedded_factory.frame_sink_id(), |
| 298 embedded_local_frame_id); | 307 embedded_local_frame_id); |
| 299 factory_.Create(embedded_local_frame_id); | |
| 300 | 308 |
| 301 test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)}; | 309 test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)}; |
| 302 test::Pass embedded_passes[] = { | 310 test::Pass embedded_passes[] = { |
| 303 test::Pass(embedded_quads, arraysize(embedded_quads))}; | 311 test::Pass(embedded_quads, arraysize(embedded_quads))}; |
| 304 | 312 |
| 305 SubmitCompositorFrame(&factory_, embedded_passes, arraysize(embedded_passes), | 313 SubmitCompositorFrame(&embedded_factory, embedded_passes, |
| 306 embedded_local_frame_id); | 314 arraysize(embedded_passes), embedded_local_frame_id); |
| 307 std::unique_ptr<CopyOutputRequest> copy_request( | 315 std::unique_ptr<CopyOutputRequest> copy_request( |
| 308 CopyOutputRequest::CreateEmptyRequest()); | 316 CopyOutputRequest::CreateEmptyRequest()); |
| 309 CopyOutputRequest* copy_request_ptr = copy_request.get(); | 317 CopyOutputRequest* copy_request_ptr = copy_request.get(); |
| 310 factory_.RequestCopyOfSurface(embedded_local_frame_id, | 318 embedded_factory.RequestCopyOfSurface(std::move(copy_request)); |
| 311 std::move(copy_request)); | |
| 312 | 319 |
| 313 test::Quad root_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE), | 320 test::Quad root_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE), |
| 314 test::Quad::SurfaceQuad(embedded_surface_id, 1.f), | 321 test::Quad::SurfaceQuad(embedded_surface_id, 1.f), |
| 315 test::Quad::SolidColorQuad(SK_ColorBLACK)}; | 322 test::Quad::SolidColorQuad(SK_ColorBLACK)}; |
| 316 test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))}; | 323 test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))}; |
| 317 | 324 |
| 318 SubmitCompositorFrame(&factory_, root_passes, arraysize(root_passes), | 325 SubmitCompositorFrame(&factory_, root_passes, arraysize(root_passes), |
| 319 root_local_frame_id_); | 326 root_local_frame_id_); |
| 320 | 327 |
| 321 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id_); | 328 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id_); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 337 | 344 |
| 338 SurfaceId surface_ids[] = {root_surface_id, embedded_surface_id}; | 345 SurfaceId surface_ids[] = {root_surface_id, embedded_surface_id}; |
| 339 EXPECT_EQ(arraysize(surface_ids), | 346 EXPECT_EQ(arraysize(surface_ids), |
| 340 aggregator_.previous_contained_surfaces().size()); | 347 aggregator_.previous_contained_surfaces().size()); |
| 341 for (size_t i = 0; i < arraysize(surface_ids); i++) { | 348 for (size_t i = 0; i < arraysize(surface_ids); i++) { |
| 342 EXPECT_TRUE( | 349 EXPECT_TRUE( |
| 343 aggregator_.previous_contained_surfaces().find(surface_ids[i]) != | 350 aggregator_.previous_contained_surfaces().find(surface_ids[i]) != |
| 344 aggregator_.previous_contained_surfaces().end()); | 351 aggregator_.previous_contained_surfaces().end()); |
| 345 } | 352 } |
| 346 | 353 |
| 347 factory_.Destroy(embedded_local_frame_id); | 354 embedded_factory.EvictSurface(); |
| 348 } | 355 } |
| 349 | 356 |
| 350 // Root surface may contain copy requests. | 357 // Root surface may contain copy requests. |
| 351 TEST_F(SurfaceAggregatorValidSurfaceTest, RootCopyRequest) { | 358 TEST_F(SurfaceAggregatorValidSurfaceTest, RootCopyRequest) { |
| 359 SurfaceFactory embedded_factory(kArbitraryChildFrameSinkId, &manager_, |
| 360 &empty_client_); |
| 352 LocalFrameId embedded_local_frame_id = allocator_.GenerateId(); | 361 LocalFrameId embedded_local_frame_id = allocator_.GenerateId(); |
| 353 SurfaceId embedded_surface_id(factory_.frame_sink_id(), | 362 SurfaceId embedded_surface_id(embedded_factory.frame_sink_id(), |
| 354 embedded_local_frame_id); | 363 embedded_local_frame_id); |
| 355 factory_.Create(embedded_local_frame_id); | |
| 356 | 364 |
| 357 test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)}; | 365 test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)}; |
| 358 test::Pass embedded_passes[] = { | 366 test::Pass embedded_passes[] = { |
| 359 test::Pass(embedded_quads, arraysize(embedded_quads))}; | 367 test::Pass(embedded_quads, arraysize(embedded_quads))}; |
| 360 | 368 |
| 361 SubmitCompositorFrame(&factory_, embedded_passes, arraysize(embedded_passes), | 369 SubmitCompositorFrame(&embedded_factory, embedded_passes, |
| 362 embedded_local_frame_id); | 370 arraysize(embedded_passes), embedded_local_frame_id); |
| 363 std::unique_ptr<CopyOutputRequest> copy_request( | 371 std::unique_ptr<CopyOutputRequest> copy_request( |
| 364 CopyOutputRequest::CreateEmptyRequest()); | 372 CopyOutputRequest::CreateEmptyRequest()); |
| 365 CopyOutputRequest* copy_request_ptr = copy_request.get(); | 373 CopyOutputRequest* copy_request_ptr = copy_request.get(); |
| 366 std::unique_ptr<CopyOutputRequest> copy_request2( | 374 std::unique_ptr<CopyOutputRequest> copy_request2( |
| 367 CopyOutputRequest::CreateEmptyRequest()); | 375 CopyOutputRequest::CreateEmptyRequest()); |
| 368 CopyOutputRequest* copy_request2_ptr = copy_request2.get(); | 376 CopyOutputRequest* copy_request2_ptr = copy_request2.get(); |
| 369 | 377 |
| 370 test::Quad root_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE), | 378 test::Quad root_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE), |
| 371 test::Quad::SurfaceQuad(embedded_surface_id, 1.f), | 379 test::Quad::SurfaceQuad(embedded_surface_id, 1.f), |
| 372 test::Quad::SolidColorQuad(SK_ColorBLACK)}; | 380 test::Quad::SolidColorQuad(SK_ColorBLACK)}; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 } | 423 } |
| 416 | 424 |
| 417 // Ensure copy requests have been removed from root surface. | 425 // Ensure copy requests have been removed from root surface. |
| 418 const CompositorFrame& original_frame = | 426 const CompositorFrame& original_frame = |
| 419 manager_.GetSurfaceForId(root_surface_id)->GetEligibleFrame(); | 427 manager_.GetSurfaceForId(root_surface_id)->GetEligibleFrame(); |
| 420 const RenderPassList& original_pass_list = original_frame.render_pass_list; | 428 const RenderPassList& original_pass_list = original_frame.render_pass_list; |
| 421 ASSERT_EQ(2u, original_pass_list.size()); | 429 ASSERT_EQ(2u, original_pass_list.size()); |
| 422 DCHECK(original_pass_list[0]->copy_requests.empty()); | 430 DCHECK(original_pass_list[0]->copy_requests.empty()); |
| 423 DCHECK(original_pass_list[1]->copy_requests.empty()); | 431 DCHECK(original_pass_list[1]->copy_requests.empty()); |
| 424 | 432 |
| 425 factory_.Destroy(embedded_local_frame_id); | 433 embedded_factory.EvictSurface(); |
| 426 } | 434 } |
| 427 | 435 |
| 428 TEST_F(SurfaceAggregatorValidSurfaceTest, UnreferencedSurface) { | 436 TEST_F(SurfaceAggregatorValidSurfaceTest, UnreferencedSurface) { |
| 437 SurfaceFactory embedded_factory(kArbitraryChildFrameSinkId, &manager_, |
| 438 &empty_client_); |
| 439 SurfaceFactory parent_factory(kArbitraryRootFrameSinkId, &manager_, |
| 440 &empty_client_); |
| 429 LocalFrameId embedded_local_frame_id = allocator_.GenerateId(); | 441 LocalFrameId embedded_local_frame_id = allocator_.GenerateId(); |
| 430 SurfaceId embedded_surface_id(factory_.frame_sink_id(), | 442 SurfaceId embedded_surface_id(embedded_factory.frame_sink_id(), |
| 431 embedded_local_frame_id); | 443 embedded_local_frame_id); |
| 432 SurfaceId nonexistent_surface_id(factory_.frame_sink_id(), | 444 SurfaceId nonexistent_surface_id(factory_.frame_sink_id(), |
| 433 allocator_.GenerateId()); | 445 allocator_.GenerateId()); |
| 434 factory_.Create(embedded_local_frame_id); | |
| 435 | 446 |
| 436 test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)}; | 447 test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)}; |
| 437 test::Pass embedded_passes[] = { | 448 test::Pass embedded_passes[] = { |
| 438 test::Pass(embedded_quads, arraysize(embedded_quads))}; | 449 test::Pass(embedded_quads, arraysize(embedded_quads))}; |
| 439 | 450 |
| 440 SubmitCompositorFrame(&factory_, embedded_passes, arraysize(embedded_passes), | 451 SubmitCompositorFrame(&embedded_factory, embedded_passes, |
| 441 embedded_local_frame_id); | 452 arraysize(embedded_passes), embedded_local_frame_id); |
| 442 std::unique_ptr<CopyOutputRequest> copy_request( | 453 std::unique_ptr<CopyOutputRequest> copy_request( |
| 443 CopyOutputRequest::CreateEmptyRequest()); | 454 CopyOutputRequest::CreateEmptyRequest()); |
| 444 CopyOutputRequest* copy_request_ptr = copy_request.get(); | 455 CopyOutputRequest* copy_request_ptr = copy_request.get(); |
| 445 factory_.RequestCopyOfSurface(embedded_local_frame_id, | 456 embedded_factory.RequestCopyOfSurface(std::move(copy_request)); |
| 446 std::move(copy_request)); | |
| 447 | 457 |
| 448 LocalFrameId parent_local_frame_id = allocator_.GenerateId(); | 458 LocalFrameId parent_local_frame_id = allocator_.GenerateId(); |
| 449 SurfaceId parent_surface_id(factory_.frame_sink_id(), parent_local_frame_id); | 459 SurfaceId parent_surface_id(parent_factory.frame_sink_id(), |
| 450 factory_.Create(parent_local_frame_id); | 460 parent_local_frame_id); |
| 451 | 461 |
| 452 test::Quad parent_quads[] = { | 462 test::Quad parent_quads[] = { |
| 453 test::Quad::SolidColorQuad(SK_ColorWHITE), | 463 test::Quad::SolidColorQuad(SK_ColorWHITE), |
| 454 test::Quad::SurfaceQuad(embedded_surface_id, 1.f), | 464 test::Quad::SurfaceQuad(embedded_surface_id, 1.f), |
| 455 test::Quad::SolidColorQuad(SK_ColorBLACK)}; | 465 test::Quad::SolidColorQuad(SK_ColorBLACK)}; |
| 456 test::Pass parent_passes[] = { | 466 test::Pass parent_passes[] = { |
| 457 test::Pass(parent_quads, arraysize(parent_quads))}; | 467 test::Pass(parent_quads, arraysize(parent_quads))}; |
| 458 | 468 |
| 459 { | 469 { |
| 460 CompositorFrame frame; | 470 CompositorFrame frame; |
| 461 | 471 |
| 462 AddPasses(&frame.render_pass_list, gfx::Rect(SurfaceSize()), parent_passes, | 472 AddPasses(&frame.render_pass_list, gfx::Rect(SurfaceSize()), parent_passes, |
| 463 arraysize(parent_passes)); | 473 arraysize(parent_passes)); |
| 464 | 474 |
| 465 frame.metadata.referenced_surfaces.push_back(embedded_surface_id); | 475 frame.metadata.referenced_surfaces.push_back(embedded_surface_id); |
| 466 | 476 |
| 467 factory_.SubmitCompositorFrame(parent_local_frame_id, std::move(frame), | 477 parent_factory.SubmitCompositorFrame(parent_local_frame_id, |
| 468 SurfaceFactory::DrawCallback()); | 478 std::move(frame), |
| 479 SurfaceFactory::DrawCallback()); |
| 469 } | 480 } |
| 470 | 481 |
| 471 test::Quad root_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE), | 482 test::Quad root_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE), |
| 472 test::Quad::SolidColorQuad(SK_ColorBLACK)}; | 483 test::Quad::SolidColorQuad(SK_ColorBLACK)}; |
| 473 test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))}; | 484 test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))}; |
| 474 | 485 |
| 475 { | 486 { |
| 476 CompositorFrame frame; | 487 CompositorFrame frame; |
| 477 AddPasses(&frame.render_pass_list, gfx::Rect(SurfaceSize()), root_passes, | 488 AddPasses(&frame.render_pass_list, gfx::Rect(SurfaceSize()), root_passes, |
| 478 arraysize(root_passes)); | 489 arraysize(root_passes)); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 507 SurfaceId(factory_.frame_sink_id(), root_local_frame_id_), | 518 SurfaceId(factory_.frame_sink_id(), root_local_frame_id_), |
| 508 parent_surface_id, embedded_surface_id, nonexistent_surface_id}; | 519 parent_surface_id, embedded_surface_id, nonexistent_surface_id}; |
| 509 EXPECT_EQ(arraysize(surface_ids), | 520 EXPECT_EQ(arraysize(surface_ids), |
| 510 aggregator_.previous_contained_surfaces().size()); | 521 aggregator_.previous_contained_surfaces().size()); |
| 511 for (size_t i = 0; i < arraysize(surface_ids); i++) { | 522 for (size_t i = 0; i < arraysize(surface_ids); i++) { |
| 512 EXPECT_TRUE( | 523 EXPECT_TRUE( |
| 513 aggregator_.previous_contained_surfaces().find(surface_ids[i]) != | 524 aggregator_.previous_contained_surfaces().find(surface_ids[i]) != |
| 514 aggregator_.previous_contained_surfaces().end()); | 525 aggregator_.previous_contained_surfaces().end()); |
| 515 } | 526 } |
| 516 | 527 |
| 517 factory_.Destroy(parent_local_frame_id); | 528 embedded_factory.EvictSurface(); |
| 518 factory_.Destroy(embedded_local_frame_id); | 529 parent_factory.EvictSurface(); |
| 519 } | 530 } |
| 520 | 531 |
| 521 // This tests referencing a surface that has multiple render passes. | 532 // This tests referencing a surface that has multiple render passes. |
| 522 TEST_F(SurfaceAggregatorValidSurfaceTest, MultiPassSurfaceReference) { | 533 TEST_F(SurfaceAggregatorValidSurfaceTest, MultiPassSurfaceReference) { |
| 523 LocalFrameId embedded_local_frame_id = child_allocator_.GenerateId(); | 534 LocalFrameId embedded_local_frame_id = child_allocator_.GenerateId(); |
| 524 SurfaceId embedded_surface_id(child_factory_.frame_sink_id(), | 535 SurfaceId embedded_surface_id(child_factory_.frame_sink_id(), |
| 525 embedded_local_frame_id); | 536 embedded_local_frame_id); |
| 526 child_factory_.Create(embedded_local_frame_id); | |
| 527 | 537 |
| 528 RenderPassId pass_ids[] = {RenderPassId(1, 1), RenderPassId(1, 2), | 538 RenderPassId pass_ids[] = {RenderPassId(1, 1), RenderPassId(1, 2), |
| 529 RenderPassId(1, 3)}; | 539 RenderPassId(1, 3)}; |
| 530 | 540 |
| 531 test::Quad embedded_quads[][2] = { | 541 test::Quad embedded_quads[][2] = { |
| 532 {test::Quad::SolidColorQuad(1), test::Quad::SolidColorQuad(2)}, | 542 {test::Quad::SolidColorQuad(1), test::Quad::SolidColorQuad(2)}, |
| 533 {test::Quad::SolidColorQuad(3), test::Quad::RenderPassQuad(pass_ids[0])}, | 543 {test::Quad::SolidColorQuad(3), test::Quad::RenderPassQuad(pass_ids[0])}, |
| 534 {test::Quad::SolidColorQuad(4), test::Quad::RenderPassQuad(pass_ids[1])}}; | 544 {test::Quad::SolidColorQuad(4), test::Quad::RenderPassQuad(pass_ids[1])}}; |
| 535 test::Pass embedded_passes[] = { | 545 test::Pass embedded_passes[] = { |
| 536 test::Pass(embedded_quads[0], arraysize(embedded_quads[0]), pass_ids[0]), | 546 test::Pass(embedded_quads[0], arraysize(embedded_quads[0]), pass_ids[0]), |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 647 // The last quad in the last pass will reference the second pass from the | 657 // The last quad in the last pass will reference the second pass from the |
| 648 // root surface, which after aggregating is the fourth pass in the overall | 658 // root surface, which after aggregating is the fourth pass in the overall |
| 649 // list. | 659 // list. |
| 650 ASSERT_EQ(DrawQuad::RENDER_PASS, | 660 ASSERT_EQ(DrawQuad::RENDER_PASS, |
| 651 fifth_pass_quad_list.ElementAt(1)->material); | 661 fifth_pass_quad_list.ElementAt(1)->material); |
| 652 const RenderPassDrawQuad* fifth_pass_render_pass_draw_quad = | 662 const RenderPassDrawQuad* fifth_pass_render_pass_draw_quad = |
| 653 RenderPassDrawQuad::MaterialCast(fifth_pass_quad_list.ElementAt(1)); | 663 RenderPassDrawQuad::MaterialCast(fifth_pass_quad_list.ElementAt(1)); |
| 654 EXPECT_EQ(actual_pass_ids[3], | 664 EXPECT_EQ(actual_pass_ids[3], |
| 655 fifth_pass_render_pass_draw_quad->render_pass_id); | 665 fifth_pass_render_pass_draw_quad->render_pass_id); |
| 656 } | 666 } |
| 657 child_factory_.Destroy(embedded_local_frame_id); | |
| 658 } | 667 } |
| 659 | 668 |
| 660 // Tests an invalid surface reference in a frame. The surface quad should just | 669 // Tests an invalid surface reference in a frame. The surface quad should just |
| 661 // be dropped. | 670 // be dropped. |
| 662 TEST_F(SurfaceAggregatorValidSurfaceTest, InvalidSurfaceReference) { | 671 TEST_F(SurfaceAggregatorValidSurfaceTest, InvalidSurfaceReference) { |
| 663 test::Quad quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), | 672 test::Quad quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), |
| 664 test::Quad::SurfaceQuad(InvalidSurfaceId(), 1.f), | 673 test::Quad::SurfaceQuad(InvalidSurfaceId(), 1.f), |
| 665 test::Quad::SolidColorQuad(SK_ColorBLUE)}; | 674 test::Quad::SolidColorQuad(SK_ColorBLUE)}; |
| 666 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; | 675 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; |
| 667 | 676 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 678 AggregateAndVerify( | 687 AggregateAndVerify( |
| 679 expected_passes, arraysize(expected_passes), ids, arraysize(ids)); | 688 expected_passes, arraysize(expected_passes), ids, arraysize(ids)); |
| 680 } | 689 } |
| 681 | 690 |
| 682 // Tests a reference to a valid surface with no submitted frame. This quad | 691 // Tests a reference to a valid surface with no submitted frame. This quad |
| 683 // should also just be dropped. | 692 // should also just be dropped. |
| 684 TEST_F(SurfaceAggregatorValidSurfaceTest, ValidSurfaceReferenceWithNoFrame) { | 693 TEST_F(SurfaceAggregatorValidSurfaceTest, ValidSurfaceReferenceWithNoFrame) { |
| 685 LocalFrameId empty_local_frame_id = allocator_.GenerateId(); | 694 LocalFrameId empty_local_frame_id = allocator_.GenerateId(); |
| 686 SurfaceId surface_with_no_frame_id(factory_.frame_sink_id(), | 695 SurfaceId surface_with_no_frame_id(factory_.frame_sink_id(), |
| 687 empty_local_frame_id); | 696 empty_local_frame_id); |
| 688 factory_.Create(empty_local_frame_id); | |
| 689 | 697 |
| 690 test::Quad quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), | 698 test::Quad quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), |
| 691 test::Quad::SurfaceQuad(surface_with_no_frame_id, 1.f), | 699 test::Quad::SurfaceQuad(surface_with_no_frame_id, 1.f), |
| 692 test::Quad::SolidColorQuad(SK_ColorBLUE)}; | 700 test::Quad::SolidColorQuad(SK_ColorBLUE)}; |
| 693 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; | 701 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; |
| 694 | 702 |
| 695 SubmitCompositorFrame(&factory_, passes, arraysize(passes), | 703 SubmitCompositorFrame(&factory_, passes, arraysize(passes), |
| 696 root_local_frame_id_); | 704 root_local_frame_id_); |
| 697 | 705 |
| 698 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), | 706 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), |
| 699 test::Quad::SolidColorQuad(SK_ColorBLUE)}; | 707 test::Quad::SolidColorQuad(SK_ColorBLUE)}; |
| 700 test::Pass expected_passes[] = { | 708 test::Pass expected_passes[] = { |
| 701 test::Pass(expected_quads, arraysize(expected_quads))}; | 709 test::Pass(expected_quads, arraysize(expected_quads))}; |
| 702 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id_); | 710 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id_); |
| 703 SurfaceId ids[] = {root_surface_id, surface_with_no_frame_id}; | 711 SurfaceId ids[] = {root_surface_id, surface_with_no_frame_id}; |
| 704 AggregateAndVerify( | 712 AggregateAndVerify( |
| 705 expected_passes, arraysize(expected_passes), ids, arraysize(ids)); | 713 expected_passes, arraysize(expected_passes), ids, arraysize(ids)); |
| 706 factory_.Destroy(empty_local_frame_id); | |
| 707 } | 714 } |
| 708 | 715 |
| 709 // Tests a surface quad referencing itself, generating a trivial cycle. | 716 // Tests a surface quad referencing itself, generating a trivial cycle. |
| 710 // The quad creating the cycle should be dropped from the final frame. | 717 // The quad creating the cycle should be dropped from the final frame. |
| 711 TEST_F(SurfaceAggregatorValidSurfaceTest, SimpleCyclicalReference) { | 718 TEST_F(SurfaceAggregatorValidSurfaceTest, SimpleCyclicalReference) { |
| 712 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id_); | 719 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id_); |
| 713 test::Quad quads[] = {test::Quad::SurfaceQuad(root_surface_id, 1.f), | 720 test::Quad quads[] = {test::Quad::SurfaceQuad(root_surface_id, 1.f), |
| 714 test::Quad::SolidColorQuad(SK_ColorYELLOW)}; | 721 test::Quad::SolidColorQuad(SK_ColorYELLOW)}; |
| 715 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; | 722 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; |
| 716 | 723 |
| 717 SubmitCompositorFrame(&factory_, passes, arraysize(passes), | 724 SubmitCompositorFrame(&factory_, passes, arraysize(passes), |
| 718 root_local_frame_id_); | 725 root_local_frame_id_); |
| 719 | 726 |
| 720 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorYELLOW)}; | 727 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorYELLOW)}; |
| 721 test::Pass expected_passes[] = { | 728 test::Pass expected_passes[] = { |
| 722 test::Pass(expected_quads, arraysize(expected_quads))}; | 729 test::Pass(expected_quads, arraysize(expected_quads))}; |
| 723 SurfaceId ids[] = {root_surface_id}; | 730 SurfaceId ids[] = {root_surface_id}; |
| 724 AggregateAndVerify( | 731 AggregateAndVerify( |
| 725 expected_passes, arraysize(expected_passes), ids, arraysize(ids)); | 732 expected_passes, arraysize(expected_passes), ids, arraysize(ids)); |
| 726 } | 733 } |
| 727 | 734 |
| 728 // Tests a more complex cycle with one intermediate surface. | 735 // Tests a more complex cycle with one intermediate surface. |
| 729 TEST_F(SurfaceAggregatorValidSurfaceTest, TwoSurfaceCyclicalReference) { | 736 TEST_F(SurfaceAggregatorValidSurfaceTest, TwoSurfaceCyclicalReference) { |
| 730 LocalFrameId child_local_frame_id = allocator_.GenerateId(); | 737 LocalFrameId child_local_frame_id = allocator_.GenerateId(); |
| 731 SurfaceId child_surface_id(factory_.frame_sink_id(), child_local_frame_id); | 738 SurfaceId child_surface_id(child_factory_.frame_sink_id(), |
| 732 factory_.Create(child_local_frame_id); | 739 child_local_frame_id); |
| 733 | 740 |
| 734 test::Quad parent_quads[] = {test::Quad::SolidColorQuad(SK_ColorBLUE), | 741 test::Quad parent_quads[] = {test::Quad::SolidColorQuad(SK_ColorBLUE), |
| 735 test::Quad::SurfaceQuad(child_surface_id, 1.f), | 742 test::Quad::SurfaceQuad(child_surface_id, 1.f), |
| 736 test::Quad::SolidColorQuad(SK_ColorCYAN)}; | 743 test::Quad::SolidColorQuad(SK_ColorCYAN)}; |
| 737 test::Pass parent_passes[] = { | 744 test::Pass parent_passes[] = { |
| 738 test::Pass(parent_quads, arraysize(parent_quads))}; | 745 test::Pass(parent_quads, arraysize(parent_quads))}; |
| 739 | 746 |
| 740 SubmitCompositorFrame(&factory_, parent_passes, arraysize(parent_passes), | 747 SubmitCompositorFrame(&factory_, parent_passes, arraysize(parent_passes), |
| 741 root_local_frame_id_); | 748 root_local_frame_id_); |
| 742 | 749 |
| 743 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id_); | 750 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id_); |
| 744 test::Quad child_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), | 751 test::Quad child_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), |
| 745 test::Quad::SurfaceQuad(root_surface_id, 1.f), | 752 test::Quad::SurfaceQuad(root_surface_id, 1.f), |
| 746 test::Quad::SolidColorQuad(SK_ColorMAGENTA)}; | 753 test::Quad::SolidColorQuad(SK_ColorMAGENTA)}; |
| 747 test::Pass child_passes[] = {test::Pass(child_quads, arraysize(child_quads))}; | 754 test::Pass child_passes[] = {test::Pass(child_quads, arraysize(child_quads))}; |
| 748 | 755 |
| 749 SubmitCompositorFrame(&factory_, child_passes, arraysize(child_passes), | 756 SubmitCompositorFrame(&child_factory_, child_passes, arraysize(child_passes), |
| 750 child_local_frame_id); | 757 child_local_frame_id); |
| 751 | 758 |
| 752 // The child surface's reference to the root_surface_ will be dropped, so | 759 // The child surface's reference to the root_surface_ will be dropped, so |
| 753 // we'll end up with: | 760 // we'll end up with: |
| 754 // SK_ColorBLUE from the parent | 761 // SK_ColorBLUE from the parent |
| 755 // SK_ColorGREEN from the child | 762 // SK_ColorGREEN from the child |
| 756 // SK_ColorMAGENTA from the child | 763 // SK_ColorMAGENTA from the child |
| 757 // SK_ColorCYAN from the parent | 764 // SK_ColorCYAN from the parent |
| 758 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorBLUE), | 765 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorBLUE), |
| 759 test::Quad::SolidColorQuad(SK_ColorGREEN), | 766 test::Quad::SolidColorQuad(SK_ColorGREEN), |
| 760 test::Quad::SolidColorQuad(SK_ColorMAGENTA), | 767 test::Quad::SolidColorQuad(SK_ColorMAGENTA), |
| 761 test::Quad::SolidColorQuad(SK_ColorCYAN)}; | 768 test::Quad::SolidColorQuad(SK_ColorCYAN)}; |
| 762 test::Pass expected_passes[] = { | 769 test::Pass expected_passes[] = { |
| 763 test::Pass(expected_quads, arraysize(expected_quads))}; | 770 test::Pass(expected_quads, arraysize(expected_quads))}; |
| 764 SurfaceId ids[] = {root_surface_id, child_surface_id}; | 771 SurfaceId ids[] = {root_surface_id, child_surface_id}; |
| 765 AggregateAndVerify( | 772 AggregateAndVerify( |
| 766 expected_passes, arraysize(expected_passes), ids, arraysize(ids)); | 773 expected_passes, arraysize(expected_passes), ids, arraysize(ids)); |
| 767 factory_.Destroy(child_local_frame_id); | |
| 768 } | 774 } |
| 769 | 775 |
| 770 // Tests that we map render pass IDs from different surfaces into a unified | 776 // Tests that we map render pass IDs from different surfaces into a unified |
| 771 // namespace and update RenderPassDrawQuad's id references to match. | 777 // namespace and update RenderPassDrawQuad's id references to match. |
| 772 TEST_F(SurfaceAggregatorValidSurfaceTest, RenderPassIdMapping) { | 778 TEST_F(SurfaceAggregatorValidSurfaceTest, RenderPassIdMapping) { |
| 773 LocalFrameId child_local_frame_id = allocator_.GenerateId(); | 779 LocalFrameId child_local_frame_id = allocator_.GenerateId(); |
| 774 SurfaceId child_surface_id(factory_.frame_sink_id(), child_local_frame_id); | 780 SurfaceId child_surface_id(child_factory_.frame_sink_id(), |
| 775 factory_.Create(child_local_frame_id); | 781 child_local_frame_id); |
| 776 | 782 |
| 777 RenderPassId child_pass_id[] = {RenderPassId(1, 1), RenderPassId(1, 2)}; | 783 RenderPassId child_pass_id[] = {RenderPassId(1, 1), RenderPassId(1, 2)}; |
| 778 test::Quad child_quad[][1] = {{test::Quad::SolidColorQuad(SK_ColorGREEN)}, | 784 test::Quad child_quad[][1] = {{test::Quad::SolidColorQuad(SK_ColorGREEN)}, |
| 779 {test::Quad::RenderPassQuad(child_pass_id[0])}}; | 785 {test::Quad::RenderPassQuad(child_pass_id[0])}}; |
| 780 test::Pass surface_passes[] = { | 786 test::Pass surface_passes[] = { |
| 781 test::Pass(child_quad[0], arraysize(child_quad[0]), child_pass_id[0]), | 787 test::Pass(child_quad[0], arraysize(child_quad[0]), child_pass_id[0]), |
| 782 test::Pass(child_quad[1], arraysize(child_quad[1]), child_pass_id[1])}; | 788 test::Pass(child_quad[1], arraysize(child_quad[1]), child_pass_id[1])}; |
| 783 | 789 |
| 784 SubmitCompositorFrame(&factory_, surface_passes, arraysize(surface_passes), | 790 SubmitCompositorFrame(&child_factory_, surface_passes, |
| 785 child_local_frame_id); | 791 arraysize(surface_passes), child_local_frame_id); |
| 786 | 792 |
| 787 // Pass IDs from the parent surface may collide with ones from the child. | 793 // Pass IDs from the parent surface may collide with ones from the child. |
| 788 RenderPassId parent_pass_id[] = {RenderPassId(2, 1), RenderPassId(1, 2)}; | 794 RenderPassId parent_pass_id[] = {RenderPassId(2, 1), RenderPassId(1, 2)}; |
| 789 test::Quad parent_quad[][1] = { | 795 test::Quad parent_quad[][1] = { |
| 790 {test::Quad::SurfaceQuad(child_surface_id, 1.f)}, | 796 {test::Quad::SurfaceQuad(child_surface_id, 1.f)}, |
| 791 {test::Quad::RenderPassQuad(parent_pass_id[0])}}; | 797 {test::Quad::RenderPassQuad(parent_pass_id[0])}}; |
| 792 test::Pass parent_passes[] = { | 798 test::Pass parent_passes[] = { |
| 793 test::Pass(parent_quad[0], arraysize(parent_quad[0]), parent_pass_id[0]), | 799 test::Pass(parent_quad[0], arraysize(parent_quad[0]), parent_pass_id[0]), |
| 794 test::Pass(parent_quad[1], arraysize(parent_quad[1]), parent_pass_id[1])}; | 800 test::Pass(parent_quad[1], arraysize(parent_quad[1]), parent_pass_id[1])}; |
| 795 | 801 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 819 aggregated_pass_list[2]->quad_list.front()}; | 825 aggregated_pass_list[2]->quad_list.front()}; |
| 820 ASSERT_EQ(render_pass_quads[0]->material, DrawQuad::RENDER_PASS); | 826 ASSERT_EQ(render_pass_quads[0]->material, DrawQuad::RENDER_PASS); |
| 821 EXPECT_EQ( | 827 EXPECT_EQ( |
| 822 actual_pass_ids[0], | 828 actual_pass_ids[0], |
| 823 RenderPassDrawQuad::MaterialCast(render_pass_quads[0])->render_pass_id); | 829 RenderPassDrawQuad::MaterialCast(render_pass_quads[0])->render_pass_id); |
| 824 | 830 |
| 825 ASSERT_EQ(render_pass_quads[1]->material, DrawQuad::RENDER_PASS); | 831 ASSERT_EQ(render_pass_quads[1]->material, DrawQuad::RENDER_PASS); |
| 826 EXPECT_EQ( | 832 EXPECT_EQ( |
| 827 actual_pass_ids[1], | 833 actual_pass_ids[1], |
| 828 RenderPassDrawQuad::MaterialCast(render_pass_quads[1])->render_pass_id); | 834 RenderPassDrawQuad::MaterialCast(render_pass_quads[1])->render_pass_id); |
| 829 factory_.Destroy(child_local_frame_id); | |
| 830 } | 835 } |
| 831 | 836 |
| 832 void AddSolidColorQuadWithBlendMode(const gfx::Size& size, | 837 void AddSolidColorQuadWithBlendMode(const gfx::Size& size, |
| 833 RenderPass* pass, | 838 RenderPass* pass, |
| 834 const SkBlendMode blend_mode) { | 839 const SkBlendMode blend_mode) { |
| 835 const gfx::Transform layer_to_target_transform; | 840 const gfx::Transform layer_to_target_transform; |
| 836 const gfx::Size layer_bounds(size); | 841 const gfx::Size layer_bounds(size); |
| 837 const gfx::Rect visible_layer_rect(size); | 842 const gfx::Rect visible_layer_rect(size); |
| 838 const gfx::Rect clip_rect(size); | 843 const gfx::Rect clip_rect(size); |
| 839 | 844 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 883 const SkBlendMode blend_modes[] = { | 888 const SkBlendMode blend_modes[] = { |
| 884 SkBlendMode::kClear, // 0 | 889 SkBlendMode::kClear, // 0 |
| 885 SkBlendMode::kSrc, // 1 | 890 SkBlendMode::kSrc, // 1 |
| 886 SkBlendMode::kDst, // 2 | 891 SkBlendMode::kDst, // 2 |
| 887 SkBlendMode::kSrcOver, // 3 | 892 SkBlendMode::kSrcOver, // 3 |
| 888 SkBlendMode::kDstOver, // 4 | 893 SkBlendMode::kDstOver, // 4 |
| 889 SkBlendMode::kSrcIn, // 5 | 894 SkBlendMode::kSrcIn, // 5 |
| 890 SkBlendMode::kDstIn, // 6 | 895 SkBlendMode::kDstIn, // 6 |
| 891 }; | 896 }; |
| 892 | 897 |
| 898 SurfaceFactory grandchild_factory(FrameSinkId(2, 2), &manager_, |
| 899 &empty_client_); |
| 900 SurfaceFactory child_one_factory(FrameSinkId(3, 3), &manager_, |
| 901 &empty_client_); |
| 902 SurfaceFactory child_two_factory(FrameSinkId(4, 4), &manager_, |
| 903 &empty_client_); |
| 893 RenderPassId pass_id(1, 1); | 904 RenderPassId pass_id(1, 1); |
| 894 LocalFrameId grandchild_local_frame_id = allocator_.GenerateId(); | 905 LocalFrameId grandchild_local_frame_id = allocator_.GenerateId(); |
| 895 SurfaceId grandchild_surface_id(factory_.frame_sink_id(), | 906 SurfaceId grandchild_surface_id(grandchild_factory.frame_sink_id(), |
| 896 grandchild_local_frame_id); | 907 grandchild_local_frame_id); |
| 897 factory_.Create(grandchild_local_frame_id); | 908 grandchild_factory.SubmitCompositorFrame(grandchild_local_frame_id, |
| 909 CompositorFrame(), |
| 910 SurfaceFactory::DrawCallback()); |
| 898 std::unique_ptr<RenderPass> grandchild_pass = RenderPass::Create(); | 911 std::unique_ptr<RenderPass> grandchild_pass = RenderPass::Create(); |
| 899 gfx::Rect output_rect(SurfaceSize()); | 912 gfx::Rect output_rect(SurfaceSize()); |
| 900 gfx::Rect damage_rect(SurfaceSize()); | 913 gfx::Rect damage_rect(SurfaceSize()); |
| 901 gfx::Transform transform_to_root_target; | 914 gfx::Transform transform_to_root_target; |
| 902 grandchild_pass->SetNew( | 915 grandchild_pass->SetNew( |
| 903 pass_id, output_rect, damage_rect, transform_to_root_target); | 916 pass_id, output_rect, damage_rect, transform_to_root_target); |
| 904 AddSolidColorQuadWithBlendMode( | 917 AddSolidColorQuadWithBlendMode( |
| 905 SurfaceSize(), grandchild_pass.get(), blend_modes[2]); | 918 SurfaceSize(), grandchild_pass.get(), blend_modes[2]); |
| 906 QueuePassAsFrame(std::move(grandchild_pass), grandchild_local_frame_id); | 919 QueuePassAsFrame(std::move(grandchild_pass), grandchild_local_frame_id, |
| 920 &grandchild_factory); |
| 907 | 921 |
| 908 LocalFrameId child_one_local_frame_id = allocator_.GenerateId(); | 922 LocalFrameId child_one_local_frame_id = allocator_.GenerateId(); |
| 909 SurfaceId child_one_surface_id(factory_.frame_sink_id(), | 923 SurfaceId child_one_surface_id(child_one_factory.frame_sink_id(), |
| 910 child_one_local_frame_id); | 924 child_one_local_frame_id); |
| 911 factory_.Create(child_one_local_frame_id); | 925 child_one_factory.SubmitCompositorFrame(child_one_local_frame_id, |
| 926 CompositorFrame(), |
| 927 SurfaceFactory::DrawCallback()); |
| 912 | 928 |
| 913 std::unique_ptr<RenderPass> child_one_pass = RenderPass::Create(); | 929 std::unique_ptr<RenderPass> child_one_pass = RenderPass::Create(); |
| 914 child_one_pass->SetNew( | 930 child_one_pass->SetNew( |
| 915 pass_id, output_rect, damage_rect, transform_to_root_target); | 931 pass_id, output_rect, damage_rect, transform_to_root_target); |
| 916 AddSolidColorQuadWithBlendMode( | 932 AddSolidColorQuadWithBlendMode( |
| 917 SurfaceSize(), child_one_pass.get(), blend_modes[1]); | 933 SurfaceSize(), child_one_pass.get(), blend_modes[1]); |
| 918 SurfaceDrawQuad* grandchild_surface_quad = | 934 SurfaceDrawQuad* grandchild_surface_quad = |
| 919 child_one_pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); | 935 child_one_pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); |
| 920 grandchild_surface_quad->SetNew(child_one_pass->shared_quad_state_list.back(), | 936 grandchild_surface_quad->SetNew(child_one_pass->shared_quad_state_list.back(), |
| 921 gfx::Rect(SurfaceSize()), | 937 gfx::Rect(SurfaceSize()), |
| 922 gfx::Rect(SurfaceSize()), | 938 gfx::Rect(SurfaceSize()), |
| 923 grandchild_surface_id); | 939 grandchild_surface_id); |
| 924 AddSolidColorQuadWithBlendMode( | 940 AddSolidColorQuadWithBlendMode( |
| 925 SurfaceSize(), child_one_pass.get(), blend_modes[3]); | 941 SurfaceSize(), child_one_pass.get(), blend_modes[3]); |
| 926 QueuePassAsFrame(std::move(child_one_pass), child_one_local_frame_id); | 942 QueuePassAsFrame(std::move(child_one_pass), child_one_local_frame_id, |
| 943 &child_one_factory); |
| 927 | 944 |
| 928 LocalFrameId child_two_local_frame_id = allocator_.GenerateId(); | 945 LocalFrameId child_two_local_frame_id = allocator_.GenerateId(); |
| 929 SurfaceId child_two_surface_id(factory_.frame_sink_id(), | 946 SurfaceId child_two_surface_id(child_two_factory.frame_sink_id(), |
| 930 child_two_local_frame_id); | 947 child_two_local_frame_id); |
| 931 factory_.Create(child_two_local_frame_id); | 948 child_two_factory.SubmitCompositorFrame(child_two_local_frame_id, |
| 949 CompositorFrame(), |
| 950 SurfaceFactory::DrawCallback()); |
| 932 | 951 |
| 933 std::unique_ptr<RenderPass> child_two_pass = RenderPass::Create(); | 952 std::unique_ptr<RenderPass> child_two_pass = RenderPass::Create(); |
| 934 child_two_pass->SetNew( | 953 child_two_pass->SetNew( |
| 935 pass_id, output_rect, damage_rect, transform_to_root_target); | 954 pass_id, output_rect, damage_rect, transform_to_root_target); |
| 936 AddSolidColorQuadWithBlendMode( | 955 AddSolidColorQuadWithBlendMode( |
| 937 SurfaceSize(), child_two_pass.get(), blend_modes[5]); | 956 SurfaceSize(), child_two_pass.get(), blend_modes[5]); |
| 938 QueuePassAsFrame(std::move(child_two_pass), child_two_local_frame_id); | 957 QueuePassAsFrame(std::move(child_two_pass), child_two_local_frame_id, |
| 958 &child_two_factory); |
| 939 | 959 |
| 940 std::unique_ptr<RenderPass> root_pass = RenderPass::Create(); | 960 std::unique_ptr<RenderPass> root_pass = RenderPass::Create(); |
| 941 root_pass->SetNew( | 961 root_pass->SetNew( |
| 942 pass_id, output_rect, damage_rect, transform_to_root_target); | 962 pass_id, output_rect, damage_rect, transform_to_root_target); |
| 943 | 963 |
| 944 AddSolidColorQuadWithBlendMode( | 964 AddSolidColorQuadWithBlendMode( |
| 945 SurfaceSize(), root_pass.get(), blend_modes[0]); | 965 SurfaceSize(), root_pass.get(), blend_modes[0]); |
| 946 SurfaceDrawQuad* child_one_surface_quad = | 966 SurfaceDrawQuad* child_one_surface_quad = |
| 947 root_pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); | 967 root_pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); |
| 948 child_one_surface_quad->SetNew(root_pass->shared_quad_state_list.back(), | 968 child_one_surface_quad->SetNew(root_pass->shared_quad_state_list.back(), |
| 949 gfx::Rect(SurfaceSize()), | 969 gfx::Rect(SurfaceSize()), |
| 950 gfx::Rect(SurfaceSize()), | 970 gfx::Rect(SurfaceSize()), |
| 951 child_one_surface_id); | 971 child_one_surface_id); |
| 952 AddSolidColorQuadWithBlendMode( | 972 AddSolidColorQuadWithBlendMode( |
| 953 SurfaceSize(), root_pass.get(), blend_modes[4]); | 973 SurfaceSize(), root_pass.get(), blend_modes[4]); |
| 954 SurfaceDrawQuad* child_two_surface_quad = | 974 SurfaceDrawQuad* child_two_surface_quad = |
| 955 root_pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); | 975 root_pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); |
| 956 child_two_surface_quad->SetNew(root_pass->shared_quad_state_list.back(), | 976 child_two_surface_quad->SetNew(root_pass->shared_quad_state_list.back(), |
| 957 gfx::Rect(SurfaceSize()), | 977 gfx::Rect(SurfaceSize()), |
| 958 gfx::Rect(SurfaceSize()), | 978 gfx::Rect(SurfaceSize()), |
| 959 child_two_surface_id); | 979 child_two_surface_id); |
| 960 AddSolidColorQuadWithBlendMode( | 980 AddSolidColorQuadWithBlendMode( |
| 961 SurfaceSize(), root_pass.get(), blend_modes[6]); | 981 SurfaceSize(), root_pass.get(), blend_modes[6]); |
| 962 | 982 |
| 963 QueuePassAsFrame(std::move(root_pass), root_local_frame_id_); | 983 QueuePassAsFrame(std::move(root_pass), root_local_frame_id_, &factory_); |
| 964 | 984 |
| 965 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id_); | 985 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id_); |
| 966 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); | 986 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); |
| 967 | 987 |
| 968 const RenderPassList& aggregated_pass_list = | 988 const RenderPassList& aggregated_pass_list = |
| 969 aggregated_frame.render_pass_list; | 989 aggregated_frame.render_pass_list; |
| 970 | 990 |
| 971 ASSERT_EQ(1u, aggregated_pass_list.size()); | 991 ASSERT_EQ(1u, aggregated_pass_list.size()); |
| 972 | 992 |
| 973 const QuadList& aggregated_quad_list = aggregated_pass_list[0]->quad_list; | 993 const QuadList& aggregated_quad_list = aggregated_pass_list[0]->quad_list; |
| 974 | 994 |
| 975 ASSERT_EQ(7u, aggregated_quad_list.size()); | 995 ASSERT_EQ(7u, aggregated_quad_list.size()); |
| 976 | 996 |
| 977 for (auto iter = aggregated_quad_list.cbegin(); | 997 for (auto iter = aggregated_quad_list.cbegin(); |
| 978 iter != aggregated_quad_list.cend(); | 998 iter != aggregated_quad_list.cend(); |
| 979 ++iter) { | 999 ++iter) { |
| 980 EXPECT_EQ(blend_modes[iter.index()], iter->shared_quad_state->blend_mode) | 1000 EXPECT_EQ(blend_modes[iter.index()], iter->shared_quad_state->blend_mode) |
| 981 << iter.index(); | 1001 << iter.index(); |
| 982 } | 1002 } |
| 983 factory_.Destroy(child_one_local_frame_id); | 1003 |
| 984 factory_.Destroy(child_two_local_frame_id); | 1004 grandchild_factory.EvictSurface(); |
| 985 factory_.Destroy(grandchild_local_frame_id); | 1005 child_one_factory.EvictSurface(); |
| 1006 child_two_factory.EvictSurface(); |
| 986 } | 1007 } |
| 987 | 1008 |
| 988 // This tests that when aggregating a frame with multiple render passes that we | 1009 // This tests that when aggregating a frame with multiple render passes that we |
| 989 // map the transforms for the root pass but do not modify the transform on child | 1010 // map the transforms for the root pass but do not modify the transform on child |
| 990 // passes. | 1011 // passes. |
| 991 // | 1012 // |
| 992 // The root surface has one pass with a surface quad transformed by +10 in the y | 1013 // The root surface has one pass with a surface quad transformed by +10 in the y |
| 993 // direction. | 1014 // direction. |
| 994 // | 1015 // |
| 995 // The middle surface has one pass with a surface quad scaled by 2 in the x | 1016 // The middle surface has one pass with a surface quad scaled by 2 in the x |
| 996 // and 3 in the y directions. | 1017 // and 3 in the y directions. |
| 997 // | 1018 // |
| 998 // The child surface has two passes. The first pass has a quad with a transform | 1019 // The child surface has two passes. The first pass has a quad with a transform |
| 999 // of +5 in the x direction. The second pass has a reference to the first pass' | 1020 // of +5 in the x direction. The second pass has a reference to the first pass' |
| 1000 // pass id and a transform of +8 in the x direction. | 1021 // pass id and a transform of +8 in the x direction. |
| 1001 // | 1022 // |
| 1002 // After aggregation, the child surface's root pass quad should have all | 1023 // After aggregation, the child surface's root pass quad should have all |
| 1003 // transforms concatenated for a total transform of +23 x, +10 y. The | 1024 // transforms concatenated for a total transform of +23 x, +10 y. The |
| 1004 // contributing render pass' transform in the aggregate frame should not be | 1025 // contributing render pass' transform in the aggregate frame should not be |
| 1005 // affected. | 1026 // affected. |
| 1006 TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateMultiplePassWithTransform) { | 1027 TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateMultiplePassWithTransform) { |
| 1028 SurfaceFactory middle_factory(kArbitraryMiddleFrameSinkId, &manager_, |
| 1029 &empty_client_); |
| 1007 // Innermost child surface. | 1030 // Innermost child surface. |
| 1008 LocalFrameId child_local_frame_id = allocator_.GenerateId(); | 1031 LocalFrameId child_local_frame_id = allocator_.GenerateId(); |
| 1009 SurfaceId child_surface_id(factory_.frame_sink_id(), child_local_frame_id); | 1032 SurfaceId child_surface_id(child_factory_.frame_sink_id(), |
| 1010 factory_.Create(child_local_frame_id); | 1033 child_local_frame_id); |
| 1011 { | 1034 { |
| 1012 RenderPassId child_pass_id[] = {RenderPassId(1, 1), RenderPassId(1, 2)}; | 1035 RenderPassId child_pass_id[] = {RenderPassId(1, 1), RenderPassId(1, 2)}; |
| 1013 test::Quad child_quads[][1] = { | 1036 test::Quad child_quads[][1] = { |
| 1014 {test::Quad::SolidColorQuad(SK_ColorGREEN)}, | 1037 {test::Quad::SolidColorQuad(SK_ColorGREEN)}, |
| 1015 {test::Quad::RenderPassQuad(child_pass_id[0])}, | 1038 {test::Quad::RenderPassQuad(child_pass_id[0])}, |
| 1016 }; | 1039 }; |
| 1017 test::Pass child_passes[] = { | 1040 test::Pass child_passes[] = { |
| 1018 test::Pass(child_quads[0], arraysize(child_quads[0]), child_pass_id[0]), | 1041 test::Pass(child_quads[0], arraysize(child_quads[0]), child_pass_id[0]), |
| 1019 test::Pass(child_quads[1], arraysize(child_quads[1]), | 1042 test::Pass(child_quads[1], arraysize(child_quads[1]), |
| 1020 child_pass_id[1])}; | 1043 child_pass_id[1])}; |
| 1021 | 1044 |
| 1022 CompositorFrame child_frame; | 1045 CompositorFrame child_frame; |
| 1023 AddPasses(&child_frame.render_pass_list, gfx::Rect(SurfaceSize()), | 1046 AddPasses(&child_frame.render_pass_list, gfx::Rect(SurfaceSize()), |
| 1024 child_passes, arraysize(child_passes)); | 1047 child_passes, arraysize(child_passes)); |
| 1025 | 1048 |
| 1026 RenderPass* child_nonroot_pass = child_frame.render_pass_list[0].get(); | 1049 RenderPass* child_nonroot_pass = child_frame.render_pass_list[0].get(); |
| 1027 child_nonroot_pass->transform_to_root_target.Translate(8, 0); | 1050 child_nonroot_pass->transform_to_root_target.Translate(8, 0); |
| 1028 SharedQuadState* child_nonroot_pass_sqs = | 1051 SharedQuadState* child_nonroot_pass_sqs = |
| 1029 child_nonroot_pass->shared_quad_state_list.front(); | 1052 child_nonroot_pass->shared_quad_state_list.front(); |
| 1030 child_nonroot_pass_sqs->quad_to_target_transform.Translate(5, 0); | 1053 child_nonroot_pass_sqs->quad_to_target_transform.Translate(5, 0); |
| 1031 | 1054 |
| 1032 RenderPass* child_root_pass = child_frame.render_pass_list[1].get(); | 1055 RenderPass* child_root_pass = child_frame.render_pass_list[1].get(); |
| 1033 SharedQuadState* child_root_pass_sqs = | 1056 SharedQuadState* child_root_pass_sqs = |
| 1034 child_root_pass->shared_quad_state_list.front(); | 1057 child_root_pass->shared_quad_state_list.front(); |
| 1035 child_root_pass_sqs->quad_to_target_transform.Translate(8, 0); | 1058 child_root_pass_sqs->quad_to_target_transform.Translate(8, 0); |
| 1036 child_root_pass_sqs->is_clipped = true; | 1059 child_root_pass_sqs->is_clipped = true; |
| 1037 child_root_pass_sqs->clip_rect = gfx::Rect(0, 0, 5, 5); | 1060 child_root_pass_sqs->clip_rect = gfx::Rect(0, 0, 5, 5); |
| 1038 | 1061 |
| 1039 factory_.SubmitCompositorFrame(child_local_frame_id, std::move(child_frame), | 1062 child_factory_.SubmitCompositorFrame(child_local_frame_id, |
| 1040 SurfaceFactory::DrawCallback()); | 1063 std::move(child_frame), |
| 1064 SurfaceFactory::DrawCallback()); |
| 1041 } | 1065 } |
| 1042 | 1066 |
| 1043 // Middle child surface. | 1067 // Middle child surface. |
| 1044 LocalFrameId middle_local_frame_id = allocator_.GenerateId(); | 1068 LocalFrameId middle_local_frame_id = allocator_.GenerateId(); |
| 1045 SurfaceId middle_surface_id(factory_.frame_sink_id(), middle_local_frame_id); | 1069 SurfaceId middle_surface_id(middle_factory.frame_sink_id(), |
| 1046 factory_.Create(middle_local_frame_id); | 1070 middle_local_frame_id); |
| 1047 { | 1071 { |
| 1048 test::Quad middle_quads[] = { | 1072 test::Quad middle_quads[] = { |
| 1049 test::Quad::SurfaceQuad(child_surface_id, 1.f)}; | 1073 test::Quad::SurfaceQuad(child_surface_id, 1.f)}; |
| 1050 test::Pass middle_passes[] = { | 1074 test::Pass middle_passes[] = { |
| 1051 test::Pass(middle_quads, arraysize(middle_quads)), | 1075 test::Pass(middle_quads, arraysize(middle_quads)), |
| 1052 }; | 1076 }; |
| 1053 | 1077 |
| 1054 CompositorFrame middle_frame; | 1078 CompositorFrame middle_frame; |
| 1055 AddPasses(&middle_frame.render_pass_list, gfx::Rect(SurfaceSize()), | 1079 AddPasses(&middle_frame.render_pass_list, gfx::Rect(SurfaceSize()), |
| 1056 middle_passes, arraysize(middle_passes)); | 1080 middle_passes, arraysize(middle_passes)); |
| 1057 | 1081 |
| 1058 RenderPass* middle_root_pass = middle_frame.render_pass_list[0].get(); | 1082 RenderPass* middle_root_pass = middle_frame.render_pass_list[0].get(); |
| 1059 middle_root_pass->quad_list.ElementAt(0)->visible_rect = | 1083 middle_root_pass->quad_list.ElementAt(0)->visible_rect = |
| 1060 gfx::Rect(0, 1, 100, 7); | 1084 gfx::Rect(0, 1, 100, 7); |
| 1061 SharedQuadState* middle_root_pass_sqs = | 1085 SharedQuadState* middle_root_pass_sqs = |
| 1062 middle_root_pass->shared_quad_state_list.front(); | 1086 middle_root_pass->shared_quad_state_list.front(); |
| 1063 middle_root_pass_sqs->quad_to_target_transform.Scale(2, 3); | 1087 middle_root_pass_sqs->quad_to_target_transform.Scale(2, 3); |
| 1064 | 1088 |
| 1065 factory_.SubmitCompositorFrame(middle_local_frame_id, | 1089 middle_factory.SubmitCompositorFrame(middle_local_frame_id, |
| 1066 std::move(middle_frame), | 1090 std::move(middle_frame), |
| 1067 SurfaceFactory::DrawCallback()); | 1091 SurfaceFactory::DrawCallback()); |
| 1068 } | 1092 } |
| 1069 | 1093 |
| 1070 // Root surface. | 1094 // Root surface. |
| 1071 test::Quad secondary_quads[] = { | 1095 test::Quad secondary_quads[] = { |
| 1072 test::Quad::SolidColorQuad(1), | 1096 test::Quad::SolidColorQuad(1), |
| 1073 test::Quad::SurfaceQuad(middle_surface_id, 1.f)}; | 1097 test::Quad::SurfaceQuad(middle_surface_id, 1.f)}; |
| 1074 test::Quad root_quads[] = {test::Quad::SolidColorQuad(1)}; | 1098 test::Quad root_quads[] = {test::Quad::SolidColorQuad(1)}; |
| 1075 test::Pass root_passes[] = { | 1099 test::Pass root_passes[] = { |
| 1076 test::Pass(secondary_quads, arraysize(secondary_quads)), | 1100 test::Pass(secondary_quads, arraysize(secondary_quads)), |
| 1077 test::Pass(root_quads, arraysize(root_quads))}; | 1101 test::Pass(root_quads, arraysize(root_quads))}; |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1160 aggregated_pass_list[1]->shared_quad_state_list.ElementAt(1)->is_clipped); | 1184 aggregated_pass_list[1]->shared_quad_state_list.ElementAt(1)->is_clipped); |
| 1161 | 1185 |
| 1162 // The second quad in the root pass is aggregated from the child, so its | 1186 // The second quad in the root pass is aggregated from the child, so its |
| 1163 // clip rect must be transformed by the child's translation/scale and | 1187 // clip rect must be transformed by the child's translation/scale and |
| 1164 // clipped be the visible_rects for both children. | 1188 // clipped be the visible_rects for both children. |
| 1165 EXPECT_EQ(gfx::Rect(0, 13, 8, 12).ToString(), | 1189 EXPECT_EQ(gfx::Rect(0, 13, 8, 12).ToString(), |
| 1166 aggregated_pass_list[1] | 1190 aggregated_pass_list[1] |
| 1167 ->shared_quad_state_list.ElementAt(1) | 1191 ->shared_quad_state_list.ElementAt(1) |
| 1168 ->clip_rect.ToString()); | 1192 ->clip_rect.ToString()); |
| 1169 | 1193 |
| 1170 factory_.Destroy(middle_local_frame_id); | 1194 middle_factory.EvictSurface(); |
| 1171 factory_.Destroy(child_local_frame_id); | |
| 1172 } | 1195 } |
| 1173 | 1196 |
| 1174 // Tests that damage rects are aggregated correctly when surfaces change. | 1197 // Tests that damage rects are aggregated correctly when surfaces change. |
| 1175 TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateDamageRect) { | 1198 TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateDamageRect) { |
| 1199 SurfaceFactory parent_factory(kArbitraryMiddleFrameSinkId, &manager_, |
| 1200 &empty_client_); |
| 1176 test::Quad child_quads[] = {test::Quad::RenderPassQuad(RenderPassId(1, 1))}; | 1201 test::Quad child_quads[] = {test::Quad::RenderPassQuad(RenderPassId(1, 1))}; |
| 1177 test::Pass child_passes[] = { | 1202 test::Pass child_passes[] = { |
| 1178 test::Pass(child_quads, arraysize(child_quads), RenderPassId(1, 1))}; | 1203 test::Pass(child_quads, arraysize(child_quads), RenderPassId(1, 1))}; |
| 1179 | 1204 |
| 1180 CompositorFrame child_frame; | 1205 CompositorFrame child_frame; |
| 1181 AddPasses(&child_frame.render_pass_list, gfx::Rect(SurfaceSize()), | 1206 AddPasses(&child_frame.render_pass_list, gfx::Rect(SurfaceSize()), |
| 1182 child_passes, arraysize(child_passes)); | 1207 child_passes, arraysize(child_passes)); |
| 1183 | 1208 |
| 1184 RenderPass* child_root_pass = child_frame.render_pass_list[0].get(); | 1209 RenderPass* child_root_pass = child_frame.render_pass_list[0].get(); |
| 1185 SharedQuadState* child_root_pass_sqs = | 1210 SharedQuadState* child_root_pass_sqs = |
| 1186 child_root_pass->shared_quad_state_list.front(); | 1211 child_root_pass->shared_quad_state_list.front(); |
| 1187 child_root_pass_sqs->quad_to_target_transform.Translate(8, 0); | 1212 child_root_pass_sqs->quad_to_target_transform.Translate(8, 0); |
| 1188 | 1213 |
| 1189 LocalFrameId child_local_frame_id = allocator_.GenerateId(); | 1214 LocalFrameId child_local_frame_id = allocator_.GenerateId(); |
| 1190 SurfaceId child_surface_id(factory_.frame_sink_id(), child_local_frame_id); | 1215 SurfaceId child_surface_id(child_factory_.frame_sink_id(), |
| 1191 factory_.Create(child_local_frame_id); | 1216 child_local_frame_id); |
| 1192 factory_.SubmitCompositorFrame(child_local_frame_id, std::move(child_frame), | 1217 child_factory_.SubmitCompositorFrame(child_local_frame_id, |
| 1193 SurfaceFactory::DrawCallback()); | 1218 std::move(child_frame), |
| 1219 SurfaceFactory::DrawCallback()); |
| 1194 | 1220 |
| 1195 test::Quad parent_surface_quads[] = { | 1221 test::Quad parent_surface_quads[] = { |
| 1196 test::Quad::SurfaceQuad(child_surface_id, 1.f)}; | 1222 test::Quad::SurfaceQuad(child_surface_id, 1.f)}; |
| 1197 test::Pass parent_surface_passes[] = { | 1223 test::Pass parent_surface_passes[] = { |
| 1198 test::Pass(parent_surface_quads, arraysize(parent_surface_quads), | 1224 test::Pass(parent_surface_quads, arraysize(parent_surface_quads), |
| 1199 RenderPassId(1, 1))}; | 1225 RenderPassId(1, 1))}; |
| 1200 | 1226 |
| 1201 // Parent surface is only used to test if the transform is applied correctly | 1227 // Parent surface is only used to test if the transform is applied correctly |
| 1202 // to the child surface's damage. | 1228 // to the child surface's damage. |
| 1203 CompositorFrame parent_surface_frame; | 1229 CompositorFrame parent_surface_frame; |
| 1204 AddPasses(&parent_surface_frame.render_pass_list, gfx::Rect(SurfaceSize()), | 1230 AddPasses(&parent_surface_frame.render_pass_list, gfx::Rect(SurfaceSize()), |
| 1205 parent_surface_passes, arraysize(parent_surface_passes)); | 1231 parent_surface_passes, arraysize(parent_surface_passes)); |
| 1206 | 1232 |
| 1207 LocalFrameId parent_local_frame_id = allocator_.GenerateId(); | 1233 LocalFrameId parent_local_frame_id = allocator_.GenerateId(); |
| 1208 SurfaceId parent_surface_id(factory_.frame_sink_id(), parent_local_frame_id); | 1234 SurfaceId parent_surface_id(parent_factory.frame_sink_id(), |
| 1209 factory_.Create(parent_local_frame_id); | 1235 parent_local_frame_id); |
| 1210 factory_.SubmitCompositorFrame(parent_local_frame_id, | 1236 parent_factory.SubmitCompositorFrame(parent_local_frame_id, |
| 1211 std::move(parent_surface_frame), | 1237 std::move(parent_surface_frame), |
| 1212 SurfaceFactory::DrawCallback()); | 1238 SurfaceFactory::DrawCallback()); |
| 1213 | 1239 |
| 1214 test::Quad root_surface_quads[] = { | 1240 test::Quad root_surface_quads[] = { |
| 1215 test::Quad::SurfaceQuad(parent_surface_id, 1.f)}; | 1241 test::Quad::SurfaceQuad(parent_surface_id, 1.f)}; |
| 1216 test::Quad root_render_pass_quads[] = { | 1242 test::Quad root_render_pass_quads[] = { |
| 1217 test::Quad::RenderPassQuad(RenderPassId(1, 1))}; | 1243 test::Quad::RenderPassQuad(RenderPassId(1, 1))}; |
| 1218 | 1244 |
| 1219 test::Pass root_passes[] = { | 1245 test::Pass root_passes[] = { |
| 1220 test::Pass(root_surface_quads, arraysize(root_surface_quads), | 1246 test::Pass(root_surface_quads, arraysize(root_surface_quads), |
| 1221 RenderPassId(1, 1)), | 1247 RenderPassId(1, 1)), |
| 1222 test::Pass(root_render_pass_quads, arraysize(root_render_pass_quads), | 1248 test::Pass(root_render_pass_quads, arraysize(root_render_pass_quads), |
| (...skipping 28 matching lines...) Expand all Loading... |
| 1251 CompositorFrame child_frame; | 1277 CompositorFrame child_frame; |
| 1252 AddPasses(&child_frame.render_pass_list, gfx::Rect(SurfaceSize()), | 1278 AddPasses(&child_frame.render_pass_list, gfx::Rect(SurfaceSize()), |
| 1253 child_passes, arraysize(child_passes)); | 1279 child_passes, arraysize(child_passes)); |
| 1254 | 1280 |
| 1255 RenderPass* child_root_pass = child_frame.render_pass_list[0].get(); | 1281 RenderPass* child_root_pass = child_frame.render_pass_list[0].get(); |
| 1256 SharedQuadState* child_root_pass_sqs = | 1282 SharedQuadState* child_root_pass_sqs = |
| 1257 child_root_pass->shared_quad_state_list.front(); | 1283 child_root_pass->shared_quad_state_list.front(); |
| 1258 child_root_pass_sqs->quad_to_target_transform.Translate(8, 0); | 1284 child_root_pass_sqs->quad_to_target_transform.Translate(8, 0); |
| 1259 child_root_pass->damage_rect = gfx::Rect(10, 10, 10, 10); | 1285 child_root_pass->damage_rect = gfx::Rect(10, 10, 10, 10); |
| 1260 | 1286 |
| 1261 factory_.SubmitCompositorFrame(child_local_frame_id, std::move(child_frame), | 1287 child_factory_.SubmitCompositorFrame(child_local_frame_id, |
| 1262 SurfaceFactory::DrawCallback()); | 1288 std::move(child_frame), |
| 1289 SurfaceFactory::DrawCallback()); |
| 1263 | 1290 |
| 1264 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id_); | 1291 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id_); |
| 1265 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); | 1292 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); |
| 1266 | 1293 |
| 1267 const RenderPassList& aggregated_pass_list = | 1294 const RenderPassList& aggregated_pass_list = |
| 1268 aggregated_frame.render_pass_list; | 1295 aggregated_frame.render_pass_list; |
| 1269 | 1296 |
| 1270 ASSERT_EQ(2u, aggregated_pass_list.size()); | 1297 ASSERT_EQ(2u, aggregated_pass_list.size()); |
| 1271 | 1298 |
| 1272 // Outer surface didn't change, so transformed inner damage rect should be | 1299 // Outer surface didn't change, so transformed inner damage rect should be |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1337 | 1364 |
| 1338 const RenderPassList& aggregated_pass_list = | 1365 const RenderPassList& aggregated_pass_list = |
| 1339 aggregated_frame.render_pass_list; | 1366 aggregated_frame.render_pass_list; |
| 1340 | 1367 |
| 1341 ASSERT_EQ(2u, aggregated_pass_list.size()); | 1368 ASSERT_EQ(2u, aggregated_pass_list.size()); |
| 1342 | 1369 |
| 1343 EXPECT_TRUE(aggregated_pass_list[1]->damage_rect.Contains( | 1370 EXPECT_TRUE(aggregated_pass_list[1]->damage_rect.Contains( |
| 1344 gfx::Rect(SurfaceSize()))); | 1371 gfx::Rect(SurfaceSize()))); |
| 1345 } | 1372 } |
| 1346 | 1373 |
| 1347 factory_.Destroy(child_local_frame_id); | 1374 parent_factory.EvictSurface(); |
| 1348 } | 1375 } |
| 1349 | 1376 |
| 1350 // Check that damage is correctly calculated for surfaces with | 1377 // Check that damage is correctly calculated for surfaces. |
| 1351 // SetPreviousFrameSurface. | |
| 1352 TEST_F(SurfaceAggregatorValidSurfaceTest, SwitchSurfaceDamage) { | 1378 TEST_F(SurfaceAggregatorValidSurfaceTest, SwitchSurfaceDamage) { |
| 1353 test::Quad root_render_pass_quads[] = {test::Quad::SolidColorQuad(1)}; | 1379 test::Quad root_render_pass_quads[] = {test::Quad::SolidColorQuad(1)}; |
| 1354 | 1380 |
| 1355 test::Pass root_passes[] = {test::Pass(root_render_pass_quads, | 1381 test::Pass root_passes[] = {test::Pass(root_render_pass_quads, |
| 1356 arraysize(root_render_pass_quads), | 1382 arraysize(root_render_pass_quads), |
| 1357 RenderPassId(2, 1))}; | 1383 RenderPassId(2, 1))}; |
| 1358 | 1384 |
| 1359 CompositorFrame root_frame; | 1385 CompositorFrame root_frame; |
| 1360 AddPasses(&root_frame.render_pass_list, gfx::Rect(SurfaceSize()), root_passes, | 1386 AddPasses(&root_frame.render_pass_list, gfx::Rect(SurfaceSize()), root_passes, |
| 1361 arraysize(root_passes)); | 1387 arraysize(root_passes)); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1388 test::Pass root_passes[] = {test::Pass(root_render_pass_quads, | 1414 test::Pass root_passes[] = {test::Pass(root_render_pass_quads, |
| 1389 arraysize(root_render_pass_quads), | 1415 arraysize(root_render_pass_quads), |
| 1390 RenderPassId(2, 1))}; | 1416 RenderPassId(2, 1))}; |
| 1391 | 1417 |
| 1392 CompositorFrame root_frame; | 1418 CompositorFrame root_frame; |
| 1393 AddPasses(&root_frame.render_pass_list, gfx::Rect(SurfaceSize()), | 1419 AddPasses(&root_frame.render_pass_list, gfx::Rect(SurfaceSize()), |
| 1394 root_passes, arraysize(root_passes)); | 1420 root_passes, arraysize(root_passes)); |
| 1395 | 1421 |
| 1396 root_frame.render_pass_list[0]->damage_rect = gfx::Rect(1, 2, 3, 4); | 1422 root_frame.render_pass_list[0]->damage_rect = gfx::Rect(1, 2, 3, 4); |
| 1397 | 1423 |
| 1398 factory_.Create(second_root_local_frame_id); | |
| 1399 factory_.SubmitCompositorFrame(second_root_local_frame_id, | 1424 factory_.SubmitCompositorFrame(second_root_local_frame_id, |
| 1400 std::move(root_frame), | 1425 std::move(root_frame), |
| 1401 SurfaceFactory::DrawCallback()); | 1426 SurfaceFactory::DrawCallback()); |
| 1402 factory_.SetPreviousFrameSurface(second_root_local_frame_id, | |
| 1403 root_local_frame_id_); | |
| 1404 } | 1427 } |
| 1405 { | 1428 { |
| 1406 CompositorFrame aggregated_frame = | 1429 CompositorFrame aggregated_frame = |
| 1407 aggregator_.Aggregate(second_root_surface_id); | 1430 aggregator_.Aggregate(second_root_surface_id); |
| 1408 | 1431 |
| 1409 const RenderPassList& aggregated_pass_list = | 1432 const RenderPassList& aggregated_pass_list = |
| 1410 aggregated_frame.render_pass_list; | 1433 aggregated_frame.render_pass_list; |
| 1411 | 1434 |
| 1412 ASSERT_EQ(1u, aggregated_pass_list.size()); | 1435 ASSERT_EQ(1u, aggregated_pass_list.size()); |
| 1413 | 1436 |
| 1414 // Frame from SetPreviousFrameSurface was aggregated last, so damage rect | |
| 1415 // from new surface should be used. | |
| 1416 EXPECT_EQ(gfx::Rect(1, 2, 3, 4), aggregated_pass_list[0]->damage_rect); | 1437 EXPECT_EQ(gfx::Rect(1, 2, 3, 4), aggregated_pass_list[0]->damage_rect); |
| 1417 } | 1438 } |
| 1418 { | 1439 { |
| 1419 CompositorFrame aggregated_frame = | 1440 CompositorFrame aggregated_frame = |
| 1420 aggregator_.Aggregate(second_root_surface_id); | 1441 aggregator_.Aggregate(second_root_surface_id); |
| 1421 | 1442 |
| 1422 const RenderPassList& aggregated_pass_list = | 1443 const RenderPassList& aggregated_pass_list = |
| 1423 aggregated_frame.render_pass_list; | 1444 aggregated_frame.render_pass_list; |
| 1424 | 1445 |
| 1425 ASSERT_EQ(1u, aggregated_pass_list.size()); | 1446 ASSERT_EQ(1u, aggregated_pass_list.size()); |
| 1426 | 1447 |
| 1427 // No new frame, so no new damage. | 1448 // No new frame, so no new damage. |
| 1428 EXPECT_TRUE(aggregated_pass_list[0]->damage_rect.IsEmpty()); | 1449 EXPECT_TRUE(aggregated_pass_list[0]->damage_rect.IsEmpty()); |
| 1429 } | 1450 } |
| 1430 factory_.Destroy(second_root_local_frame_id); | |
| 1431 } | 1451 } |
| 1432 | 1452 |
| 1433 class SurfaceAggregatorPartialSwapTest | 1453 class SurfaceAggregatorPartialSwapTest |
| 1434 : public SurfaceAggregatorValidSurfaceTest { | 1454 : public SurfaceAggregatorValidSurfaceTest { |
| 1435 public: | 1455 public: |
| 1436 SurfaceAggregatorPartialSwapTest() | 1456 SurfaceAggregatorPartialSwapTest() |
| 1437 : SurfaceAggregatorValidSurfaceTest(true) {} | 1457 : SurfaceAggregatorValidSurfaceTest(true) {} |
| 1438 }; | 1458 }; |
| 1439 | 1459 |
| 1440 // Tests that quads outside the damage rect are ignored. | 1460 // Tests that quads outside the damage rect are ignored. |
| 1441 TEST_F(SurfaceAggregatorPartialSwapTest, IgnoreOutside) { | 1461 TEST_F(SurfaceAggregatorPartialSwapTest, IgnoreOutside) { |
| 1442 LocalFrameId child_local_frame_id = allocator_.GenerateId(); | 1462 LocalFrameId child_local_frame_id = allocator_.GenerateId(); |
| 1443 SurfaceId child_surface_id(factory_.frame_sink_id(), child_local_frame_id); | 1463 SurfaceId child_surface_id(child_factory_.frame_sink_id(), |
| 1444 factory_.Create(child_local_frame_id); | 1464 child_local_frame_id); |
| 1445 // The child surface has three quads, one with a visible rect of 13,13 4x4 and | 1465 // The child surface has three quads, one with a visible rect of 13,13 4x4 and |
| 1446 // the other other with a visible rect of 10,10 2x2 (relative to root target | 1466 // the other other with a visible rect of 10,10 2x2 (relative to root target |
| 1447 // space), and one with a non-invertible transform. | 1467 // space), and one with a non-invertible transform. |
| 1448 { | 1468 { |
| 1449 RenderPassId child_pass_id = RenderPassId(1, 1); | 1469 RenderPassId child_pass_id = RenderPassId(1, 1); |
| 1450 test::Quad child_quads1[] = {test::Quad::RenderPassQuad(child_pass_id)}; | 1470 test::Quad child_quads1[] = {test::Quad::RenderPassQuad(child_pass_id)}; |
| 1451 test::Quad child_quads2[] = {test::Quad::RenderPassQuad(child_pass_id)}; | 1471 test::Quad child_quads2[] = {test::Quad::RenderPassQuad(child_pass_id)}; |
| 1452 test::Quad child_quads3[] = {test::Quad::RenderPassQuad(child_pass_id)}; | 1472 test::Quad child_quads3[] = {test::Quad::RenderPassQuad(child_pass_id)}; |
| 1453 test::Pass child_passes[] = { | 1473 test::Pass child_passes[] = { |
| 1454 test::Pass(child_quads1, arraysize(child_quads1), child_pass_id), | 1474 test::Pass(child_quads1, arraysize(child_quads1), child_pass_id), |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1471 | 1491 |
| 1472 SharedQuadState* child_noninvertible_sqs = | 1492 SharedQuadState* child_noninvertible_sqs = |
| 1473 child_pass_list[2]->shared_quad_state_list.ElementAt(0u); | 1493 child_pass_list[2]->shared_quad_state_list.ElementAt(0u); |
| 1474 child_noninvertible_sqs->quad_to_target_transform.matrix().setDouble(0, 0, | 1494 child_noninvertible_sqs->quad_to_target_transform.matrix().setDouble(0, 0, |
| 1475 0.0); | 1495 0.0); |
| 1476 EXPECT_FALSE( | 1496 EXPECT_FALSE( |
| 1477 child_noninvertible_sqs->quad_to_target_transform.IsInvertible()); | 1497 child_noninvertible_sqs->quad_to_target_transform.IsInvertible()); |
| 1478 child_pass_list[2]->quad_list.ElementAt(0)->visible_rect = | 1498 child_pass_list[2]->quad_list.ElementAt(0)->visible_rect = |
| 1479 gfx::Rect(0, 0, 2, 2); | 1499 gfx::Rect(0, 0, 2, 2); |
| 1480 | 1500 |
| 1481 SubmitPassListAsFrame(&factory_, child_local_frame_id, &child_pass_list); | 1501 SubmitPassListAsFrame(&child_factory_, child_local_frame_id, |
| 1502 &child_pass_list); |
| 1482 } | 1503 } |
| 1483 | 1504 |
| 1484 { | 1505 { |
| 1485 test::Quad root_quads[] = {test::Quad::SurfaceQuad(child_surface_id, 1.f)}; | 1506 test::Quad root_quads[] = {test::Quad::SurfaceQuad(child_surface_id, 1.f)}; |
| 1486 | 1507 |
| 1487 test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))}; | 1508 test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))}; |
| 1488 | 1509 |
| 1489 RenderPassList root_pass_list; | 1510 RenderPassList root_pass_list; |
| 1490 AddPasses(&root_pass_list, gfx::Rect(SurfaceSize()), root_passes, | 1511 AddPasses(&root_pass_list, gfx::Rect(SurfaceSize()), root_passes, |
| 1491 arraysize(root_passes)); | 1512 arraysize(root_passes)); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1569 child_sqs->quad_to_target_transform.Scale(2, 2); | 1590 child_sqs->quad_to_target_transform.Scale(2, 2); |
| 1570 | 1591 |
| 1571 child_pass_list[1]->quad_list.ElementAt(0)->visible_rect = | 1592 child_pass_list[1]->quad_list.ElementAt(0)->visible_rect = |
| 1572 gfx::Rect(0, 0, 2, 2); | 1593 gfx::Rect(0, 0, 2, 2); |
| 1573 | 1594 |
| 1574 RenderPass* child_root_pass = child_pass_list[1].get(); | 1595 RenderPass* child_root_pass = child_pass_list[1].get(); |
| 1575 | 1596 |
| 1576 child_root_pass->copy_requests.push_back( | 1597 child_root_pass->copy_requests.push_back( |
| 1577 CopyOutputRequest::CreateEmptyRequest()); | 1598 CopyOutputRequest::CreateEmptyRequest()); |
| 1578 child_root_pass->damage_rect = gfx::Rect(); | 1599 child_root_pass->damage_rect = gfx::Rect(); |
| 1579 SubmitPassListAsFrame(&factory_, child_local_frame_id, &child_pass_list); | 1600 SubmitPassListAsFrame(&child_factory_, child_local_frame_id, |
| 1601 &child_pass_list); |
| 1580 } | 1602 } |
| 1581 | 1603 |
| 1582 { | 1604 { |
| 1583 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); | 1605 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); |
| 1584 | 1606 |
| 1585 const RenderPassList& aggregated_pass_list = | 1607 const RenderPassList& aggregated_pass_list = |
| 1586 aggregated_frame.render_pass_list; | 1608 aggregated_frame.render_pass_list; |
| 1587 | 1609 |
| 1588 // Output frame should have no damage, but all quads included. | 1610 // Output frame should have no damage, but all quads included. |
| 1589 ASSERT_EQ(3u, aggregated_pass_list.size()); | 1611 ASSERT_EQ(3u, aggregated_pass_list.size()); |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1696 EXPECT_EQ(0u, aggregated_pass_list[0]->quad_list.size()); | 1718 EXPECT_EQ(0u, aggregated_pass_list[0]->quad_list.size()); |
| 1697 EXPECT_EQ(gfx::Rect(SurfaceSize()), aggregated_pass_list[1]->damage_rect); | 1719 EXPECT_EQ(gfx::Rect(SurfaceSize()), aggregated_pass_list[1]->damage_rect); |
| 1698 EXPECT_EQ(1u, aggregated_pass_list[1]->quad_list.size()); | 1720 EXPECT_EQ(1u, aggregated_pass_list[1]->quad_list.size()); |
| 1699 | 1721 |
| 1700 // First render pass draw quad is outside damage rect, so shouldn't be | 1722 // First render pass draw quad is outside damage rect, so shouldn't be |
| 1701 // drawn. SurfaceDrawQuad is after background filter, so corresponding | 1723 // drawn. SurfaceDrawQuad is after background filter, so corresponding |
| 1702 // RenderPassDrawQuad should be drawn. | 1724 // RenderPassDrawQuad should be drawn. |
| 1703 EXPECT_EQ(gfx::Rect(10, 10, 2, 2), aggregated_pass_list[2]->damage_rect); | 1725 EXPECT_EQ(gfx::Rect(10, 10, 2, 2), aggregated_pass_list[2]->damage_rect); |
| 1704 EXPECT_EQ(1u, aggregated_pass_list[2]->quad_list.size()); | 1726 EXPECT_EQ(1u, aggregated_pass_list[2]->quad_list.size()); |
| 1705 } | 1727 } |
| 1706 | |
| 1707 factory_.Destroy(child_local_frame_id); | |
| 1708 } | 1728 } |
| 1709 | 1729 |
| 1710 class SurfaceAggregatorWithResourcesTest : public testing::Test { | 1730 class SurfaceAggregatorWithResourcesTest : public testing::Test { |
| 1711 public: | 1731 public: |
| 1712 void SetUp() override { | 1732 void SetUp() override { |
| 1713 shared_bitmap_manager_.reset(new TestSharedBitmapManager); | 1733 shared_bitmap_manager_.reset(new TestSharedBitmapManager); |
| 1714 resource_provider_ = | 1734 resource_provider_ = |
| 1715 FakeResourceProvider::Create(nullptr, shared_bitmap_manager_.get()); | 1735 FakeResourceProvider::Create(nullptr, shared_bitmap_manager_.get()); |
| 1716 | 1736 |
| 1717 aggregator_.reset( | 1737 aggregator_.reset( |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1789 uv_bottom_right, background_color, vertex_opacity, flipped, | 1809 uv_bottom_right, background_color, vertex_opacity, flipped, |
| 1790 nearest_neighbor, secure_output_only); | 1810 nearest_neighbor, secure_output_only); |
| 1791 } | 1811 } |
| 1792 frame.render_pass_list.push_back(std::move(pass)); | 1812 frame.render_pass_list.push_back(std::move(pass)); |
| 1793 factory->SubmitCompositorFrame(surface_id.local_frame_id(), std::move(frame), | 1813 factory->SubmitCompositorFrame(surface_id.local_frame_id(), std::move(frame), |
| 1794 SurfaceFactory::DrawCallback()); | 1814 SurfaceFactory::DrawCallback()); |
| 1795 } | 1815 } |
| 1796 | 1816 |
| 1797 TEST_F(SurfaceAggregatorWithResourcesTest, TakeResourcesOneSurface) { | 1817 TEST_F(SurfaceAggregatorWithResourcesTest, TakeResourcesOneSurface) { |
| 1798 ResourceTrackingSurfaceFactoryClient client; | 1818 ResourceTrackingSurfaceFactoryClient client; |
| 1799 SurfaceFactory factory(kArbitraryFrameSinkId, &manager_, &client); | 1819 SurfaceFactory factory(kArbitraryRootFrameSinkId, &manager_, &client); |
| 1800 LocalFrameId local_frame_id(7u, base::UnguessableToken::Create()); | 1820 LocalFrameId local_frame_id(7u, base::UnguessableToken::Create()); |
| 1801 SurfaceId surface_id(kArbitraryFrameSinkId, local_frame_id); | 1821 SurfaceId surface_id(factory.frame_sink_id(), local_frame_id); |
| 1802 factory.Create(local_frame_id); | |
| 1803 | 1822 |
| 1804 ResourceId ids[] = {11, 12, 13}; | 1823 ResourceId ids[] = {11, 12, 13}; |
| 1805 SubmitCompositorFrameWithResources(ids, arraysize(ids), true, SurfaceId(), | 1824 SubmitCompositorFrameWithResources(ids, arraysize(ids), true, SurfaceId(), |
| 1806 &factory, surface_id); | 1825 &factory, surface_id); |
| 1807 | 1826 |
| 1808 CompositorFrame frame = aggregator_->Aggregate(surface_id); | 1827 CompositorFrame frame = aggregator_->Aggregate(surface_id); |
| 1809 | 1828 |
| 1810 // Nothing should be available to be returned yet. | 1829 // Nothing should be available to be returned yet. |
| 1811 EXPECT_TRUE(client.returned_resources().empty()); | 1830 EXPECT_TRUE(client.returned_resources().empty()); |
| 1812 | 1831 |
| 1813 SubmitCompositorFrameWithResources(NULL, 0u, true, SurfaceId(), &factory, | 1832 SubmitCompositorFrameWithResources(NULL, 0u, true, SurfaceId(), &factory, |
| 1814 surface_id); | 1833 surface_id); |
| 1815 | 1834 |
| 1816 frame = aggregator_->Aggregate(surface_id); | 1835 frame = aggregator_->Aggregate(surface_id); |
| 1817 | 1836 |
| 1818 ASSERT_EQ(3u, client.returned_resources().size()); | 1837 ASSERT_EQ(3u, client.returned_resources().size()); |
| 1819 ResourceId returned_ids[3]; | 1838 ResourceId returned_ids[3]; |
| 1820 for (size_t i = 0; i < 3; ++i) { | 1839 for (size_t i = 0; i < 3; ++i) { |
| 1821 returned_ids[i] = client.returned_resources()[i].id; | 1840 returned_ids[i] = client.returned_resources()[i].id; |
| 1822 } | 1841 } |
| 1823 EXPECT_THAT(returned_ids, | 1842 EXPECT_THAT(returned_ids, |
| 1824 testing::WhenSorted(testing::ElementsAreArray(ids))); | 1843 testing::WhenSorted(testing::ElementsAreArray(ids))); |
| 1825 factory.Destroy(local_frame_id); | 1844 |
| 1845 factory.EvictSurface(); |
| 1826 } | 1846 } |
| 1827 | 1847 |
| 1828 TEST_F(SurfaceAggregatorWithResourcesTest, TakeInvalidResources) { | 1848 TEST_F(SurfaceAggregatorWithResourcesTest, TakeInvalidResources) { |
| 1829 ResourceTrackingSurfaceFactoryClient client; | 1849 ResourceTrackingSurfaceFactoryClient client; |
| 1830 SurfaceFactory factory(kArbitraryFrameSinkId, &manager_, &client); | 1850 SurfaceFactory factory(kArbitraryRootFrameSinkId, &manager_, &client); |
| 1831 LocalFrameId local_frame_id(7u, base::UnguessableToken::Create()); | 1851 LocalFrameId local_frame_id(7u, base::UnguessableToken::Create()); |
| 1832 SurfaceId surface_id(kArbitraryFrameSinkId, local_frame_id); | 1852 SurfaceId surface_id(factory.frame_sink_id(), local_frame_id); |
| 1833 factory.Create(local_frame_id); | |
| 1834 | 1853 |
| 1835 CompositorFrame frame; | 1854 CompositorFrame frame; |
| 1836 std::unique_ptr<RenderPass> pass = RenderPass::Create(); | 1855 std::unique_ptr<RenderPass> pass = RenderPass::Create(); |
| 1837 pass->id = RenderPassId(1, 1); | 1856 pass->id = RenderPassId(1, 1); |
| 1838 TransferableResource resource; | 1857 TransferableResource resource; |
| 1839 resource.id = 11; | 1858 resource.id = 11; |
| 1840 // ResourceProvider is software but resource is not, so it should be | 1859 // ResourceProvider is software but resource is not, so it should be |
| 1841 // ignored. | 1860 // ignored. |
| 1842 resource.is_software = false; | 1861 resource.is_software = false; |
| 1843 frame.resource_list.push_back(resource); | 1862 frame.resource_list.push_back(resource); |
| 1844 frame.render_pass_list.push_back(std::move(pass)); | 1863 frame.render_pass_list.push_back(std::move(pass)); |
| 1845 factory.SubmitCompositorFrame(local_frame_id, std::move(frame), | 1864 factory.SubmitCompositorFrame(local_frame_id, std::move(frame), |
| 1846 SurfaceFactory::DrawCallback()); | 1865 SurfaceFactory::DrawCallback()); |
| 1847 | 1866 |
| 1848 CompositorFrame returned_frame = aggregator_->Aggregate(surface_id); | 1867 CompositorFrame returned_frame = aggregator_->Aggregate(surface_id); |
| 1849 | 1868 |
| 1850 // Nothing should be available to be returned yet. | 1869 // Nothing should be available to be returned yet. |
| 1851 EXPECT_TRUE(client.returned_resources().empty()); | 1870 EXPECT_TRUE(client.returned_resources().empty()); |
| 1852 | 1871 |
| 1853 SubmitCompositorFrameWithResources(NULL, 0, true, SurfaceId(), &factory, | 1872 SubmitCompositorFrameWithResources(NULL, 0, true, SurfaceId(), &factory, |
| 1854 surface_id); | 1873 surface_id); |
| 1855 ASSERT_EQ(1u, client.returned_resources().size()); | 1874 ASSERT_EQ(1u, client.returned_resources().size()); |
| 1856 EXPECT_EQ(11u, client.returned_resources()[0].id); | 1875 EXPECT_EQ(11u, client.returned_resources()[0].id); |
| 1857 | 1876 |
| 1858 factory.Destroy(local_frame_id); | 1877 factory.EvictSurface(); |
| 1859 } | 1878 } |
| 1860 | 1879 |
| 1861 TEST_F(SurfaceAggregatorWithResourcesTest, TwoSurfaces) { | 1880 TEST_F(SurfaceAggregatorWithResourcesTest, TwoSurfaces) { |
| 1862 ResourceTrackingSurfaceFactoryClient client; | 1881 ResourceTrackingSurfaceFactoryClient client; |
| 1863 SurfaceFactory factory(kArbitraryFrameSinkId, &manager_, &client); | 1882 SurfaceFactory factory1(FrameSinkId(1, 1), &manager_, &client); |
| 1883 SurfaceFactory factory2(FrameSinkId(2, 2), &manager_, &client); |
| 1864 LocalFrameId local_frame1_id(7u, base::UnguessableToken::Create()); | 1884 LocalFrameId local_frame1_id(7u, base::UnguessableToken::Create()); |
| 1865 SurfaceId surface1_id(kArbitraryFrameSinkId, local_frame1_id); | 1885 SurfaceId surface1_id(factory1.frame_sink_id(), local_frame1_id); |
| 1866 factory.Create(local_frame1_id); | |
| 1867 | 1886 |
| 1868 LocalFrameId local_frame2_id(8u, base::UnguessableToken::Create()); | 1887 LocalFrameId local_frame2_id(8u, base::UnguessableToken::Create()); |
| 1869 SurfaceId surface2_id(kArbitraryFrameSinkId, local_frame2_id); | 1888 SurfaceId surface2_id(factory2.frame_sink_id(), local_frame2_id); |
| 1870 factory.Create(local_frame2_id); | |
| 1871 | 1889 |
| 1872 ResourceId ids[] = {11, 12, 13}; | 1890 ResourceId ids[] = {11, 12, 13}; |
| 1873 SubmitCompositorFrameWithResources(ids, arraysize(ids), true, SurfaceId(), | 1891 SubmitCompositorFrameWithResources(ids, arraysize(ids), true, SurfaceId(), |
| 1874 &factory, surface1_id); | 1892 &factory1, surface1_id); |
| 1875 ResourceId ids2[] = {14, 15, 16}; | 1893 ResourceId ids2[] = {14, 15, 16}; |
| 1876 SubmitCompositorFrameWithResources(ids2, arraysize(ids2), true, SurfaceId(), | 1894 SubmitCompositorFrameWithResources(ids2, arraysize(ids2), true, SurfaceId(), |
| 1877 &factory, surface2_id); | 1895 &factory2, surface2_id); |
| 1878 | 1896 |
| 1879 CompositorFrame frame = aggregator_->Aggregate(surface1_id); | 1897 CompositorFrame frame = aggregator_->Aggregate(surface1_id); |
| 1880 | 1898 |
| 1881 SubmitCompositorFrameWithResources(NULL, 0, true, SurfaceId(), &factory, | 1899 SubmitCompositorFrameWithResources(NULL, 0, true, SurfaceId(), &factory1, |
| 1882 surface1_id); | 1900 surface1_id); |
| 1883 | 1901 |
| 1884 // Nothing should be available to be returned yet. | 1902 // Nothing should be available to be returned yet. |
| 1885 EXPECT_TRUE(client.returned_resources().empty()); | 1903 EXPECT_TRUE(client.returned_resources().empty()); |
| 1886 | 1904 |
| 1887 frame = aggregator_->Aggregate(surface2_id); | 1905 frame = aggregator_->Aggregate(surface2_id); |
| 1888 | 1906 |
| 1889 // surface1_id wasn't referenced, so its resources should be returned. | 1907 // surface1_id wasn't referenced, so its resources should be returned. |
| 1890 ASSERT_EQ(3u, client.returned_resources().size()); | 1908 ASSERT_EQ(3u, client.returned_resources().size()); |
| 1891 ResourceId returned_ids[3]; | 1909 ResourceId returned_ids[3]; |
| 1892 for (size_t i = 0; i < 3; ++i) { | 1910 for (size_t i = 0; i < 3; ++i) { |
| 1893 returned_ids[i] = client.returned_resources()[i].id; | 1911 returned_ids[i] = client.returned_resources()[i].id; |
| 1894 } | 1912 } |
| 1895 EXPECT_THAT(returned_ids, | 1913 EXPECT_THAT(returned_ids, |
| 1896 testing::WhenSorted(testing::ElementsAreArray(ids))); | 1914 testing::WhenSorted(testing::ElementsAreArray(ids))); |
| 1897 EXPECT_EQ(3u, resource_provider_->num_resources()); | 1915 EXPECT_EQ(3u, resource_provider_->num_resources()); |
| 1898 factory.Destroy(local_frame1_id); | 1916 |
| 1899 factory.Destroy(local_frame2_id); | 1917 factory1.EvictSurface(); |
| 1918 factory2.EvictSurface(); |
| 1900 } | 1919 } |
| 1901 | 1920 |
| 1902 // Ensure that aggregator completely ignores Surfaces that reference invalid | 1921 // Ensure that aggregator completely ignores Surfaces that reference invalid |
| 1903 // resources. | 1922 // resources. |
| 1904 TEST_F(SurfaceAggregatorWithResourcesTest, InvalidChildSurface) { | 1923 TEST_F(SurfaceAggregatorWithResourcesTest, InvalidChildSurface) { |
| 1905 ResourceTrackingSurfaceFactoryClient client; | 1924 ResourceTrackingSurfaceFactoryClient client; |
| 1906 SurfaceFactory factory(kArbitraryFrameSinkId, &manager_, &client); | 1925 SurfaceFactory root_factory(kArbitraryRootFrameSinkId, &manager_, &client); |
| 1926 SurfaceFactory middle_factory(kArbitraryMiddleFrameSinkId, &manager_, |
| 1927 &client); |
| 1928 SurfaceFactory child_factory(kArbitraryChildFrameSinkId, &manager_, &client); |
| 1907 LocalFrameId root_local_frame_id(7u, kArbitraryToken); | 1929 LocalFrameId root_local_frame_id(7u, kArbitraryToken); |
| 1908 SurfaceId root_surface_id(kArbitraryFrameSinkId, root_local_frame_id); | 1930 SurfaceId root_surface_id(root_factory.frame_sink_id(), root_local_frame_id); |
| 1909 factory.Create(root_local_frame_id); | |
| 1910 LocalFrameId middle_local_frame_id(8u, kArbitraryToken); | 1931 LocalFrameId middle_local_frame_id(8u, kArbitraryToken); |
| 1911 SurfaceId middle_surface_id(kArbitraryFrameSinkId, middle_local_frame_id); | 1932 SurfaceId middle_surface_id(middle_factory.frame_sink_id(), |
| 1912 factory.Create(middle_local_frame_id); | 1933 middle_local_frame_id); |
| 1913 LocalFrameId child_local_frame_id(9u, kArbitraryToken); | 1934 LocalFrameId child_local_frame_id(9u, kArbitraryToken); |
| 1914 SurfaceId child_surface_id(kArbitraryFrameSinkId, child_local_frame_id); | 1935 SurfaceId child_surface_id(child_factory.frame_sink_id(), |
| 1915 factory.Create(child_local_frame_id); | 1936 child_local_frame_id); |
| 1916 | 1937 |
| 1917 ResourceId ids[] = {14, 15, 16}; | 1938 ResourceId ids[] = {14, 15, 16}; |
| 1918 SubmitCompositorFrameWithResources(ids, arraysize(ids), true, SurfaceId(), | 1939 SubmitCompositorFrameWithResources(ids, arraysize(ids), true, SurfaceId(), |
| 1919 &factory, child_surface_id); | 1940 &child_factory, child_surface_id); |
| 1920 | 1941 |
| 1921 ResourceId ids2[] = {17, 18, 19}; | 1942 ResourceId ids2[] = {17, 18, 19}; |
| 1922 SubmitCompositorFrameWithResources(ids2, arraysize(ids2), false, | 1943 SubmitCompositorFrameWithResources(ids2, arraysize(ids2), false, |
| 1923 child_surface_id, &factory, | 1944 child_surface_id, &middle_factory, |
| 1924 middle_surface_id); | 1945 middle_surface_id); |
| 1925 | 1946 |
| 1926 ResourceId ids3[] = {20, 21, 22}; | 1947 ResourceId ids3[] = {20, 21, 22}; |
| 1927 SubmitCompositorFrameWithResources(ids3, arraysize(ids3), true, | 1948 SubmitCompositorFrameWithResources(ids3, arraysize(ids3), true, |
| 1928 middle_surface_id, &factory, | 1949 middle_surface_id, &root_factory, |
| 1929 root_surface_id); | 1950 root_surface_id); |
| 1930 | 1951 |
| 1931 CompositorFrame frame; | 1952 CompositorFrame frame; |
| 1932 frame = aggregator_->Aggregate(root_surface_id); | 1953 frame = aggregator_->Aggregate(root_surface_id); |
| 1933 | 1954 |
| 1934 RenderPassList* pass_list = &frame.render_pass_list; | 1955 RenderPassList* pass_list = &frame.render_pass_list; |
| 1935 ASSERT_EQ(1u, pass_list->size()); | 1956 ASSERT_EQ(1u, pass_list->size()); |
| 1936 EXPECT_EQ(1u, pass_list->back()->shared_quad_state_list.size()); | 1957 EXPECT_EQ(1u, pass_list->back()->shared_quad_state_list.size()); |
| 1937 EXPECT_EQ(3u, pass_list->back()->quad_list.size()); | 1958 EXPECT_EQ(3u, pass_list->back()->quad_list.size()); |
| 1938 SubmitCompositorFrameWithResources(ids2, arraysize(ids), true, | 1959 SubmitCompositorFrameWithResources(ids2, arraysize(ids), true, |
| 1939 child_surface_id, &factory, | 1960 child_surface_id, &middle_factory, |
| 1940 middle_surface_id); | 1961 middle_surface_id); |
| 1941 | 1962 |
| 1942 frame = aggregator_->Aggregate(root_surface_id); | 1963 frame = aggregator_->Aggregate(root_surface_id); |
| 1943 | 1964 |
| 1944 pass_list = &frame.render_pass_list; | 1965 pass_list = &frame.render_pass_list; |
| 1945 ASSERT_EQ(1u, pass_list->size()); | 1966 ASSERT_EQ(1u, pass_list->size()); |
| 1946 EXPECT_EQ(3u, pass_list->back()->shared_quad_state_list.size()); | 1967 EXPECT_EQ(3u, pass_list->back()->shared_quad_state_list.size()); |
| 1947 EXPECT_EQ(9u, pass_list->back()->quad_list.size()); | 1968 EXPECT_EQ(9u, pass_list->back()->quad_list.size()); |
| 1948 | 1969 |
| 1949 factory.Destroy(root_local_frame_id); | 1970 root_factory.EvictSurface(); |
| 1950 factory.Destroy(child_local_frame_id); | 1971 middle_factory.EvictSurface(); |
| 1951 factory.Destroy(middle_local_frame_id); | 1972 child_factory.EvictSurface(); |
| 1952 } | 1973 } |
| 1953 | 1974 |
| 1954 TEST_F(SurfaceAggregatorWithResourcesTest, SecureOutputTexture) { | 1975 TEST_F(SurfaceAggregatorWithResourcesTest, SecureOutputTexture) { |
| 1955 ResourceTrackingSurfaceFactoryClient client; | 1976 ResourceTrackingSurfaceFactoryClient client; |
| 1956 SurfaceFactory factory(kArbitraryFrameSinkId, &manager_, &client); | 1977 SurfaceFactory factory1(FrameSinkId(1, 1), &manager_, &client); |
| 1978 SurfaceFactory factory2(FrameSinkId(2, 2), &manager_, &client); |
| 1957 LocalFrameId local_frame1_id(7u, base::UnguessableToken::Create()); | 1979 LocalFrameId local_frame1_id(7u, base::UnguessableToken::Create()); |
| 1958 SurfaceId surface1_id(kArbitraryFrameSinkId, local_frame1_id); | 1980 SurfaceId surface1_id(factory1.frame_sink_id(), local_frame1_id); |
| 1959 factory.Create(local_frame1_id); | |
| 1960 | 1981 |
| 1961 LocalFrameId local_frame2_id(8u, base::UnguessableToken::Create()); | 1982 LocalFrameId local_frame2_id(8u, base::UnguessableToken::Create()); |
| 1962 SurfaceId surface2_id(kArbitraryFrameSinkId, local_frame2_id); | 1983 SurfaceId surface2_id(factory2.frame_sink_id(), local_frame2_id); |
| 1963 factory.Create(local_frame2_id); | |
| 1964 | 1984 |
| 1965 ResourceId ids[] = {11, 12, 13}; | 1985 ResourceId ids[] = {11, 12, 13}; |
| 1966 SubmitCompositorFrameWithResources(ids, arraysize(ids), true, SurfaceId(), | 1986 SubmitCompositorFrameWithResources(ids, arraysize(ids), true, SurfaceId(), |
| 1967 &factory, surface1_id); | 1987 &factory1, surface1_id); |
| 1968 | 1988 |
| 1969 CompositorFrame frame = aggregator_->Aggregate(surface1_id); | 1989 CompositorFrame frame = aggregator_->Aggregate(surface1_id); |
| 1970 | 1990 |
| 1971 RenderPass* render_pass = frame.render_pass_list.back().get(); | 1991 RenderPass* render_pass = frame.render_pass_list.back().get(); |
| 1972 | 1992 |
| 1973 EXPECT_EQ(DrawQuad::TEXTURE_CONTENT, render_pass->quad_list.back()->material); | 1993 EXPECT_EQ(DrawQuad::TEXTURE_CONTENT, render_pass->quad_list.back()->material); |
| 1974 | 1994 |
| 1975 { | 1995 { |
| 1976 std::unique_ptr<RenderPass> pass = RenderPass::Create(); | 1996 std::unique_ptr<RenderPass> pass = RenderPass::Create(); |
| 1977 pass->id = RenderPassId(1, 1); | 1997 pass->id = RenderPassId(1, 1); |
| 1978 SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState(); | 1998 SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState(); |
| 1979 sqs->opacity = 1.f; | 1999 sqs->opacity = 1.f; |
| 1980 SurfaceDrawQuad* surface_quad = | 2000 SurfaceDrawQuad* surface_quad = |
| 1981 pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); | 2001 pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); |
| 2002 |
| 1982 surface_quad->SetNew(sqs, gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1), | 2003 surface_quad->SetNew(sqs, gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1), |
| 1983 surface1_id); | 2004 surface1_id); |
| 1984 pass->copy_requests.push_back(CopyOutputRequest::CreateEmptyRequest()); | 2005 pass->copy_requests.push_back(CopyOutputRequest::CreateEmptyRequest()); |
| 1985 | 2006 |
| 1986 CompositorFrame frame; | 2007 CompositorFrame frame; |
| 1987 frame.render_pass_list.push_back(std::move(pass)); | 2008 frame.render_pass_list.push_back(std::move(pass)); |
| 1988 | 2009 |
| 1989 factory.SubmitCompositorFrame(local_frame2_id, std::move(frame), | 2010 factory2.SubmitCompositorFrame(local_frame2_id, std::move(frame), |
| 1990 SurfaceFactory::DrawCallback()); | 2011 SurfaceFactory::DrawCallback()); |
| 1991 } | 2012 } |
| 1992 | 2013 |
| 1993 frame = aggregator_->Aggregate(surface2_id); | 2014 frame = aggregator_->Aggregate(surface2_id); |
| 1994 EXPECT_EQ(1u, frame.render_pass_list.size()); | 2015 EXPECT_EQ(1u, frame.render_pass_list.size()); |
| 1995 render_pass = frame.render_pass_list.front().get(); | 2016 render_pass = frame.render_pass_list.front().get(); |
| 1996 | 2017 |
| 1997 // Parent has copy request, so texture should not be drawn. | 2018 // Parent has copy request, so texture should not be drawn. |
| 1998 EXPECT_EQ(DrawQuad::SOLID_COLOR, render_pass->quad_list.back()->material); | 2019 EXPECT_EQ(DrawQuad::SOLID_COLOR, render_pass->quad_list.back()->material); |
| 1999 | 2020 |
| 2000 frame = aggregator_->Aggregate(surface2_id); | 2021 frame = aggregator_->Aggregate(surface2_id); |
| 2001 EXPECT_EQ(1u, frame.render_pass_list.size()); | 2022 EXPECT_EQ(1u, frame.render_pass_list.size()); |
| 2002 render_pass = frame.render_pass_list.front().get(); | 2023 render_pass = frame.render_pass_list.front().get(); |
| 2003 | 2024 |
| 2004 // Copy request has been executed earlier, so texture should be drawn. | 2025 // Copy request has been executed earlier, so texture should be drawn. |
| 2005 EXPECT_EQ(DrawQuad::TEXTURE_CONTENT, | 2026 EXPECT_EQ(DrawQuad::TEXTURE_CONTENT, |
| 2006 render_pass->quad_list.front()->material); | 2027 render_pass->quad_list.front()->material); |
| 2007 | 2028 |
| 2008 aggregator_->set_output_is_secure(false); | 2029 aggregator_->set_output_is_secure(false); |
| 2009 | 2030 |
| 2010 frame = aggregator_->Aggregate(surface2_id); | 2031 frame = aggregator_->Aggregate(surface2_id); |
| 2011 render_pass = frame.render_pass_list.back().get(); | 2032 render_pass = frame.render_pass_list.back().get(); |
| 2012 | 2033 |
| 2013 // Output is insecure, so texture should be drawn. | 2034 // Output is insecure, so texture should be drawn. |
| 2014 EXPECT_EQ(DrawQuad::SOLID_COLOR, render_pass->quad_list.back()->material); | 2035 EXPECT_EQ(DrawQuad::SOLID_COLOR, render_pass->quad_list.back()->material); |
| 2015 | 2036 |
| 2016 factory.Destroy(local_frame1_id); | 2037 factory1.EvictSurface(); |
| 2017 factory.Destroy(local_frame2_id); | 2038 factory2.EvictSurface(); |
| 2018 } | 2039 } |
| 2019 | 2040 |
| 2020 } // namespace | 2041 } // namespace |
| 2021 } // namespace cc | 2042 } // namespace cc |
| 2022 | 2043 |
| OLD | NEW |