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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "core/animation/WorkletAnimationController.h"
6
7 #include "core/animation/WorkletAnimationBase.h"
8
9 namespace blink {
10
11 WorkletAnimationController::WorkletAnimationController() = default;
12
13 WorkletAnimationController::~WorkletAnimationController() = default;
14
15 void WorkletAnimationController::AttachAnimation(
16 WorkletAnimationBase& animation) {
17 DCHECK(IsMainThread());
18 // TODO(smcgruer): Call NeedsCompositingUpdate on the relevant LocalFrameView.
19 DCHECK(!pending_animations_.Contains(&animation));
20 DCHECK(!compositor_animations_.Contains(&animation));
21 pending_animations_.insert(&animation);
22 }
23
24 void WorkletAnimationController::DetachAnimation(
25 WorkletAnimationBase& animation) {
26 DCHECK(IsMainThread());
27 DCHECK(pending_animations_.Contains(&animation) !=
28 compositor_animations_.Contains(&animation));
29 if (pending_animations_.Contains(&animation))
30 pending_animations_.erase(&animation);
31 else
32 compositor_animations_.erase(&animation);
33 }
34
35 void WorkletAnimationController::Update() {
36 DCHECK(IsMainThread());
37 HeapHashSet<Member<WorkletAnimationBase>> animations;
38 animations.swap(pending_animations_);
39 for (const auto& animation : animations) {
40 if (animation->StartOnCompositor()) {
41 compositor_animations_.insert(animation);
42 }
43 // TODO(smcgruer): On failure, warn user. Perhaps fire cancel event?
44 }
45 }
46
47 DEFINE_TRACE(WorkletAnimationController) {
48 visitor->Trace(pending_animations_);
49 visitor->Trace(compositor_animations_);
50 }
51
52 } // namespace blink
OLDNEW
« 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