| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "modules/compositorworker/CompositorWorkerGlobalScope.h" | 5 #include "modules/compositorworker/CompositorWorkerGlobalScope.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/SerializedScriptValue.h" | 7 #include "bindings/core/v8/SerializedScriptValue.h" |
| 8 #include "core/workers/InProcessWorkerObjectProxy.h" | 8 #include "core/workers/InProcessWorkerObjectProxy.h" |
| 9 #include "core/workers/WorkerThreadStartupData.h" | 9 #include "core/workers/WorkerThreadStartupData.h" |
| 10 #include "modules/EventTargetModules.h" | 10 #include "modules/EventTargetModules.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 { | 49 { |
| 50 // Disentangle the port in preparation for sending it to the remote context. | 50 // Disentangle the port in preparation for sending it to the remote context. |
| 51 OwnPtr<MessagePortChannelArray> channels = MessagePort::disentanglePorts(exe
cutionContext, ports, exceptionState); | 51 OwnPtr<MessagePortChannelArray> channels = MessagePort::disentanglePorts(exe
cutionContext, ports, exceptionState); |
| 52 if (exceptionState.hadException()) | 52 if (exceptionState.hadException()) |
| 53 return; | 53 return; |
| 54 thread()->workerObjectProxy().postMessageToWorkerObject(message, std::move(c
hannels)); | 54 thread()->workerObjectProxy().postMessageToWorkerObject(message, std::move(c
hannels)); |
| 55 } | 55 } |
| 56 | 56 |
| 57 int CompositorWorkerGlobalScope::requestAnimationFrame(FrameRequestCallback* cal
lback) | 57 int CompositorWorkerGlobalScope::requestAnimationFrame(FrameRequestCallback* cal
lback) |
| 58 { | 58 { |
| 59 // For now, just post a task to call mutate on the compositor proxy client. | 59 const bool shouldSignal = !m_executingAnimationFrameCallbacks && m_callbackC
ollection.isEmpty(); |
| 60 // TODO(flackr): Remove this as soon as CompositorProxyClient can request a | 60 if (shouldSignal) |
| 61 // compositor frame from the CompositorMutatorImpl. | 61 CompositorProxyClient::from(clients())->requestAnimationFrame(); |
| 62 thread()->postTask(BLINK_FROM_HERE, createSameThreadTask(&CompositorProxyCli
ent::runAnimationFrameCallbacks, | |
| 63 CompositorProxyClient::from(clients()))); | |
| 64 // TODO(flackr): Signal the compositor to call mutate on the next compositor
frame. | |
| 65 return m_callbackCollection.registerCallback(callback); | 62 return m_callbackCollection.registerCallback(callback); |
| 66 } | 63 } |
| 67 | 64 |
| 68 void CompositorWorkerGlobalScope::cancelAnimationFrame(int id) | 65 void CompositorWorkerGlobalScope::cancelAnimationFrame(int id) |
| 69 { | 66 { |
| 70 m_callbackCollection.cancelCallback(id); | 67 m_callbackCollection.cancelCallback(id); |
| 71 } | 68 } |
| 72 | 69 |
| 73 bool CompositorWorkerGlobalScope::executeAnimationFrameCallbacks(double highResT
imeMs) | 70 bool CompositorWorkerGlobalScope::executeAnimationFrameCallbacks(double highResT
imeMs) |
| 74 { | 71 { |
| 75 TemporaryChange<bool> temporaryChange(m_executingAnimationFrameCallbacks, tr
ue); | 72 TemporaryChange<bool> temporaryChange(m_executingAnimationFrameCallbacks, tr
ue); |
| 76 m_callbackCollection.executeCallbacks(highResTimeMs, highResTimeMs); | 73 m_callbackCollection.executeCallbacks(highResTimeMs, highResTimeMs); |
| 77 return !m_callbackCollection.isEmpty(); | 74 return !m_callbackCollection.isEmpty(); |
| 78 } | 75 } |
| 79 | 76 |
| 80 CompositorWorkerThread* CompositorWorkerGlobalScope::thread() const | 77 CompositorWorkerThread* CompositorWorkerGlobalScope::thread() const |
| 81 { | 78 { |
| 82 return static_cast<CompositorWorkerThread*>(WorkerGlobalScope::thread()); | 79 return static_cast<CompositorWorkerThread*>(WorkerGlobalScope::thread()); |
| 83 } | 80 } |
| 84 | 81 |
| 85 } // namespace blink | 82 } // namespace blink |
| OLD | NEW |