| 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/picture_layer_impl.h" | 5 #include "cc/picture_layer_impl.h" |
| 6 | 6 |
| 7 #include "base/time.h" | 7 #include "base/time.h" |
| 8 #include "cc/append_quads_data.h" | 8 #include "cc/append_quads_data.h" |
| 9 #include "cc/checkerboard_draw_quad.h" | 9 #include "cc/checkerboard_draw_quad.h" |
| 10 #include "cc/debug_border_draw_quad.h" | 10 #include "cc/debug_border_draw_quad.h" |
| (...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 572 | 572 |
| 573 void PictureLayerImpl::ManageTilings(bool animating_transform_to_screen) { | 573 void PictureLayerImpl::ManageTilings(bool animating_transform_to_screen) { |
| 574 DCHECK(ideal_contents_scale_); | 574 DCHECK(ideal_contents_scale_); |
| 575 DCHECK(ideal_page_scale_); | 575 DCHECK(ideal_page_scale_); |
| 576 DCHECK(ideal_device_scale_); | 576 DCHECK(ideal_device_scale_); |
| 577 DCHECK(ideal_source_scale_); | 577 DCHECK(ideal_source_scale_); |
| 578 | 578 |
| 579 if (pile_->recorded_region().IsEmpty()) | 579 if (pile_->recorded_region().IsEmpty()) |
| 580 return; | 580 return; |
| 581 | 581 |
| 582 float low_res_factor = layerTreeImpl()->settings().lowResContentsScaleFactor; | |
| 583 | |
| 584 bool is_active_layer = layerTreeImpl()->IsActiveTree(); | 582 bool is_active_layer = layerTreeImpl()->IsActiveTree(); |
| 585 bool is_pinching = layerTreeImpl()->PinchGestureActive(); | 583 bool is_pinching = layerTreeImpl()->PinchGestureActive(); |
| 586 | 584 |
| 587 bool change_target_tiling = false; | 585 bool change_target_tiling = false; |
| 588 | 586 |
| 589 if (!raster_page_scale_ || !raster_device_scale_ || !raster_source_scale_) | 587 if (!raster_page_scale_ || !raster_device_scale_ || !raster_source_scale_) |
| 590 change_target_tiling = true; | 588 change_target_tiling = true; |
| 591 | 589 |
| 592 // TODO(danakj): Adjust raster_source_scale_ closer to ideal_source_scale_ at | 590 // TODO(danakj): Adjust raster_source_scale_ closer to ideal_source_scale_ at |
| 593 // a throttled rate. Possibly make use of invalidation_.IsEmpty() on pending | 591 // a throttled rate. Possibly make use of invalidation_.IsEmpty() on pending |
| (...skipping 24 matching lines...) Expand all Loading... |
| 618 if (raster_device_scale_ != ideal_device_scale_) | 616 if (raster_device_scale_ != ideal_device_scale_) |
| 619 change_target_tiling = true; | 617 change_target_tiling = true; |
| 620 | 618 |
| 621 if (!change_target_tiling) | 619 if (!change_target_tiling) |
| 622 return; | 620 return; |
| 623 | 621 |
| 624 raster_page_scale_ = ideal_page_scale_; | 622 raster_page_scale_ = ideal_page_scale_; |
| 625 raster_device_scale_ = ideal_device_scale_; | 623 raster_device_scale_ = ideal_device_scale_; |
| 626 raster_source_scale_ = ideal_source_scale_; | 624 raster_source_scale_ = ideal_source_scale_; |
| 627 | 625 |
| 628 float raster_contents_scale = ideal_contents_scale_; | 626 float raster_contents_scale; |
| 629 | 627 float low_res_raster_contents_scale; |
| 630 // Don't allow animating CSS scales to drop below 1. | 628 CalculateRasterContentsScale(animating_transform_to_screen, |
| 631 if (animating_transform_to_screen) { | 629 &raster_contents_scale, |
| 632 raster_contents_scale = std::max( | 630 &low_res_raster_contents_scale); |
| 633 raster_contents_scale, 1.f * ideal_page_scale_ * ideal_device_scale_); | |
| 634 } | |
| 635 | |
| 636 float low_res_raster_contents_scale = std::max( | |
| 637 raster_contents_scale * low_res_factor, | |
| 638 layerTreeImpl()->settings().minimumContentsScale); | |
| 639 | 631 |
| 640 PictureLayerTiling* high_res = NULL; | 632 PictureLayerTiling* high_res = NULL; |
| 641 PictureLayerTiling* low_res = NULL; | 633 PictureLayerTiling* low_res = NULL; |
| 642 | 634 |
| 643 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { | 635 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { |
| 644 PictureLayerTiling* tiling = tilings_->tiling_at(i); | 636 PictureLayerTiling* tiling = tilings_->tiling_at(i); |
| 645 if (tiling->contents_scale() == raster_contents_scale) | 637 if (tiling->contents_scale() == raster_contents_scale) |
| 646 high_res = tiling; | 638 high_res = tiling; |
| 647 if (tiling->contents_scale() == low_res_raster_contents_scale) | 639 if (tiling->contents_scale() == low_res_raster_contents_scale) |
| 648 low_res = tiling; | 640 low_res = tiling; |
| 649 | 641 |
| 650 // Reset all tilings to non-ideal until the end of this function. | 642 // Reset all tilings to non-ideal until the end of this function. |
| 651 tiling->set_resolution(NON_IDEAL_RESOLUTION); | 643 tiling->set_resolution(NON_IDEAL_RESOLUTION); |
| 652 } | 644 } |
| 653 | 645 |
| 654 if (!high_res) | 646 if (!high_res) { |
| 655 high_res = AddTiling(raster_contents_scale); | 647 high_res = AddTiling(raster_contents_scale); |
| 648 if (raster_contents_scale == low_res_raster_contents_scale) |
| 649 low_res = high_res; |
| 650 } |
| 656 if (!low_res && low_res != high_res) | 651 if (!low_res && low_res != high_res) |
| 657 low_res = AddTiling(low_res_raster_contents_scale); | 652 low_res = AddTiling(low_res_raster_contents_scale); |
| 658 | 653 |
| 659 if (high_res) | 654 if (high_res) |
| 660 high_res->set_resolution(HIGH_RESOLUTION); | 655 high_res->set_resolution(HIGH_RESOLUTION); |
| 661 if (low_res && low_res != high_res) | 656 if (low_res && low_res != high_res) |
| 662 low_res->set_resolution(LOW_RESOLUTION); | 657 low_res->set_resolution(LOW_RESOLUTION); |
| 663 } | 658 } |
| 664 | 659 |
| 660 void PictureLayerImpl::CalculateRasterContentsScale( |
| 661 bool animating_transform_to_screen, |
| 662 float* raster_contents_scale, |
| 663 float* low_res_raster_contents_scale) { |
| 664 *raster_contents_scale = ideal_contents_scale_; |
| 665 |
| 666 // Don't allow animating CSS scales to drop below 1. |
| 667 if (animating_transform_to_screen) { |
| 668 *raster_contents_scale = std::max( |
| 669 *raster_contents_scale, 1.f * ideal_page_scale_ * ideal_device_scale_); |
| 670 } |
| 671 |
| 672 float low_res_factor = layerTreeImpl()->settings().lowResContentsScaleFactor; |
| 673 *low_res_raster_contents_scale = std::max( |
| 674 *raster_contents_scale * low_res_factor, |
| 675 layerTreeImpl()->settings().minimumContentsScale); |
| 676 } |
| 677 |
| 665 void PictureLayerImpl::CleanUpTilingsOnActiveLayer( | 678 void PictureLayerImpl::CleanUpTilingsOnActiveLayer( |
| 666 std::vector<PictureLayerTiling*> used_tilings) { | 679 std::vector<PictureLayerTiling*> used_tilings) { |
| 667 DCHECK(layerTreeImpl()->IsActiveTree()); | 680 DCHECK(layerTreeImpl()->IsActiveTree()); |
| 668 | 681 |
| 669 float raster_contents_scale = | 682 float raster_contents_scale = |
| 670 raster_page_scale_ * raster_device_scale_ * raster_source_scale_; | 683 raster_page_scale_ * raster_device_scale_ * raster_source_scale_; |
| 671 | 684 |
| 672 float min_acceptable_high_res_scale = std::min( | 685 float min_acceptable_high_res_scale = std::min( |
| 673 raster_contents_scale, ideal_contents_scale_); | 686 raster_contents_scale, ideal_contents_scale_); |
| 674 float max_acceptable_high_res_scale = std::max( | 687 float max_acceptable_high_res_scale = std::max( |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 752 scoped_ptr<base::Value> PictureLayerImpl::AsValue() const { | 765 scoped_ptr<base::Value> PictureLayerImpl::AsValue() const { |
| 753 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); | 766 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); |
| 754 LayerImpl::AsValueInto(state.get()); | 767 LayerImpl::AsValueInto(state.get()); |
| 755 | 768 |
| 756 state->SetDouble("ideal_contents_scale", ideal_contents_scale_); | 769 state->SetDouble("ideal_contents_scale", ideal_contents_scale_); |
| 757 state->Set("tilings", tilings_->AsValue().release()); | 770 state->Set("tilings", tilings_->AsValue().release()); |
| 758 return state.PassAs<base::Value>(); | 771 return state.PassAs<base::Value>(); |
| 759 } | 772 } |
| 760 | 773 |
| 761 } // namespace cc | 774 } // namespace cc |
| OLD | NEW |