Chromium Code Reviews| 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 "cc/layers/layer_impl.h" |
| 8 #include "cc/trees/layer_tree_impl.h" | 8 #include "cc/trees/layer_tree_impl.h" |
| 9 #include "platform/graphics/CompositorMutation.h" | 9 #include "platform/graphics/CompositorMutation.h" |
| 10 | 10 |
| 11 namespace blink { | 11 namespace blink { |
| 12 CompositorMutableState::CompositorMutableState(CompositorMutation* mutation, | 12 CompositorMutableState::CompositorMutableState(CompositorMutation* mutation, |
| 13 cc::LayerImpl* main, | 13 cc::LayerImpl* main, |
| 14 cc::LayerImpl* scroll) | 14 cc::LayerImpl* scroll) |
| 15 : m_mutation(mutation), m_mainLayer(main), m_scrollLayer(scroll) {} | 15 : m_mutation(mutation), m_mainLayer(main), m_scrollLayer(scroll) {} |
| 16 | 16 |
| 17 CompositorMutableState::~CompositorMutableState() {} | 17 CompositorMutableState::~CompositorMutableState() {} |
| 18 | 18 |
| 19 double CompositorMutableState::opacity() const { | 19 double CompositorMutableState::opacity() const { |
| 20 return m_mainLayer->Opacity(); | 20 return m_mainLayer->Opacity(); |
| 21 } | 21 } |
| 22 | 22 |
| 23 void CompositorMutableState::setOpacity(double opacity) { | 23 void CompositorMutableState::setOpacity(double opacity) { |
| 24 if (!m_mainLayer) | 24 if (!m_mainLayer) |
| 25 return; | 25 return; |
| 26 m_mainLayer->layer_tree_impl() | 26 m_mainLayer->layer_tree_impl()->SetOpacityMutated(m_mainLayer->element_id(), |
|
wkorman
2017/03/27 22:21:52
How feasible to add unit tests for this and below
weiliangc
2017/03/28 20:21:28
I assume this is more along the line of the Compos
wkorman
2017/03/28 23:32:46
Oh cool, I looked but missed that somehow, thanks.
| |
| 27 ->property_trees() | 27 opacity); |
| 28 ->effect_tree.OnOpacityAnimated(opacity, m_mainLayer->effect_tree_index(), | |
| 29 m_mainLayer->layer_tree_impl()); | |
| 30 m_mutation->setOpacity(opacity); | 28 m_mutation->setOpacity(opacity); |
| 31 } | 29 } |
| 32 | 30 |
| 33 const SkMatrix44& CompositorMutableState::transform() const { | 31 const SkMatrix44& CompositorMutableState::transform() const { |
| 34 return m_mainLayer ? m_mainLayer->Transform().matrix() : SkMatrix44::I(); | 32 return m_mainLayer ? m_mainLayer->Transform().matrix() : SkMatrix44::I(); |
| 35 } | 33 } |
| 36 | 34 |
| 37 void CompositorMutableState::setTransform(const SkMatrix44& matrix) { | 35 void CompositorMutableState::setTransform(const SkMatrix44& matrix) { |
| 38 if (!m_mainLayer) | 36 if (!m_mainLayer) |
| 39 return; | 37 return; |
| 40 m_mainLayer->layer_tree_impl() | 38 m_mainLayer->layer_tree_impl()->SetTransformMutated(m_mainLayer->element_id(), |
| 41 ->property_trees() | 39 gfx::Transform(matrix)); |
| 42 ->transform_tree.OnTransformAnimated(gfx::Transform(matrix), | |
| 43 m_mainLayer->transform_tree_index(), | |
| 44 m_mainLayer->layer_tree_impl()); | |
| 45 m_mutation->setTransform(matrix); | 40 m_mutation->setTransform(matrix); |
| 46 } | 41 } |
| 47 | 42 |
| 48 float CompositorMutableState::scrollLeft() const { | 43 float CompositorMutableState::scrollLeft() const { |
| 49 return m_scrollLayer ? m_scrollLayer->CurrentScrollOffset().x() : 0.0; | 44 return m_scrollLayer ? m_scrollLayer->CurrentScrollOffset().x() : 0.0; |
| 50 } | 45 } |
| 51 | 46 |
| 52 void CompositorMutableState::setScrollLeft(float scrollLeft) { | 47 void CompositorMutableState::setScrollLeft(float scrollLeft) { |
| 53 if (!m_scrollLayer) | 48 if (!m_scrollLayer) |
| 54 return; | 49 return; |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 74 offset.set_y(scrollTop); | 69 offset.set_y(scrollTop); |
| 75 m_scrollLayer->layer_tree_impl() | 70 m_scrollLayer->layer_tree_impl() |
| 76 ->property_trees() | 71 ->property_trees() |
| 77 ->scroll_tree.OnScrollOffsetAnimated( | 72 ->scroll_tree.OnScrollOffsetAnimated( |
| 78 m_scrollLayer->id(), m_scrollLayer->scroll_tree_index(), offset, | 73 m_scrollLayer->id(), m_scrollLayer->scroll_tree_index(), offset, |
| 79 m_scrollLayer->layer_tree_impl()); | 74 m_scrollLayer->layer_tree_impl()); |
| 80 m_mutation->setScrollTop(scrollTop); | 75 m_mutation->setScrollTop(scrollTop); |
| 81 } | 76 } |
| 82 | 77 |
| 83 } // namespace blink | 78 } // namespace blink |
| OLD | NEW |