Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(769)

Unified Diff: third_party/WebKit/Source/platform/graphics/CompositorMutatorClient.cpp

Issue 1547893003: WIP - compositor worker mega patch. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698