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

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: Refactoring and more unittests for low res disabled. 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) {
reveman 2014/05/13 15:38:05 what if |should_have_low_res| is true but tilings_
Sergey 2014/05/14 05:53:35 If |should_have_low_res| is true and tilings_->num
reveman 2014/05/14 15:13:49 Could be low_res != NULL if high_res = NULL but we
799 if (should_have_low_res)
800 twin_low_res = GetTwinTiling(low_res);
801 if (twin_low_res || !should_have_low_res)
reveman 2014/05/13 15:38:05 Do we need this check or could we just make it unc
Sergey 2014/05/14 05:53:35 For some reason before we only executed this if we
reveman 2014/05/14 15:13:49 Fine to keep existing logic if you prefer but clea
Sergey 2014/05/15 01:08:04 Ok, let it be my next patch :) And I would like to
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) &&
820 should_have_low_res) {
reveman 2014/05/13 15:38:05 Maybe move the "should_have_low_res" check into it
Sergey 2014/05/14 05:53:35 Done.
814 // As an optional third pass, if a high res tile was skipped because its 821 // 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 822 // 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 823 // in case the active twin is substituting those for missing high res
817 // content. 824 // content. Only suitable, when low res is enabled.
818 MarkVisibleTilesAsRequired( 825 MarkVisibleTilesAsRequired(
819 low_res, twin_low_res, contents_scale_x(), rect, missing_region); 826 low_res, twin_low_res, contents_scale_x(), rect, missing_region);
820 } 827 }
821 } 828 }
822 829
823 bool PictureLayerImpl::MarkVisibleTilesAsRequired( 830 bool PictureLayerImpl::MarkVisibleTilesAsRequired(
824 PictureLayerTiling* tiling, 831 PictureLayerTiling* tiling,
825 const PictureLayerTiling* optional_twin_tiling, 832 const PictureLayerTiling* optional_twin_tiling,
826 float contents_scale, 833 float contents_scale,
827 const gfx::Rect& rect, 834 const gfx::Rect& rect,
(...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after
1508 return iterator_index_ < iterators_.size(); 1515 return iterator_index_ < iterators_.size();
1509 } 1516 }
1510 1517
1511 bool PictureLayerImpl::LayerEvictionTileIterator::IsCorrectType( 1518 bool PictureLayerImpl::LayerEvictionTileIterator::IsCorrectType(
1512 PictureLayerTiling::TilingEvictionTileIterator* it) const { 1519 PictureLayerTiling::TilingEvictionTileIterator* it) const {
1513 return it->get_type() == iteration_stage_ && 1520 return it->get_type() == iteration_stage_ &&
1514 (**it)->required_for_activation() == required_for_activation_; 1521 (**it)->required_for_activation() == required_for_activation_;
1515 } 1522 }
1516 1523
1517 } // namespace cc 1524 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698