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..9e79fa5c583f276a893c3beb9ce541abe921b41f |
--- /dev/null |
+++ b/third_party/WebKit/Source/platform/graphics/CompositorMutatorClient.cpp |
@@ -0,0 +1,60 @@ |
+// 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/TraceEvent.h" |
+#include "platform/graphics/CompositorMutableProperties.h" |
+#include "platform/graphics/CompositorMutableStateProvider.h" |
+#include "platform/graphics/CompositorMutation.h" |
+#include "platform/graphics/CompositorMutator.h" |
+#include "public/platform/WebCompositorMutations.h" |
+ |
+namespace blink { |
+ |
+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 compositorState(state, m_mutations.get()); |
+ bool shouldReinvoke = m_mutator->mutate(time, &compositorState); |
+ return shouldReinvoke; |
+} |
+ |
+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 |