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

Unified 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, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | cc/layers/picture_layer_impl_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/layers/picture_layer_impl.cc
diff --git a/cc/layers/picture_layer_impl.cc b/cc/layers/picture_layer_impl.cc
index 4c82e7310c2eeba5d2815e484ca6c08fc2b32063..4f6bfdb2981a21197bad72053e068f6b34ae6fd8 100644
--- a/cc/layers/picture_layer_impl.cc
+++ b/cc/layers/picture_layer_impl.cc
@@ -1174,23 +1174,21 @@ float PictureLayerImpl::MinimumContentsScale() const {
float PictureLayerImpl::MaximumContentsScale() const {
// Masks can not have tilings that would become larger than the
// max_texture_size since they use a single tile for the entire
- // tiling. Other layers can have tilings of any scale.
- if (!is_mask_)
- return std::numeric_limits<float>::max();
-
- int max_texture_size =
- layer_tree_impl()->resource_provider()->max_texture_size();
- float max_scale_width =
- static_cast<float>(max_texture_size) / bounds().width();
- float max_scale_height =
- static_cast<float>(max_texture_size) / bounds().height();
+ // tiling. Other layers can have tilings such that dimension * scale
+ // does not overflow.
+ float max_dimension = static_cast<float>(
+ is_mask_ ? layer_tree_impl()->resource_provider()->max_texture_size()
+ : std::numeric_limits<int>::max());
+ float max_scale_width = max_dimension / bounds().width();
+ float max_scale_height = max_dimension / bounds().height();
float max_scale = std::min(max_scale_width, max_scale_height);
+
// We require that multiplying the layer size by the contents scale and
- // ceiling produces a value <= |max_texture_size|. Because for large layer
+ // ceiling produces a value <= |max_dimension|. Because for large layer
// sizes floating point ambiguity may crop up, making the result larger or
// smaller than expected, we use a slightly smaller floating point value for
// the scale, to help ensure that the resulting content bounds will never end
- // up larger than |max_texture_size|.
+ // up larger than |max_dimension|.
return nextafterf(max_scale, 0.f);
}
« 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