Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(57)

Side by Side Diff: cc/layers/picture_layer_impl.cc

Issue 260963008: Fixing crash in PictureLayerImpl::MarkVisibleResourcesAsRequired when low-res tiles are disabled (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reverting back ImplSidePaintingSettings class and adjusting the code for readability. Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 769 matching lines...) Expand 10 before | Expand all | Expand 10 after
780 DCHECK(high_res) << "There must be one high res tiling"; 780 DCHECK(high_res) << "There must be one high res tiling";
781 781
782 // If these pointers are null (because no twin, no matching tiling, or the 782 // If these pointers are null (because no twin, no matching tiling, or the
783 // simpification just below), then high res tiles will be required to fill any 783 // simpification just below), then high res tiles will be required to fill any
784 // holes left by the first pass above. If the pointers are valid, then this 784 // holes left by the first pass above. If the pointers are valid, then this
785 // layer is allowed to skip any tiles that are not ready on its twin. 785 // layer is allowed to skip any tiles that are not ready on its twin.
786 const PictureLayerTiling* twin_high_res = NULL; 786 const PictureLayerTiling* twin_high_res = NULL;
787 const PictureLayerTiling* twin_low_res = NULL; 787 const PictureLayerTiling* twin_low_res = NULL;
788 788
789 // As a simplification, only allow activating to skip twin tiles that the 789 // As a simplification, only allow activating to skip twin tiles that the
790 // active layer is also missing when both this layer and its twin have 2 790 // active layer is also missing when both this layer and its twin have
791 // tilings (high and low). This avoids having to iterate/track coverage of 791 // "simple" sets of tilings: only 2 tilings (high and low) for case, when low
792 // non-ideal tilings during the last draw call on the active layer. 792 // res is enabled; or only 1 high res tiling, when low res is disabled. This
793 if (high_res && low_res && tilings_->num_tilings() == 2 && 793 // avoids having to iterate/track coverage of non-ideal tilings during the
794 twin_layer_ && twin_layer_->tilings_->num_tilings() == 2) { 794 // last draw call on the active layer.
795 twin_low_res = GetTwinTiling(low_res); 795 bool should_have_low_res = ShouldHaveLowResTiling();
796 if (twin_low_res) 796 if (high_res && (low_res || !should_have_low_res) && twin_layer_ &&
797 tilings_->num_tilings() == twin_layer_->tilings_->num_tilings() &&
798 tilings_->num_tilings() <= 2) {
799 if (should_have_low_res)
800 twin_low_res = GetTwinTiling(low_res);
801 if (twin_low_res || !should_have_low_res)
797 twin_high_res = GetTwinTiling(high_res); 802 twin_high_res = GetTwinTiling(high_res);
798 } 803 }
804
799 // If this layer and its twin have different transforms, then don't compare 805 // If this layer and its twin have different transforms, then don't compare
800 // them and only allow activating to high res tiles, since tiles on each layer 806 // them and only allow activating to high res tiles, since tiles on each layer
801 // will be in different places on screen. 807 // will be in different places on screen.
802 if (!twin_high_res || !twin_low_res || 808 if (!twin_high_res || (!twin_low_res && should_have_low_res) ||
803 twin_layer_->layer_tree_impl()->RequiresHighResToDraw() || 809 twin_layer_->layer_tree_impl()->RequiresHighResToDraw() ||
804 draw_properties().screen_space_transform != 810 draw_properties().screen_space_transform !=
805 twin_layer_->draw_properties().screen_space_transform) { 811 twin_layer_->draw_properties().screen_space_transform) {
806 twin_high_res = NULL; 812 twin_high_res = NULL;
807 twin_low_res = NULL; 813 twin_low_res = NULL;
808 } 814 }
809 815
810 // As a second pass, mark as required any visible high res tiles not filled in 816 // As a second pass, mark as required any visible high res tiles not filled in
811 // by acceptable non-ideal tiles from the first pass. 817 // by acceptable non-ideal tiles from the first pass.
812 if (MarkVisibleTilesAsRequired( 818 if (MarkVisibleTilesAsRequired(
813 high_res, twin_high_res, contents_scale_x(), rect, missing_region)) { 819 high_res, twin_high_res, contents_scale_x(), rect, missing_region)) {
814 // As an optional third pass, if a high res tile was skipped because its 820 // As an optional third pass, if a high res tile was skipped because its
815 // twin was also missing, then fall back to mark low res tiles as required 821 // twin was also missing, then fall back to mark low res tiles as required
816 // in case the active twin is substituting those for missing high res 822 // in case the active twin is substituting those for missing high res
817 // content. 823 // content. Only suitable, when low res is enabled.
818 MarkVisibleTilesAsRequired( 824 if (should_have_low_res) {
819 low_res, twin_low_res, contents_scale_x(), rect, missing_region); 825 MarkVisibleTilesAsRequired(
826 low_res, twin_low_res, contents_scale_x(), rect, missing_region);
827 }
820 } 828 }
821 } 829 }
822 830
823 bool PictureLayerImpl::MarkVisibleTilesAsRequired( 831 bool PictureLayerImpl::MarkVisibleTilesAsRequired(
824 PictureLayerTiling* tiling, 832 PictureLayerTiling* tiling,
825 const PictureLayerTiling* optional_twin_tiling, 833 const PictureLayerTiling* optional_twin_tiling,
826 float contents_scale, 834 float contents_scale,
827 const gfx::Rect& rect, 835 const gfx::Rect& rect,
828 const Region& missing_region) const { 836 const Region& missing_region) const {
829 bool twin_had_missing_tile = false; 837 bool twin_had_missing_tile = false;
(...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after
1508 return iterator_index_ < iterators_.size(); 1516 return iterator_index_ < iterators_.size();
1509 } 1517 }
1510 1518
1511 bool PictureLayerImpl::LayerEvictionTileIterator::IsCorrectType( 1519 bool PictureLayerImpl::LayerEvictionTileIterator::IsCorrectType(
1512 PictureLayerTiling::TilingEvictionTileIterator* it) const { 1520 PictureLayerTiling::TilingEvictionTileIterator* it) const {
1513 return it->get_type() == iteration_stage_ && 1521 return it->get_type() == iteration_stage_ &&
1514 (**it)->required_for_activation() == required_for_activation_; 1522 (**it)->required_for_activation() == required_for_activation_;
1515 } 1523 }
1516 1524
1517 } // namespace cc 1525 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | cc/layers/picture_layer_impl_unittest.cc » ('j') | cc/layers/picture_layer_impl_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698