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

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

Issue 584503005: Make scroll offset type of float in cc (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: link crbug to TODO Created 6 years, 2 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 | « cc/test/animation_test_common.cc ('k') | cc/trees/layer_tree_host_common.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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/trees/layer_tree_host.h" 5 #include "cc/trees/layer_tree_host.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <stack> 8 #include <stack>
9 #include <string> 9 #include <string>
10 10
(...skipping 1067 matching lines...) Expand 10 before | Expand all | Expand 10 after
1078 for (size_t i = 0; i < info->scrolls.size(); ++i) { 1078 for (size_t i = 0; i < info->scrolls.size(); ++i) {
1079 Layer* layer = LayerTreeHostCommon::FindLayerInSubtree( 1079 Layer* layer = LayerTreeHostCommon::FindLayerInSubtree(
1080 root_layer_.get(), info->scrolls[i].layer_id); 1080 root_layer_.get(), info->scrolls[i].layer_id);
1081 if (!layer) 1081 if (!layer)
1082 continue; 1082 continue;
1083 if (layer == outer_viewport_scroll_layer_.get()) { 1083 if (layer == outer_viewport_scroll_layer_.get()) {
1084 outer_viewport_scroll_delta += info->scrolls[i].scroll_delta; 1084 outer_viewport_scroll_delta += info->scrolls[i].scroll_delta;
1085 } else if (layer == inner_viewport_scroll_layer_.get()) { 1085 } else if (layer == inner_viewport_scroll_layer_.get()) {
1086 inner_viewport_scroll_delta += info->scrolls[i].scroll_delta; 1086 inner_viewport_scroll_delta += info->scrolls[i].scroll_delta;
1087 } else { 1087 } else {
1088 layer->SetScrollOffsetFromImplSide(layer->scroll_offset() + 1088 layer->SetScrollOffsetFromImplSide(
1089 info->scrolls[i].scroll_delta); 1089 gfx::ScrollOffsetWithDelta(layer->scroll_offset(),
1090 info->scrolls[i].scroll_delta));
1090 } 1091 }
1091 } 1092 }
1092 1093
1093 if (!inner_viewport_scroll_delta.IsZero() || 1094 if (!inner_viewport_scroll_delta.IsZero() ||
1094 !outer_viewport_scroll_delta.IsZero() || 1095 !outer_viewport_scroll_delta.IsZero() ||
1095 info->page_scale_delta != 1.f || 1096 info->page_scale_delta != 1.f ||
1096 info->top_controls_delta) { 1097 info->top_controls_delta) {
1097 // SetScrollOffsetFromImplSide above could have destroyed the tree, 1098 // SetScrollOffsetFromImplSide above could have destroyed the tree,
1098 // so re-get this layer before doing anything to it. 1099 // so re-get this layer before doing anything to it.
1099 1100
1100 DCHECK(inner_viewport_scroll_layer_.get()); // We should always have this. 1101 DCHECK(inner_viewport_scroll_layer_.get()); // We should always have this.
1101 1102
1102 // Preemptively apply the scroll offset and scale delta here before sending 1103 // Preemptively apply the scroll offset and scale delta here before sending
1103 // it to the client. If the client comes back and sets it to the same 1104 // it to the client. If the client comes back and sets it to the same
1104 // value, then the layer can early out without needing a full commit. 1105 // value, then the layer can early out without needing a full commit.
1105 inner_viewport_scroll_layer_->SetScrollOffsetFromImplSide( 1106 inner_viewport_scroll_layer_->SetScrollOffsetFromImplSide(
1106 inner_viewport_scroll_layer_->scroll_offset() + 1107 gfx::ScrollOffsetWithDelta(
1107 inner_viewport_scroll_delta); 1108 inner_viewport_scroll_layer_->scroll_offset(),
1109 inner_viewport_scroll_delta));
1108 if (outer_viewport_scroll_layer_.get()) { 1110 if (outer_viewport_scroll_layer_.get()) {
1109 outer_viewport_scroll_layer_->SetScrollOffsetFromImplSide( 1111 outer_viewport_scroll_layer_->SetScrollOffsetFromImplSide(
1110 outer_viewport_scroll_layer_->scroll_offset() + 1112 gfx::ScrollOffsetWithDelta(
1111 outer_viewport_scroll_delta); 1113 outer_viewport_scroll_layer_->scroll_offset(),
1114 outer_viewport_scroll_delta));
1112 } 1115 }
1113 1116
1114 ApplyPageScaleDeltaFromImplSide(info->page_scale_delta); 1117 ApplyPageScaleDeltaFromImplSide(info->page_scale_delta);
1115 if (!outer_viewport_scroll_layer_.get()) { 1118 if (!outer_viewport_scroll_layer_.get()) {
1116 client_->ApplyViewportDeltas( 1119 client_->ApplyViewportDeltas(
1117 inner_viewport_scroll_delta + outer_viewport_scroll_delta, 1120 inner_viewport_scroll_delta + outer_viewport_scroll_delta,
1118 info->page_scale_delta, 1121 info->page_scale_delta,
1119 info->top_controls_delta); 1122 info->top_controls_delta);
1120 } else { 1123 } else {
1121 client_->ApplyViewportDeltas( 1124 client_->ApplyViewportDeltas(
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
1331 swap_promise_list_.push_back(swap_promise.Pass()); 1334 swap_promise_list_.push_back(swap_promise.Pass());
1332 } 1335 }
1333 1336
1334 void LayerTreeHost::BreakSwapPromises(SwapPromise::DidNotSwapReason reason) { 1337 void LayerTreeHost::BreakSwapPromises(SwapPromise::DidNotSwapReason reason) {
1335 for (size_t i = 0; i < swap_promise_list_.size(); i++) 1338 for (size_t i = 0; i < swap_promise_list_.size(); i++)
1336 swap_promise_list_[i]->DidNotSwap(reason); 1339 swap_promise_list_[i]->DidNotSwap(reason);
1337 swap_promise_list_.clear(); 1340 swap_promise_list_.clear();
1338 } 1341 }
1339 1342
1340 } // namespace cc 1343 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/animation_test_common.cc ('k') | cc/trees/layer_tree_host_common.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698