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

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

Issue 1766053002: Clean LayerImpl's scroll offset callers in unit tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove transform tree update setting Created 4 years, 9 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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <utility> 10 #include <utility>
(...skipping 1434 matching lines...) Expand 10 before | Expand all | Expand 10 after
1445 void LayerImpl::SetCurrentScrollOffset(const gfx::ScrollOffset& scroll_offset) { 1445 void LayerImpl::SetCurrentScrollOffset(const gfx::ScrollOffset& scroll_offset) {
1446 DCHECK(IsActive()); 1446 DCHECK(IsActive());
1447 if (synced_scroll_offset()->SetCurrent(scroll_offset)) 1447 if (synced_scroll_offset()->SetCurrent(scroll_offset))
1448 DidUpdateScrollOffset(); 1448 DidUpdateScrollOffset();
1449 } 1449 }
1450 1450
1451 gfx::ScrollOffset LayerImpl::CurrentScrollOffset() const { 1451 gfx::ScrollOffset LayerImpl::CurrentScrollOffset() const {
1452 return synced_scroll_offset()->Current(IsActive()); 1452 return synced_scroll_offset()->Current(IsActive());
1453 } 1453 }
1454 1454
1455 gfx::Vector2dF LayerImpl::ScrollDelta() const {
1456 if (IsActive())
1457 return gfx::Vector2dF(synced_scroll_offset()->Delta().x(),
1458 synced_scroll_offset()->Delta().y());
1459 else
1460 return gfx::Vector2dF(synced_scroll_offset()->PendingDelta().get().x(),
1461 synced_scroll_offset()->PendingDelta().get().y());
1462 }
1463
1464 void LayerImpl::SetScrollDelta(const gfx::Vector2dF& delta) {
1465 DCHECK(IsActive());
1466 DCHECK(scrollable() || delta.IsZero());
1467 SetCurrentScrollOffset(synced_scroll_offset()->ActiveBase() +
1468 gfx::ScrollOffset(delta));
1469 }
1470
1471 gfx::ScrollOffset LayerImpl::BaseScrollOffset() const {
1472 if (IsActive())
1473 return synced_scroll_offset()->ActiveBase();
1474 else
1475 return synced_scroll_offset()->PendingBase();
1476 }
1477
1478 void LayerImpl::PushScrollOffsetFromMainThread(
1479 const gfx::ScrollOffset& scroll_offset) {
1480 bool changed = false;
1481 DCHECK(!IsActive() || !layer_tree_impl_->FindPendingTreeLayerById(id()));
1482 changed |= synced_scroll_offset()->PushFromMainThread(scroll_offset);
1483
1484 if (IsActive()) {
1485 changed |= synced_scroll_offset()->PushPendingToActive();
1486 }
1487
1488 if (changed)
1489 DidUpdateScrollOffset();
1490 }
1491
1492 void LayerImpl::UpdatePropertyTreeScrollOffset() { 1455 void LayerImpl::UpdatePropertyTreeScrollOffset() {
1493 // TODO(enne): in the future, scrolling should update the scroll tree 1456 // TODO(enne): in the future, scrolling should update the scroll tree
1494 // directly instead of going through layers. 1457 // directly instead of going through layers.
1495 if (transform_tree_index_ != -1) { 1458 if (transform_tree_index_ != -1) {
1496 TransformTree& transform_tree = 1459 TransformTree& transform_tree =
1497 layer_tree_impl()->property_trees()->transform_tree; 1460 layer_tree_impl()->property_trees()->transform_tree;
1498 TransformNode* node = transform_tree.Node(transform_tree_index_); 1461 TransformNode* node = transform_tree.Node(transform_tree_index_);
1499 gfx::ScrollOffset current_offset = 1462 gfx::ScrollOffset current_offset =
1500 synced_scroll_offset()->Current(IsActive()); 1463 synced_scroll_offset()->Current(IsActive());
1501 if (node->data.scroll_offset != current_offset) { 1464 if (node->data.scroll_offset != current_offset) {
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
1795 .layer_transforms_should_scale_layer_contents) { 1758 .layer_transforms_should_scale_layer_contents) {
1796 return default_scale; 1759 return default_scale;
1797 } 1760 }
1798 1761
1799 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents( 1762 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents(
1800 DrawTransform(), default_scale); 1763 DrawTransform(), default_scale);
1801 return std::max(transform_scales.x(), transform_scales.y()); 1764 return std::max(transform_scales.x(), transform_scales.y());
1802 } 1765 }
1803 1766
1804 } // namespace cc 1767 } // 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