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

Side by Side 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, 3 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 | no next file » | 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 <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
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 float RoundToFixedPrecision(float value) {
59 // Limiting precision 1 <= kScalePrecision <= 8, as floating point precision
60 // of >= 12 gives different values, 8 on a safer side.
61 DCHECK(kScalePrecision >= 1 && kScalePrecision <= 8);
62
63 const float factor = pow(10, kScalePrecision);
64 float integral;
65 float fractional = std::modf(value, &integral);
prashant.n 2015/09/01 16:55:25 I tried checking standard way for doing this. Defi
66 fractional *= factor;
67 fractional = std::round(fractional);
68 fractional /= factor;
69 return integral + fractional;
70 }
71
52 } // namespace 72 } // namespace
53 73
54 namespace cc { 74 namespace cc {
55 75
56 PictureLayerImpl::PictureLayerImpl( 76 PictureLayerImpl::PictureLayerImpl(
57 LayerTreeImpl* tree_impl, 77 LayerTreeImpl* tree_impl,
58 int id, 78 int id,
59 bool is_mask, 79 bool is_mask,
60 scoped_refptr<SyncedScrollOffset> scroll_offset) 80 scoped_refptr<SyncedScrollOffset> scroll_offset)
61 : LayerImpl(tree_impl, id, scroll_offset), 81 : LayerImpl(tree_impl, id, scroll_offset),
(...skipping 833 matching lines...) Expand 10 before | Expand all | Expand 10 after
895 return true; 915 return true;
896 916
897 return false; 917 return false;
898 } 918 }
899 919
900 void PictureLayerImpl::RecalculateRasterScales() { 920 void PictureLayerImpl::RecalculateRasterScales() {
901 float old_raster_contents_scale = raster_contents_scale_; 921 float old_raster_contents_scale = raster_contents_scale_;
902 float old_raster_page_scale = raster_page_scale_; 922 float old_raster_page_scale = raster_page_scale_;
903 float old_raster_source_scale = raster_source_scale_; 923 float old_raster_source_scale = raster_source_scale_;
904 924
925 // Get fixed precision values to avoid creating extra tilings for scales
926 // which are almost equal.
905 raster_device_scale_ = ideal_device_scale_; 927 raster_device_scale_ = ideal_device_scale_;
906 raster_page_scale_ = ideal_page_scale_; 928 raster_page_scale_ = ideal_page_scale_;
907 raster_source_scale_ = ideal_source_scale_; 929 raster_source_scale_ = ideal_source_scale_;
908 raster_contents_scale_ = ideal_contents_scale_; 930 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
909 931
910 // If we're not animating, or leaving an animation, and the 932 // If we're not animating, or leaving an animation, and the
911 // ideal_source_scale_ changes, then things are unpredictable, and we fix 933 // ideal_source_scale_ changes, then things are unpredictable, and we fix
912 // the raster_source_scale_ in place. 934 // the raster_source_scale_ in place.
913 if (old_raster_source_scale && 935 if (old_raster_source_scale &&
914 !draw_properties().screen_space_transform_is_animating && 936 !draw_properties().screen_space_transform_is_animating &&
915 !was_screen_space_transform_animating_ && 937 !was_screen_space_transform_animating_ &&
916 old_raster_source_scale != ideal_source_scale_) 938 old_raster_source_scale != ideal_source_scale_)
917 raster_source_scale_is_fixed_ = true; 939 raster_source_scale_is_fixed_ = true;
918 940
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
1226 1248
1227 bool PictureLayerImpl::IsOnActiveOrPendingTree() const { 1249 bool PictureLayerImpl::IsOnActiveOrPendingTree() const {
1228 return !layer_tree_impl()->IsRecycleTree(); 1250 return !layer_tree_impl()->IsRecycleTree();
1229 } 1251 }
1230 1252
1231 bool PictureLayerImpl::HasValidTilePriorities() const { 1253 bool PictureLayerImpl::HasValidTilePriorities() const {
1232 return IsOnActiveOrPendingTree() && IsDrawnRenderSurfaceLayerListMember(); 1254 return IsOnActiveOrPendingTree() && IsDrawnRenderSurfaceLayerListMember();
1233 } 1255 }
1234 1256
1235 } // namespace cc 1257 } // namespace cc
OLDNEW
« 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