OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "platform/graphics/CompositorMutableState.h" | |
6 | |
7 #include "cc/layers/layer_impl.h" | |
8 #include "cc/trees/layer_tree_impl.h" | |
9 #include "platform/graphics/CompositorMutation.h" | |
10 | |
11 namespace blink { | |
12 | |
13 CompositorMutableState::CompositorMutableState(CompositorMutation* mutation, cc: :LayerImpl* main, cc::LayerImpl* scroll) | |
14 : m_mutation(mutation) | |
15 , m_mainLayer(main) | |
16 , m_scrollLayer(scroll) | |
17 { | |
18 } | |
19 | |
20 CompositorMutableState::~CompositorMutableState() {} | |
21 | |
22 double CompositorMutableState::opacity() const | |
23 { | |
24 return m_mainLayer->opacity(); | |
25 } | |
26 | |
27 void CompositorMutableState::setOpacity(double opacity) | |
28 { | |
29 if (!m_mainLayer) | |
30 return; | |
31 m_mainLayer->OnOpacityAnimated(opacity); | |
32 m_mutation->setOpacity(opacity); | |
33 } | |
34 | |
35 const SkMatrix44& CompositorMutableState::transform() const | |
36 { | |
37 static SkMatrix44 identity; | |
jbroman
2016/01/18 19:07:22
These both applied to the old cc code, so you may
Ian Vollick
2016/01/18 21:25:04
Nice! Fixed.
| |
38 return m_mainLayer ? m_mainLayer->transform().matrix() : identity; | |
39 } | |
40 | |
41 void CompositorMutableState::setTransform(const SkMatrix44& matrix) | |
42 { | |
43 if (!m_mainLayer) | |
44 return; | |
45 m_mainLayer->OnTransformAnimated(gfx::Transform(matrix)); | |
46 m_mutation->setTransform(matrix); | |
47 } | |
48 | |
49 double CompositorMutableState::scrollLeft() const | |
50 { | |
51 return m_scrollLayer ? m_scrollLayer->CurrentScrollOffset().x() : 0.0; | |
52 } | |
53 | |
54 void CompositorMutableState::setScrollLeft(double scrollLeft) | |
55 { | |
56 if (!m_scrollLayer) | |
57 return; | |
58 | |
59 gfx::ScrollOffset offset = m_scrollLayer->CurrentScrollOffset(); | |
60 offset.set_x(scrollLeft); | |
61 m_scrollLayer->OnScrollOffsetAnimated(offset); | |
62 m_mutation->setScrollLeft(scrollLeft); | |
63 } | |
64 | |
65 double CompositorMutableState::scrollTop() const | |
66 { | |
67 return m_scrollLayer ? m_scrollLayer->CurrentScrollOffset().y() : 0.0; | |
68 } | |
69 | |
70 void CompositorMutableState::setScrollTop(double scrollTop) | |
71 { | |
72 if (!m_scrollLayer) | |
73 return; | |
74 gfx::ScrollOffset offset = m_scrollLayer->CurrentScrollOffset(); | |
75 offset.set_y(scrollTop); | |
76 m_scrollLayer->OnScrollOffsetAnimated(offset); | |
77 m_mutation->setScrollTop(scrollTop); | |
78 } | |
79 | |
80 } // namespace blink | |
OLD | NEW |