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

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

Issue 2100483003: cc: Change directly composited image raster source scale occasionally. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tests Created 4 years, 5 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
« no previous file with comments | « no previous file | cc/layers/picture_layer_impl_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 856 matching lines...) Expand 10 before | Expand all | Expand 10 after
867 if (layer_tree_impl()->IsPendingTree()) { 867 if (layer_tree_impl()->IsPendingTree()) {
868 // On the pending tree, drop any tilings that are non-ideal since we don't 868 // On the pending tree, drop any tilings that are non-ideal since we don't
869 // need them to activate anyway. 869 // need them to activate anyway.
870 tilings_->RemoveNonIdealTilings(); 870 tilings_->RemoveNonIdealTilings();
871 } 871 }
872 872
873 SanityCheckTilingState(); 873 SanityCheckTilingState();
874 } 874 }
875 875
876 bool PictureLayerImpl::ShouldAdjustRasterScale() const { 876 bool PictureLayerImpl::ShouldAdjustRasterScale() const {
877 // TODO(vmpstr): We might want to adjust the raster scale once in a while. 877 if (is_directly_composited_image_) {
878 if (is_directly_composited_image_) 878 float max_scale = std::max(1.f, MinimumContentsScale());
879 if (raster_source_scale_ < std::min(ideal_source_scale_, max_scale))
880 return true;
881 if (raster_source_scale_ > 4 * ideal_source_scale_)
882 return true;
879 return false; 883 return false;
884 }
880 885
881 if (was_screen_space_transform_animating_ != 886 if (was_screen_space_transform_animating_ !=
882 draw_properties().screen_space_transform_is_animating) 887 draw_properties().screen_space_transform_is_animating)
883 return true; 888 return true;
884 889
885 if (draw_properties().screen_space_transform_is_animating && 890 if (draw_properties().screen_space_transform_is_animating &&
886 raster_contents_scale_ != ideal_contents_scale_ && 891 raster_contents_scale_ != ideal_contents_scale_ &&
887 ShouldAdjustRasterScaleDuringScaleAnimations()) 892 ShouldAdjustRasterScaleDuringScaleAnimations())
888 return true; 893 return true;
889 894
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
949 bool is_pinching = layer_tree_impl()->PinchGestureActive(); 954 bool is_pinching = layer_tree_impl()->PinchGestureActive();
950 bool is_animating = draw_properties().screen_space_transform_is_animating; 955 bool is_animating = draw_properties().screen_space_transform_is_animating;
951 if (!is_pinching && !is_animating) { 956 if (!is_pinching && !is_animating) {
952 if (!low_res) 957 if (!low_res)
953 low_res = AddTiling(low_res_raster_contents_scale_); 958 low_res = AddTiling(low_res_raster_contents_scale_);
954 low_res->set_resolution(LOW_RESOLUTION); 959 low_res->set_resolution(LOW_RESOLUTION);
955 } 960 }
956 } 961 }
957 962
958 void PictureLayerImpl::RecalculateRasterScales() { 963 void PictureLayerImpl::RecalculateRasterScales() {
959 // TODO(vmpstr): We might want to adjust these once in a while.
960 if (is_directly_composited_image_) { 964 if (is_directly_composited_image_) {
965 if (!raster_source_scale_)
966 raster_source_scale_ = 1.f;
967
968 float min_scale = MinimumContentsScale();
969 float max_scale = std::max(1.f, MinimumContentsScale());
970 float clamped_ideal_source_scale_ =
971 std::max(min_scale, std::min(ideal_source_scale_, max_scale));
972
973 while (raster_source_scale_ < clamped_ideal_source_scale_)
974 raster_source_scale_ *= 2.f;
975 while (raster_source_scale_ > 4 * clamped_ideal_source_scale_)
976 raster_source_scale_ /= 2.f;
977
978 raster_source_scale_ =
979 std::max(min_scale, std::min(raster_source_scale_, max_scale));
980
961 raster_page_scale_ = 1.f; 981 raster_page_scale_ = 1.f;
962 raster_device_scale_ = 1.f; 982 raster_device_scale_ = 1.f;
963 raster_source_scale_ = std::max(1.f, MinimumContentsScale());
964 raster_contents_scale_ = raster_source_scale_; 983 raster_contents_scale_ = raster_source_scale_;
965 low_res_raster_contents_scale_ = raster_contents_scale_; 984 low_res_raster_contents_scale_ = raster_contents_scale_;
966 return; 985 return;
967 } 986 }
968 987
969 float old_raster_contents_scale = raster_contents_scale_; 988 float old_raster_contents_scale = raster_contents_scale_;
970 float old_raster_page_scale = raster_page_scale_; 989 float old_raster_page_scale = raster_page_scale_;
971 990
972 raster_device_scale_ = ideal_device_scale_; 991 raster_device_scale_ = ideal_device_scale_;
973 raster_page_scale_ = ideal_page_scale_; 992 raster_page_scale_ = ideal_page_scale_;
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
1188 const LayerTreeSettings& settings = layer_tree_impl()->settings(); 1207 const LayerTreeSettings& settings = layer_tree_impl()->settings();
1189 return PictureLayerTilingSet::Create( 1208 return PictureLayerTilingSet::Create(
1190 GetTree(), this, settings.tiling_interest_area_padding, 1209 GetTree(), this, settings.tiling_interest_area_padding,
1191 layer_tree_impl()->use_gpu_rasterization() 1210 layer_tree_impl()->use_gpu_rasterization()
1192 ? settings.gpu_rasterization_skewport_target_time_in_seconds 1211 ? settings.gpu_rasterization_skewport_target_time_in_seconds
1193 : settings.skewport_target_time_in_seconds, 1212 : settings.skewport_target_time_in_seconds,
1194 settings.skewport_extrapolation_limit_in_screen_pixels); 1213 settings.skewport_extrapolation_limit_in_screen_pixels);
1195 } 1214 }
1196 1215
1197 void PictureLayerImpl::UpdateIdealScales() { 1216 void PictureLayerImpl::UpdateIdealScales() {
1198 // TODO(vmpstr): We might want to adjust these once in a while.
1199 if (is_directly_composited_image_) {
1200 ideal_contents_scale_ = 1.f;
1201 ideal_page_scale_ = 1.f;
1202 ideal_device_scale_ = 1.f;
1203 ideal_source_scale_ = 1.f;
1204 return;
1205 }
1206
1207 DCHECK(CanHaveTilings()); 1217 DCHECK(CanHaveTilings());
1208 1218
1209 float min_contents_scale = MinimumContentsScale(); 1219 float min_contents_scale = MinimumContentsScale();
1210 DCHECK_GT(min_contents_scale, 0.f); 1220 DCHECK_GT(min_contents_scale, 0.f);
1211 1221
1212 ideal_page_scale_ = IsAffectedByPageScale() 1222 ideal_page_scale_ = IsAffectedByPageScale()
1213 ? layer_tree_impl()->current_page_scale_factor() 1223 ? layer_tree_impl()->current_page_scale_factor()
1214 : 1.f; 1224 : 1.f;
1215 ideal_device_scale_ = layer_tree_impl()->device_scale_factor(); 1225 ideal_device_scale_ = layer_tree_impl()->device_scale_factor();
1216 ideal_contents_scale_ = std::max(GetIdealContentsScale(), min_contents_scale); 1226 ideal_contents_scale_ = std::max(GetIdealContentsScale(), min_contents_scale);
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
1291 bool PictureLayerImpl::IsOnActiveOrPendingTree() const { 1301 bool PictureLayerImpl::IsOnActiveOrPendingTree() const {
1292 return !layer_tree_impl()->IsRecycleTree(); 1302 return !layer_tree_impl()->IsRecycleTree();
1293 } 1303 }
1294 1304
1295 bool PictureLayerImpl::HasValidTilePriorities() const { 1305 bool PictureLayerImpl::HasValidTilePriorities() const {
1296 return IsOnActiveOrPendingTree() && 1306 return IsOnActiveOrPendingTree() &&
1297 is_drawn_render_surface_layer_list_member(); 1307 is_drawn_render_surface_layer_list_member();
1298 } 1308 }
1299 1309
1300 } // namespace cc 1310 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | cc/layers/picture_layer_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698