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/dom/CompositorProxy.h" |
| 8 #include "modules/compositorworker/CompositorWorkerThread.h" |
| 9 #include "platform/graphics/CompositorMutableStateProvider.h" |
| 10 #include "platform/graphics/CompositorMutatorClient.h" |
| 11 #include "platform/Task.h" |
| 12 #include "platform/TraceEvent.h" |
| 13 #include "platform/WebThreadSupportingGC.h" |
| 14 #include "public/platform/Platform.h" |
| 15 #include "public/platform/WebCompositorSupport.h" |
| 16 #include "public/platform/WebWaitableEvent.h" |
| 17 #include "web/CompositorProxyClientImpl.h" |
| 18 #include "wtf/Functional.h" |
| 19 |
| 20 namespace blink { |
| 21 |
| 22 CompositorMutatorImpl::CompositorMutatorImpl() |
| 23 : m_client(adoptPtr(new CompositorMutatorClient(this))) |
| 24 { |
| 25 } |
| 26 |
| 27 CompositorMutatorImpl::~CompositorMutatorImpl() |
| 28 { |
| 29 TRACE_EVENT0("compositor-worker", "CompositorMutatorImpl::~CompositorMutator
Impl"); |
| 30 // We must have torn down all compositor workers before destroying this |
| 31 // instance. |
| 32 ASSERT(m_clients.isEmpty()); |
| 33 } |
| 34 |
| 35 PassOwnPtr<CompositorMutatorImpl> CompositorMutatorImpl::create() |
| 36 { |
| 37 return adoptPtr(new CompositorMutatorImpl()); |
| 38 } |
| 39 |
| 40 bool CompositorMutatorImpl::mutate(double timeNow, CompositorMutableStateProvide
r* stateProvider) |
| 41 { |
| 42 TRACE_EVENT0("compositor-worker", "CompositorMutatorImpl::mutate"); |
| 43 Clients copy = m_clients; |
| 44 bool needToReinvoke = false; |
| 45 // TODO(vollick): we should avoid executing the animation frame |
| 46 // callbacks if none of the proxies in the global scope are affected by |
| 47 // m_mutations. |
| 48 for (CompositorProxyClientImpl* client : copy) { |
| 49 if (client->mutate(timeNow, stateProvider)) |
| 50 needToReinvoke = true; |
| 51 } |
| 52 |
| 53 return needToReinvoke; |
| 54 |
| 55 } |
| 56 |
| 57 void CompositorMutatorImpl::registerClient(CompositorProxyClientImpl* client) |
| 58 { |
| 59 TRACE_EVENT0("compositor-worker", "CompositorMutatorImpl::registerClient"); |
| 60 m_clients.add(client); |
| 61 setNeedsMutate(); |
| 62 } |
| 63 |
| 64 void CompositorMutatorImpl::unregisterClient(CompositorProxyClientImpl* client) |
| 65 { |
| 66 TRACE_EVENT0("compositor-worker", "CompositorMutatorImpl::unregisterClient")
; |
| 67 m_clients.remove(client); |
| 68 } |
| 69 |
| 70 CompositorProxyClient* CompositorMutatorImpl::createCompositorProxyClient() |
| 71 { |
| 72 TRACE_EVENT0("compositor-worker", "CompositorMutatorImpl::createCompositorPr
oxyClient"); |
| 73 return new CompositorProxyClientImpl(this); |
| 74 } |
| 75 |
| 76 void CompositorMutatorImpl::setNeedsMutate() |
| 77 { |
| 78 TRACE_EVENT0("compositor-worker", "CompositorMutatorImpl::requestMutation"); |
| 79 m_client->setNeedsMutate(); |
| 80 } |
| 81 |
| 82 } // namespace blink |
OLD | NEW |