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

Side by Side Diff: cc/trees/property_tree.cc

Issue 2511473003: Round the scroll offset synced back to main instead of flooring. (Closed)
Patch Set: Wait for scroll animation to complete before checking main thread scrolling reasons. Created 4 years 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include <set> 7 #include <set>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 1202 matching lines...) Expand 10 before | Expand all | Expand 10 after
1213 1213
1214 const gfx::ScrollOffset ScrollTree::current_scroll_offset(int layer_id) const { 1214 const gfx::ScrollOffset ScrollTree::current_scroll_offset(int layer_id) const {
1215 return synced_scroll_offset(layer_id) 1215 return synced_scroll_offset(layer_id)
1216 ? synced_scroll_offset(layer_id)->Current( 1216 ? synced_scroll_offset(layer_id)->Current(
1217 property_trees()->is_active) 1217 property_trees()->is_active)
1218 : gfx::ScrollOffset(); 1218 : gfx::ScrollOffset();
1219 } 1219 }
1220 1220
1221 gfx::ScrollOffset ScrollTree::PullDeltaForMainThread( 1221 gfx::ScrollOffset ScrollTree::PullDeltaForMainThread(
1222 SyncedScrollOffset* scroll_offset) { 1222 SyncedScrollOffset* scroll_offset) {
1223 // TODO(miletus): Remove all this temporary flooring machinery when 1223 // TODO(flackr): We should pass the fractional scroll deltas when Blink fully
1224 // Blink fully supports fractional scrolls. 1224 // supports fractional scrolls.
1225 // TODO(flackr): We should ideally round the fractional scrolls in the same
1226 // direction as the scroll will be snapped but for common cases this is
1227 // equivalent to rounding to the nearest integer offset.
1225 gfx::ScrollOffset current_offset = 1228 gfx::ScrollOffset current_offset =
1226 scroll_offset->Current(property_trees()->is_active); 1229 scroll_offset->Current(property_trees()->is_active);
1227 gfx::ScrollOffset current_delta = property_trees()->is_active 1230 gfx::ScrollOffset rounded_offset =
1228 ? scroll_offset->Delta() 1231 gfx::ScrollOffset(roundf(current_offset.x()), roundf(current_offset.y()));
1229 : scroll_offset->PendingDelta().get(); 1232 scroll_offset->SetCurrent(rounded_offset);
1230 gfx::ScrollOffset floored_delta(floor(current_delta.x()),
1231 floor(current_delta.y()));
1232 gfx::ScrollOffset diff_delta = floored_delta - current_delta;
1233 gfx::ScrollOffset tmp_offset = current_offset + diff_delta;
1234 scroll_offset->SetCurrent(tmp_offset);
1235 gfx::ScrollOffset delta = scroll_offset->PullDeltaForMainThread(); 1233 gfx::ScrollOffset delta = scroll_offset->PullDeltaForMainThread();
1236 scroll_offset->SetCurrent(current_offset); 1234 scroll_offset->SetCurrent(current_offset);
1237 return delta; 1235 return delta;
1238 } 1236 }
1239 1237
1240 void ScrollTree::CollectScrollDeltas(ScrollAndScaleSet* scroll_info, 1238 void ScrollTree::CollectScrollDeltas(ScrollAndScaleSet* scroll_info,
1241 int inner_viewport_layer_id) { 1239 int inner_viewport_layer_id) {
1242 for (auto map_entry : layer_id_to_scroll_offset_map_) { 1240 for (auto map_entry : layer_id_to_scroll_offset_map_) {
1243 gfx::ScrollOffset scroll_delta = 1241 gfx::ScrollOffset scroll_delta =
1244 PullDeltaForMainThread(map_entry.second.get()); 1242 PullDeltaForMainThread(map_entry.second.get());
(...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after
1978 1976
1979 const EffectNode* effect_node = effect_tree.Node(effect_id); 1977 const EffectNode* effect_node = effect_tree.Node(effect_id);
1980 1978
1981 bool success = GetFromTarget(transform_id, effect_id, transform); 1979 bool success = GetFromTarget(transform_id, effect_id, transform);
1982 transform->Scale(effect_node->surface_contents_scale.x(), 1980 transform->Scale(effect_node->surface_contents_scale.x(),
1983 effect_node->surface_contents_scale.y()); 1981 effect_node->surface_contents_scale.y());
1984 return success; 1982 return success;
1985 } 1983 }
1986 1984
1987 } // namespace cc 1985 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698