Chromium Code Reviews| OLD | NEW |
|---|---|
| (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) { | |
|
nhiroki
2017/09/12 00:10:36
DCHECK(IsMainThread()) here and in other functions
smcgruer
2017/09/12 15:46:02
Done.
| |
| 17 // TODO(smcgruer): Call NeedsCompositingUpdate on the relevant LocalFrameView. | |
| 18 DCHECK(!pending_animations_.Contains(&animation)); | |
| 19 DCHECK(!compositor_animations_.Contains(&animation)); | |
| 20 pending_animations_.insert(&animation); | |
| 21 } | |
| 22 | |
| 23 void WorkletAnimationController::DetachAnimation( | |
| 24 WorkletAnimationBase& animation) { | |
| 25 DCHECK(pending_animations_.Contains(&animation) != | |
| 26 compositor_animations_.Contains(&animation)); | |
| 27 if (pending_animations_.Contains(&animation)) | |
| 28 pending_animations_.erase(&animation); | |
| 29 else | |
| 30 compositor_animations_.erase(&animation); | |
| 31 } | |
| 32 | |
| 33 void WorkletAnimationController::Update() { | |
| 34 HeapHashSet<Member<WorkletAnimationBase>> animations; | |
| 35 animations.swap(pending_animations_); | |
| 36 for (const auto& animation : animations) { | |
| 37 if (animation->StartOnCompositor()) { | |
| 38 compositor_animations_.insert(animation); | |
| 39 } | |
| 40 // TODO(smcgruer): On failure, warn user. Perhaps fire cancel event? | |
| 41 } | |
| 42 } | |
| 43 | |
| 44 DEFINE_TRACE(WorkletAnimationController) { | |
| 45 visitor->Trace(pending_animations_); | |
| 46 visitor->Trace(compositor_animations_); | |
| 47 } | |
| 48 | |
| 49 } // namespace blink | |
| OLD | NEW |