Chromium Code Reviews| 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 |