| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "platform/graphics/CompositorMutableState.h" | 5 #include "platform/graphics/CompositorMutableState.h" |
| 6 | 6 |
| 7 #include "cc/layers/layer_impl.h" | 7 #include "platform/graphics/CompositorMutableProperties.h" |
| 8 #include "cc/trees/layer_tree_impl.h" | |
| 9 #include "platform/graphics/CompositorMutation.h" | 8 #include "platform/graphics/CompositorMutation.h" |
| 10 | 9 |
| 11 namespace blink { | 10 namespace blink { |
| 12 CompositorMutableState::CompositorMutableState(CompositorMutation* mutation, | 11 CompositorMutableState::CompositorMutableState( |
| 13 cc::LayerImpl* main, | 12 CompositorMutation* mutation, |
| 14 cc::LayerImpl* scroll) | 13 CompositorMutableProperties* properties) |
| 15 : m_mutation(mutation), m_mainLayer(main), m_scrollLayer(scroll) {} | 14 : m_mutation(mutation), m_properties(properties) {} |
| 16 | 15 |
| 17 CompositorMutableState::~CompositorMutableState() {} | 16 CompositorMutableState::~CompositorMutableState() {} |
| 18 | 17 |
| 19 double CompositorMutableState::opacity() const { | 18 double CompositorMutableState::opacity() const { |
| 20 return m_mainLayer->Opacity(); | 19 return m_properties->opacity; |
| 21 } | 20 } |
| 22 | 21 |
| 23 void CompositorMutableState::setOpacity(double opacity) { | 22 void CompositorMutableState::setOpacity(double opacity) { |
| 24 if (!m_mainLayer) | 23 m_properties->opacity = opacity; |
| 25 return; | |
| 26 m_mainLayer->layer_tree_impl() | |
| 27 ->property_trees() | |
| 28 ->effect_tree.OnOpacityAnimated(opacity, m_mainLayer->effect_tree_index(), | |
| 29 m_mainLayer->layer_tree_impl()); | |
| 30 m_mutation->setOpacity(opacity); | 24 m_mutation->setOpacity(opacity); |
| 31 } | 25 } |
| 32 | 26 |
| 33 const SkMatrix44& CompositorMutableState::transform() const { | 27 const SkMatrix44& CompositorMutableState::transform() const { |
| 34 return m_mainLayer ? m_mainLayer->Transform().matrix() : SkMatrix44::I(); | 28 return m_properties->transform; |
| 35 } | 29 } |
| 36 | 30 |
| 37 void CompositorMutableState::setTransform(const SkMatrix44& matrix) { | 31 void CompositorMutableState::setTransform(const SkMatrix44& matrix) { |
| 38 if (!m_mainLayer) | 32 m_properties->transform = matrix; |
| 39 return; | |
| 40 m_mainLayer->layer_tree_impl() | |
| 41 ->property_trees() | |
| 42 ->transform_tree.OnTransformAnimated(gfx::Transform(matrix), | |
| 43 m_mainLayer->transform_tree_index(), | |
| 44 m_mainLayer->layer_tree_impl()); | |
| 45 m_mutation->setTransform(matrix); | 33 m_mutation->setTransform(matrix); |
| 46 } | 34 } |
| 47 | 35 |
| 48 float CompositorMutableState::scrollLeft() const { | 36 float CompositorMutableState::scrollLeft() const { |
| 49 return m_scrollLayer ? m_scrollLayer->CurrentScrollOffset().x() : 0.0; | 37 return m_properties->scrollLeft; |
| 50 } | 38 } |
| 51 | 39 |
| 52 void CompositorMutableState::setScrollLeft(float scrollLeft) { | 40 void CompositorMutableState::setScrollLeft(float scrollLeft) { |
| 53 if (!m_scrollLayer) | 41 m_properties->scrollLeft = scrollLeft; |
| 54 return; | |
| 55 | |
| 56 gfx::ScrollOffset offset = m_scrollLayer->CurrentScrollOffset(); | |
| 57 offset.set_x(scrollLeft); | |
| 58 m_scrollLayer->layer_tree_impl() | |
| 59 ->property_trees() | |
| 60 ->scroll_tree.OnScrollOffsetAnimated( | |
| 61 m_scrollLayer->id(), m_scrollLayer->scroll_tree_index(), offset, | |
| 62 m_scrollLayer->layer_tree_impl()); | |
| 63 m_mutation->setScrollLeft(scrollLeft); | 42 m_mutation->setScrollLeft(scrollLeft); |
| 64 } | 43 } |
| 65 | 44 |
| 66 float CompositorMutableState::scrollTop() const { | 45 float CompositorMutableState::scrollTop() const { |
| 67 return m_scrollLayer ? m_scrollLayer->CurrentScrollOffset().y() : 0.0; | 46 return m_properties->scrollTop; |
| 68 } | 47 } |
| 69 | 48 |
| 70 void CompositorMutableState::setScrollTop(float scrollTop) { | 49 void CompositorMutableState::setScrollTop(float scrollTop) { |
| 71 if (!m_scrollLayer) | 50 m_properties->scrollTop = scrollTop; |
| 72 return; | |
| 73 gfx::ScrollOffset offset = m_scrollLayer->CurrentScrollOffset(); | |
| 74 offset.set_y(scrollTop); | |
| 75 m_scrollLayer->layer_tree_impl() | |
| 76 ->property_trees() | |
| 77 ->scroll_tree.OnScrollOffsetAnimated( | |
| 78 m_scrollLayer->id(), m_scrollLayer->scroll_tree_index(), offset, | |
| 79 m_scrollLayer->layer_tree_impl()); | |
| 80 m_mutation->setScrollTop(scrollTop); | 51 m_mutation->setScrollTop(scrollTop); |
| 81 } | 52 } |
| 82 | 53 |
| 83 } // namespace blink | 54 } // namespace blink |
| OLD | NEW |