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 | 9 |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
(...skipping 823 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
834 } | 834 } |
835 DCHECK(high_res) << "There must be one high res tiling"; | 835 DCHECK(high_res) << "There must be one high res tiling"; |
836 | 836 |
837 // If these pointers are null (because no twin, no matching tiling, or the | 837 // If these pointers are null (because no twin, no matching tiling, or the |
838 // simpification just below), then high res tiles will be required to fill any | 838 // simpification just below), then high res tiles will be required to fill any |
839 // holes left by the first pass above. If the pointers are valid, then this | 839 // holes left by the first pass above. If the pointers are valid, then this |
840 // layer is allowed to skip any tiles that are not ready on its twin. | 840 // layer is allowed to skip any tiles that are not ready on its twin. |
841 const PictureLayerTiling* twin_high_res = NULL; | 841 const PictureLayerTiling* twin_high_res = NULL; |
842 const PictureLayerTiling* twin_low_res = NULL; | 842 const PictureLayerTiling* twin_low_res = NULL; |
843 | 843 |
844 // As a simplification, only allow activating to skip twin tiles that the | 844 if (twin_layer_) { |
845 // active layer is also missing when both this layer and its twin have 2 | 845 // As a simplification, only allow activating to skip twin tiles that the |
846 // tilings (high and low). This avoids having to iterate/track coverage of | 846 // active layer is also missing when both this layer and its twin have |
847 // non-ideal tilings during the last draw call on the active layer. | 847 // "simple" sets of tilings: only 2 tilings (high and low) or only 1 high |
848 if (high_res && low_res && tilings_->num_tilings() == 2 && | 848 // res tiling. This avoids having to iterate/track coverage of non-ideal |
849 twin_layer_ && twin_layer_->tilings_->num_tilings() == 2) { | 849 // tilings during the last draw call on the active layer. |
850 twin_low_res = GetTwinTiling(low_res); | 850 if (tilings_->num_tilings() <= 2 && |
851 if (twin_low_res) | 851 twin_layer_->tilings_->num_tilings() <= tilings_->num_tilings()) { |
852 twin_high_res = GetTwinTiling(high_res); | 852 twin_low_res = low_res ? GetTwinTiling(low_res) : NULL; |
853 } | 853 twin_high_res = high_res ? GetTwinTiling(high_res) : NULL; |
854 // If this layer and its twin have different bounds or transforms, then don't | 854 } |
855 // compare them and only allow activating to high res tiles, since tiles on | 855 |
856 // each layer will occupy different areas of the screen. | 856 // If this layer and its twin have different transforms, then don't compare |
857 if (!twin_high_res || !twin_low_res || | 857 // them and only allow activating to high res tiles, since tiles on each |
858 twin_layer_->layer_tree_impl()->RequiresHighResToDraw() || | 858 // layer will be in different places on screen. |
859 bounds() != twin_layer_->bounds() || | 859 if (twin_layer_->layer_tree_impl()->RequiresHighResToDraw() || |
860 draw_properties().screen_space_transform != | 860 bounds() != twin_layer_->bounds() || |
861 twin_layer_->draw_properties().screen_space_transform) { | 861 draw_properties().screen_space_transform != |
862 twin_high_res = NULL; | 862 twin_layer_->draw_properties().screen_space_transform) { |
863 twin_low_res = NULL; | 863 twin_high_res = NULL; |
| 864 twin_low_res = NULL; |
| 865 } |
864 } | 866 } |
865 | 867 |
866 // As a second pass, mark as required any visible high res tiles not filled in | 868 // As a second pass, mark as required any visible high res tiles not filled in |
867 // by acceptable non-ideal tiles from the first pass. | 869 // by acceptable non-ideal tiles from the first pass. |
868 if (MarkVisibleTilesAsRequired( | 870 if (MarkVisibleTilesAsRequired( |
869 high_res, twin_high_res, contents_scale_x(), rect, missing_region)) { | 871 high_res, twin_high_res, contents_scale_x(), rect, missing_region)) { |
870 // As an optional third pass, if a high res tile was skipped because its | 872 // As an optional third pass, if a high res tile was skipped because its |
871 // twin was also missing, then fall back to mark low res tiles as required | 873 // twin was also missing, then fall back to mark low res tiles as required |
872 // in case the active twin is substituting those for missing high res | 874 // in case the active twin is substituting those for missing high res |
873 // content. | 875 // content. Only suitable, when low res is enabled. |
874 MarkVisibleTilesAsRequired( | 876 if (low_res) { |
875 low_res, twin_low_res, contents_scale_x(), rect, missing_region); | 877 MarkVisibleTilesAsRequired( |
| 878 low_res, twin_low_res, contents_scale_x(), rect, missing_region); |
| 879 } |
876 } | 880 } |
877 } | 881 } |
878 | 882 |
879 bool PictureLayerImpl::MarkVisibleTilesAsRequired( | 883 bool PictureLayerImpl::MarkVisibleTilesAsRequired( |
880 PictureLayerTiling* tiling, | 884 PictureLayerTiling* tiling, |
881 const PictureLayerTiling* optional_twin_tiling, | 885 const PictureLayerTiling* optional_twin_tiling, |
882 float contents_scale, | 886 float contents_scale, |
883 const gfx::Rect& rect, | 887 const gfx::Rect& rect, |
884 const Region& missing_region) const { | 888 const Region& missing_region) const { |
885 bool twin_had_missing_tile = false; | 889 bool twin_had_missing_tile = false; |
(...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1614 return iterator_index_ < iterators_.size(); | 1618 return iterator_index_ < iterators_.size(); |
1615 } | 1619 } |
1616 | 1620 |
1617 bool PictureLayerImpl::LayerEvictionTileIterator::IsCorrectType( | 1621 bool PictureLayerImpl::LayerEvictionTileIterator::IsCorrectType( |
1618 PictureLayerTiling::TilingEvictionTileIterator* it) const { | 1622 PictureLayerTiling::TilingEvictionTileIterator* it) const { |
1619 return it->get_type() == iteration_stage_ && | 1623 return it->get_type() == iteration_stage_ && |
1620 (**it)->required_for_activation() == required_for_activation_; | 1624 (**it)->required_for_activation() == required_for_activation_; |
1621 } | 1625 } |
1622 | 1626 |
1623 } // namespace cc | 1627 } // namespace cc |
OLD | NEW |