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

Unified Diff: third_party/WebKit/Source/core/animation/WorkletAnimationController.cpp

Issue 2869183002: Initial implementation of WorkletAnimation (Closed)
Patch Set: Add more DCHECKs Created 3 years, 3 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/core/animation/WorkletAnimationController.cpp
diff --git a/third_party/WebKit/Source/core/animation/WorkletAnimationController.cpp b/third_party/WebKit/Source/core/animation/WorkletAnimationController.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..47b9c700ab0a3186f1ec0a8fb60ad6c8741ed47f
--- /dev/null
+++ b/third_party/WebKit/Source/core/animation/WorkletAnimationController.cpp
@@ -0,0 +1,52 @@
+// Copyright 2017 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 "core/animation/WorkletAnimationController.h"
+
+#include "core/animation/WorkletAnimationBase.h"
+
+namespace blink {
+
+WorkletAnimationController::WorkletAnimationController() = default;
+
+WorkletAnimationController::~WorkletAnimationController() = default;
+
+void WorkletAnimationController::AttachAnimation(
+ WorkletAnimationBase& animation) {
+ DCHECK(IsMainThread());
+ // TODO(smcgruer): Call NeedsCompositingUpdate on the relevant LocalFrameView.
+ DCHECK(!pending_animations_.Contains(&animation));
+ DCHECK(!compositor_animations_.Contains(&animation));
+ pending_animations_.insert(&animation);
+}
+
+void WorkletAnimationController::DetachAnimation(
+ WorkletAnimationBase& animation) {
+ DCHECK(IsMainThread());
+ DCHECK(pending_animations_.Contains(&animation) !=
+ compositor_animations_.Contains(&animation));
+ if (pending_animations_.Contains(&animation))
+ pending_animations_.erase(&animation);
+ else
+ compositor_animations_.erase(&animation);
+}
+
+void WorkletAnimationController::Update() {
+ DCHECK(IsMainThread());
+ HeapHashSet<Member<WorkletAnimationBase>> animations;
+ animations.swap(pending_animations_);
+ for (const auto& animation : animations) {
+ if (animation->StartOnCompositor()) {
+ compositor_animations_.insert(animation);
+ }
+ // TODO(smcgruer): On failure, warn user. Perhaps fire cancel event?
+ }
+}
+
+DEFINE_TRACE(WorkletAnimationController) {
+ visitor->Trace(pending_animations_);
+ visitor->Trace(compositor_animations_);
+}
+
+} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/animation/WorkletAnimationController.h ('k') | third_party/WebKit/Source/core/dom/Document.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698