| 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 18 matching lines...) Expand all Loading... |
| 29 #include "cc/test/surface_aggregator_test_helpers.h" | 29 #include "cc/test/surface_aggregator_test_helpers.h" |
| 30 #include "cc/test/test_shared_bitmap_manager.h" | 30 #include "cc/test/test_shared_bitmap_manager.h" |
| 31 #include "testing/gmock/include/gmock/gmock.h" | 31 #include "testing/gmock/include/gmock/gmock.h" |
| 32 #include "testing/gtest/include/gtest/gtest.h" | 32 #include "testing/gtest/include/gtest/gtest.h" |
| 33 #include "third_party/skia/include/core/SkColor.h" | 33 #include "third_party/skia/include/core/SkColor.h" |
| 34 | 34 |
| 35 namespace cc { | 35 namespace cc { |
| 36 namespace { | 36 namespace { |
| 37 | 37 |
| 38 static constexpr FrameSinkId kArbitraryFrameSinkId(1, 1); | 38 static constexpr FrameSinkId kArbitraryFrameSinkId(1, 1); |
| 39 static constexpr FrameSinkId kArbitraryChildFrameSinkId(2, 2); |
| 39 | 40 |
| 40 SurfaceId InvalidSurfaceId() { | 41 SurfaceId InvalidSurfaceId() { |
| 41 static SurfaceId invalid(kArbitraryFrameSinkId, 0xdeadbeef, 0); | 42 static SurfaceId invalid(kArbitraryFrameSinkId, 0xdeadbeef, 0); |
| 42 return invalid; | 43 return invalid; |
| 43 } | 44 } |
| 44 | 45 |
| 45 gfx::Size SurfaceSize() { | 46 gfx::Size SurfaceSize() { |
| 46 static gfx::Size size(100, 100); | 47 static gfx::Size size(100, 100); |
| 47 return size; | 48 return size; |
| 48 } | 49 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 59 | 60 |
| 60 void SetBeginFrameSource(BeginFrameSource* begin_frame_source) override {} | 61 void SetBeginFrameSource(BeginFrameSource* begin_frame_source) override {} |
| 61 | 62 |
| 62 gfx::Rect last_damage_rect_; | 63 gfx::Rect last_damage_rect_; |
| 63 SurfaceId last_surface_id_; | 64 SurfaceId last_surface_id_; |
| 64 }; | 65 }; |
| 65 | 66 |
| 66 class SurfaceAggregatorTest : public testing::Test { | 67 class SurfaceAggregatorTest : public testing::Test { |
| 67 public: | 68 public: |
| 68 explicit SurfaceAggregatorTest(bool use_damage_rect) | 69 explicit SurfaceAggregatorTest(bool use_damage_rect) |
| 69 : factory_(&manager_, &empty_client_), | 70 : factory_(kArbitraryFrameSinkId, &manager_, &empty_client_), |
| 70 aggregator_(&manager_, NULL, use_damage_rect) {} | 71 aggregator_(&manager_, NULL, use_damage_rect) {} |
| 71 | 72 |
| 72 SurfaceAggregatorTest() : SurfaceAggregatorTest(false) {} | 73 SurfaceAggregatorTest() : SurfaceAggregatorTest(false) {} |
| 73 | 74 |
| 74 protected: | 75 protected: |
| 75 SurfaceManager manager_; | 76 SurfaceManager manager_; |
| 76 EmptySurfaceFactoryClient empty_client_; | 77 EmptySurfaceFactoryClient empty_client_; |
| 77 SurfaceFactory factory_; | 78 SurfaceFactory factory_; |
| 78 SurfaceAggregator aggregator_; | 79 SurfaceAggregator aggregator_; |
| 79 }; | 80 }; |
| 80 | 81 |
| 81 TEST_F(SurfaceAggregatorTest, ValidSurfaceNoFrame) { | 82 TEST_F(SurfaceAggregatorTest, ValidSurfaceNoFrame) { |
| 82 SurfaceId one_id(kArbitraryFrameSinkId, 7, 0); | 83 SurfaceId one_id(kArbitraryFrameSinkId, 7, 0); |
| 83 factory_.Create(one_id); | 84 factory_.Create(one_id); |
| 84 | 85 |
| 85 CompositorFrame frame = aggregator_.Aggregate(one_id); | 86 CompositorFrame frame = aggregator_.Aggregate(one_id); |
| 86 EXPECT_FALSE(frame.delegated_frame_data); | 87 EXPECT_FALSE(frame.delegated_frame_data); |
| 87 | 88 |
| 88 factory_.Destroy(one_id); | 89 factory_.Destroy(one_id); |
| 89 } | 90 } |
| 90 | 91 |
| 91 class SurfaceAggregatorValidSurfaceTest : public SurfaceAggregatorTest { | 92 class SurfaceAggregatorValidSurfaceTest : public SurfaceAggregatorTest { |
| 92 public: | 93 public: |
| 93 explicit SurfaceAggregatorValidSurfaceTest(bool use_damage_rect) | 94 explicit SurfaceAggregatorValidSurfaceTest(bool use_damage_rect) |
| 94 : SurfaceAggregatorTest(use_damage_rect), | 95 : SurfaceAggregatorTest(use_damage_rect), |
| 95 allocator_(FrameSinkId(1, 1)), | 96 allocator_(kArbitraryFrameSinkId), |
| 96 child_allocator_(FrameSinkId(2, 2)) {} | 97 child_factory_(kArbitraryChildFrameSinkId, |
| 98 &manager_, |
| 99 &empty_child_client_), |
| 100 child_allocator_(kArbitraryChildFrameSinkId) {} |
| 97 SurfaceAggregatorValidSurfaceTest() | 101 SurfaceAggregatorValidSurfaceTest() |
| 98 : SurfaceAggregatorValidSurfaceTest(false) {} | 102 : SurfaceAggregatorValidSurfaceTest(false) {} |
| 99 | 103 |
| 100 void SetUp() override { | 104 void SetUp() override { |
| 101 SurfaceAggregatorTest::SetUp(); | 105 SurfaceAggregatorTest::SetUp(); |
| 102 root_surface_id_ = allocator_.GenerateId(); | 106 root_surface_id_ = allocator_.GenerateId(); |
| 103 factory_.Create(root_surface_id_); | 107 factory_.Create(root_surface_id_); |
| 104 root_surface_ = manager_.GetSurfaceForId(root_surface_id_); | 108 root_surface_ = manager_.GetSurfaceForId(root_surface_id_); |
| 105 } | 109 } |
| 106 | 110 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 131 | 135 |
| 132 EXPECT_EQ(expected_surface_count, | 136 EXPECT_EQ(expected_surface_count, |
| 133 aggregator_.previous_contained_surfaces().size()); | 137 aggregator_.previous_contained_surfaces().size()); |
| 134 for (size_t i = 0; i < expected_surface_count; i++) { | 138 for (size_t i = 0; i < expected_surface_count; i++) { |
| 135 EXPECT_TRUE( | 139 EXPECT_TRUE( |
| 136 aggregator_.previous_contained_surfaces().find(surface_ids[i]) != | 140 aggregator_.previous_contained_surfaces().find(surface_ids[i]) != |
| 137 aggregator_.previous_contained_surfaces().end()); | 141 aggregator_.previous_contained_surfaces().end()); |
| 138 } | 142 } |
| 139 } | 143 } |
| 140 | 144 |
| 141 void SubmitPassListAsFrame(const SurfaceId& surface_id, | 145 void SubmitPassListAsFrame(SurfaceFactory* factory, |
| 146 const SurfaceId& surface_id, |
| 142 RenderPassList* pass_list) { | 147 RenderPassList* pass_list) { |
| 143 std::unique_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData); | 148 std::unique_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData); |
| 144 pass_list->swap(frame_data->render_pass_list); | 149 pass_list->swap(frame_data->render_pass_list); |
| 145 | 150 |
| 146 CompositorFrame frame; | 151 CompositorFrame frame; |
| 147 frame.delegated_frame_data = std::move(frame_data); | 152 frame.delegated_frame_data = std::move(frame_data); |
| 148 | 153 |
| 149 factory_.SubmitCompositorFrame(surface_id, std::move(frame), | 154 factory->SubmitCompositorFrame(surface_id, std::move(frame), |
| 150 SurfaceFactory::DrawCallback()); | 155 SurfaceFactory::DrawCallback()); |
| 151 } | 156 } |
| 152 | 157 |
| 153 void SubmitCompositorFrame(test::Pass* passes, | 158 void SubmitCompositorFrame(SurfaceFactory* factory, |
| 159 test::Pass* passes, |
| 154 size_t pass_count, | 160 size_t pass_count, |
| 155 const SurfaceId& surface_id) { | 161 const SurfaceId& surface_id) { |
| 156 RenderPassList pass_list; | 162 RenderPassList pass_list; |
| 157 AddPasses(&pass_list, gfx::Rect(SurfaceSize()), passes, pass_count); | 163 AddPasses(&pass_list, gfx::Rect(SurfaceSize()), passes, pass_count); |
| 158 SubmitPassListAsFrame(surface_id, &pass_list); | 164 SubmitPassListAsFrame(factory, surface_id, &pass_list); |
| 159 } | 165 } |
| 160 | 166 |
| 161 void QueuePassAsFrame(std::unique_ptr<RenderPass> pass, | 167 void QueuePassAsFrame(std::unique_ptr<RenderPass> pass, |
| 162 const SurfaceId& surface_id) { | 168 const SurfaceId& surface_id) { |
| 163 std::unique_ptr<DelegatedFrameData> delegated_frame_data( | 169 std::unique_ptr<DelegatedFrameData> delegated_frame_data( |
| 164 new DelegatedFrameData); | 170 new DelegatedFrameData); |
| 165 delegated_frame_data->render_pass_list.push_back(std::move(pass)); | 171 delegated_frame_data->render_pass_list.push_back(std::move(pass)); |
| 166 | 172 |
| 167 CompositorFrame child_frame; | 173 CompositorFrame child_frame; |
| 168 child_frame.delegated_frame_data = std::move(delegated_frame_data); | 174 child_frame.delegated_frame_data = std::move(delegated_frame_data); |
| 169 | 175 |
| 170 factory_.SubmitCompositorFrame(surface_id, std::move(child_frame), | 176 factory_.SubmitCompositorFrame(surface_id, std::move(child_frame), |
| 171 SurfaceFactory::DrawCallback()); | 177 SurfaceFactory::DrawCallback()); |
| 172 } | 178 } |
| 173 | 179 |
| 174 protected: | 180 protected: |
| 175 SurfaceId root_surface_id_; | 181 SurfaceId root_surface_id_; |
| 176 Surface* root_surface_; | 182 Surface* root_surface_; |
| 177 SurfaceIdAllocator allocator_; | 183 SurfaceIdAllocator allocator_; |
| 184 EmptySurfaceFactoryClient empty_child_client_; |
| 185 SurfaceFactory child_factory_; |
| 178 SurfaceIdAllocator child_allocator_; | 186 SurfaceIdAllocator child_allocator_; |
| 179 }; | 187 }; |
| 180 | 188 |
| 181 // Tests that a very simple frame containing only two solid color quads makes it | 189 // Tests that a very simple frame containing only two solid color quads makes it |
| 182 // through the aggregator correctly. | 190 // through the aggregator correctly. |
| 183 TEST_F(SurfaceAggregatorValidSurfaceTest, SimpleFrame) { | 191 TEST_F(SurfaceAggregatorValidSurfaceTest, SimpleFrame) { |
| 184 test::Quad quads[] = {test::Quad::SolidColorQuad(SK_ColorRED), | 192 test::Quad quads[] = {test::Quad::SolidColorQuad(SK_ColorRED), |
| 185 test::Quad::SolidColorQuad(SK_ColorBLUE)}; | 193 test::Quad::SolidColorQuad(SK_ColorBLUE)}; |
| 186 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; | 194 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; |
| 187 | 195 |
| 188 SubmitCompositorFrame(passes, arraysize(passes), root_surface_id_); | 196 SubmitCompositorFrame(&factory_, passes, arraysize(passes), root_surface_id_); |
| 189 | 197 |
| 190 SurfaceId ids[] = {root_surface_id_}; | 198 SurfaceId ids[] = {root_surface_id_}; |
| 191 | 199 |
| 192 AggregateAndVerify(passes, arraysize(passes), ids, arraysize(ids)); | 200 AggregateAndVerify(passes, arraysize(passes), ids, arraysize(ids)); |
| 193 | 201 |
| 194 // Check that WillDrawSurface was called. | 202 // Check that WillDrawSurface was called. |
| 195 EXPECT_EQ(gfx::Rect(SurfaceSize()), empty_client_.last_damage_rect_); | 203 EXPECT_EQ(gfx::Rect(SurfaceSize()), empty_client_.last_damage_rect_); |
| 196 EXPECT_EQ(root_surface_id_, empty_client_.last_surface_id_); | 204 EXPECT_EQ(root_surface_id_, empty_client_.last_surface_id_); |
| 197 } | 205 } |
| 198 | 206 |
| 199 TEST_F(SurfaceAggregatorValidSurfaceTest, OpacityCopied) { | 207 TEST_F(SurfaceAggregatorValidSurfaceTest, OpacityCopied) { |
| 200 SurfaceId embedded_surface_id = allocator_.GenerateId(); | 208 SurfaceId embedded_surface_id = allocator_.GenerateId(); |
| 201 factory_.Create(embedded_surface_id); | 209 factory_.Create(embedded_surface_id); |
| 202 | 210 |
| 203 test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), | 211 test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), |
| 204 test::Quad::SolidColorQuad(SK_ColorBLUE)}; | 212 test::Quad::SolidColorQuad(SK_ColorBLUE)}; |
| 205 test::Pass embedded_passes[] = { | 213 test::Pass embedded_passes[] = { |
| 206 test::Pass(embedded_quads, arraysize(embedded_quads))}; | 214 test::Pass(embedded_quads, arraysize(embedded_quads))}; |
| 207 | 215 |
| 208 SubmitCompositorFrame(embedded_passes, arraysize(embedded_passes), | 216 SubmitCompositorFrame(&factory_, embedded_passes, arraysize(embedded_passes), |
| 209 embedded_surface_id); | 217 embedded_surface_id); |
| 210 | 218 |
| 211 test::Quad quads[] = {test::Quad::SurfaceQuad(embedded_surface_id, .5f)}; | 219 test::Quad quads[] = {test::Quad::SurfaceQuad(embedded_surface_id, .5f)}; |
| 212 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; | 220 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; |
| 213 | 221 |
| 214 SubmitCompositorFrame(passes, arraysize(passes), root_surface_id_); | 222 SubmitCompositorFrame(&factory_, passes, arraysize(passes), root_surface_id_); |
| 215 | 223 |
| 216 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id_); | 224 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id_); |
| 217 | 225 |
| 218 ASSERT_TRUE(aggregated_frame.delegated_frame_data); | 226 ASSERT_TRUE(aggregated_frame.delegated_frame_data); |
| 219 | 227 |
| 220 DelegatedFrameData* frame_data = aggregated_frame.delegated_frame_data.get(); | 228 DelegatedFrameData* frame_data = aggregated_frame.delegated_frame_data.get(); |
| 221 | 229 |
| 222 RenderPassList& render_pass_list(frame_data->render_pass_list); | 230 RenderPassList& render_pass_list(frame_data->render_pass_list); |
| 223 ASSERT_EQ(2u, render_pass_list.size()); | 231 ASSERT_EQ(2u, render_pass_list.size()); |
| 224 SharedQuadStateList& shared_quad_state_list( | 232 SharedQuadStateList& shared_quad_state_list( |
| (...skipping 12 matching lines...) Expand all Loading... |
| 237 | 245 |
| 238 TEST_F(SurfaceAggregatorValidSurfaceTest, MultiPassSimpleFrame) { | 246 TEST_F(SurfaceAggregatorValidSurfaceTest, MultiPassSimpleFrame) { |
| 239 test::Quad quads[][2] = {{test::Quad::SolidColorQuad(SK_ColorWHITE), | 247 test::Quad quads[][2] = {{test::Quad::SolidColorQuad(SK_ColorWHITE), |
| 240 test::Quad::SolidColorQuad(SK_ColorLTGRAY)}, | 248 test::Quad::SolidColorQuad(SK_ColorLTGRAY)}, |
| 241 {test::Quad::SolidColorQuad(SK_ColorGRAY), | 249 {test::Quad::SolidColorQuad(SK_ColorGRAY), |
| 242 test::Quad::SolidColorQuad(SK_ColorDKGRAY)}}; | 250 test::Quad::SolidColorQuad(SK_ColorDKGRAY)}}; |
| 243 test::Pass passes[] = { | 251 test::Pass passes[] = { |
| 244 test::Pass(quads[0], arraysize(quads[0]), RenderPassId(1, 1)), | 252 test::Pass(quads[0], arraysize(quads[0]), RenderPassId(1, 1)), |
| 245 test::Pass(quads[1], arraysize(quads[1]), RenderPassId(1, 2))}; | 253 test::Pass(quads[1], arraysize(quads[1]), RenderPassId(1, 2))}; |
| 246 | 254 |
| 247 SubmitCompositorFrame(passes, arraysize(passes), root_surface_id_); | 255 SubmitCompositorFrame(&factory_, passes, arraysize(passes), root_surface_id_); |
| 248 | 256 |
| 249 SurfaceId ids[] = {root_surface_id_}; | 257 SurfaceId ids[] = {root_surface_id_}; |
| 250 | 258 |
| 251 AggregateAndVerify(passes, arraysize(passes), ids, arraysize(ids)); | 259 AggregateAndVerify(passes, arraysize(passes), ids, arraysize(ids)); |
| 252 } | 260 } |
| 253 | 261 |
| 254 // This tests very simple embedding. root_surface has a frame containing a few | 262 // This tests very simple embedding. root_surface has a frame containing a few |
| 255 // solid color quads and a surface quad referencing embedded_surface. | 263 // solid color quads and a surface quad referencing embedded_surface. |
| 256 // embedded_surface has a frame containing only a solid color quad. The solid | 264 // embedded_surface has a frame containing only a solid color quad. The solid |
| 257 // color quad should be aggregated into the final frame. | 265 // color quad should be aggregated into the final frame. |
| 258 TEST_F(SurfaceAggregatorValidSurfaceTest, SimpleSurfaceReference) { | 266 TEST_F(SurfaceAggregatorValidSurfaceTest, SimpleSurfaceReference) { |
| 259 SurfaceId embedded_surface_id = allocator_.GenerateId(); | 267 SurfaceId embedded_surface_id = allocator_.GenerateId(); |
| 260 factory_.Create(embedded_surface_id); | 268 factory_.Create(embedded_surface_id); |
| 261 | 269 |
| 262 test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)}; | 270 test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)}; |
| 263 test::Pass embedded_passes[] = { | 271 test::Pass embedded_passes[] = { |
| 264 test::Pass(embedded_quads, arraysize(embedded_quads))}; | 272 test::Pass(embedded_quads, arraysize(embedded_quads))}; |
| 265 | 273 |
| 266 SubmitCompositorFrame(embedded_passes, arraysize(embedded_passes), | 274 SubmitCompositorFrame(&factory_, embedded_passes, arraysize(embedded_passes), |
| 267 embedded_surface_id); | 275 embedded_surface_id); |
| 268 | 276 |
| 269 test::Quad root_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE), | 277 test::Quad root_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE), |
| 270 test::Quad::SurfaceQuad(embedded_surface_id, 1.f), | 278 test::Quad::SurfaceQuad(embedded_surface_id, 1.f), |
| 271 test::Quad::SolidColorQuad(SK_ColorBLACK)}; | 279 test::Quad::SolidColorQuad(SK_ColorBLACK)}; |
| 272 test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))}; | 280 test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))}; |
| 273 | 281 |
| 274 SubmitCompositorFrame(root_passes, arraysize(root_passes), root_surface_id_); | 282 SubmitCompositorFrame(&factory_, root_passes, arraysize(root_passes), |
| 283 root_surface_id_); |
| 275 | 284 |
| 276 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE), | 285 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE), |
| 277 test::Quad::SolidColorQuad(SK_ColorGREEN), | 286 test::Quad::SolidColorQuad(SK_ColorGREEN), |
| 278 test::Quad::SolidColorQuad(SK_ColorBLACK)}; | 287 test::Quad::SolidColorQuad(SK_ColorBLACK)}; |
| 279 test::Pass expected_passes[] = { | 288 test::Pass expected_passes[] = { |
| 280 test::Pass(expected_quads, arraysize(expected_quads))}; | 289 test::Pass(expected_quads, arraysize(expected_quads))}; |
| 281 SurfaceId ids[] = {root_surface_id_, embedded_surface_id}; | 290 SurfaceId ids[] = {root_surface_id_, embedded_surface_id}; |
| 282 AggregateAndVerify( | 291 AggregateAndVerify( |
| 283 expected_passes, arraysize(expected_passes), ids, arraysize(ids)); | 292 expected_passes, arraysize(expected_passes), ids, arraysize(ids)); |
| 284 | 293 |
| 285 factory_.Destroy(embedded_surface_id); | 294 factory_.Destroy(embedded_surface_id); |
| 286 } | 295 } |
| 287 | 296 |
| 288 TEST_F(SurfaceAggregatorValidSurfaceTest, CopyRequest) { | 297 TEST_F(SurfaceAggregatorValidSurfaceTest, CopyRequest) { |
| 289 SurfaceId embedded_surface_id = allocator_.GenerateId(); | 298 SurfaceId embedded_surface_id = allocator_.GenerateId(); |
| 290 factory_.Create(embedded_surface_id); | 299 factory_.Create(embedded_surface_id); |
| 291 | 300 |
| 292 test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)}; | 301 test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)}; |
| 293 test::Pass embedded_passes[] = { | 302 test::Pass embedded_passes[] = { |
| 294 test::Pass(embedded_quads, arraysize(embedded_quads))}; | 303 test::Pass(embedded_quads, arraysize(embedded_quads))}; |
| 295 | 304 |
| 296 SubmitCompositorFrame(embedded_passes, arraysize(embedded_passes), | 305 SubmitCompositorFrame(&factory_, embedded_passes, arraysize(embedded_passes), |
| 297 embedded_surface_id); | 306 embedded_surface_id); |
| 298 std::unique_ptr<CopyOutputRequest> copy_request( | 307 std::unique_ptr<CopyOutputRequest> copy_request( |
| 299 CopyOutputRequest::CreateEmptyRequest()); | 308 CopyOutputRequest::CreateEmptyRequest()); |
| 300 CopyOutputRequest* copy_request_ptr = copy_request.get(); | 309 CopyOutputRequest* copy_request_ptr = copy_request.get(); |
| 301 factory_.RequestCopyOfSurface(embedded_surface_id, std::move(copy_request)); | 310 factory_.RequestCopyOfSurface(embedded_surface_id, std::move(copy_request)); |
| 302 | 311 |
| 303 test::Quad root_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE), | 312 test::Quad root_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE), |
| 304 test::Quad::SurfaceQuad(embedded_surface_id, 1.f), | 313 test::Quad::SurfaceQuad(embedded_surface_id, 1.f), |
| 305 test::Quad::SolidColorQuad(SK_ColorBLACK)}; | 314 test::Quad::SolidColorQuad(SK_ColorBLACK)}; |
| 306 test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))}; | 315 test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))}; |
| 307 | 316 |
| 308 SubmitCompositorFrame(root_passes, arraysize(root_passes), root_surface_id_); | 317 SubmitCompositorFrame(&factory_, root_passes, arraysize(root_passes), |
| 318 root_surface_id_); |
| 309 | 319 |
| 310 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id_); | 320 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id_); |
| 311 | 321 |
| 312 ASSERT_TRUE(aggregated_frame.delegated_frame_data); | 322 ASSERT_TRUE(aggregated_frame.delegated_frame_data); |
| 313 | 323 |
| 314 DelegatedFrameData* frame_data = aggregated_frame.delegated_frame_data.get(); | 324 DelegatedFrameData* frame_data = aggregated_frame.delegated_frame_data.get(); |
| 315 | 325 |
| 316 test::Quad expected_quads[] = { | 326 test::Quad expected_quads[] = { |
| 317 test::Quad::SolidColorQuad(SK_ColorWHITE), | 327 test::Quad::SolidColorQuad(SK_ColorWHITE), |
| 318 test::Quad::RenderPassQuad(frame_data->render_pass_list[0]->id), | 328 test::Quad::RenderPassQuad(frame_data->render_pass_list[0]->id), |
| (...skipping 23 matching lines...) Expand all Loading... |
| 342 | 352 |
| 343 // Root surface may contain copy requests. | 353 // Root surface may contain copy requests. |
| 344 TEST_F(SurfaceAggregatorValidSurfaceTest, RootCopyRequest) { | 354 TEST_F(SurfaceAggregatorValidSurfaceTest, RootCopyRequest) { |
| 345 SurfaceId embedded_surface_id = allocator_.GenerateId(); | 355 SurfaceId embedded_surface_id = allocator_.GenerateId(); |
| 346 factory_.Create(embedded_surface_id); | 356 factory_.Create(embedded_surface_id); |
| 347 | 357 |
| 348 test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)}; | 358 test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)}; |
| 349 test::Pass embedded_passes[] = { | 359 test::Pass embedded_passes[] = { |
| 350 test::Pass(embedded_quads, arraysize(embedded_quads))}; | 360 test::Pass(embedded_quads, arraysize(embedded_quads))}; |
| 351 | 361 |
| 352 SubmitCompositorFrame(embedded_passes, arraysize(embedded_passes), | 362 SubmitCompositorFrame(&factory_, embedded_passes, arraysize(embedded_passes), |
| 353 embedded_surface_id); | 363 embedded_surface_id); |
| 354 std::unique_ptr<CopyOutputRequest> copy_request( | 364 std::unique_ptr<CopyOutputRequest> copy_request( |
| 355 CopyOutputRequest::CreateEmptyRequest()); | 365 CopyOutputRequest::CreateEmptyRequest()); |
| 356 CopyOutputRequest* copy_request_ptr = copy_request.get(); | 366 CopyOutputRequest* copy_request_ptr = copy_request.get(); |
| 357 std::unique_ptr<CopyOutputRequest> copy_request2( | 367 std::unique_ptr<CopyOutputRequest> copy_request2( |
| 358 CopyOutputRequest::CreateEmptyRequest()); | 368 CopyOutputRequest::CreateEmptyRequest()); |
| 359 CopyOutputRequest* copy_request2_ptr = copy_request2.get(); | 369 CopyOutputRequest* copy_request2_ptr = copy_request2.get(); |
| 360 | 370 |
| 361 test::Quad root_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE), | 371 test::Quad root_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE), |
| 362 test::Quad::SurfaceQuad(embedded_surface_id, 1.f), | 372 test::Quad::SurfaceQuad(embedded_surface_id, 1.f), |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 | 440 |
| 431 TEST_F(SurfaceAggregatorValidSurfaceTest, UnreferencedSurface) { | 441 TEST_F(SurfaceAggregatorValidSurfaceTest, UnreferencedSurface) { |
| 432 SurfaceId embedded_surface_id = allocator_.GenerateId(); | 442 SurfaceId embedded_surface_id = allocator_.GenerateId(); |
| 433 SurfaceId nonexistent_surface_id = allocator_.GenerateId(); | 443 SurfaceId nonexistent_surface_id = allocator_.GenerateId(); |
| 434 factory_.Create(embedded_surface_id); | 444 factory_.Create(embedded_surface_id); |
| 435 | 445 |
| 436 test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)}; | 446 test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)}; |
| 437 test::Pass embedded_passes[] = { | 447 test::Pass embedded_passes[] = { |
| 438 test::Pass(embedded_quads, arraysize(embedded_quads))}; | 448 test::Pass(embedded_quads, arraysize(embedded_quads))}; |
| 439 | 449 |
| 440 SubmitCompositorFrame(embedded_passes, arraysize(embedded_passes), | 450 SubmitCompositorFrame(&factory_, embedded_passes, arraysize(embedded_passes), |
| 441 embedded_surface_id); | 451 embedded_surface_id); |
| 442 std::unique_ptr<CopyOutputRequest> copy_request( | 452 std::unique_ptr<CopyOutputRequest> copy_request( |
| 443 CopyOutputRequest::CreateEmptyRequest()); | 453 CopyOutputRequest::CreateEmptyRequest()); |
| 444 CopyOutputRequest* copy_request_ptr = copy_request.get(); | 454 CopyOutputRequest* copy_request_ptr = copy_request.get(); |
| 445 factory_.RequestCopyOfSurface(embedded_surface_id, std::move(copy_request)); | 455 factory_.RequestCopyOfSurface(embedded_surface_id, std::move(copy_request)); |
| 446 | 456 |
| 447 SurfaceId parent_surface_id = allocator_.GenerateId(); | 457 SurfaceId parent_surface_id = allocator_.GenerateId(); |
| 448 factory_.Create(parent_surface_id); | 458 factory_.Create(parent_surface_id); |
| 449 | 459 |
| 450 test::Quad parent_quads[] = { | 460 test::Quad parent_quads[] = { |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 517 aggregator_.previous_contained_surfaces().end()); | 527 aggregator_.previous_contained_surfaces().end()); |
| 518 } | 528 } |
| 519 | 529 |
| 520 factory_.Destroy(parent_surface_id); | 530 factory_.Destroy(parent_surface_id); |
| 521 factory_.Destroy(embedded_surface_id); | 531 factory_.Destroy(embedded_surface_id); |
| 522 } | 532 } |
| 523 | 533 |
| 524 // This tests referencing a surface that has multiple render passes. | 534 // This tests referencing a surface that has multiple render passes. |
| 525 TEST_F(SurfaceAggregatorValidSurfaceTest, MultiPassSurfaceReference) { | 535 TEST_F(SurfaceAggregatorValidSurfaceTest, MultiPassSurfaceReference) { |
| 526 SurfaceId embedded_surface_id = child_allocator_.GenerateId(); | 536 SurfaceId embedded_surface_id = child_allocator_.GenerateId(); |
| 527 factory_.Create(embedded_surface_id); | 537 child_factory_.Create(embedded_surface_id); |
| 528 | 538 |
| 529 RenderPassId pass_ids[] = {RenderPassId(1, 1), RenderPassId(1, 2), | 539 RenderPassId pass_ids[] = {RenderPassId(1, 1), RenderPassId(1, 2), |
| 530 RenderPassId(1, 3)}; | 540 RenderPassId(1, 3)}; |
| 531 | 541 |
| 532 test::Quad embedded_quads[][2] = { | 542 test::Quad embedded_quads[][2] = { |
| 533 {test::Quad::SolidColorQuad(1), test::Quad::SolidColorQuad(2)}, | 543 {test::Quad::SolidColorQuad(1), test::Quad::SolidColorQuad(2)}, |
| 534 {test::Quad::SolidColorQuad(3), test::Quad::RenderPassQuad(pass_ids[0])}, | 544 {test::Quad::SolidColorQuad(3), test::Quad::RenderPassQuad(pass_ids[0])}, |
| 535 {test::Quad::SolidColorQuad(4), test::Quad::RenderPassQuad(pass_ids[1])}}; | 545 {test::Quad::SolidColorQuad(4), test::Quad::RenderPassQuad(pass_ids[1])}}; |
| 536 test::Pass embedded_passes[] = { | 546 test::Pass embedded_passes[] = { |
| 537 test::Pass(embedded_quads[0], arraysize(embedded_quads[0]), pass_ids[0]), | 547 test::Pass(embedded_quads[0], arraysize(embedded_quads[0]), pass_ids[0]), |
| 538 test::Pass(embedded_quads[1], arraysize(embedded_quads[1]), pass_ids[1]), | 548 test::Pass(embedded_quads[1], arraysize(embedded_quads[1]), pass_ids[1]), |
| 539 test::Pass(embedded_quads[2], arraysize(embedded_quads[2]), pass_ids[2])}; | 549 test::Pass(embedded_quads[2], arraysize(embedded_quads[2]), pass_ids[2])}; |
| 540 | 550 |
| 541 SubmitCompositorFrame(embedded_passes, arraysize(embedded_passes), | 551 SubmitCompositorFrame(&child_factory_, embedded_passes, |
| 542 embedded_surface_id); | 552 arraysize(embedded_passes), embedded_surface_id); |
| 543 | 553 |
| 544 test::Quad root_quads[][2] = { | 554 test::Quad root_quads[][2] = { |
| 545 {test::Quad::SolidColorQuad(5), test::Quad::SolidColorQuad(6)}, | 555 {test::Quad::SolidColorQuad(5), test::Quad::SolidColorQuad(6)}, |
| 546 {test::Quad::SurfaceQuad(embedded_surface_id, 1.f), | 556 {test::Quad::SurfaceQuad(embedded_surface_id, 1.f), |
| 547 test::Quad::RenderPassQuad(pass_ids[0])}, | 557 test::Quad::RenderPassQuad(pass_ids[0])}, |
| 548 {test::Quad::SolidColorQuad(7), test::Quad::RenderPassQuad(pass_ids[1])}}; | 558 {test::Quad::SolidColorQuad(7), test::Quad::RenderPassQuad(pass_ids[1])}}; |
| 549 test::Pass root_passes[] = { | 559 test::Pass root_passes[] = { |
| 550 test::Pass(root_quads[0], arraysize(root_quads[0]), pass_ids[0]), | 560 test::Pass(root_quads[0], arraysize(root_quads[0]), pass_ids[0]), |
| 551 test::Pass(root_quads[1], arraysize(root_quads[1]), pass_ids[1]), | 561 test::Pass(root_quads[1], arraysize(root_quads[1]), pass_ids[1]), |
| 552 test::Pass(root_quads[2], arraysize(root_quads[2]), pass_ids[2])}; | 562 test::Pass(root_quads[2], arraysize(root_quads[2]), pass_ids[2])}; |
| 553 | 563 |
| 554 SubmitCompositorFrame(root_passes, arraysize(root_passes), root_surface_id_); | 564 SubmitCompositorFrame(&factory_, root_passes, arraysize(root_passes), |
| 565 root_surface_id_); |
| 555 | 566 |
| 556 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id_); | 567 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id_); |
| 557 | 568 |
| 558 ASSERT_TRUE(aggregated_frame.delegated_frame_data); | 569 ASSERT_TRUE(aggregated_frame.delegated_frame_data); |
| 559 | 570 |
| 560 DelegatedFrameData* frame_data = aggregated_frame.delegated_frame_data.get(); | 571 DelegatedFrameData* frame_data = aggregated_frame.delegated_frame_data.get(); |
| 561 | 572 |
| 562 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; | 573 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; |
| 563 | 574 |
| 564 ASSERT_EQ(5u, aggregated_pass_list.size()); | 575 ASSERT_EQ(5u, aggregated_pass_list.size()); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 649 // The last quad in the last pass will reference the second pass from the | 660 // The last quad in the last pass will reference the second pass from the |
| 650 // root surface, which after aggregating is the fourth pass in the overall | 661 // root surface, which after aggregating is the fourth pass in the overall |
| 651 // list. | 662 // list. |
| 652 ASSERT_EQ(DrawQuad::RENDER_PASS, | 663 ASSERT_EQ(DrawQuad::RENDER_PASS, |
| 653 fifth_pass_quad_list.ElementAt(1)->material); | 664 fifth_pass_quad_list.ElementAt(1)->material); |
| 654 const RenderPassDrawQuad* fifth_pass_render_pass_draw_quad = | 665 const RenderPassDrawQuad* fifth_pass_render_pass_draw_quad = |
| 655 RenderPassDrawQuad::MaterialCast(fifth_pass_quad_list.ElementAt(1)); | 666 RenderPassDrawQuad::MaterialCast(fifth_pass_quad_list.ElementAt(1)); |
| 656 EXPECT_EQ(actual_pass_ids[3], | 667 EXPECT_EQ(actual_pass_ids[3], |
| 657 fifth_pass_render_pass_draw_quad->render_pass_id); | 668 fifth_pass_render_pass_draw_quad->render_pass_id); |
| 658 } | 669 } |
| 659 factory_.Destroy(embedded_surface_id); | 670 child_factory_.Destroy(embedded_surface_id); |
| 660 } | 671 } |
| 661 | 672 |
| 662 // Tests an invalid surface reference in a frame. The surface quad should just | 673 // Tests an invalid surface reference in a frame. The surface quad should just |
| 663 // be dropped. | 674 // be dropped. |
| 664 TEST_F(SurfaceAggregatorValidSurfaceTest, InvalidSurfaceReference) { | 675 TEST_F(SurfaceAggregatorValidSurfaceTest, InvalidSurfaceReference) { |
| 665 test::Quad quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), | 676 test::Quad quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), |
| 666 test::Quad::SurfaceQuad(InvalidSurfaceId(), 1.f), | 677 test::Quad::SurfaceQuad(InvalidSurfaceId(), 1.f), |
| 667 test::Quad::SolidColorQuad(SK_ColorBLUE)}; | 678 test::Quad::SolidColorQuad(SK_ColorBLUE)}; |
| 668 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; | 679 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; |
| 669 | 680 |
| 670 SubmitCompositorFrame(passes, arraysize(passes), root_surface_id_); | 681 SubmitCompositorFrame(&factory_, passes, arraysize(passes), root_surface_id_); |
| 671 | 682 |
| 672 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), | 683 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), |
| 673 test::Quad::SolidColorQuad(SK_ColorBLUE)}; | 684 test::Quad::SolidColorQuad(SK_ColorBLUE)}; |
| 674 test::Pass expected_passes[] = { | 685 test::Pass expected_passes[] = { |
| 675 test::Pass(expected_quads, arraysize(expected_quads))}; | 686 test::Pass(expected_quads, arraysize(expected_quads))}; |
| 676 SurfaceId ids[] = {root_surface_id_, InvalidSurfaceId()}; | 687 SurfaceId ids[] = {root_surface_id_, InvalidSurfaceId()}; |
| 677 | 688 |
| 678 AggregateAndVerify( | 689 AggregateAndVerify( |
| 679 expected_passes, arraysize(expected_passes), ids, arraysize(ids)); | 690 expected_passes, arraysize(expected_passes), ids, arraysize(ids)); |
| 680 } | 691 } |
| 681 | 692 |
| 682 // Tests a reference to a valid surface with no submitted frame. This quad | 693 // Tests a reference to a valid surface with no submitted frame. This quad |
| 683 // should also just be dropped. | 694 // should also just be dropped. |
| 684 TEST_F(SurfaceAggregatorValidSurfaceTest, ValidSurfaceReferenceWithNoFrame) { | 695 TEST_F(SurfaceAggregatorValidSurfaceTest, ValidSurfaceReferenceWithNoFrame) { |
| 685 SurfaceId surface_with_no_frame_id = allocator_.GenerateId(); | 696 SurfaceId surface_with_no_frame_id = allocator_.GenerateId(); |
| 686 factory_.Create(surface_with_no_frame_id); | 697 factory_.Create(surface_with_no_frame_id); |
| 687 | 698 |
| 688 test::Quad quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), | 699 test::Quad quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), |
| 689 test::Quad::SurfaceQuad(surface_with_no_frame_id, 1.f), | 700 test::Quad::SurfaceQuad(surface_with_no_frame_id, 1.f), |
| 690 test::Quad::SolidColorQuad(SK_ColorBLUE)}; | 701 test::Quad::SolidColorQuad(SK_ColorBLUE)}; |
| 691 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; | 702 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; |
| 692 | 703 |
| 693 SubmitCompositorFrame(passes, arraysize(passes), root_surface_id_); | 704 SubmitCompositorFrame(&factory_, passes, arraysize(passes), root_surface_id_); |
| 694 | 705 |
| 695 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), | 706 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), |
| 696 test::Quad::SolidColorQuad(SK_ColorBLUE)}; | 707 test::Quad::SolidColorQuad(SK_ColorBLUE)}; |
| 697 test::Pass expected_passes[] = { | 708 test::Pass expected_passes[] = { |
| 698 test::Pass(expected_quads, arraysize(expected_quads))}; | 709 test::Pass(expected_quads, arraysize(expected_quads))}; |
| 699 SurfaceId ids[] = {root_surface_id_, surface_with_no_frame_id}; | 710 SurfaceId ids[] = {root_surface_id_, surface_with_no_frame_id}; |
| 700 AggregateAndVerify( | 711 AggregateAndVerify( |
| 701 expected_passes, arraysize(expected_passes), ids, arraysize(ids)); | 712 expected_passes, arraysize(expected_passes), ids, arraysize(ids)); |
| 702 factory_.Destroy(surface_with_no_frame_id); | 713 factory_.Destroy(surface_with_no_frame_id); |
| 703 } | 714 } |
| 704 | 715 |
| 705 // Tests a surface quad referencing itself, generating a trivial cycle. | 716 // Tests a surface quad referencing itself, generating a trivial cycle. |
| 706 // 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. |
| 707 TEST_F(SurfaceAggregatorValidSurfaceTest, SimpleCyclicalReference) { | 718 TEST_F(SurfaceAggregatorValidSurfaceTest, SimpleCyclicalReference) { |
| 708 test::Quad quads[] = {test::Quad::SurfaceQuad(root_surface_id_, 1.f), | 719 test::Quad quads[] = {test::Quad::SurfaceQuad(root_surface_id_, 1.f), |
| 709 test::Quad::SolidColorQuad(SK_ColorYELLOW)}; | 720 test::Quad::SolidColorQuad(SK_ColorYELLOW)}; |
| 710 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; | 721 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; |
| 711 | 722 |
| 712 SubmitCompositorFrame(passes, arraysize(passes), root_surface_id_); | 723 SubmitCompositorFrame(&factory_, passes, arraysize(passes), root_surface_id_); |
| 713 | 724 |
| 714 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorYELLOW)}; | 725 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorYELLOW)}; |
| 715 test::Pass expected_passes[] = { | 726 test::Pass expected_passes[] = { |
| 716 test::Pass(expected_quads, arraysize(expected_quads))}; | 727 test::Pass(expected_quads, arraysize(expected_quads))}; |
| 717 SurfaceId ids[] = {root_surface_id_}; | 728 SurfaceId ids[] = {root_surface_id_}; |
| 718 AggregateAndVerify( | 729 AggregateAndVerify( |
| 719 expected_passes, arraysize(expected_passes), ids, arraysize(ids)); | 730 expected_passes, arraysize(expected_passes), ids, arraysize(ids)); |
| 720 } | 731 } |
| 721 | 732 |
| 722 // Tests a more complex cycle with one intermediate surface. | 733 // Tests a more complex cycle with one intermediate surface. |
| 723 TEST_F(SurfaceAggregatorValidSurfaceTest, TwoSurfaceCyclicalReference) { | 734 TEST_F(SurfaceAggregatorValidSurfaceTest, TwoSurfaceCyclicalReference) { |
| 724 SurfaceId child_surface_id = allocator_.GenerateId(); | 735 SurfaceId child_surface_id = allocator_.GenerateId(); |
| 725 factory_.Create(child_surface_id); | 736 factory_.Create(child_surface_id); |
| 726 | 737 |
| 727 test::Quad parent_quads[] = {test::Quad::SolidColorQuad(SK_ColorBLUE), | 738 test::Quad parent_quads[] = {test::Quad::SolidColorQuad(SK_ColorBLUE), |
| 728 test::Quad::SurfaceQuad(child_surface_id, 1.f), | 739 test::Quad::SurfaceQuad(child_surface_id, 1.f), |
| 729 test::Quad::SolidColorQuad(SK_ColorCYAN)}; | 740 test::Quad::SolidColorQuad(SK_ColorCYAN)}; |
| 730 test::Pass parent_passes[] = { | 741 test::Pass parent_passes[] = { |
| 731 test::Pass(parent_quads, arraysize(parent_quads))}; | 742 test::Pass(parent_quads, arraysize(parent_quads))}; |
| 732 | 743 |
| 733 SubmitCompositorFrame(parent_passes, arraysize(parent_passes), | 744 SubmitCompositorFrame(&factory_, parent_passes, arraysize(parent_passes), |
| 734 root_surface_id_); | 745 root_surface_id_); |
| 735 | 746 |
| 736 test::Quad child_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), | 747 test::Quad child_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), |
| 737 test::Quad::SurfaceQuad(root_surface_id_, 1.f), | 748 test::Quad::SurfaceQuad(root_surface_id_, 1.f), |
| 738 test::Quad::SolidColorQuad(SK_ColorMAGENTA)}; | 749 test::Quad::SolidColorQuad(SK_ColorMAGENTA)}; |
| 739 test::Pass child_passes[] = {test::Pass(child_quads, arraysize(child_quads))}; | 750 test::Pass child_passes[] = {test::Pass(child_quads, arraysize(child_quads))}; |
| 740 | 751 |
| 741 SubmitCompositorFrame(child_passes, arraysize(child_passes), | 752 SubmitCompositorFrame(&factory_, child_passes, arraysize(child_passes), |
| 742 child_surface_id); | 753 child_surface_id); |
| 743 | 754 |
| 744 // The child surface's reference to the root_surface_ will be dropped, so | 755 // The child surface's reference to the root_surface_ will be dropped, so |
| 745 // we'll end up with: | 756 // we'll end up with: |
| 746 // SK_ColorBLUE from the parent | 757 // SK_ColorBLUE from the parent |
| 747 // SK_ColorGREEN from the child | 758 // SK_ColorGREEN from the child |
| 748 // SK_ColorMAGENTA from the child | 759 // SK_ColorMAGENTA from the child |
| 749 // SK_ColorCYAN from the parent | 760 // SK_ColorCYAN from the parent |
| 750 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorBLUE), | 761 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorBLUE), |
| 751 test::Quad::SolidColorQuad(SK_ColorGREEN), | 762 test::Quad::SolidColorQuad(SK_ColorGREEN), |
| (...skipping 13 matching lines...) Expand all Loading... |
| 765 SurfaceId child_surface_id = allocator_.GenerateId(); | 776 SurfaceId child_surface_id = allocator_.GenerateId(); |
| 766 factory_.Create(child_surface_id); | 777 factory_.Create(child_surface_id); |
| 767 | 778 |
| 768 RenderPassId child_pass_id[] = {RenderPassId(1, 1), RenderPassId(1, 2)}; | 779 RenderPassId child_pass_id[] = {RenderPassId(1, 1), RenderPassId(1, 2)}; |
| 769 test::Quad child_quad[][1] = {{test::Quad::SolidColorQuad(SK_ColorGREEN)}, | 780 test::Quad child_quad[][1] = {{test::Quad::SolidColorQuad(SK_ColorGREEN)}, |
| 770 {test::Quad::RenderPassQuad(child_pass_id[0])}}; | 781 {test::Quad::RenderPassQuad(child_pass_id[0])}}; |
| 771 test::Pass surface_passes[] = { | 782 test::Pass surface_passes[] = { |
| 772 test::Pass(child_quad[0], arraysize(child_quad[0]), child_pass_id[0]), | 783 test::Pass(child_quad[0], arraysize(child_quad[0]), child_pass_id[0]), |
| 773 test::Pass(child_quad[1], arraysize(child_quad[1]), child_pass_id[1])}; | 784 test::Pass(child_quad[1], arraysize(child_quad[1]), child_pass_id[1])}; |
| 774 | 785 |
| 775 SubmitCompositorFrame(surface_passes, arraysize(surface_passes), | 786 SubmitCompositorFrame(&factory_, surface_passes, arraysize(surface_passes), |
| 776 child_surface_id); | 787 child_surface_id); |
| 777 | 788 |
| 778 // Pass IDs from the parent surface may collide with ones from the child. | 789 // Pass IDs from the parent surface may collide with ones from the child. |
| 779 RenderPassId parent_pass_id[] = {RenderPassId(2, 1), RenderPassId(1, 2)}; | 790 RenderPassId parent_pass_id[] = {RenderPassId(2, 1), RenderPassId(1, 2)}; |
| 780 test::Quad parent_quad[][1] = { | 791 test::Quad parent_quad[][1] = { |
| 781 {test::Quad::SurfaceQuad(child_surface_id, 1.f)}, | 792 {test::Quad::SurfaceQuad(child_surface_id, 1.f)}, |
| 782 {test::Quad::RenderPassQuad(parent_pass_id[0])}}; | 793 {test::Quad::RenderPassQuad(parent_pass_id[0])}}; |
| 783 test::Pass parent_passes[] = { | 794 test::Pass parent_passes[] = { |
| 784 test::Pass(parent_quad[0], arraysize(parent_quad[0]), parent_pass_id[0]), | 795 test::Pass(parent_quad[0], arraysize(parent_quad[0]), parent_pass_id[0]), |
| 785 test::Pass(parent_quad[1], arraysize(parent_quad[1]), parent_pass_id[1])}; | 796 test::Pass(parent_quad[1], arraysize(parent_quad[1]), parent_pass_id[1])}; |
| 786 | 797 |
| 787 SubmitCompositorFrame(parent_passes, arraysize(parent_passes), | 798 SubmitCompositorFrame(&factory_, parent_passes, arraysize(parent_passes), |
| 788 root_surface_id_); | 799 root_surface_id_); |
| 789 | 800 |
| 790 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id_); | 801 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id_); |
| 791 | 802 |
| 792 ASSERT_TRUE(aggregated_frame.delegated_frame_data); | 803 ASSERT_TRUE(aggregated_frame.delegated_frame_data); |
| 793 | 804 |
| 794 DelegatedFrameData* frame_data = aggregated_frame.delegated_frame_data.get(); | 805 DelegatedFrameData* frame_data = aggregated_frame.delegated_frame_data.get(); |
| 795 | 806 |
| 796 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; | 807 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; |
| 797 | 808 |
| (...skipping 764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1562 | 1573 |
| 1563 SharedQuadState* child_noninvertible_sqs = | 1574 SharedQuadState* child_noninvertible_sqs = |
| 1564 child_pass_list[2]->shared_quad_state_list.ElementAt(0u); | 1575 child_pass_list[2]->shared_quad_state_list.ElementAt(0u); |
| 1565 child_noninvertible_sqs->quad_to_target_transform.matrix().setDouble(0, 0, | 1576 child_noninvertible_sqs->quad_to_target_transform.matrix().setDouble(0, 0, |
| 1566 0.0); | 1577 0.0); |
| 1567 EXPECT_FALSE( | 1578 EXPECT_FALSE( |
| 1568 child_noninvertible_sqs->quad_to_target_transform.IsInvertible()); | 1579 child_noninvertible_sqs->quad_to_target_transform.IsInvertible()); |
| 1569 child_pass_list[2]->quad_list.ElementAt(0)->visible_rect = | 1580 child_pass_list[2]->quad_list.ElementAt(0)->visible_rect = |
| 1570 gfx::Rect(0, 0, 2, 2); | 1581 gfx::Rect(0, 0, 2, 2); |
| 1571 | 1582 |
| 1572 SubmitPassListAsFrame(child_surface_id, &child_pass_list); | 1583 SubmitPassListAsFrame(&factory_, child_surface_id, &child_pass_list); |
| 1573 } | 1584 } |
| 1574 | 1585 |
| 1575 { | 1586 { |
| 1576 test::Quad root_quads[] = {test::Quad::SurfaceQuad(child_surface_id, 1.f)}; | 1587 test::Quad root_quads[] = {test::Quad::SurfaceQuad(child_surface_id, 1.f)}; |
| 1577 | 1588 |
| 1578 test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))}; | 1589 test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))}; |
| 1579 | 1590 |
| 1580 RenderPassList root_pass_list; | 1591 RenderPassList root_pass_list; |
| 1581 AddPasses(&root_pass_list, gfx::Rect(SurfaceSize()), root_passes, | 1592 AddPasses(&root_pass_list, gfx::Rect(SurfaceSize()), root_passes, |
| 1582 arraysize(root_passes)); | 1593 arraysize(root_passes)); |
| 1583 | 1594 |
| 1584 RenderPass* root_pass = root_pass_list[0].get(); | 1595 RenderPass* root_pass = root_pass_list[0].get(); |
| 1585 root_pass->shared_quad_state_list.front() | 1596 root_pass->shared_quad_state_list.front() |
| 1586 ->quad_to_target_transform.Translate(10, 10); | 1597 ->quad_to_target_transform.Translate(10, 10); |
| 1587 root_pass->damage_rect = gfx::Rect(0, 0, 1, 1); | 1598 root_pass->damage_rect = gfx::Rect(0, 0, 1, 1); |
| 1588 | 1599 |
| 1589 SubmitPassListAsFrame(root_surface_id_, &root_pass_list); | 1600 SubmitPassListAsFrame(&factory_, root_surface_id_, &root_pass_list); |
| 1590 } | 1601 } |
| 1591 | 1602 |
| 1592 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id_); | 1603 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id_); |
| 1593 | 1604 |
| 1594 ASSERT_TRUE(aggregated_frame.delegated_frame_data); | 1605 ASSERT_TRUE(aggregated_frame.delegated_frame_data); |
| 1595 | 1606 |
| 1596 DelegatedFrameData* frame_data = aggregated_frame.delegated_frame_data.get(); | 1607 DelegatedFrameData* frame_data = aggregated_frame.delegated_frame_data.get(); |
| 1597 | 1608 |
| 1598 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; | 1609 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; |
| 1599 | 1610 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1612 test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))}; | 1623 test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))}; |
| 1613 | 1624 |
| 1614 RenderPassList root_pass_list; | 1625 RenderPassList root_pass_list; |
| 1615 AddPasses(&root_pass_list, gfx::Rect(SurfaceSize()), root_passes, | 1626 AddPasses(&root_pass_list, gfx::Rect(SurfaceSize()), root_passes, |
| 1616 arraysize(root_passes)); | 1627 arraysize(root_passes)); |
| 1617 | 1628 |
| 1618 RenderPass* root_pass = root_pass_list[0].get(); | 1629 RenderPass* root_pass = root_pass_list[0].get(); |
| 1619 root_pass->shared_quad_state_list.front() | 1630 root_pass->shared_quad_state_list.front() |
| 1620 ->quad_to_target_transform.Translate(10, 10); | 1631 ->quad_to_target_transform.Translate(10, 10); |
| 1621 root_pass->damage_rect = gfx::Rect(10, 10, 2, 2); | 1632 root_pass->damage_rect = gfx::Rect(10, 10, 2, 2); |
| 1622 SubmitPassListAsFrame(root_surface_id_, &root_pass_list); | 1633 SubmitPassListAsFrame(&factory_, root_surface_id_, &root_pass_list); |
| 1623 } | 1634 } |
| 1624 | 1635 |
| 1625 { | 1636 { |
| 1626 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id_); | 1637 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id_); |
| 1627 | 1638 |
| 1628 ASSERT_TRUE(aggregated_frame.delegated_frame_data); | 1639 ASSERT_TRUE(aggregated_frame.delegated_frame_data); |
| 1629 | 1640 |
| 1630 DelegatedFrameData* frame_data = | 1641 DelegatedFrameData* frame_data = |
| 1631 aggregated_frame.delegated_frame_data.get(); | 1642 aggregated_frame.delegated_frame_data.get(); |
| 1632 | 1643 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1666 child_sqs->quad_to_target_transform.Scale(2, 2); | 1677 child_sqs->quad_to_target_transform.Scale(2, 2); |
| 1667 | 1678 |
| 1668 child_pass_list[1]->quad_list.ElementAt(0)->visible_rect = | 1679 child_pass_list[1]->quad_list.ElementAt(0)->visible_rect = |
| 1669 gfx::Rect(0, 0, 2, 2); | 1680 gfx::Rect(0, 0, 2, 2); |
| 1670 | 1681 |
| 1671 RenderPass* child_root_pass = child_pass_list[1].get(); | 1682 RenderPass* child_root_pass = child_pass_list[1].get(); |
| 1672 | 1683 |
| 1673 child_root_pass->copy_requests.push_back( | 1684 child_root_pass->copy_requests.push_back( |
| 1674 CopyOutputRequest::CreateEmptyRequest()); | 1685 CopyOutputRequest::CreateEmptyRequest()); |
| 1675 child_root_pass->damage_rect = gfx::Rect(); | 1686 child_root_pass->damage_rect = gfx::Rect(); |
| 1676 SubmitPassListAsFrame(child_surface_id, &child_pass_list); | 1687 SubmitPassListAsFrame(&factory_, child_surface_id, &child_pass_list); |
| 1677 } | 1688 } |
| 1678 | 1689 |
| 1679 { | 1690 { |
| 1680 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id_); | 1691 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id_); |
| 1681 | 1692 |
| 1682 ASSERT_TRUE(aggregated_frame.delegated_frame_data); | 1693 ASSERT_TRUE(aggregated_frame.delegated_frame_data); |
| 1683 | 1694 |
| 1684 DelegatedFrameData* frame_data = | 1695 DelegatedFrameData* frame_data = |
| 1685 aggregated_frame.delegated_frame_data.get(); | 1696 aggregated_frame.delegated_frame_data.get(); |
| 1686 | 1697 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1732 arraysize(root_passes)); | 1743 arraysize(root_passes)); |
| 1733 | 1744 |
| 1734 RenderPass* pass = root_pass_list[0].get(); | 1745 RenderPass* pass = root_pass_list[0].get(); |
| 1735 pass->shared_quad_state_list.front()->quad_to_target_transform.Translate( | 1746 pass->shared_quad_state_list.front()->quad_to_target_transform.Translate( |
| 1736 10, 10); | 1747 10, 10); |
| 1737 RenderPass* root_pass = root_pass_list[1].get(); | 1748 RenderPass* root_pass = root_pass_list[1].get(); |
| 1738 RenderPassDrawQuad* quad = | 1749 RenderPassDrawQuad* quad = |
| 1739 static_cast<RenderPassDrawQuad*>(root_pass->quad_list.front()); | 1750 static_cast<RenderPassDrawQuad*>(root_pass->quad_list.front()); |
| 1740 quad->filters.Append(FilterOperation::CreateBlurFilter(2)); | 1751 quad->filters.Append(FilterOperation::CreateBlurFilter(2)); |
| 1741 root_pass->damage_rect = gfx::Rect(10, 10, 2, 2); | 1752 root_pass->damage_rect = gfx::Rect(10, 10, 2, 2); |
| 1742 SubmitPassListAsFrame(root_surface_id_, &root_pass_list); | 1753 SubmitPassListAsFrame(&factory_, root_surface_id_, &root_pass_list); |
| 1743 } | 1754 } |
| 1744 | 1755 |
| 1745 { | 1756 { |
| 1746 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id_); | 1757 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id_); |
| 1747 | 1758 |
| 1748 ASSERT_TRUE(aggregated_frame.delegated_frame_data); | 1759 ASSERT_TRUE(aggregated_frame.delegated_frame_data); |
| 1749 | 1760 |
| 1750 DelegatedFrameData* frame_data = | 1761 DelegatedFrameData* frame_data = |
| 1751 aggregated_frame.delegated_frame_data.get(); | 1762 aggregated_frame.delegated_frame_data.get(); |
| 1752 | 1763 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1782 AddPasses(&root_pass_list, gfx::Rect(SurfaceSize()), root_passes, | 1793 AddPasses(&root_pass_list, gfx::Rect(SurfaceSize()), root_passes, |
| 1783 arraysize(root_passes)); | 1794 arraysize(root_passes)); |
| 1784 | 1795 |
| 1785 RenderPass* root_pass = root_pass_list[1].get(); | 1796 RenderPass* root_pass = root_pass_list[1].get(); |
| 1786 root_pass->shared_quad_state_list.ElementAt(1) | 1797 root_pass->shared_quad_state_list.ElementAt(1) |
| 1787 ->quad_to_target_transform.Translate(10, 10); | 1798 ->quad_to_target_transform.Translate(10, 10); |
| 1788 RenderPassDrawQuad* quad = | 1799 RenderPassDrawQuad* quad = |
| 1789 static_cast<RenderPassDrawQuad*>(root_pass->quad_list.front()); | 1800 static_cast<RenderPassDrawQuad*>(root_pass->quad_list.front()); |
| 1790 quad->background_filters.Append(FilterOperation::CreateBlurFilter(2)); | 1801 quad->background_filters.Append(FilterOperation::CreateBlurFilter(2)); |
| 1791 root_pass->damage_rect = gfx::Rect(10, 10, 2, 2); | 1802 root_pass->damage_rect = gfx::Rect(10, 10, 2, 2); |
| 1792 SubmitPassListAsFrame(root_surface_id_, &root_pass_list); | 1803 SubmitPassListAsFrame(&factory_, root_surface_id_, &root_pass_list); |
| 1793 } | 1804 } |
| 1794 | 1805 |
| 1795 { | 1806 { |
| 1796 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id_); | 1807 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id_); |
| 1797 | 1808 |
| 1798 ASSERT_TRUE(aggregated_frame.delegated_frame_data); | 1809 ASSERT_TRUE(aggregated_frame.delegated_frame_data); |
| 1799 | 1810 |
| 1800 DelegatedFrameData* frame_data = | 1811 DelegatedFrameData* frame_data = |
| 1801 aggregated_frame.delegated_frame_data.get(); | 1812 aggregated_frame.delegated_frame_data.get(); |
| 1802 | 1813 |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1904 } | 1915 } |
| 1905 frame_data->render_pass_list.push_back(std::move(pass)); | 1916 frame_data->render_pass_list.push_back(std::move(pass)); |
| 1906 CompositorFrame frame; | 1917 CompositorFrame frame; |
| 1907 frame.delegated_frame_data = std::move(frame_data); | 1918 frame.delegated_frame_data = std::move(frame_data); |
| 1908 factory->SubmitCompositorFrame(surface_id, std::move(frame), | 1919 factory->SubmitCompositorFrame(surface_id, std::move(frame), |
| 1909 SurfaceFactory::DrawCallback()); | 1920 SurfaceFactory::DrawCallback()); |
| 1910 } | 1921 } |
| 1911 | 1922 |
| 1912 TEST_F(SurfaceAggregatorWithResourcesTest, TakeResourcesOneSurface) { | 1923 TEST_F(SurfaceAggregatorWithResourcesTest, TakeResourcesOneSurface) { |
| 1913 ResourceTrackingSurfaceFactoryClient client; | 1924 ResourceTrackingSurfaceFactoryClient client; |
| 1914 SurfaceFactory factory(&manager_, &client); | 1925 SurfaceFactory factory(kArbitraryFrameSinkId, &manager_, &client); |
| 1915 SurfaceId surface_id(kArbitraryFrameSinkId, 7u, 0); | 1926 SurfaceId surface_id(kArbitraryFrameSinkId, 7u, 0); |
| 1916 factory.Create(surface_id); | 1927 factory.Create(surface_id); |
| 1917 | 1928 |
| 1918 ResourceId ids[] = {11, 12, 13}; | 1929 ResourceId ids[] = {11, 12, 13}; |
| 1919 SubmitCompositorFrameWithResources(ids, arraysize(ids), true, SurfaceId(), | 1930 SubmitCompositorFrameWithResources(ids, arraysize(ids), true, SurfaceId(), |
| 1920 &factory, surface_id); | 1931 &factory, surface_id); |
| 1921 | 1932 |
| 1922 CompositorFrame frame = aggregator_->Aggregate(surface_id); | 1933 CompositorFrame frame = aggregator_->Aggregate(surface_id); |
| 1923 | 1934 |
| 1924 // Nothing should be available to be returned yet. | 1935 // Nothing should be available to be returned yet. |
| 1925 EXPECT_TRUE(client.returned_resources().empty()); | 1936 EXPECT_TRUE(client.returned_resources().empty()); |
| 1926 | 1937 |
| 1927 SubmitCompositorFrameWithResources(NULL, 0u, true, SurfaceId(), &factory, | 1938 SubmitCompositorFrameWithResources(NULL, 0u, true, SurfaceId(), &factory, |
| 1928 surface_id); | 1939 surface_id); |
| 1929 | 1940 |
| 1930 frame = aggregator_->Aggregate(surface_id); | 1941 frame = aggregator_->Aggregate(surface_id); |
| 1931 | 1942 |
| 1932 ASSERT_EQ(3u, client.returned_resources().size()); | 1943 ASSERT_EQ(3u, client.returned_resources().size()); |
| 1933 ResourceId returned_ids[3]; | 1944 ResourceId returned_ids[3]; |
| 1934 for (size_t i = 0; i < 3; ++i) { | 1945 for (size_t i = 0; i < 3; ++i) { |
| 1935 returned_ids[i] = client.returned_resources()[i].id; | 1946 returned_ids[i] = client.returned_resources()[i].id; |
| 1936 } | 1947 } |
| 1937 EXPECT_THAT(returned_ids, | 1948 EXPECT_THAT(returned_ids, |
| 1938 testing::WhenSorted(testing::ElementsAreArray(ids))); | 1949 testing::WhenSorted(testing::ElementsAreArray(ids))); |
| 1939 factory.Destroy(surface_id); | 1950 factory.Destroy(surface_id); |
| 1940 } | 1951 } |
| 1941 | 1952 |
| 1942 TEST_F(SurfaceAggregatorWithResourcesTest, TakeInvalidResources) { | 1953 TEST_F(SurfaceAggregatorWithResourcesTest, TakeInvalidResources) { |
| 1943 ResourceTrackingSurfaceFactoryClient client; | 1954 ResourceTrackingSurfaceFactoryClient client; |
| 1944 SurfaceFactory factory(&manager_, &client); | 1955 SurfaceFactory factory(kArbitraryFrameSinkId, &manager_, &client); |
| 1945 SurfaceId surface_id(kArbitraryFrameSinkId, 7u, 0); | 1956 SurfaceId surface_id(kArbitraryFrameSinkId, 7u, 0); |
| 1946 factory.Create(surface_id); | 1957 factory.Create(surface_id); |
| 1947 | 1958 |
| 1948 std::unique_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData); | 1959 std::unique_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData); |
| 1949 std::unique_ptr<RenderPass> pass = RenderPass::Create(); | 1960 std::unique_ptr<RenderPass> pass = RenderPass::Create(); |
| 1950 pass->id = RenderPassId(1, 1); | 1961 pass->id = RenderPassId(1, 1); |
| 1951 TransferableResource resource; | 1962 TransferableResource resource; |
| 1952 resource.id = 11; | 1963 resource.id = 11; |
| 1953 // ResourceProvider is software but resource is not, so it should be | 1964 // ResourceProvider is software but resource is not, so it should be |
| 1954 // ignored. | 1965 // ignored. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1968 SubmitCompositorFrameWithResources(NULL, 0, true, SurfaceId(), &factory, | 1979 SubmitCompositorFrameWithResources(NULL, 0, true, SurfaceId(), &factory, |
| 1969 surface_id); | 1980 surface_id); |
| 1970 ASSERT_EQ(1u, client.returned_resources().size()); | 1981 ASSERT_EQ(1u, client.returned_resources().size()); |
| 1971 EXPECT_EQ(11u, client.returned_resources()[0].id); | 1982 EXPECT_EQ(11u, client.returned_resources()[0].id); |
| 1972 | 1983 |
| 1973 factory.Destroy(surface_id); | 1984 factory.Destroy(surface_id); |
| 1974 } | 1985 } |
| 1975 | 1986 |
| 1976 TEST_F(SurfaceAggregatorWithResourcesTest, TwoSurfaces) { | 1987 TEST_F(SurfaceAggregatorWithResourcesTest, TwoSurfaces) { |
| 1977 ResourceTrackingSurfaceFactoryClient client; | 1988 ResourceTrackingSurfaceFactoryClient client; |
| 1978 SurfaceFactory factory(&manager_, &client); | 1989 SurfaceFactory factory(kArbitraryFrameSinkId, &manager_, &client); |
| 1979 SurfaceId surface1_id(kArbitraryFrameSinkId, 7u, 0); | 1990 SurfaceId surface1_id(kArbitraryFrameSinkId, 7u, 0); |
| 1980 factory.Create(surface1_id); | 1991 factory.Create(surface1_id); |
| 1981 | 1992 |
| 1982 SurfaceId surface2_id(kArbitraryFrameSinkId, 8u, 0); | 1993 SurfaceId surface2_id(kArbitraryFrameSinkId, 8u, 0); |
| 1983 factory.Create(surface2_id); | 1994 factory.Create(surface2_id); |
| 1984 | 1995 |
| 1985 ResourceId ids[] = {11, 12, 13}; | 1996 ResourceId ids[] = {11, 12, 13}; |
| 1986 SubmitCompositorFrameWithResources(ids, arraysize(ids), true, SurfaceId(), | 1997 SubmitCompositorFrameWithResources(ids, arraysize(ids), true, SurfaceId(), |
| 1987 &factory, surface1_id); | 1998 &factory, surface1_id); |
| 1988 ResourceId ids2[] = {14, 15, 16}; | 1999 ResourceId ids2[] = {14, 15, 16}; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 2009 testing::WhenSorted(testing::ElementsAreArray(ids))); | 2020 testing::WhenSorted(testing::ElementsAreArray(ids))); |
| 2010 EXPECT_EQ(3u, resource_provider_->num_resources()); | 2021 EXPECT_EQ(3u, resource_provider_->num_resources()); |
| 2011 factory.Destroy(surface1_id); | 2022 factory.Destroy(surface1_id); |
| 2012 factory.Destroy(surface2_id); | 2023 factory.Destroy(surface2_id); |
| 2013 } | 2024 } |
| 2014 | 2025 |
| 2015 // Ensure that aggregator completely ignores Surfaces that reference invalid | 2026 // Ensure that aggregator completely ignores Surfaces that reference invalid |
| 2016 // resources. | 2027 // resources. |
| 2017 TEST_F(SurfaceAggregatorWithResourcesTest, InvalidChildSurface) { | 2028 TEST_F(SurfaceAggregatorWithResourcesTest, InvalidChildSurface) { |
| 2018 ResourceTrackingSurfaceFactoryClient client; | 2029 ResourceTrackingSurfaceFactoryClient client; |
| 2019 SurfaceFactory factory(&manager_, &client); | 2030 SurfaceFactory factory(kArbitraryFrameSinkId, &manager_, &client); |
| 2020 SurfaceId root_surface_id(kArbitraryFrameSinkId, 7u, 0); | 2031 SurfaceId root_surface_id(kArbitraryFrameSinkId, 7u, 0); |
| 2021 factory.Create(root_surface_id); | 2032 factory.Create(root_surface_id); |
| 2022 SurfaceId middle_surface_id(kArbitraryFrameSinkId, 8u, 0); | 2033 SurfaceId middle_surface_id(kArbitraryFrameSinkId, 8u, 0); |
| 2023 factory.Create(middle_surface_id); | 2034 factory.Create(middle_surface_id); |
| 2024 SurfaceId child_surface_id(kArbitraryFrameSinkId, 9u, 0); | 2035 SurfaceId child_surface_id(kArbitraryFrameSinkId, 9u, 0); |
| 2025 factory.Create(child_surface_id); | 2036 factory.Create(child_surface_id); |
| 2026 | 2037 |
| 2027 ResourceId ids[] = {14, 15, 16}; | 2038 ResourceId ids[] = {14, 15, 16}; |
| 2028 SubmitCompositorFrameWithResources(ids, arraysize(ids), true, SurfaceId(), | 2039 SubmitCompositorFrameWithResources(ids, arraysize(ids), true, SurfaceId(), |
| 2029 &factory, child_surface_id); | 2040 &factory, child_surface_id); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 2057 EXPECT_EQ(3u, pass_list->back()->shared_quad_state_list.size()); | 2068 EXPECT_EQ(3u, pass_list->back()->shared_quad_state_list.size()); |
| 2058 EXPECT_EQ(9u, pass_list->back()->quad_list.size()); | 2069 EXPECT_EQ(9u, pass_list->back()->quad_list.size()); |
| 2059 | 2070 |
| 2060 factory.Destroy(root_surface_id); | 2071 factory.Destroy(root_surface_id); |
| 2061 factory.Destroy(child_surface_id); | 2072 factory.Destroy(child_surface_id); |
| 2062 factory.Destroy(middle_surface_id); | 2073 factory.Destroy(middle_surface_id); |
| 2063 } | 2074 } |
| 2064 | 2075 |
| 2065 TEST_F(SurfaceAggregatorWithResourcesTest, SecureOutputTexture) { | 2076 TEST_F(SurfaceAggregatorWithResourcesTest, SecureOutputTexture) { |
| 2066 ResourceTrackingSurfaceFactoryClient client; | 2077 ResourceTrackingSurfaceFactoryClient client; |
| 2067 SurfaceFactory factory(&manager_, &client); | 2078 SurfaceFactory factory(kArbitraryFrameSinkId, &manager_, &client); |
| 2068 SurfaceId surface1_id(kArbitraryFrameSinkId, 7u, 0); | 2079 SurfaceId surface1_id(kArbitraryFrameSinkId, 7u, 0); |
| 2069 factory.Create(surface1_id); | 2080 factory.Create(surface1_id); |
| 2070 | 2081 |
| 2071 SurfaceId surface2_id(kArbitraryFrameSinkId, 8u, 0); | 2082 SurfaceId surface2_id(kArbitraryFrameSinkId, 8u, 0); |
| 2072 factory.Create(surface2_id); | 2083 factory.Create(surface2_id); |
| 2073 | 2084 |
| 2074 ResourceId ids[] = {11, 12, 13}; | 2085 ResourceId ids[] = {11, 12, 13}; |
| 2075 SubmitCompositorFrameWithResources(ids, arraysize(ids), true, SurfaceId(), | 2086 SubmitCompositorFrameWithResources(ids, arraysize(ids), true, SurfaceId(), |
| 2076 &factory, surface1_id); | 2087 &factory, surface1_id); |
| 2077 | 2088 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2124 // Output is insecure, so texture should be drawn. | 2135 // Output is insecure, so texture should be drawn. |
| 2125 EXPECT_EQ(DrawQuad::SOLID_COLOR, render_pass->quad_list.back()->material); | 2136 EXPECT_EQ(DrawQuad::SOLID_COLOR, render_pass->quad_list.back()->material); |
| 2126 | 2137 |
| 2127 factory.Destroy(surface1_id); | 2138 factory.Destroy(surface1_id); |
| 2128 factory.Destroy(surface2_id); | 2139 factory.Destroy(surface2_id); |
| 2129 } | 2140 } |
| 2130 | 2141 |
| 2131 } // namespace | 2142 } // namespace |
| 2132 } // namespace cc | 2143 } // namespace cc |
| 2133 | 2144 |
| OLD | NEW |