 Chromium Code Reviews
 Chromium Code Reviews Issue 1321503002:
  cc: Do not create separate tilings for almost equal scale factors. 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master
    
  
    Issue 1321503002:
  cc: Do not create separate tilings for almost equal scale factors. 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master| OLD | NEW | 
|---|---|
| 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 <algorithm> | 7 #include <algorithm> | 
| 8 #include <cmath> | 8 #include <cmath> | 
| 9 #include <limits> | 9 #include <limits> | 
| 10 #include <set> | 10 #include <set> | 
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 42 | 42 | 
| 43 // Even for really wide viewports, at some point GPU raster should use | 43 // Even for really wide viewports, at some point GPU raster should use | 
| 44 // less than 4 tiles to fill the viewport. This is set to 256 as a | 44 // less than 4 tiles to fill the viewport. This is set to 256 as a | 
| 45 // sane minimum for now, but we might want to tune this for low-end. | 45 // sane minimum for now, but we might want to tune this for low-end. | 
| 46 const int kMinHeightForGpuRasteredTile = 256; | 46 const int kMinHeightForGpuRasteredTile = 256; | 
| 47 | 47 | 
| 48 // When making odd-sized tiles, round them up to increase the chances | 48 // When making odd-sized tiles, round them up to increase the chances | 
| 49 // of using the same tile size. | 49 // of using the same tile size. | 
| 50 const int kTileRoundUp = 64; | 50 const int kTileRoundUp = 64; | 
| 51 | 51 | 
| 52 // The precision value for rounding floating points values (of scale factors), | |
| 53 // to given decimal places so that scale factors which are almost equal (differ | |
| 54 // by some threshold magnitude of floating point epsilon) are considered as | |
| 55 // same. | |
| 56 const int kScalePrecision = 4; | |
| 57 | |
| 58 bool VerifyFixedPrecisionValue(float value) { | |
| 59 const base::CheckedNumeric<float> checked_factor = pow(10, kScalePrecision); | |
| 60 if (!checked_factor.IsValid()) | |
| 61 return false; | |
| 62 | |
| 63 base::CheckedNumeric<float> checked_value = value; | |
| 64 checked_value *= checked_factor.ValueOrDie(); | |
| 65 if (!checked_value.IsValid()) | |
| 66 return false; | |
| 67 | |
| 68 checked_value = floor(checked_value.ValueOrDie()); | |
| 69 checked_value /= checked_factor.ValueOrDie(); | |
| 70 return checked_value.IsValid(); | |
| 71 } | |
| 72 | |
| 73 float GetFixedPrecisionValue(float value) { | |
| 74 // Limiting precision 1 <= kScalePrecision <= 8, as floating point precision | |
| 75 // of >= 12 gives different values, 8 on a safer side. | |
| 76 DCHECK(kScalePrecision >= 1 && kScalePrecision <= 8); | |
| 77 DCHECK(VerifyFixedPrecisionValue(value)); | |
| 78 | |
| 79 const float factor = pow(10, kScalePrecision); | |
| 
enne (OOO)
2015/08/27 18:08:34
It is weird to do math with base 10.  Surely there
 | |
| 80 value *= factor; | |
| 81 value = floor(value); | |
| 82 value /= factor; | |
| 83 return value; | |
| 84 } | |
| 85 | |
| 52 } // namespace | 86 } // namespace | 
| 53 | 87 | 
| 54 namespace cc { | 88 namespace cc { | 
| 55 | 89 | 
| 56 PictureLayerImpl::PictureLayerImpl( | 90 PictureLayerImpl::PictureLayerImpl( | 
| 57 LayerTreeImpl* tree_impl, | 91 LayerTreeImpl* tree_impl, | 
| 58 int id, | 92 int id, | 
| 59 bool is_mask, | 93 bool is_mask, | 
| 60 scoped_refptr<SyncedScrollOffset> scroll_offset) | 94 scoped_refptr<SyncedScrollOffset> scroll_offset) | 
| 61 : LayerImpl(tree_impl, id, scroll_offset), | 95 : LayerImpl(tree_impl, id, scroll_offset), | 
| (...skipping 833 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 895 return true; | 929 return true; | 
| 896 | 930 | 
| 897 return false; | 931 return false; | 
| 898 } | 932 } | 
| 899 | 933 | 
| 900 void PictureLayerImpl::RecalculateRasterScales() { | 934 void PictureLayerImpl::RecalculateRasterScales() { | 
| 901 float old_raster_contents_scale = raster_contents_scale_; | 935 float old_raster_contents_scale = raster_contents_scale_; | 
| 902 float old_raster_page_scale = raster_page_scale_; | 936 float old_raster_page_scale = raster_page_scale_; | 
| 903 float old_raster_source_scale = raster_source_scale_; | 937 float old_raster_source_scale = raster_source_scale_; | 
| 904 | 938 | 
| 905 raster_device_scale_ = ideal_device_scale_; | 939 // Get fixed precision values to avoid creating extra tilings for scales | 
| 906 raster_page_scale_ = ideal_page_scale_; | 940 // which are almost equal. | 
| 907 raster_source_scale_ = ideal_source_scale_; | 941 raster_device_scale_ = GetFixedPrecisionValue(ideal_device_scale_); | 
| 908 raster_contents_scale_ = ideal_contents_scale_; | 942 raster_page_scale_ = GetFixedPrecisionValue(ideal_page_scale_); | 
| 943 raster_source_scale_ = GetFixedPrecisionValue(ideal_source_scale_); | |
| 944 raster_contents_scale_ = GetFixedPrecisionValue(ideal_contents_scale_); | |
| 
enne (OOO)
2015/08/27 18:08:34
Do we really need fixed precision for all of these
 | |
| 909 | 945 | 
| 910 // If we're not animating, or leaving an animation, and the | 946 // If we're not animating, or leaving an animation, and the | 
| 911 // ideal_source_scale_ changes, then things are unpredictable, and we fix | 947 // ideal_source_scale_ changes, then things are unpredictable, and we fix | 
| 912 // the raster_source_scale_ in place. | 948 // the raster_source_scale_ in place. | 
| 913 if (old_raster_source_scale && | 949 if (old_raster_source_scale && | 
| 914 !draw_properties().screen_space_transform_is_animating && | 950 !draw_properties().screen_space_transform_is_animating && | 
| 915 !was_screen_space_transform_animating_ && | 951 !was_screen_space_transform_animating_ && | 
| 916 old_raster_source_scale != ideal_source_scale_) | 952 old_raster_source_scale != ideal_source_scale_) | 
| 917 raster_source_scale_is_fixed_ = true; | 953 raster_source_scale_is_fixed_ = true; | 
| 918 | 954 | 
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1226 | 1262 | 
| 1227 bool PictureLayerImpl::IsOnActiveOrPendingTree() const { | 1263 bool PictureLayerImpl::IsOnActiveOrPendingTree() const { | 
| 1228 return !layer_tree_impl()->IsRecycleTree(); | 1264 return !layer_tree_impl()->IsRecycleTree(); | 
| 1229 } | 1265 } | 
| 1230 | 1266 | 
| 1231 bool PictureLayerImpl::HasValidTilePriorities() const { | 1267 bool PictureLayerImpl::HasValidTilePriorities() const { | 
| 1232 return IsOnActiveOrPendingTree() && IsDrawnRenderSurfaceLayerListMember(); | 1268 return IsOnActiveOrPendingTree() && IsDrawnRenderSurfaceLayerListMember(); | 
| 1233 } | 1269 } | 
| 1234 | 1270 | 
| 1235 } // namespace cc | 1271 } // namespace cc | 
| OLD | NEW |