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..00b6fc44f79e20de74f24bc60c4a18bd8d3f11dc |
| --- /dev/null |
| +++ b/third_party/WebKit/Source/platform/graphics/CompositorMutableState.cpp |
| @@ -0,0 +1,101 @@ |
| +// 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/animation/mutable_properties.h" |
| +#include "cc/layers/layer_impl.h" |
| +#include "cc/trees/layer_tree_impl.h" |
| +#include "platform/graphics/CompositorMutableProperties.h" |
| +#include "platform/graphics/CompositorMutation.h" |
| + |
| +namespace blink { |
| + |
| +static_assert( |
|
jbroman
2016/01/18 21:40:26
nit: I'd weakly prefer this somewhere easier to fi
Ian Vollick
2016/01/18 21:56:40
Moved to CompositorMutableProperties.cpp. Much nic
|
| + static_cast<cc::MutableProperty>(CompositorMutablePropertyNone) == cc::kMutablePropertyNone, |
| + "MutableProperty and CompositorMutableProperty enums must match"); |
| + |
| +static_assert( |
| + static_cast<cc::MutableProperty>(CompositorMutablePropertyOpacity) == cc::kMutablePropertyOpacity, |
| + "MutableProperty and CompositorMutableProperty enums must match"); |
| + |
| +static_assert( |
| + static_cast<cc::MutableProperty>(CompositorMutablePropertyScrollLeft) == cc::kMutablePropertyScrollLeft, |
| + "MutableProperty and CompositorMutableProperty enums must match"); |
| + |
| +static_assert( |
| + static_cast<cc::MutableProperty>(CompositorMutablePropertyScrollTop) == cc::kMutablePropertyScrollTop, |
| + "MutableProperty and CompositorMutableProperty enums must match"); |
| + |
| +static_assert( |
| + static_cast<cc::MutableProperty>(CompositorMutablePropertyTransform) == cc::kMutablePropertyTransform, |
| + "MutableProperty and CompositorMutableProperty enums must match"); |
| + |
| +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 |
| +{ |
| + return m_mainLayer ? m_mainLayer->transform().matrix() : SkMatrix44::I(); |
| +} |
| + |
| +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 |