Chromium Code Reviews| Index: third_party/WebKit/Source/platform/graphics/CompositorMutableState.cpp |
| diff --git a/third_party/WebKit/Source/platform/graphics/CompositorMutableState.cpp b/third_party/WebKit/Source/platform/graphics/CompositorMutableState.cpp |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..28c2f61e0d19969f2fede340f7f804d4a3f645cc |
| --- /dev/null |
| +++ b/third_party/WebKit/Source/platform/graphics/CompositorMutableState.cpp |
| @@ -0,0 +1,80 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "platform/graphics/CompositorMutableState.h" |
| + |
| +#include "cc/layers/layer_impl.h" |
| +#include "cc/trees/layer_tree_impl.h" |
| +#include "platform/graphics/CompositorMutation.h" |
| + |
| +namespace blink { |
| + |
| +CompositorMutableState::CompositorMutableState(CompositorMutation* mutation, cc::LayerImpl* main, cc::LayerImpl* scroll) |
| + : m_mutation(mutation) |
| + , m_mainLayer(main) |
| + , m_scrollLayer(scroll) |
| +{ |
| +} |
| + |
| +CompositorMutableState::~CompositorMutableState() {} |
| + |
| +double CompositorMutableState::opacity() const |
| +{ |
| + return m_mainLayer->opacity(); |
| +} |
| + |
| +void CompositorMutableState::setOpacity(double opacity) |
| +{ |
| + if (!m_mainLayer) |
| + return; |
| + m_mainLayer->OnOpacityAnimated(opacity); |
| + m_mutation->setOpacity(opacity); |
| +} |
| + |
| +const SkMatrix44& CompositorMutableState::transform() const |
| +{ |
| + 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.
|
| + return m_mainLayer ? m_mainLayer->transform().matrix() : identity; |
| +} |
| + |
| +void CompositorMutableState::setTransform(const SkMatrix44& matrix) |
| +{ |
| + if (!m_mainLayer) |
| + return; |
| + m_mainLayer->OnTransformAnimated(gfx::Transform(matrix)); |
| + m_mutation->setTransform(matrix); |
| +} |
| + |
| +double CompositorMutableState::scrollLeft() const |
| +{ |
| + return m_scrollLayer ? m_scrollLayer->CurrentScrollOffset().x() : 0.0; |
| +} |
| + |
| +void CompositorMutableState::setScrollLeft(double scrollLeft) |
| +{ |
| + if (!m_scrollLayer) |
| + return; |
| + |
| + gfx::ScrollOffset offset = m_scrollLayer->CurrentScrollOffset(); |
| + offset.set_x(scrollLeft); |
| + m_scrollLayer->OnScrollOffsetAnimated(offset); |
| + m_mutation->setScrollLeft(scrollLeft); |
| +} |
| + |
| +double CompositorMutableState::scrollTop() const |
| +{ |
| + return m_scrollLayer ? m_scrollLayer->CurrentScrollOffset().y() : 0.0; |
| +} |
| + |
| +void CompositorMutableState::setScrollTop(double scrollTop) |
| +{ |
| + if (!m_scrollLayer) |
| + return; |
| + gfx::ScrollOffset offset = m_scrollLayer->CurrentScrollOffset(); |
| + offset.set_y(scrollTop); |
| + m_scrollLayer->OnScrollOffsetAnimated(offset); |
| + m_mutation->setScrollTop(scrollTop); |
| +} |
| + |
| +} // namespace blink |