| Index: cc/blink/web_mutator_client_impl.cc
|
| diff --git a/cc/blink/web_mutator_client_impl.cc b/cc/blink/web_mutator_client_impl.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..a939abd765ecb2be539012b1fcf5f18ef1311c19
|
| --- /dev/null
|
| +++ b/cc/blink/web_mutator_client_impl.cc
|
| @@ -0,0 +1,55 @@
|
| +// Copyright 2015 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 "cc/blink/web_mutator_client_impl.h"
|
| +
|
| +#include "base/trace_event/trace_event.h"
|
| +#include "cc/blink/mutation_conversions.h"
|
| +#include "cc/blink/web_compositor_mutable_state_provider_impl.h"
|
| +#include "third_party/WebKit/public/platform/Platform.h"
|
| +#include "third_party/WebKit/public/platform/WebMutator.h"
|
| +
|
| +namespace cc_blink {
|
| +
|
| +WebMutatorClientImpl::WebMutatorClientImpl(blink::WebMutator* mutator)
|
| + : client_(nullptr), mutator_(mutator) {
|
| + TRACE_EVENT0("compositor-worker",
|
| + "WebMutatorClientImpl::WebMutatorClientImpl");
|
| +}
|
| +
|
| +WebMutatorClientImpl::~WebMutatorClientImpl() {
|
| + TRACE_EVENT0("compositor-worker",
|
| + "WebMutatorClientImpl::~WebMutatorClientImpl");
|
| +}
|
| +
|
| +bool WebMutatorClientImpl::Mutate(base::TimeTicks now,
|
| + cc::LayerTreeImpl* state) {
|
| + TRACE_EVENT0("compositor-worker", "WebMutatorClientImpl::GetMutations");
|
| + double time = (now - base::TimeTicks()).InSecondsF();
|
| + if (!mutations_)
|
| + mutations_.reset(new cc::LayerTreeMutationMap);
|
| + WebCompositorMutableStateProviderImpl compositor_state(state,
|
| + mutations_.get());
|
| + bool should_reinvoke = mutator_->mutate(time, &compositor_state);
|
| + // TODO(flackr): Detect if there actually were any mutations and set
|
| + // needs commit?
|
| + return should_reinvoke;
|
| +}
|
| +
|
| +void WebMutatorClientImpl::SetClient(cc::LayerTreeMutatorClient* client) {
|
| + TRACE_EVENT0("compositor-worker", "WebMutatorClientImpl::SetClient");
|
| + client_ = client;
|
| + setNeedsMutate();
|
| +}
|
| +
|
| +cc::LayerTreeMutationMap* WebMutatorClientImpl::TakeMutations() {
|
| + return mutations_.release();
|
| +}
|
| +
|
| +void WebMutatorClientImpl::setNeedsMutate() {
|
| + TRACE_EVENT0("compositor-worker", "WebMutatorClientImpl::requestMutation");
|
| + client_->SetNeedsMutate();
|
| +}
|
| +
|
| +} // namespace cc_blink
|
|
|