| Index: third_party/WebKit/Source/platform/graphics/CompositorMutatorClient.cpp
|
| diff --git a/third_party/WebKit/Source/platform/graphics/CompositorMutatorClient.cpp b/third_party/WebKit/Source/platform/graphics/CompositorMutatorClient.cpp
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..4f881607fd1faf52009e5d91a2500bcd7e3a341e
|
| --- /dev/null
|
| +++ b/third_party/WebKit/Source/platform/graphics/CompositorMutatorClient.cpp
|
| @@ -0,0 +1,81 @@
|
| +// 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/CompositorMutatorClient.h"
|
| +
|
| +#include "cc/animation/mutable_properties.h"
|
| +#include "platform/graphics/CompositorMutation.h"
|
| +#include "platform/graphics/CompositorMutator.h"
|
| +#include "platform/graphics/CompositorMutableProperties.h"
|
| +#include "platform/graphics/CompositorMutableStateProvider.h"
|
| +#include "platform/TraceEvent.h"
|
| +
|
| +namespace blink {
|
| +
|
| +static_assert(
|
| + 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");
|
| +
|
| +CompositorMutatorClient::CompositorMutatorClient(CompositorMutator* mutator)
|
| + : m_client(nullptr)
|
| + , m_mutator(mutator)
|
| +{
|
| + TRACE_EVENT0("compositor-worker", "CompositorMutatorClient::CompositorMutatorClient");
|
| +}
|
| +
|
| +CompositorMutatorClient::~CompositorMutatorClient()
|
| +{
|
| + TRACE_EVENT0("compositor-worker", "CompositorMutatorClient::~CompositorMutatorClient");
|
| +}
|
| +
|
| +bool CompositorMutatorClient::Mutate(
|
| + base::TimeTicks now,
|
| + cc::LayerTreeImpl* state)
|
| +{
|
| + TRACE_EVENT0("compositor-worker", "CompositorMutatorClient::GetMutations");
|
| + double time = (now - base::TimeTicks()).InSecondsF();
|
| + if (!m_mutations)
|
| + m_mutations = adoptPtr(new CompositorMutations);
|
| + CompositorMutableStateProvider compositor_state(state, m_mutations.get());
|
| + bool should_reinvoke = m_mutator->mutate(time, &compositor_state);
|
| + // TODO(flackr): Detect if there actually were any mutations and set
|
| + // needs commit?
|
| + return should_reinvoke;
|
| +}
|
| +
|
| +void CompositorMutatorClient::SetClient(cc::LayerTreeMutatorClient* client)
|
| +{
|
| + TRACE_EVENT0("compositor-worker", "CompositorMutatorClient::SetClient");
|
| + m_client = client;
|
| + setNeedsMutate();
|
| +}
|
| +
|
| +scoped_ptr<cc::LayerTreeMutations> CompositorMutatorClient::TakeMutations()
|
| +{
|
| + return make_scoped_ptr<cc::LayerTreeMutations>(m_mutations.leakPtr());
|
| +}
|
| +
|
| +void CompositorMutatorClient::setNeedsMutate()
|
| +{
|
| + TRACE_EVENT0("compositor-worker", "CompositorMutatorClient::requestMutation");
|
| + m_client->SetNeedsMutate();
|
| +}
|
| +
|
| +} // namespace blink
|
|
|