OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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 "web/CompositorMutatorImpl.h" |
| 6 |
| 7 #include "core/animation/CustomCompositorAnimationManager.h" |
| 8 #include "core/dom/CompositorProxy.h" |
| 9 #include "platform/TraceEvent.h" |
| 10 #include "platform/graphics/CompositorMutationsTarget.h" |
| 11 #include "platform/graphics/CompositorMutatorClient.h" |
| 12 #include "platform/heap/Handle.h" |
| 13 #include "web/CompositorProxyClientImpl.h" |
| 14 |
| 15 namespace blink { |
| 16 |
| 17 CompositorMutatorImpl::CompositorMutatorImpl() |
| 18 : m_animationManager(adoptPtr(new CustomCompositorAnimationManager)) |
| 19 , m_client(nullptr) |
| 20 { |
| 21 } |
| 22 |
| 23 CompositorMutatorImpl::~CompositorMutatorImpl() |
| 24 { |
| 25 TRACE_EVENT0("compositor-worker", "CompositorMutatorImpl::~CompositorMutator
Impl"); |
| 26 } |
| 27 |
| 28 CompositorMutatorImpl* CompositorMutatorImpl::create() |
| 29 { |
| 30 return new CompositorMutatorImpl(); |
| 31 } |
| 32 |
| 33 bool CompositorMutatorImpl::mutate(double monotonicTimeNow) |
| 34 { |
| 35 TRACE_EVENT0("compositor-worker", "CompositorMutatorImpl::mutate"); |
| 36 bool needToReinvoke = false; |
| 37 // TODO(vollick): we should avoid executing the animation frame |
| 38 // callbacks if none of the proxies in the global scope are affected by |
| 39 // m_mutations. |
| 40 for (CompositorProxyClientImpl* client : m_proxyClients) { |
| 41 if (client->mutate(monotonicTimeNow)) |
| 42 needToReinvoke = true; |
| 43 } |
| 44 |
| 45 return needToReinvoke; |
| 46 } |
| 47 |
| 48 void CompositorMutatorImpl::registerProxyClient(CompositorProxyClientImpl* clien
t) |
| 49 { |
| 50 TRACE_EVENT0("compositor-worker", "CompositorMutatorImpl::registerClient"); |
| 51 m_proxyClients.add(client); |
| 52 setNeedsMutate(); |
| 53 } |
| 54 |
| 55 void CompositorMutatorImpl::unregisterProxyClient(CompositorProxyClientImpl* cli
ent) |
| 56 { |
| 57 TRACE_EVENT0("compositor-worker", "CompositorMutatorImpl::unregisterClient")
; |
| 58 m_proxyClients.remove(client); |
| 59 } |
| 60 |
| 61 void CompositorMutatorImpl::setNeedsMutate() |
| 62 { |
| 63 TRACE_EVENT0("compositor-worker", "CompositorMutatorImpl::setNeedsMutate"); |
| 64 m_client->setNeedsMutate(); |
| 65 } |
| 66 |
| 67 } // namespace blink |
OLD | NEW |