Chromium Code Reviews| 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 "web/CompositorProxyClientImpl.h" | |
| 13 | |
| 14 namespace blink { | |
| 15 | |
| 16 CompositorMutatorImpl::CompositorMutatorImpl() | |
| 17 : m_animationManager(adoptPtr(new CustomCompositorAnimationManager)) | |
| 18 , m_client(adoptPtr(new CompositorMutatorClient(this, m_animationManager.get ()))) | |
| 19 { | |
| 20 } | |
| 21 | |
| 22 CompositorMutatorImpl::~CompositorMutatorImpl() | |
| 23 { | |
| 24 TRACE_EVENT0("compositor-worker", "CompositorMutatorImpl::~CompositorMutator Impl"); | |
| 25 // We must have torn down all compositor workers before destroying this | |
| 26 // instance. | |
| 27 ASSERT(m_proxyClients.empty()); | |
| 28 } | |
| 29 | |
| 30 PassOwnPtr<CompositorMutatorImpl> CompositorMutatorImpl::create() | |
| 31 { | |
| 32 return adoptPtr(new CompositorMutatorImpl()); | |
| 33 } | |
| 34 | |
| 35 bool CompositorMutatorImpl::mutate(double timeNow) | |
| 36 { | |
| 37 TRACE_EVENT0("compositor-worker", "CompositorMutatorImpl::mutate"); | |
| 38 bool needToReinvoke = false; | |
| 39 // TODO(vollick): we should avoid executing the animation frame | |
| 40 // callbacks if none of the proxies in the global scope are affected by | |
| 41 // m_mutations. | |
| 42 for (CompositorProxyClient* client : m_proxyClients) { | |
| 43 if (client->mutate(timeNow)) | |
| 44 needToReinvoke = true; | |
| 45 } | |
| 46 | |
| 47 return needToReinvoke; | |
| 48 } | |
| 49 | |
| 50 void CompositorMutatorImpl::registerClient(CompositorProxyClient* client) | |
| 51 { | |
| 52 TRACE_EVENT0("compositor-worker", "CompositorMutatorImpl::registerClient"); | |
| 53 m_proxyClients.insert(client); | |
| 54 setNeedsMutate(); | |
| 55 } | |
| 56 | |
| 57 void CompositorMutatorImpl::unregisterClient(CompositorProxyClient* client) | |
| 58 { | |
| 59 TRACE_EVENT0("compositor-worker", "CompositorMutatorImpl::unregisterClient") ; | |
| 60 m_proxyClients.erase(client); | |
| 61 } | |
| 62 | |
| 63 CompositorProxyClient* CompositorMutatorImpl::createCompositorProxyClient() | |
| 64 { | |
| 65 TRACE_EVENT0("compositor-worker", "CompositorMutatorImpl::createCompositorPr oxyClient"); | |
| 66 return new CompositorProxyClientImpl(this); | |
| 67 } | |
| 68 | |
| 69 void CompositorMutatorImpl::setNeedsMutate() | |
| 70 { | |
| 71 TRACE_EVENT0("compositor-worker", "CompositorMutatorImpl::requestMutation"); | |
|
jbroman
2016/04/20 21:06:42
nit: trace event / method name mismatch
flackr
2016/04/25 14:06:28
Fixed.
| |
| 72 m_client->setNeedsMutate(); | |
| 73 } | |
| 74 | |
| 75 } // namespace blink | |
| OLD | NEW |