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

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

Issue 2647343012: cc: Ensure that layer bounds * content scale doesn't overflow (Closed)
Patch Set: Typo Created 3 years, 10 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 1156 matching lines...) Expand 10 before | Expand all | Expand 10 after
1167 raster_source_->GetSize().height()); 1167 raster_source_->GetSize().height());
1168 if (!min_dimension) 1168 if (!min_dimension)
1169 return setting_min; 1169 return setting_min;
1170 1170
1171 return std::max(1.f / min_dimension, setting_min); 1171 return std::max(1.f / min_dimension, setting_min);
1172 } 1172 }
1173 1173
1174 float PictureLayerImpl::MaximumContentsScale() const { 1174 float PictureLayerImpl::MaximumContentsScale() const {
1175 // Masks can not have tilings that would become larger than the 1175 // Masks can not have tilings that would become larger than the
1176 // max_texture_size since they use a single tile for the entire 1176 // max_texture_size since they use a single tile for the entire
1177 // tiling. Other layers can have tilings of any scale. 1177 // tiling. Other layers can have tilings such that dimension * scale
1178 if (!is_mask_) 1178 // does not overflow.
1179 return std::numeric_limits<float>::max(); 1179 float max_dimension = static_cast<float>(
1180 is_mask_ ? layer_tree_impl()->resource_provider()->max_texture_size()
1181 : std::numeric_limits<int>::max());
1182 float max_scale_width = max_dimension / bounds().width();
1183 float max_scale_height = max_dimension / bounds().height();
1184 float max_scale = std::min(max_scale_width, max_scale_height);
1180 1185
1181 int max_texture_size =
1182 layer_tree_impl()->resource_provider()->max_texture_size();
1183 float max_scale_width =
1184 static_cast<float>(max_texture_size) / bounds().width();
1185 float max_scale_height =
1186 static_cast<float>(max_texture_size) / bounds().height();
1187 float max_scale = std::min(max_scale_width, max_scale_height);
1188 // We require that multiplying the layer size by the contents scale and 1186 // We require that multiplying the layer size by the contents scale and
1189 // ceiling produces a value <= |max_texture_size|. Because for large layer 1187 // ceiling produces a value <= |max_dimension|. Because for large layer
1190 // sizes floating point ambiguity may crop up, making the result larger or 1188 // sizes floating point ambiguity may crop up, making the result larger or
1191 // smaller than expected, we use a slightly smaller floating point value for 1189 // smaller than expected, we use a slightly smaller floating point value for
1192 // the scale, to help ensure that the resulting content bounds will never end 1190 // the scale, to help ensure that the resulting content bounds will never end
1193 // up larger than |max_texture_size|. 1191 // up larger than |max_dimension|.
1194 return nextafterf(max_scale, 0.f); 1192 return nextafterf(max_scale, 0.f);
1195 } 1193 }
1196 1194
1197 void PictureLayerImpl::ResetRasterScale() { 1195 void PictureLayerImpl::ResetRasterScale() {
1198 raster_page_scale_ = 0.f; 1196 raster_page_scale_ = 0.f;
1199 raster_device_scale_ = 0.f; 1197 raster_device_scale_ = 0.f;
1200 raster_source_scale_ = 0.f; 1198 raster_source_scale_ = 0.f;
1201 raster_contents_scale_ = 0.f; 1199 raster_contents_scale_ = 0.f;
1202 low_res_raster_contents_scale_ = 0.f; 1200 low_res_raster_contents_scale_ = 0.f;
1203 } 1201 }
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
1365 bool PictureLayerImpl::IsOnActiveOrPendingTree() const { 1363 bool PictureLayerImpl::IsOnActiveOrPendingTree() const {
1366 return !layer_tree_impl()->IsRecycleTree(); 1364 return !layer_tree_impl()->IsRecycleTree();
1367 } 1365 }
1368 1366
1369 bool PictureLayerImpl::HasValidTilePriorities() const { 1367 bool PictureLayerImpl::HasValidTilePriorities() const {
1370 return IsOnActiveOrPendingTree() && 1368 return IsOnActiveOrPendingTree() &&
1371 is_drawn_render_surface_layer_list_member(); 1369 is_drawn_render_surface_layer_list_member();
1372 } 1370 }
1373 1371
1374 } // namespace cc 1372 } // 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