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

Unified Diff: cc/layers/picture_layer_impl.cc

Issue 1321503002: cc: Do not create separate tilings for almost equal scale factors. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed few review comments. Created 5 years, 4 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 | no next file » | 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 8be30987e03be429d9c3e9919c4dc18c85dc6889..34a0ebb761d148427ffb3c768ed4c6375e39a33f 100644
--- a/cc/layers/picture_layer_impl.cc
+++ b/cc/layers/picture_layer_impl.cc
@@ -49,6 +49,26 @@ const int kMinHeightForGpuRasteredTile = 256;
// of using the same tile size.
const int kTileRoundUp = 64;
+// The precision value for rounding floating points values (of scale factors),
+// to given decimal places so that scale factors which are almost equal (differ
+// by some threshold magnitude of floating point epsilon) are considered as
+// same.
+const int kScalePrecision = 4;
+
+float RoundToFixedPrecision(float value) {
+ // Limiting precision 1 <= kScalePrecision <= 8, as floating point precision
+ // of >= 12 gives different values, 8 on a safer side.
+ DCHECK(kScalePrecision >= 1 && kScalePrecision <= 8);
+
+ const float factor = pow(10, kScalePrecision);
+ float integral;
+ float fractional = std::modf(value, &integral);
prashant.n 2015/09/01 16:55:25 I tried checking standard way for doing this. Defi
+ fractional *= factor;
+ fractional = std::round(fractional);
+ fractional /= factor;
+ return integral + fractional;
+}
+
} // namespace
namespace cc {
@@ -902,10 +922,12 @@ void PictureLayerImpl::RecalculateRasterScales() {
float old_raster_page_scale = raster_page_scale_;
float old_raster_source_scale = raster_source_scale_;
+ // Get fixed precision values to avoid creating extra tilings for scales
+ // which are almost equal.
raster_device_scale_ = ideal_device_scale_;
raster_page_scale_ = ideal_page_scale_;
raster_source_scale_ = ideal_source_scale_;
- raster_contents_scale_ = ideal_contents_scale_;
+ raster_contents_scale_ = RoundToFixedPrecision(ideal_contents_scale_);
prashant.n 2015/09/01 16:55:25 I thought of rounding all raster scales, so that a
// If we're not animating, or leaving an animation, and the
// ideal_source_scale_ changes, then things are unpredictable, and we fix
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698