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 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 | 291 |
292 EXPECT_EQ(pending_layer_->tilings()->num_tilings(), | 292 EXPECT_EQ(pending_layer_->tilings()->num_tilings(), |
293 active_layer_->tilings()->num_tilings()); | 293 active_layer_->tilings()->num_tilings()); |
294 | 294 |
295 const PictureLayerTilingSet* tilings = pending_layer_->tilings(); | 295 const PictureLayerTilingSet* tilings = pending_layer_->tilings(); |
296 EXPECT_GT(tilings->num_tilings(), 0u); | 296 EXPECT_GT(tilings->num_tilings(), 0u); |
297 for (size_t i = 0; i < tilings->num_tilings(); ++i) | 297 for (size_t i = 0; i < tilings->num_tilings(); ++i) |
298 VerifyAllTilesExistAndHavePile(tilings->tiling_at(i), active_pile.get()); | 298 VerifyAllTilesExistAndHavePile(tilings->tiling_at(i), active_pile.get()); |
299 } | 299 } |
300 | 300 |
301 TEST_F(PictureLayerImplTest, TileManagerRegisterUnregister) { | |
302 gfx::Size tile_size(100, 100); | |
303 gfx::Size layer_bounds(400, 400); | |
304 | |
305 scoped_refptr<FakePicturePileImpl> pending_pile = | |
306 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | |
307 scoped_refptr<FakePicturePileImpl> active_pile = | |
308 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | |
309 | |
310 SetupTrees(pending_pile, active_pile); | |
311 | |
312 std::vector<TileManager::PairedPictureLayer> paired_layers; | |
313 host_impl_.tile_manager()->GetPairedPictureLayers(&paired_layers); | |
314 EXPECT_EQ(0u, paired_layers.size()); | |
315 | |
316 // Update tile priorities will force the layer to register itself. | |
317 float dummy_contents_scale_x; | |
318 float dummy_contents_scale_y; | |
319 gfx::Size dummy_content_bounds; | |
320 active_layer_->CalculateContentsScale(1.f, | |
321 1.f, | |
322 1.f, | |
323 1.f, | |
324 false, | |
325 &dummy_contents_scale_x, | |
326 &dummy_contents_scale_y, | |
327 &dummy_content_bounds); | |
328 active_layer_->UpdateTilePriorities(); | |
329 host_impl_.pending_tree()->UpdateDrawProperties(); | |
330 pending_layer_->CalculateContentsScale(1.f, | |
331 1.f, | |
332 1.f, | |
333 1.f, | |
334 false, | |
335 &dummy_contents_scale_x, | |
336 &dummy_contents_scale_y, | |
337 &dummy_content_bounds); | |
338 pending_layer_->UpdateTilePriorities(); | |
339 | |
340 host_impl_.tile_manager()->GetPairedPictureLayers(&paired_layers); | |
341 EXPECT_EQ(1u, paired_layers.size()); | |
342 EXPECT_EQ(active_layer_, paired_layers[0].active_layer); | |
343 EXPECT_EQ(pending_layer_, paired_layers[0].pending_layer); | |
344 | |
345 // Destroy and recreate tile manager. | |
346 host_impl_.DidLoseOutputSurface(); | |
347 scoped_ptr<TestWebGraphicsContext3D> context = | |
348 TestWebGraphicsContext3D::Create(); | |
349 host_impl_.InitializeRenderer( | |
350 FakeOutputSurface::Create3d(context.Pass()).PassAs<OutputSurface>()); | |
351 | |
352 host_impl_.tile_manager()->GetPairedPictureLayers(&paired_layers); | |
353 EXPECT_EQ(0u, paired_layers.size()); | |
354 | |
355 active_layer_->CalculateContentsScale(1.f, | |
356 1.f, | |
357 1.f, | |
358 1.f, | |
359 false, | |
360 &dummy_contents_scale_x, | |
361 &dummy_contents_scale_y, | |
362 &dummy_content_bounds); | |
363 active_layer_->UpdateTilePriorities(); | |
364 host_impl_.pending_tree()->UpdateDrawProperties(); | |
365 pending_layer_->CalculateContentsScale(1.f, | |
366 1.f, | |
367 1.f, | |
368 1.f, | |
369 false, | |
370 &dummy_contents_scale_x, | |
371 &dummy_contents_scale_y, | |
372 &dummy_content_bounds); | |
373 pending_layer_->UpdateTilePriorities(); | |
374 | |
375 host_impl_.tile_manager()->GetPairedPictureLayers(&paired_layers); | |
376 EXPECT_EQ(1u, paired_layers.size()); | |
377 EXPECT_EQ(active_layer_, paired_layers[0].active_layer); | |
378 EXPECT_EQ(pending_layer_, paired_layers[0].pending_layer); | |
379 } | |
380 | |
381 TEST_F(PictureLayerImplTest, InvalidViewportForPrioritizingTiles) { | 301 TEST_F(PictureLayerImplTest, InvalidViewportForPrioritizingTiles) { |
382 base::TimeTicks time_ticks; | 302 base::TimeTicks time_ticks; |
383 host_impl_.SetCurrentFrameTimeTicks(time_ticks); | 303 host_impl_.SetCurrentFrameTimeTicks(time_ticks); |
384 | 304 |
385 gfx::Size tile_size(100, 100); | 305 gfx::Size tile_size(100, 100); |
386 gfx::Size layer_bounds(400, 400); | 306 gfx::Size layer_bounds(400, 400); |
387 | 307 |
388 scoped_refptr<FakePicturePileImpl> pending_pile = | 308 scoped_refptr<FakePicturePileImpl> pending_pile = |
389 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 309 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
390 scoped_refptr<FakePicturePileImpl> active_pile = | 310 scoped_refptr<FakePicturePileImpl> active_pile = |
(...skipping 2203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2594 EXPECT_EQ(active_layer_->HighResTiling()->AllTilesForTesting().size(), 0u); | 2514 EXPECT_EQ(active_layer_->HighResTiling()->AllTilesForTesting().size(), 0u); |
2595 | 2515 |
2596 // Since the active layer has no tiles at all, the pending layer doesn't | 2516 // Since the active layer has no tiles at all, the pending layer doesn't |
2597 // need content in order to activate. | 2517 // need content in order to activate. |
2598 pending_layer_->MarkVisibleResourcesAsRequired(); | 2518 pending_layer_->MarkVisibleResourcesAsRequired(); |
2599 AssertNoTilesRequired(pending_layer_->HighResTiling()); | 2519 AssertNoTilesRequired(pending_layer_->HighResTiling()); |
2600 if (host_impl_.settings().create_low_res_tiling) | 2520 if (host_impl_.settings().create_low_res_tiling) |
2601 AssertNoTilesRequired(pending_layer_->LowResTiling()); | 2521 AssertNoTilesRequired(pending_layer_->LowResTiling()); |
2602 } | 2522 } |
2603 | 2523 |
2604 TEST_F(NoLowResPictureLayerImplTest, TileManagerRegisterUnregister) { | |
2605 gfx::Size tile_size(100, 100); | |
2606 gfx::Size layer_bounds(400, 400); | |
2607 | |
2608 scoped_refptr<FakePicturePileImpl> pending_pile = | |
2609 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | |
2610 scoped_refptr<FakePicturePileImpl> active_pile = | |
2611 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | |
2612 | |
2613 SetupTrees(pending_pile, active_pile); | |
2614 | |
2615 std::vector<TileManager::PairedPictureLayer> paired_layers; | |
2616 host_impl_.tile_manager()->GetPairedPictureLayers(&paired_layers); | |
2617 EXPECT_EQ(0u, paired_layers.size()); | |
2618 | |
2619 // Update tile priorities will force the layer to register itself. | |
2620 float dummy_contents_scale_x; | |
2621 float dummy_contents_scale_y; | |
2622 gfx::Size dummy_content_bounds; | |
2623 active_layer_->CalculateContentsScale(1.f, | |
2624 1.f, | |
2625 1.f, | |
2626 1.f, | |
2627 false, | |
2628 &dummy_contents_scale_x, | |
2629 &dummy_contents_scale_y, | |
2630 &dummy_content_bounds); | |
2631 active_layer_->UpdateTilePriorities(); | |
2632 host_impl_.pending_tree()->UpdateDrawProperties(); | |
2633 pending_layer_->CalculateContentsScale(1.f, | |
2634 1.f, | |
2635 1.f, | |
2636 1.f, | |
2637 false, | |
2638 &dummy_contents_scale_x, | |
2639 &dummy_contents_scale_y, | |
2640 &dummy_content_bounds); | |
2641 pending_layer_->UpdateTilePriorities(); | |
2642 | |
2643 host_impl_.tile_manager()->GetPairedPictureLayers(&paired_layers); | |
2644 EXPECT_EQ(1u, paired_layers.size()); | |
2645 EXPECT_EQ(active_layer_, paired_layers[0].active_layer); | |
2646 EXPECT_EQ(pending_layer_, paired_layers[0].pending_layer); | |
2647 | |
2648 // Destroy and recreate tile manager. | |
2649 host_impl_.DidLoseOutputSurface(); | |
2650 scoped_ptr<TestWebGraphicsContext3D> context = | |
2651 TestWebGraphicsContext3D::Create(); | |
2652 host_impl_.InitializeRenderer( | |
2653 FakeOutputSurface::Create3d(context.Pass()).PassAs<OutputSurface>()); | |
2654 | |
2655 host_impl_.tile_manager()->GetPairedPictureLayers(&paired_layers); | |
2656 EXPECT_EQ(0u, paired_layers.size()); | |
2657 | |
2658 active_layer_->CalculateContentsScale(1.f, | |
2659 1.f, | |
2660 1.f, | |
2661 1.f, | |
2662 false, | |
2663 &dummy_contents_scale_x, | |
2664 &dummy_contents_scale_y, | |
2665 &dummy_content_bounds); | |
2666 active_layer_->UpdateTilePriorities(); | |
2667 host_impl_.pending_tree()->UpdateDrawProperties(); | |
2668 pending_layer_->CalculateContentsScale(1.f, | |
2669 1.f, | |
2670 1.f, | |
2671 1.f, | |
2672 false, | |
2673 &dummy_contents_scale_x, | |
2674 &dummy_contents_scale_y, | |
2675 &dummy_content_bounds); | |
2676 pending_layer_->UpdateTilePriorities(); | |
2677 | |
2678 host_impl_.tile_manager()->GetPairedPictureLayers(&paired_layers); | |
2679 EXPECT_EQ(1u, paired_layers.size()); | |
2680 EXPECT_EQ(active_layer_, paired_layers[0].active_layer); | |
2681 EXPECT_EQ(pending_layer_, paired_layers[0].pending_layer); | |
2682 } | |
2683 | |
2684 TEST_F(NoLowResPictureLayerImplTest, InvalidViewportForPrioritizingTiles) { | 2524 TEST_F(NoLowResPictureLayerImplTest, InvalidViewportForPrioritizingTiles) { |
2685 base::TimeTicks time_ticks; | 2525 base::TimeTicks time_ticks; |
2686 host_impl_.SetCurrentFrameTimeTicks(time_ticks); | 2526 host_impl_.SetCurrentFrameTimeTicks(time_ticks); |
2687 | 2527 |
2688 gfx::Size tile_size(100, 100); | 2528 gfx::Size tile_size(100, 100); |
2689 gfx::Size layer_bounds(400, 400); | 2529 gfx::Size layer_bounds(400, 400); |
2690 | 2530 |
2691 scoped_refptr<FakePicturePileImpl> pending_pile = | 2531 scoped_refptr<FakePicturePileImpl> pending_pile = |
2692 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 2532 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
2693 scoped_refptr<FakePicturePileImpl> active_pile = | 2533 scoped_refptr<FakePicturePileImpl> active_pile = |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3035 1.f, // maximum animation scale | 2875 1.f, // maximum animation scale |
3036 false, | 2876 false, |
3037 &result_scale_x, | 2877 &result_scale_x, |
3038 &result_scale_y, | 2878 &result_scale_y, |
3039 &result_bounds); | 2879 &result_bounds); |
3040 EXPECT_EQ(1u, pending_layer_->tilings()->num_tilings()); | 2880 EXPECT_EQ(1u, pending_layer_->tilings()->num_tilings()); |
3041 } | 2881 } |
3042 | 2882 |
3043 } // namespace | 2883 } // namespace |
3044 } // namespace cc | 2884 } // namespace cc |
OLD | NEW |