OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 | 10 |
(...skipping 13 matching lines...) Expand all Loading... |
24 #include "cc/quads/solid_color_draw_quad.h" | 24 #include "cc/quads/solid_color_draw_quad.h" |
25 #include "cc/quads/tile_draw_quad.h" | 25 #include "cc/quads/tile_draw_quad.h" |
26 #include "cc/resources/tile_manager.h" | 26 #include "cc/resources/tile_manager.h" |
27 #include "cc/trees/layer_tree_impl.h" | 27 #include "cc/trees/layer_tree_impl.h" |
28 #include "cc/trees/occlusion.h" | 28 #include "cc/trees/occlusion.h" |
29 #include "ui/gfx/geometry/quad_f.h" | 29 #include "ui/gfx/geometry/quad_f.h" |
30 #include "ui/gfx/geometry/rect_conversions.h" | 30 #include "ui/gfx/geometry/rect_conversions.h" |
31 #include "ui/gfx/geometry/size_conversions.h" | 31 #include "ui/gfx/geometry/size_conversions.h" |
32 | 32 |
33 namespace { | 33 namespace { |
| 34 // This must be > 1 as we multiply or divide by this to find a new raster |
| 35 // scale during pinch. |
34 const float kMaxScaleRatioDuringPinch = 2.0f; | 36 const float kMaxScaleRatioDuringPinch = 2.0f; |
35 | 37 |
36 // When creating a new tiling during pinch, snap to an existing | 38 // When creating a new tiling during pinch, snap to an existing |
37 // tiling's scale if the desired scale is within this ratio. | 39 // tiling's scale if the desired scale is within this ratio. |
38 const float kSnapToExistingTilingRatio = 1.2f; | 40 const float kSnapToExistingTilingRatio = 1.2f; |
39 | 41 |
40 // Estimate skewport 60 frames ahead for pre-rasterization on the CPU. | 42 // Estimate skewport 60 frames ahead for pre-rasterization on the CPU. |
41 const float kCpuSkewportTargetTimeInFrames = 60.0f; | 43 const float kCpuSkewportTargetTimeInFrames = 60.0f; |
42 | 44 |
43 // Don't pre-rasterize on the GPU (except for kBackflingGuardDistancePixels in | 45 // Don't pre-rasterize on the GPU (except for kBackflingGuardDistancePixels in |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 ideal_contents_scale_(0.f), | 80 ideal_contents_scale_(0.f), |
79 raster_page_scale_(0.f), | 81 raster_page_scale_(0.f), |
80 raster_device_scale_(0.f), | 82 raster_device_scale_(0.f), |
81 raster_source_scale_(0.f), | 83 raster_source_scale_(0.f), |
82 raster_contents_scale_(0.f), | 84 raster_contents_scale_(0.f), |
83 low_res_raster_contents_scale_(0.f), | 85 low_res_raster_contents_scale_(0.f), |
84 raster_source_scale_is_fixed_(false), | 86 raster_source_scale_is_fixed_(false), |
85 was_screen_space_transform_animating_(false), | 87 was_screen_space_transform_animating_(false), |
86 needs_post_commit_initialization_(true), | 88 needs_post_commit_initialization_(true), |
87 should_update_tile_priorities_(false), | 89 should_update_tile_priorities_(false), |
88 only_used_low_res_last_append_quads_(false) { | 90 only_used_low_res_last_append_quads_(false), |
| 91 is_mask_(false) { |
89 layer_tree_impl()->RegisterPictureLayerImpl(this); | 92 layer_tree_impl()->RegisterPictureLayerImpl(this); |
90 } | 93 } |
91 | 94 |
92 PictureLayerImpl::~PictureLayerImpl() { | 95 PictureLayerImpl::~PictureLayerImpl() { |
93 if (twin_layer_) | 96 if (twin_layer_) |
94 twin_layer_->twin_layer_ = nullptr; | 97 twin_layer_->twin_layer_ = nullptr; |
95 layer_tree_impl()->UnregisterPictureLayerImpl(this); | 98 layer_tree_impl()->UnregisterPictureLayerImpl(this); |
96 } | 99 } |
97 | 100 |
98 const char* PictureLayerImpl::LayerTypeAsString() const { | 101 const char* PictureLayerImpl::LayerTypeAsString() const { |
(...skipping 18 matching lines...) Expand all Loading... |
117 DCHECK_IMPLIES(twin_layer_, layer_impl->twin_layer_ == this); | 120 DCHECK_IMPLIES(twin_layer_, layer_impl->twin_layer_ == this); |
118 // The twin relationship does not need to exist before the first | 121 // The twin relationship does not need to exist before the first |
119 // PushPropertiesTo from pending to active layer since before that the active | 122 // PushPropertiesTo from pending to active layer since before that the active |
120 // layer can not have a pile or tilings, it has only been created and inserted | 123 // layer can not have a pile or tilings, it has only been created and inserted |
121 // into the tree at that point. | 124 // into the tree at that point. |
122 twin_layer_ = layer_impl; | 125 twin_layer_ = layer_impl; |
123 layer_impl->twin_layer_ = this; | 126 layer_impl->twin_layer_ = this; |
124 | 127 |
125 layer_impl->UpdateRasterSource(raster_source_); | 128 layer_impl->UpdateRasterSource(raster_source_); |
126 | 129 |
127 DCHECK(!raster_source_->IsSolidColor() || !tilings_->num_tilings()); | 130 DCHECK_IMPLIES(raster_source_->IsSolidColor(), tilings_->num_tilings() == 0); |
128 // Tilings would be expensive to push, so we swap. | 131 // Tilings would be expensive to push, so we swap. |
129 layer_impl->tilings_.swap(tilings_); | 132 layer_impl->tilings_.swap(tilings_); |
130 layer_impl->tilings_->SetClient(layer_impl); | 133 layer_impl->tilings_->SetClient(layer_impl); |
131 if (tilings_) | 134 if (tilings_) |
132 tilings_->SetClient(this); | 135 tilings_->SetClient(this); |
133 | 136 |
134 // Ensure that the recycle tree doesn't have any unshared tiles. | 137 // Ensure that the recycle tree doesn't have any unshared tiles. |
135 if (tilings_ && raster_source_->IsSolidColor()) | 138 if (tilings_ && raster_source_->IsSolidColor()) |
136 tilings_->RemoveAllTilings(); | 139 tilings_->RemoveAllTilings(); |
137 | 140 |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
465 ideal_page_scale_ = 0.f; | 468 ideal_page_scale_ = 0.f; |
466 ideal_device_scale_ = 0.f; | 469 ideal_device_scale_ = 0.f; |
467 ideal_contents_scale_ = 0.f; | 470 ideal_contents_scale_ = 0.f; |
468 ideal_source_scale_ = 0.f; | 471 ideal_source_scale_ = 0.f; |
469 SanityCheckTilingState(); | 472 SanityCheckTilingState(); |
470 return; | 473 return; |
471 } | 474 } |
472 | 475 |
473 UpdateIdealScales(); | 476 UpdateIdealScales(); |
474 | 477 |
475 DCHECK(tilings_->num_tilings() > 0 || raster_contents_scale_ == 0.f) | 478 DCHECK_IMPLIES(tilings_->num_tilings() == 0, raster_contents_scale_ == 0.f) |
476 << "A layer with no tilings shouldn't have valid raster scales"; | 479 << "A layer with no tilings shouldn't have valid raster scales"; |
477 if (!raster_contents_scale_ || ShouldAdjustRasterScale()) { | 480 if (!raster_contents_scale_ || ShouldAdjustRasterScale()) { |
478 RecalculateRasterScales(); | 481 RecalculateRasterScales(); |
479 AddTilingsForRasterScale(); | 482 AddTilingsForRasterScale(); |
480 } | 483 } |
481 | 484 |
482 DCHECK(raster_page_scale_); | 485 DCHECK(raster_page_scale_); |
483 DCHECK(raster_device_scale_); | 486 DCHECK(raster_device_scale_); |
484 DCHECK(raster_source_scale_); | 487 DCHECK(raster_source_scale_); |
485 DCHECK(raster_contents_scale_); | 488 DCHECK(raster_contents_scale_); |
486 DCHECK(low_res_raster_contents_scale_); | 489 DCHECK(low_res_raster_contents_scale_); |
487 | 490 |
488 was_screen_space_transform_animating_ = | 491 was_screen_space_transform_animating_ = |
489 draw_properties().screen_space_transform_is_animating; | 492 draw_properties().screen_space_transform_is_animating; |
490 | 493 |
491 if (draw_transform_is_animating()) | 494 if (draw_transform_is_animating()) |
492 raster_source_->SetShouldAttemptToUseDistanceFieldText(); | 495 raster_source_->SetShouldAttemptToUseDistanceFieldText(); |
493 | 496 |
494 should_update_tile_priorities_ = true; | 497 should_update_tile_priorities_ = true; |
495 | 498 |
496 UpdateTilePriorities(occlusion_in_content_space); | 499 UpdateTilePriorities(occlusion_in_content_space); |
497 } | 500 } |
498 | 501 |
499 void PictureLayerImpl::UpdateTilePriorities( | 502 void PictureLayerImpl::UpdateTilePriorities( |
500 const Occlusion& occlusion_in_content_space) { | 503 const Occlusion& occlusion_in_content_space) { |
501 DCHECK(!raster_source_->IsSolidColor() || !tilings_->num_tilings()); | 504 DCHECK_IMPLIES(raster_source_->IsSolidColor(), tilings_->num_tilings() == 0); |
| 505 |
502 double current_frame_time_in_seconds = | 506 double current_frame_time_in_seconds = |
503 (layer_tree_impl()->CurrentBeginFrameArgs().frame_time - | 507 (layer_tree_impl()->CurrentBeginFrameArgs().frame_time - |
504 base::TimeTicks()).InSecondsF(); | 508 base::TimeTicks()).InSecondsF(); |
505 | |
506 gfx::Rect viewport_rect_in_layer_space = | 509 gfx::Rect viewport_rect_in_layer_space = |
507 GetViewportForTilePriorityInContentSpace(); | 510 GetViewportForTilePriorityInContentSpace(); |
508 bool tiling_needs_update = false; | |
509 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { | |
510 if (tilings_->tiling_at(i)->NeedsUpdateForFrameAtTimeAndViewport( | |
511 current_frame_time_in_seconds, viewport_rect_in_layer_space)) { | |
512 tiling_needs_update = true; | |
513 break; | |
514 } | |
515 } | |
516 if (!tiling_needs_update) | |
517 return; | |
518 | 511 |
519 WhichTree tree = | 512 // The tiling set can require tiles for activation any of the following |
520 layer_tree_impl()->IsActiveTree() ? ACTIVE_TREE : PENDING_TREE; | 513 // conditions are true: |
| 514 // - This layer produced a high-res or non-ideal-res tile last frame. |
| 515 // - We're in requires high res to draw mode. |
| 516 // - We're not in smoothness takes priority mode. |
| 517 // To put different, the tiling set can't require tiles for activation if |
| 518 // we're in smoothness mode and only used low-res or checkerboard to draw last |
| 519 // frame and we don't need high res to draw. |
| 520 // |
| 521 // The reason for this is that we should be able to activate sooner and get a |
| 522 // more up to date recording, so we don't run out of recording on the active |
| 523 // tree. |
521 bool can_require_tiles_for_activation = | 524 bool can_require_tiles_for_activation = |
522 !only_used_low_res_last_append_quads_ || RequiresHighResToDraw() || | 525 !only_used_low_res_last_append_quads_ || RequiresHighResToDraw() || |
523 !layer_tree_impl()->SmoothnessTakesPriority(); | 526 !layer_tree_impl()->SmoothnessTakesPriority(); |
524 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { | |
525 PictureLayerTiling* tiling = tilings_->tiling_at(i); | |
526 | 527 |
527 tiling->set_can_require_tiles_for_activation( | 528 // Pass |occlusion_in_content_space| for |occlusion_in_layer_space| since |
528 can_require_tiles_for_activation); | 529 // they are the same space in picture layer, as contents scale is always 1. |
| 530 bool updated = tilings_->UpdateTilePriorities( |
| 531 viewport_rect_in_layer_space, ideal_contents_scale_, |
| 532 current_frame_time_in_seconds, occlusion_in_content_space, |
| 533 can_require_tiles_for_activation); |
529 | 534 |
530 // Pass |occlusion_in_content_space| for |occlusion_in_layer_space| since | |
531 // they are the same space in picture layer, as contents scale is always 1. | |
532 tiling->ComputeTilePriorityRects(tree, | |
533 viewport_rect_in_layer_space, | |
534 ideal_contents_scale_, | |
535 current_frame_time_in_seconds, | |
536 occlusion_in_content_space); | |
537 } | |
538 | |
539 // Tile priorities were modified. | |
540 // TODO(vmpstr): See if this can be removed in favour of calling it from LTHI | 535 // TODO(vmpstr): See if this can be removed in favour of calling it from LTHI |
541 layer_tree_impl()->DidModifyTilePriorities(); | 536 if (updated) |
| 537 layer_tree_impl()->DidModifyTilePriorities(); |
542 } | 538 } |
543 | 539 |
544 gfx::Rect PictureLayerImpl::GetViewportForTilePriorityInContentSpace() const { | 540 gfx::Rect PictureLayerImpl::GetViewportForTilePriorityInContentSpace() const { |
545 // If visible_rect_for_tile_priority_ is empty or | 541 // If visible_rect_for_tile_priority_ is empty or |
546 // viewport_rect_for_tile_priority is set to be different from the device | 542 // viewport_rect_for_tile_priority is set to be different from the device |
547 // viewport, try to inverse project the viewport into layer space and use | 543 // viewport, try to inverse project the viewport into layer space and use |
548 // that. Otherwise just use visible_rect_for_tile_priority_ | 544 // that. Otherwise just use visible_rect_for_tile_priority_ |
549 gfx::Rect visible_rect_in_content_space = visible_rect_for_tile_priority_; | 545 gfx::Rect visible_rect_in_content_space = visible_rect_for_tile_priority_; |
550 gfx::Rect viewport_rect_for_tile_priority = | 546 gfx::Rect viewport_rect_for_tile_priority = |
551 layer_tree_impl()->ViewportRectForTilePriority(); | 547 layer_tree_impl()->ViewportRectForTilePriority(); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
616 return scoped_refptr<Tile>(); | 612 return scoped_refptr<Tile>(); |
617 | 613 |
618 int flags = 0; | 614 int flags = 0; |
619 | 615 |
620 // TODO(vmpstr): Revisit this. For now, enabling analysis means that we get as | 616 // TODO(vmpstr): Revisit this. For now, enabling analysis means that we get as |
621 // much savings on memory as we can. However, for some cases like ganesh or | 617 // much savings on memory as we can. However, for some cases like ganesh or |
622 // small layers, the amount of time we spend analyzing might not justify | 618 // small layers, the amount of time we spend analyzing might not justify |
623 // memory savings that we can get. Note that we don't handle solid color | 619 // memory savings that we can get. Note that we don't handle solid color |
624 // masks, so we shouldn't bother analyzing those. | 620 // masks, so we shouldn't bother analyzing those. |
625 // Bugs: crbug.com/397198, crbug.com/396908 | 621 // Bugs: crbug.com/397198, crbug.com/396908 |
626 if (!raster_source_->IsMask()) | 622 if (!is_mask_) |
627 flags = Tile::USE_PICTURE_ANALYSIS; | 623 flags = Tile::USE_PICTURE_ANALYSIS; |
628 | 624 |
629 return layer_tree_impl()->tile_manager()->CreateTile( | 625 return layer_tree_impl()->tile_manager()->CreateTile( |
630 raster_source_.get(), content_rect.size(), content_rect, | 626 raster_source_.get(), content_rect.size(), content_rect, |
631 tiling->contents_scale(), id(), layer_tree_impl()->source_frame_number(), | 627 tiling->contents_scale(), id(), layer_tree_impl()->source_frame_number(), |
632 flags); | 628 flags); |
633 } | 629 } |
634 | 630 |
635 RasterSource* PictureLayerImpl::GetRasterSource() { | |
636 return raster_source_.get(); | |
637 } | |
638 | |
639 const Region* PictureLayerImpl::GetPendingInvalidation() { | 631 const Region* PictureLayerImpl::GetPendingInvalidation() { |
640 if (layer_tree_impl()->IsPendingTree()) | 632 if (layer_tree_impl()->IsPendingTree()) |
641 return &invalidation_; | 633 return &invalidation_; |
642 DCHECK(layer_tree_impl()->IsActiveTree()); | 634 DCHECK(layer_tree_impl()->IsActiveTree()); |
643 if (PictureLayerImpl* twin_layer = GetPendingOrActiveTwinLayer()) | 635 if (PictureLayerImpl* twin_layer = GetPendingOrActiveTwinLayer()) |
644 return &twin_layer->invalidation_; | 636 return &twin_layer->invalidation_; |
645 return nullptr; | 637 return nullptr; |
646 } | 638 } |
647 | 639 |
648 const PictureLayerTiling* PictureLayerImpl::GetPendingOrActiveTwinTiling( | 640 const PictureLayerTiling* PictureLayerImpl::GetPendingOrActiveTwinTiling( |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
692 | 684 |
693 bool PictureLayerImpl::RequiresHighResToDraw() const { | 685 bool PictureLayerImpl::RequiresHighResToDraw() const { |
694 return layer_tree_impl()->RequiresHighResToDraw(); | 686 return layer_tree_impl()->RequiresHighResToDraw(); |
695 } | 687 } |
696 | 688 |
697 gfx::Size PictureLayerImpl::CalculateTileSize( | 689 gfx::Size PictureLayerImpl::CalculateTileSize( |
698 const gfx::Size& content_bounds) const { | 690 const gfx::Size& content_bounds) const { |
699 int max_texture_size = | 691 int max_texture_size = |
700 layer_tree_impl()->resource_provider()->max_texture_size(); | 692 layer_tree_impl()->resource_provider()->max_texture_size(); |
701 | 693 |
702 if (raster_source_->IsMask()) { | 694 if (is_mask_) { |
703 // Masks are not tiled, so if we can't cover the whole mask with one tile, | 695 // Masks are not tiled, so if we can't cover the whole mask with one tile, |
704 // don't make any tiles at all. Returning an empty size signals this. | 696 // don't make any tiles at all. Returning an empty size signals this. |
705 if (content_bounds.width() > max_texture_size || | 697 if (content_bounds.width() > max_texture_size || |
706 content_bounds.height() > max_texture_size) | 698 content_bounds.height() > max_texture_size) |
707 return gfx::Size(); | 699 return gfx::Size(); |
708 return content_bounds; | 700 return content_bounds; |
709 } | 701 } |
710 | 702 |
711 int default_tile_width = 0; | 703 int default_tile_width = 0; |
712 int default_tile_height = 0; | 704 int default_tile_height = 0; |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
781 } | 773 } |
782 | 774 |
783 raster_page_scale_ = other->raster_page_scale_; | 775 raster_page_scale_ = other->raster_page_scale_; |
784 raster_device_scale_ = other->raster_device_scale_; | 776 raster_device_scale_ = other->raster_device_scale_; |
785 raster_source_scale_ = other->raster_source_scale_; | 777 raster_source_scale_ = other->raster_source_scale_; |
786 raster_contents_scale_ = other->raster_contents_scale_; | 778 raster_contents_scale_ = other->raster_contents_scale_; |
787 low_res_raster_contents_scale_ = other->low_res_raster_contents_scale_; | 779 low_res_raster_contents_scale_ = other->low_res_raster_contents_scale_; |
788 | 780 |
789 bool synced_high_res_tiling = false; | 781 bool synced_high_res_tiling = false; |
790 if (CanHaveTilings()) { | 782 if (CanHaveTilings()) { |
791 synced_high_res_tiling = | 783 synced_high_res_tiling = tilings_->SyncTilings( |
792 tilings_->SyncTilings(*other->tilings_, raster_source_->GetSize(), | 784 *other->tilings_, raster_source_->GetSize(), invalidation_, |
793 invalidation_, MinimumContentsScale()); | 785 MinimumContentsScale(), raster_source_.get()); |
794 } else { | 786 } else { |
795 RemoveAllTilings(); | 787 RemoveAllTilings(); |
796 } | 788 } |
797 | 789 |
798 // If our MinimumContentsScale has changed to prevent the twin's high res | 790 // If our MinimumContentsScale has changed to prevent the twin's high res |
799 // tiling from being synced, we should reset the raster scale and let it be | 791 // tiling from being synced, we should reset the raster scale and let it be |
800 // recalculated (1) again. This can happen if our bounds shrink to the point | 792 // recalculated (1) again. This can happen if our bounds shrink to the point |
801 // where min contents scale grows. | 793 // where min contents scale grows. |
802 // (1) - TODO(vmpstr) Instead of hoping that this will be recalculated, we | 794 // (1) - TODO(vmpstr) Instead of hoping that this will be recalculated, we |
803 // should refactor this code a little bit and actually recalculate this. | 795 // should refactor this code a little bit and actually recalculate this. |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
858 | 850 |
859 *resource_id = draw_info.get_resource_id(); | 851 *resource_id = draw_info.get_resource_id(); |
860 *resource_size = iter.texture_size(); | 852 *resource_size = iter.texture_size(); |
861 } | 853 } |
862 | 854 |
863 void PictureLayerImpl::DoPostCommitInitialization() { | 855 void PictureLayerImpl::DoPostCommitInitialization() { |
864 DCHECK(needs_post_commit_initialization_); | 856 DCHECK(needs_post_commit_initialization_); |
865 DCHECK(layer_tree_impl()->IsPendingTree()); | 857 DCHECK(layer_tree_impl()->IsPendingTree()); |
866 | 858 |
867 if (!tilings_) | 859 if (!tilings_) |
868 tilings_ = make_scoped_ptr(new PictureLayerTilingSet(this)); | 860 tilings_ = PictureLayerTilingSet::Create(this); |
869 | 861 |
870 PictureLayerImpl* twin_layer = GetPendingOrActiveTwinLayer(); | 862 PictureLayerImpl* twin_layer = GetPendingOrActiveTwinLayer(); |
871 if (twin_layer) { | 863 if (twin_layer) { |
872 // If the twin has never been pushed to, do not sync from it. | 864 // If the twin has never been pushed to, do not sync from it. |
873 // This can happen if this function is called during activation. | 865 // This can happen if this function is called during activation. |
874 if (!twin_layer->needs_post_commit_initialization_) | 866 if (!twin_layer->needs_post_commit_initialization_) |
875 SyncFromActiveLayer(twin_layer); | 867 SyncFromActiveLayer(twin_layer); |
876 } | 868 } |
877 | 869 |
878 needs_post_commit_initialization_ = false; | 870 needs_post_commit_initialization_ = false; |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1045 // a throttled rate. Possibly make use of invalidation_.IsEmpty() on pending | 1037 // a throttled rate. Possibly make use of invalidation_.IsEmpty() on pending |
1046 // tree. This will allow CSS scale changes to get re-rastered at an | 1038 // tree. This will allow CSS scale changes to get re-rastered at an |
1047 // appropriate rate. (crbug.com/413636) | 1039 // appropriate rate. (crbug.com/413636) |
1048 if (raster_source_scale_is_fixed_) { | 1040 if (raster_source_scale_is_fixed_) { |
1049 raster_contents_scale_ /= raster_source_scale_; | 1041 raster_contents_scale_ /= raster_source_scale_; |
1050 raster_source_scale_ = 1.f; | 1042 raster_source_scale_ = 1.f; |
1051 } | 1043 } |
1052 | 1044 |
1053 // During pinch we completely ignore the current ideal scale, and just use | 1045 // During pinch we completely ignore the current ideal scale, and just use |
1054 // a multiple of the previous scale. | 1046 // a multiple of the previous scale. |
1055 // TODO(danakj): This seems crazy, we should use the current ideal, no? | |
1056 bool is_pinching = layer_tree_impl()->PinchGestureActive(); | 1047 bool is_pinching = layer_tree_impl()->PinchGestureActive(); |
1057 if (is_pinching && old_raster_contents_scale) { | 1048 if (is_pinching && old_raster_contents_scale) { |
1058 // See ShouldAdjustRasterScale: | 1049 // See ShouldAdjustRasterScale: |
1059 // - When zooming out, preemptively create new tiling at lower resolution. | 1050 // - When zooming out, preemptively create new tiling at lower resolution. |
1060 // - When zooming in, approximate ideal using multiple of kMaxScaleRatio. | 1051 // - When zooming in, approximate ideal using multiple of kMaxScaleRatio. |
1061 bool zooming_out = old_raster_page_scale > ideal_page_scale_; | 1052 bool zooming_out = old_raster_page_scale > ideal_page_scale_; |
1062 float desired_contents_scale = | 1053 float desired_contents_scale = old_raster_contents_scale; |
1063 zooming_out ? old_raster_contents_scale / kMaxScaleRatioDuringPinch | 1054 if (zooming_out) { |
1064 : old_raster_contents_scale * kMaxScaleRatioDuringPinch; | 1055 while (desired_contents_scale > ideal_contents_scale_) |
| 1056 desired_contents_scale /= kMaxScaleRatioDuringPinch; |
| 1057 } else { |
| 1058 while (desired_contents_scale < ideal_contents_scale_) |
| 1059 desired_contents_scale *= kMaxScaleRatioDuringPinch; |
| 1060 } |
1065 raster_contents_scale_ = SnappedContentsScale(desired_contents_scale); | 1061 raster_contents_scale_ = SnappedContentsScale(desired_contents_scale); |
1066 raster_page_scale_ = | 1062 raster_page_scale_ = |
1067 raster_contents_scale_ / raster_device_scale_ / raster_source_scale_; | 1063 raster_contents_scale_ / raster_device_scale_ / raster_source_scale_; |
1068 } | 1064 } |
1069 | 1065 |
1070 // If we're not re-rasterizing during animation, rasterize at the maximum | 1066 // If we're not re-rasterizing during animation, rasterize at the maximum |
1071 // scale that will occur during the animation, if the maximum scale is | 1067 // scale that will occur during the animation, if the maximum scale is |
1072 // known. However we want to avoid excessive memory use. If the scale is | 1068 // known. However we want to avoid excessive memory use. If the scale is |
1073 // smaller than what we would choose otherwise, then it's always better off | 1069 // smaller than what we would choose otherwise, then it's always better off |
1074 // for us memory-wise. But otherwise, we don't choose a scale at which this | 1070 // for us memory-wise. But otherwise, we don't choose a scale at which this |
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1712 PictureLayerTilingSet::TilingRange tiling_range = CurrentTilingRange(); | 1708 PictureLayerTilingSet::TilingRange tiling_range = CurrentTilingRange(); |
1713 size_t current_tiling_range_offset = current_tiling_ - tiling_range.start; | 1709 size_t current_tiling_range_offset = current_tiling_ - tiling_range.start; |
1714 return tiling_range.end - 1 - current_tiling_range_offset; | 1710 return tiling_range.end - 1 - current_tiling_range_offset; |
1715 } | 1711 } |
1716 } | 1712 } |
1717 NOTREACHED(); | 1713 NOTREACHED(); |
1718 return 0; | 1714 return 0; |
1719 } | 1715 } |
1720 | 1716 |
1721 } // namespace cc | 1717 } // namespace cc |
OLD | NEW |