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

Side by Side Diff: cc/trees/layer_tree_host_common.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: fix unittests 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_impl.cc ('k') | cc/trees/layer_tree_host_common_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 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_common.h" 5 #include "cc/trees/layer_tree_host_common.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "cc/base/math_util.h" 10 #include "cc/base/math_util.h"
(...skipping 28 matching lines...) Expand all
39 static void SortLayers(LayerImplList::iterator first, 39 static void SortLayers(LayerImplList::iterator first,
40 LayerImplList::iterator end, 40 LayerImplList::iterator end,
41 LayerSorter* layer_sorter) { 41 LayerSorter* layer_sorter) {
42 DCHECK(layer_sorter); 42 DCHECK(layer_sorter);
43 TRACE_EVENT0("cc", "LayerTreeHostCommon::SortLayers"); 43 TRACE_EVENT0("cc", "LayerTreeHostCommon::SortLayers");
44 layer_sorter->Sort(first, end); 44 layer_sorter->Sort(first, end);
45 } 45 }
46 46
47 template <typename LayerType> 47 template <typename LayerType>
48 static gfx::Vector2dF GetEffectiveScrollDelta(LayerType* layer) { 48 static gfx::Vector2dF GetEffectiveScrollDelta(LayerType* layer) {
49 gfx::Vector2dF scroll_delta = layer->ScrollDelta(); 49 // Layer's scroll offset can have an integer part and fractional part.
50 // Due to Blink's limitation, it only counter-scrolls the position-fixed
51 // layer using the integer part of Layer's scroll offset.
52 // CC scrolls the layer using the full scroll offset, so we have to
53 // add the fractional part of the scroll offset to the effective scroll
54 // delta which is used to counter-scroll the position-fixed layer.
55 gfx::Vector2dF scroll_delta =
56 layer->ScrollDelta() + layer->MainScrollOffsetFractionalPart();
50 // The scroll parent's scroll delta is the amount we've scrolled on the 57 // The scroll parent's scroll delta is the amount we've scrolled on the
51 // compositor thread since the commit for this layer tree's source frame. 58 // compositor thread since the commit for this layer tree's source frame.
52 // we last reported to the main thread. I.e., it's the discrepancy between 59 // we last reported to the main thread. I.e., it's the discrepancy between
53 // a scroll parent's scroll delta and offset, so we must add it here. 60 // a scroll parent's scroll delta and offset, so we must add it here.
54 if (layer->scroll_parent()) 61 if (layer->scroll_parent())
55 scroll_delta += layer->scroll_parent()->ScrollDelta(); 62 scroll_delta += layer->scroll_parent()->ScrollDelta() +
63 layer->scroll_parent()->MainScrollOffsetFractionalPart();
56 return scroll_delta; 64 return scroll_delta;
57 } 65 }
58 66
59 template <typename LayerType> 67 template <typename LayerType>
60 static gfx::ScrollOffset GetEffectiveTotalScrollOffset(LayerType* layer) { 68 static gfx::ScrollOffset GetEffectiveTotalScrollOffset(LayerType* layer) {
61 gfx::ScrollOffset offset = layer->TotalScrollOffset(); 69 gfx::ScrollOffset offset = layer->TotalScrollOffset();
62 // The scroll parent's total scroll offset (scroll offset + scroll delta) 70 // The scroll parent's total scroll offset (scroll offset + scroll delta)
63 // can't be used because its scroll offset has already been applied to the 71 // can't be used because its scroll offset has already been applied to the
64 // scroll children's positions by the main thread layer positioning code. 72 // scroll children's positions by the main thread layer positioning code.
65 if (layer->scroll_parent()) 73 if (layer->scroll_parent())
(...skipping 2498 matching lines...) Expand 10 before | Expand all | Expand 10 after
2564 inputs->current_render_surface_layer_list_id); 2572 inputs->current_render_surface_layer_list_id);
2565 2573
2566 // The dummy layer list should not have been used. 2574 // The dummy layer list should not have been used.
2567 DCHECK_EQ(0u, dummy_layer_list.size()); 2575 DCHECK_EQ(0u, dummy_layer_list.size());
2568 // A root layer render_surface should always exist after 2576 // A root layer render_surface should always exist after
2569 // CalculateDrawProperties. 2577 // CalculateDrawProperties.
2570 DCHECK(inputs->root_layer->render_surface()); 2578 DCHECK(inputs->root_layer->render_surface());
2571 } 2579 }
2572 2580
2573 } // namespace cc 2581 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/layer_impl.cc ('k') | cc/trees/layer_tree_host_common_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698