| 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) { |
| 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 |
| OLD | NEW |