| OLD | NEW |
| 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 1441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1452 | 1452 |
| 1453 gfx::Vector2dF LayerImpl::ScrollDelta() const { | 1453 gfx::Vector2dF LayerImpl::ScrollDelta() const { |
| 1454 if (IsActive()) | 1454 if (IsActive()) |
| 1455 return gfx::Vector2dF(synced_scroll_offset()->Delta().x(), | 1455 return gfx::Vector2dF(synced_scroll_offset()->Delta().x(), |
| 1456 synced_scroll_offset()->Delta().y()); | 1456 synced_scroll_offset()->Delta().y()); |
| 1457 else | 1457 else |
| 1458 return gfx::Vector2dF(synced_scroll_offset()->PendingDelta().get().x(), | 1458 return gfx::Vector2dF(synced_scroll_offset()->PendingDelta().get().x(), |
| 1459 synced_scroll_offset()->PendingDelta().get().y()); | 1459 synced_scroll_offset()->PendingDelta().get().y()); |
| 1460 } | 1460 } |
| 1461 | 1461 |
| 1462 void LayerImpl::SetScrollDelta(const gfx::Vector2dF& delta) { | |
| 1463 DCHECK(IsActive()); | |
| 1464 DCHECK(scrollable() || delta.IsZero()); | |
| 1465 SetCurrentScrollOffset(synced_scroll_offset()->ActiveBase() + | |
| 1466 gfx::ScrollOffset(delta)); | |
| 1467 } | |
| 1468 | |
| 1469 gfx::ScrollOffset LayerImpl::BaseScrollOffset() const { | |
| 1470 if (IsActive()) | |
| 1471 return synced_scroll_offset()->ActiveBase(); | |
| 1472 else | |
| 1473 return synced_scroll_offset()->PendingBase(); | |
| 1474 } | |
| 1475 | |
| 1476 void LayerImpl::PushScrollOffsetFromMainThread( | |
| 1477 const gfx::ScrollOffset& scroll_offset) { | |
| 1478 bool changed = false; | |
| 1479 DCHECK(!IsActive() || !layer_tree_impl_->FindPendingTreeLayerById(id())); | |
| 1480 changed |= synced_scroll_offset()->PushFromMainThread(scroll_offset); | |
| 1481 | |
| 1482 if (IsActive()) { | |
| 1483 changed |= synced_scroll_offset()->PushPendingToActive(); | |
| 1484 } | |
| 1485 | |
| 1486 if (changed) | |
| 1487 DidUpdateScrollOffset(); | |
| 1488 } | |
| 1489 | |
| 1490 void LayerImpl::UpdatePropertyTreeScrollOffset() { | 1462 void LayerImpl::UpdatePropertyTreeScrollOffset() { |
| 1491 // TODO(enne): in the future, scrolling should update the scroll tree | 1463 // TODO(enne): in the future, scrolling should update the scroll tree |
| 1492 // directly instead of going through layers. | 1464 // directly instead of going through layers. |
| 1493 if (transform_tree_index_ != -1) { | 1465 if (transform_tree_index_ != -1) { |
| 1494 TransformTree& transform_tree = | 1466 TransformTree& transform_tree = |
| 1495 layer_tree_impl()->property_trees()->transform_tree; | 1467 layer_tree_impl()->property_trees()->transform_tree; |
| 1496 TransformNode* node = transform_tree.Node(transform_tree_index_); | 1468 TransformNode* node = transform_tree.Node(transform_tree_index_); |
| 1497 gfx::ScrollOffset current_offset = | 1469 gfx::ScrollOffset current_offset = |
| 1498 synced_scroll_offset()->Current(IsActive()); | 1470 synced_scroll_offset()->Current(IsActive()); |
| 1499 if (node->data.scroll_offset != current_offset) { | 1471 if (node->data.scroll_offset != current_offset) { |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1813 .layer_transforms_should_scale_layer_contents) { | 1785 .layer_transforms_should_scale_layer_contents) { |
| 1814 return default_scale; | 1786 return default_scale; |
| 1815 } | 1787 } |
| 1816 | 1788 |
| 1817 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents( | 1789 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents( |
| 1818 DrawTransform(), default_scale); | 1790 DrawTransform(), default_scale); |
| 1819 return std::max(transform_scales.x(), transform_scales.y()); | 1791 return std::max(transform_scales.x(), transform_scales.y()); |
| 1820 } | 1792 } |
| 1821 | 1793 |
| 1822 } // namespace cc | 1794 } // namespace cc |
| OLD | NEW |