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

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

Issue 877173002: Fixed position layer counter-scroll with main thread scroll offset fractional part (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: resubmit Created 5 years, 10 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.h ('k') | cc/layers/layer_impl.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 2010 The Chromium Authors. All rights reserved. 1 // Copyright 2010 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.h" 5 #include "cc/layers/layer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/atomic_sequence_num.h" 9 #include "base/atomic_sequence_num.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after
665 665
666 void Layer::SetScrollOffset(const gfx::ScrollOffset& scroll_offset) { 666 void Layer::SetScrollOffset(const gfx::ScrollOffset& scroll_offset) {
667 DCHECK(IsPropertyChangeAllowed()); 667 DCHECK(IsPropertyChangeAllowed());
668 668
669 if (scroll_offset_ == scroll_offset) 669 if (scroll_offset_ == scroll_offset)
670 return; 670 return;
671 scroll_offset_ = scroll_offset; 671 scroll_offset_ = scroll_offset;
672 SetNeedsCommit(); 672 SetNeedsCommit();
673 } 673 }
674 674
675 void Layer::SetScrollOffsetFractionalPart(
aelias_OOO_until_Jul13 2015/01/28 22:34:16 Let's not mutate scroll_offset_ in this method. W
Yufeng Shen (Slow to review) 2015/01/28 22:49:27 Done.
676 const gfx::Vector2dF& scroll_offset_fractional_part) {
677 gfx::ScrollOffset floored_scroll_offset(
678 gfx::ScrollOffsetToFlooredVector2d(scroll_offset_));
679 gfx::ScrollOffset new_scroll_offset =
680 ScrollOffsetWithDelta(floored_scroll_offset,
681 scroll_offset_fractional_part);
682 if (new_scroll_offset == scroll_offset_)
683 return;
684 scroll_offset_ = new_scroll_offset;
685 SetNeedsCommit();
686 }
687
688 gfx::Vector2dF Layer::MainScrollOffsetFractionalPart() const {
689 return scroll_offset_.DeltaFrom(gfx::ScrollOffset(
690 gfx::ScrollOffsetToFlooredVector2d(scroll_offset_)));
691 }
692
675 void Layer::SetScrollOffsetFromImplSide( 693 void Layer::SetScrollOffsetFromImplSide(
676 const gfx::ScrollOffset& scroll_offset) { 694 const gfx::ScrollOffset& scroll_offset) {
677 DCHECK(IsPropertyChangeAllowed()); 695 DCHECK(IsPropertyChangeAllowed());
678 // This function only gets called during a BeginMainFrame, so there 696 // This function only gets called during a BeginMainFrame, so there
679 // is no need to call SetNeedsUpdate here. 697 // is no need to call SetNeedsUpdate here.
680 DCHECK(layer_tree_host_ && layer_tree_host_->CommitRequested()); 698 DCHECK(layer_tree_host_ && layer_tree_host_->CommitRequested());
681 if (scroll_offset_ == scroll_offset) 699 if (scroll_offset_ == scroll_offset)
682 return; 700 return;
683 scroll_offset_ = scroll_offset; 701 scroll_offset_ = scroll_offset;
684 SetNeedsPushProperties(); 702 SetNeedsPushProperties();
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
974 } else { 992 } else {
975 if (layer_animation_controller_ 993 if (layer_animation_controller_
976 ->scroll_offset_animation_was_interrupted()) { 994 ->scroll_offset_animation_was_interrupted()) {
977 layer->SetScrollOffsetAndDelta(scroll_offset_, gfx::Vector2dF()); 995 layer->SetScrollOffsetAndDelta(scroll_offset_, gfx::Vector2dF());
978 } else { 996 } else {
979 layer->SetScrollOffsetAndDelta( 997 layer->SetScrollOffsetAndDelta(
980 scroll_offset_, layer->ScrollDelta() - layer->sent_scroll_delta()); 998 scroll_offset_, layer->ScrollDelta() - layer->sent_scroll_delta());
981 } 999 }
982 layer->SetSentScrollDelta(gfx::Vector2dF()); 1000 layer->SetSentScrollDelta(gfx::Vector2dF());
983 } 1001 }
1002 layer->SetMainScrollOffsetFractionalPart(MainScrollOffsetFractionalPart());
984 1003
985 // Wrap the copy_requests_ in a PostTask to the main thread. 1004 // Wrap the copy_requests_ in a PostTask to the main thread.
986 ScopedPtrVector<CopyOutputRequest> main_thread_copy_requests; 1005 ScopedPtrVector<CopyOutputRequest> main_thread_copy_requests;
987 for (ScopedPtrVector<CopyOutputRequest>::iterator it = copy_requests_.begin(); 1006 for (ScopedPtrVector<CopyOutputRequest>::iterator it = copy_requests_.begin();
988 it != copy_requests_.end(); 1007 it != copy_requests_.end();
989 ++it) { 1008 ++it) {
990 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner = 1009 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner =
991 layer_tree_host()->proxy()->MainThreadTaskRunner(); 1010 layer_tree_host()->proxy()->MainThreadTaskRunner();
992 scoped_ptr<CopyOutputRequest> original_request = copy_requests_.take(it); 1011 scoped_ptr<CopyOutputRequest> original_request = copy_requests_.take(it);
993 const CopyOutputRequest& original_request_ref = *original_request; 1012 const CopyOutputRequest& original_request_ref = *original_request;
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
1294 } 1313 }
1295 1314
1296 void Layer::SetFrameTimingRequests( 1315 void Layer::SetFrameTimingRequests(
1297 const std::vector<FrameTimingRequest>& requests) { 1316 const std::vector<FrameTimingRequest>& requests) {
1298 frame_timing_requests_ = requests; 1317 frame_timing_requests_ = requests;
1299 frame_timing_requests_dirty_ = true; 1318 frame_timing_requests_dirty_ = true;
1300 SetNeedsCommit(); 1319 SetNeedsCommit();
1301 } 1320 }
1302 1321
1303 } // namespace cc 1322 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/layer.h ('k') | cc/layers/layer_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698