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

Side by Side Diff: cc/layers/layer_impl.cc

Issue 130443005: [#5] Pass gfx structs by const ref (gfx::Vector2dF) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Incorporated the review comments Created 6 years, 11 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/layers/layer_impl.h ('k') | cc/layers/layer_impl_unittest.cc » ('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 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/layer_impl.h" 5 #include "cc/layers/layer_impl.h"
6 6
7 #include "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "base/json/json_reader.h" 8 #include "base/json/json_reader.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "cc/animation/animation_registrar.h" 10 #include "cc/animation/animation_registrar.h"
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 void LayerImpl::SetSentScrollDelta(gfx::Vector2d sent_scroll_delta) { 369 void LayerImpl::SetSentScrollDelta(gfx::Vector2d sent_scroll_delta) {
370 // Pending tree never has sent scroll deltas 370 // Pending tree never has sent scroll deltas
371 DCHECK(layer_tree_impl()->IsActiveTree()); 371 DCHECK(layer_tree_impl()->IsActiveTree());
372 372
373 if (sent_scroll_delta_ == sent_scroll_delta) 373 if (sent_scroll_delta_ == sent_scroll_delta)
374 return; 374 return;
375 375
376 sent_scroll_delta_ = sent_scroll_delta; 376 sent_scroll_delta_ = sent_scroll_delta;
377 } 377 }
378 378
379 gfx::Vector2dF LayerImpl::ScrollBy(gfx::Vector2dF scroll) { 379 gfx::Vector2dF LayerImpl::ScrollBy(const gfx::Vector2dF& scroll) {
380 DCHECK(scrollable()); 380 DCHECK(scrollable());
381 gfx::Vector2dF min_delta = -scroll_offset_; 381 gfx::Vector2dF min_delta = -scroll_offset_;
382 gfx::Vector2dF max_delta = max_scroll_offset_ - scroll_offset_; 382 gfx::Vector2dF max_delta = max_scroll_offset_ - scroll_offset_;
383 // Clamp new_delta so that position + delta stays within scroll bounds. 383 // Clamp new_delta so that position + delta stays within scroll bounds.
384 gfx::Vector2dF new_delta = (ScrollDelta() + scroll); 384 gfx::Vector2dF new_delta = (ScrollDelta() + scroll);
385 new_delta.SetToMax(min_delta); 385 new_delta.SetToMax(min_delta);
386 new_delta.SetToMin(max_delta); 386 new_delta.SetToMin(max_delta);
387 gfx::Vector2dF unscrolled = 387 gfx::Vector2dF unscrolled =
388 ScrollDelta() + scroll - new_delta; 388 ScrollDelta() + scroll - new_delta;
389 SetScrollDelta(new_delta); 389 SetScrollDelta(new_delta);
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
724 } 724 }
725 725
726 void LayerImpl::OnOpacityAnimated(float opacity) { 726 void LayerImpl::OnOpacityAnimated(float opacity) {
727 SetOpacity(opacity); 727 SetOpacity(opacity);
728 } 728 }
729 729
730 void LayerImpl::OnTransformAnimated(const gfx::Transform& transform) { 730 void LayerImpl::OnTransformAnimated(const gfx::Transform& transform) {
731 SetTransform(transform); 731 SetTransform(transform);
732 } 732 }
733 733
734 void LayerImpl::OnScrollOffsetAnimated(gfx::Vector2dF scroll_offset) { 734 void LayerImpl::OnScrollOffsetAnimated(const gfx::Vector2dF& scroll_offset) {
735 // Only layers in the active tree should need to do anything here, since 735 // Only layers in the active tree should need to do anything here, since
736 // layers in the pending tree will find out about these changes as a 736 // layers in the pending tree will find out about these changes as a
737 // result of the call to SetScrollDelta. 737 // result of the call to SetScrollDelta.
738 if (!IsActive()) 738 if (!IsActive())
739 return; 739 return;
740 740
741 SetScrollDelta(scroll_offset - scroll_offset_); 741 SetScrollDelta(scroll_offset - scroll_offset_);
742 742
743 layer_tree_impl_->DidAnimateScrollOffset(); 743 layer_tree_impl_->DidAnimateScrollOffset();
744 } 744 }
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
1085 bool LayerImpl::IsExternalFlingActive() const { 1085 bool LayerImpl::IsExternalFlingActive() const {
1086 return scroll_offset_delegate_ && 1086 return scroll_offset_delegate_ &&
1087 scroll_offset_delegate_->IsExternalFlingActive(); 1087 scroll_offset_delegate_->IsExternalFlingActive();
1088 } 1088 }
1089 1089
1090 void LayerImpl::SetScrollOffset(gfx::Vector2d scroll_offset) { 1090 void LayerImpl::SetScrollOffset(gfx::Vector2d scroll_offset) {
1091 SetScrollOffsetAndDelta(scroll_offset, ScrollDelta()); 1091 SetScrollOffsetAndDelta(scroll_offset, ScrollDelta());
1092 } 1092 }
1093 1093
1094 void LayerImpl::SetScrollOffsetAndDelta(gfx::Vector2d scroll_offset, 1094 void LayerImpl::SetScrollOffsetAndDelta(gfx::Vector2d scroll_offset,
1095 gfx::Vector2dF scroll_delta) { 1095 const gfx::Vector2dF& scroll_delta) {
1096 bool changed = false; 1096 bool changed = false;
1097 1097
1098 if (scroll_offset_ != scroll_offset) { 1098 if (scroll_offset_ != scroll_offset) {
1099 changed = true; 1099 changed = true;
1100 scroll_offset_ = scroll_offset; 1100 scroll_offset_ = scroll_offset;
1101 1101
1102 if (scroll_offset_delegate_) 1102 if (scroll_offset_delegate_)
1103 scroll_offset_delegate_->SetTotalScrollOffset(TotalScrollOffset()); 1103 scroll_offset_delegate_->SetTotalScrollOffset(TotalScrollOffset());
1104 } 1104 }
1105 1105
(...skipping 26 matching lines...) Expand all
1132 UpdateScrollbarPositions(); 1132 UpdateScrollbarPositions();
1133 } 1133 }
1134 } 1134 }
1135 1135
1136 gfx::Vector2dF LayerImpl::ScrollDelta() const { 1136 gfx::Vector2dF LayerImpl::ScrollDelta() const {
1137 if (scroll_offset_delegate_) 1137 if (scroll_offset_delegate_)
1138 return scroll_offset_delegate_->GetTotalScrollOffset() - scroll_offset_; 1138 return scroll_offset_delegate_->GetTotalScrollOffset() - scroll_offset_;
1139 return scroll_delta_; 1139 return scroll_delta_;
1140 } 1140 }
1141 1141
1142 void LayerImpl::SetScrollDelta(gfx::Vector2dF scroll_delta) { 1142 void LayerImpl::SetScrollDelta(const gfx::Vector2dF& scroll_delta) {
1143 SetScrollOffsetAndDelta(scroll_offset_, scroll_delta); 1143 SetScrollOffsetAndDelta(scroll_offset_, scroll_delta);
1144 } 1144 }
1145 1145
1146 gfx::Vector2dF LayerImpl::TotalScrollOffset() const { 1146 gfx::Vector2dF LayerImpl::TotalScrollOffset() const {
1147 return scroll_offset_ + ScrollDelta(); 1147 return scroll_offset_ + ScrollDelta();
1148 } 1148 }
1149 1149
1150 void LayerImpl::SetDoubleSided(bool double_sided) { 1150 void LayerImpl::SetDoubleSided(bool double_sided) {
1151 if (double_sided_ == double_sided) 1151 if (double_sided_ == double_sided)
1152 return; 1152 return;
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
1337 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); 1337 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue());
1338 AsValueInto(state.get()); 1338 AsValueInto(state.get());
1339 return state.PassAs<base::Value>(); 1339 return state.PassAs<base::Value>();
1340 } 1340 }
1341 1341
1342 void LayerImpl::RunMicroBenchmark(MicroBenchmarkImpl* benchmark) { 1342 void LayerImpl::RunMicroBenchmark(MicroBenchmarkImpl* benchmark) {
1343 benchmark->RunOnLayer(this); 1343 benchmark->RunOnLayer(this);
1344 } 1344 }
1345 1345
1346 } // namespace cc 1346 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/layer_impl.h ('k') | cc/layers/layer_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698