OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/layers/picture_layer_impl.h" | 5 #include "cc/layers/picture_layer_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <set> | 9 #include <set> |
10 #include <utility> | 10 #include <utility> |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
263 // This test verifies that when drawing the contents of a specific tile | 263 // This test verifies that when drawing the contents of a specific tile |
264 // at content scale 1.0, the playback canvas never receives content from | 264 // at content scale 1.0, the playback canvas never receives content from |
265 // neighboring tiles which indicates that the tile grid embedded in | 265 // neighboring tiles which indicates that the tile grid embedded in |
266 // SkPicture is perfectly aligned with the compositor's tiles. | 266 // SkPicture is perfectly aligned with the compositor's tiles. |
267 EXPECT_EQ(1u, mock_canvas.rects_.size()); | 267 EXPECT_EQ(1u, mock_canvas.rects_.size()); |
268 EXPECT_RECT_EQ(*rect_iter, mock_canvas.rects_[0]); | 268 EXPECT_RECT_EQ(*rect_iter, mock_canvas.rects_[0]); |
269 rect_iter++; | 269 rect_iter++; |
270 } | 270 } |
271 } | 271 } |
272 | 272 |
273 void TestQuadsForSolidColor(bool test_for_solid); | |
274 | |
273 FakeImplProxy proxy_; | 275 FakeImplProxy proxy_; |
274 TestSharedBitmapManager shared_bitmap_manager_; | 276 TestSharedBitmapManager shared_bitmap_manager_; |
275 FakeLayerTreeHostImpl host_impl_; | 277 FakeLayerTreeHostImpl host_impl_; |
276 int id_; | 278 int id_; |
277 FakePictureLayerImpl* pending_layer_; | 279 FakePictureLayerImpl* pending_layer_; |
278 FakePictureLayerImpl* old_pending_layer_; | 280 FakePictureLayerImpl* old_pending_layer_; |
279 FakePictureLayerImpl* active_layer_; | 281 FakePictureLayerImpl* active_layer_; |
280 | 282 |
281 private: | 283 private: |
282 DISALLOW_COPY_AND_ASSIGN(PictureLayerImplTest); | 284 DISALLOW_COPY_AND_ASSIGN(PictureLayerImplTest); |
(...skipping 3932 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4215 EXPECT_FALSE(active_layer_->GetRecycledTwinLayer()); | 4217 EXPECT_FALSE(active_layer_->GetRecycledTwinLayer()); |
4216 | 4218 |
4217 ActivateTree(); | 4219 ActivateTree(); |
4218 EXPECT_TRUE(active_layer_->GetRecycledTwinLayer()); | 4220 EXPECT_TRUE(active_layer_->GetRecycledTwinLayer()); |
4219 EXPECT_EQ(old_pending_layer_, active_layer_->GetRecycledTwinLayer()); | 4221 EXPECT_EQ(old_pending_layer_, active_layer_->GetRecycledTwinLayer()); |
4220 | 4222 |
4221 host_impl_.ResetRecycleTreeForTesting(); | 4223 host_impl_.ResetRecycleTreeForTesting(); |
4222 EXPECT_FALSE(active_layer_->GetRecycledTwinLayer()); | 4224 EXPECT_FALSE(active_layer_->GetRecycledTwinLayer()); |
4223 } | 4225 } |
4224 | 4226 |
4227 void PictureLayerImplTest::TestQuadsForSolidColor(bool test_for_solid) { | |
4228 base::TimeTicks time_ticks; | |
4229 time_ticks += base::TimeDelta::FromMilliseconds(1); | |
4230 host_impl_.SetCurrentBeginFrameArgs( | |
4231 CreateBeginFrameArgsForTesting(time_ticks)); | |
4232 | |
4233 gfx::Size tile_size(100, 100); | |
4234 gfx::Size layer_bounds(200, 200); | |
4235 gfx::Rect layer_rect(layer_bounds); | |
4236 | |
4237 FakeContentLayerClient client; | |
4238 scoped_refptr<PictureLayer> layer = PictureLayer::Create(&client); | |
4239 scoped_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create(); | |
4240 host->SetRootLayer(layer); | |
4241 PicturePile* pile = layer->GetPicturePileForTesting(); | |
4242 | |
4243 host_impl_.SetViewportSize(layer_bounds); | |
4244 | |
4245 int frame_number = 0; | |
4246 FakeRenderingStatsInstrumentation stats_instrumentation; | |
4247 | |
4248 client.set_fill_with_nonsolid_color(!test_for_solid); | |
4249 | |
4250 Region invalidation(layer_rect); | |
4251 pile->UpdateAndExpandInvalidation(&client, | |
4252 &invalidation, | |
4253 SK_ColorWHITE, | |
4254 false, | |
4255 false, | |
4256 layer_bounds, | |
4257 layer_rect, | |
4258 frame_number++, | |
4259 Picture::RECORD_NORMALLY, | |
4260 &stats_instrumentation); | |
4261 | |
4262 scoped_refptr<PicturePileImpl> pending_pile = | |
4263 PicturePileImpl::CreateFromOther(pile); | |
4264 | |
4265 SetupPendingTree(pending_pile); | |
4266 ActivateTree(); | |
4267 | |
4268 if (test_for_solid) { | |
4269 EXPECT_EQ(0, active_layer_->tilings()->num_tilings()); | |
danakj
2014/09/19 20:44:28
0u
hendrikw
2014/09/19 22:27:13
Acknowledged.
| |
4270 } else { | |
4271 ASSERT_TRUE(active_layer_->tilings()); | |
4272 active_layer_->set_fixed_tile_size(tile_size); | |
4273 host_impl_.active_tree()->UpdateDrawProperties(); | |
4274 ASSERT_GT(active_layer_->tilings()->num_tilings(), 0u); | |
4275 std::vector<Tile*> tiles = | |
4276 active_layer_->tilings()->tiling_at(0)->AllTilesForTesting(); | |
4277 EXPECT_FALSE(tiles.empty()); | |
4278 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles); | |
4279 } | |
4280 | |
4281 MockOcclusionTracker<LayerImpl> occlusion_tracker; | |
4282 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); | |
4283 AppendQuadsData data; | |
4284 active_layer_->WillDraw(DRAW_MODE_SOFTWARE, NULL); | |
4285 active_layer_->AppendQuads(render_pass.get(), occlusion_tracker, &data); | |
4286 active_layer_->DidDraw(NULL); | |
4287 | |
4288 DrawQuad::Material expected = test_for_solid | |
4289 ? DrawQuad::Material::SOLID_COLOR | |
4290 : DrawQuad::Material::TILED_CONTENT; | |
4291 EXPECT_EQ(expected, render_pass->quad_list.front()->material); | |
4292 } | |
4293 | |
4294 TEST_F(PictureLayerImplTest, DrawSolidQuads) { | |
4295 TestQuadsForSolidColor(true); | |
4296 } | |
4297 | |
4298 TEST_F(PictureLayerImplTest, DrawNonSolidQuads) { | |
4299 TestQuadsForSolidColor(false); | |
4300 } | |
4301 | |
4302 TEST_F(PictureLayerImplTest, NonSolidToSolidNoTilings) { | |
4303 base::TimeTicks time_ticks; | |
4304 time_ticks += base::TimeDelta::FromMilliseconds(1); | |
4305 host_impl_.SetCurrentBeginFrameArgs( | |
4306 CreateBeginFrameArgsForTesting(time_ticks)); | |
4307 | |
4308 gfx::Size tile_size(100, 100); | |
4309 gfx::Size layer_bounds(200, 200); | |
4310 gfx::Rect layer_rect(layer_bounds); | |
4311 | |
4312 FakeContentLayerClient client; | |
4313 scoped_refptr<PictureLayer> layer = PictureLayer::Create(&client); | |
4314 scoped_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create(); | |
4315 host->SetRootLayer(layer); | |
4316 PicturePile* pile = layer->GetPicturePileForTesting(); | |
4317 | |
4318 host_impl_.SetViewportSize(layer_bounds); | |
4319 | |
4320 int frame_number = 0; | |
4321 FakeRenderingStatsInstrumentation stats_instrumentation; | |
4322 | |
4323 client.set_fill_with_nonsolid_color(true); | |
4324 | |
4325 Region invalidation1(layer_rect); | |
4326 pile->UpdateAndExpandInvalidation(&client, | |
4327 &invalidation1, | |
4328 SK_ColorWHITE, | |
4329 false, | |
4330 false, | |
4331 layer_bounds, | |
4332 layer_rect, | |
4333 frame_number++, | |
4334 Picture::RECORD_NORMALLY, | |
4335 &stats_instrumentation); | |
4336 | |
4337 scoped_refptr<PicturePileImpl> pending_pile1 = | |
4338 PicturePileImpl::CreateFromOther(pile); | |
4339 | |
4340 SetupPendingTree(pending_pile1); | |
4341 ActivateTree(); | |
4342 host_impl_.active_tree()->UpdateDrawProperties(); | |
4343 | |
4344 // We've started with a solid layer that contains some tilings. | |
4345 ASSERT_TRUE(active_layer_->tilings()); | |
4346 EXPECT_NE(size_t(0), active_layer_->tilings()->num_tilings()); | |
danakj
2014/09/19 20:44:28
nit: s/size_t(0)/0u/
hendrikw
2014/09/19 22:27:13
:/ Acknowledged.
| |
4347 | |
4348 client.set_fill_with_nonsolid_color(false); | |
4349 | |
4350 Region invalidation2(layer_rect); | |
4351 pile->UpdateAndExpandInvalidation(&client, | |
4352 &invalidation2, | |
4353 SK_ColorWHITE, | |
4354 false, | |
4355 false, | |
4356 layer_bounds, | |
4357 layer_rect, | |
4358 frame_number++, | |
4359 Picture::RECORD_NORMALLY, | |
4360 &stats_instrumentation); | |
4361 | |
4362 scoped_refptr<PicturePileImpl> pending_pile2 = | |
4363 PicturePileImpl::CreateFromOther(pile); | |
4364 | |
4365 SetupPendingTree(pending_pile2); | |
4366 ActivateTree(); | |
4367 | |
4368 // We've switched to a solid color, so we should end up with no tilings. | |
4369 ASSERT_TRUE(active_layer_->tilings()); | |
4370 EXPECT_EQ(0, active_layer_->tilings()->num_tilings()); | |
danakj
2014/09/19 20:44:28
0u
hendrikw
2014/09/19 22:27:13
Acknowledged.
| |
4371 } | |
4372 | |
4225 } // namespace | 4373 } // namespace |
4226 } // namespace cc | 4374 } // namespace cc |
OLD | NEW |