Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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 "web/CompositorMutatorImpl.h" | 5 #include "web/CompositorMutatorImpl.h" |
| 6 | 6 |
| 7 #include "core/animation/CustomCompositorAnimationManager.h" | 7 #include "core/animation/CustomCompositorAnimationManager.h" |
| 8 #include "core/dom/CompositorProxy.h" | 8 #include "core/dom/CompositorProxy.h" |
| 9 #include "platform/CrossThreadFunctional.h" | 9 #include "platform/CrossThreadFunctional.h" |
| 10 #include "platform/TraceEvent.h" | 10 #include "platform/TraceEvent.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 57 return new CompositorMutatorImpl(); | 57 return new CompositorMutatorImpl(); |
| 58 } | 58 } |
| 59 | 59 |
| 60 bool CompositorMutatorImpl::mutate(double monotonicTimeNow, CompositorMutableSta teProvider* stateProvider) | 60 bool CompositorMutatorImpl::mutate(double monotonicTimeNow, CompositorMutableSta teProvider* stateProvider) |
| 61 { | 61 { |
| 62 TRACE_EVENT0("compositor-worker", "CompositorMutatorImpl::mutate"); | 62 TRACE_EVENT0("compositor-worker", "CompositorMutatorImpl::mutate"); |
| 63 bool needToReinvoke = false; | 63 bool needToReinvoke = false; |
| 64 // TODO(vollick): we should avoid executing the animation frame | 64 // TODO(vollick): we should avoid executing the animation frame |
| 65 // callbacks if none of the proxies in the global scope are affected by | 65 // callbacks if none of the proxies in the global scope are affected by |
| 66 // m_mutations. | 66 // m_mutations. |
| 67 for (CompositorProxyClientImpl* client : m_proxyClients) { | 67 for (auto& it : m_proxyClients) { |
| 68 if (client->mutate(monotonicTimeNow, stateProvider)) | 68 CrossThreadPersistent<CompositorProxyClientImpl> client(it); |
| 69 if (client && client->mutate(monotonicTimeNow, stateProvider)) | |
| 69 needToReinvoke = true; | 70 needToReinvoke = true; |
| 70 } | 71 } |
| 71 | 72 |
| 72 return needToReinvoke; | 73 return needToReinvoke; |
| 73 } | 74 } |
| 74 | 75 |
| 75 void CompositorMutatorImpl::registerProxyClient(CompositorProxyClientImpl* clien t) | 76 void CompositorMutatorImpl::registerProxyClient(CompositorProxyClientImpl* clien t) |
| 76 { | 77 { |
| 77 TRACE_EVENT0("compositor-worker", "CompositorMutatorImpl::registerClient"); | 78 TRACE_EVENT0("compositor-worker", "CompositorMutatorImpl::registerClient"); |
| 78 m_proxyClients.add(client); | 79 CrossThreadWeakPersistent<CompositorProxyClientImpl>* insertPosition = nullp tr; |
| 80 for (auto& it : m_proxyClients) { | |
|
haraken
2016/08/22 14:24:44
Would it make more sense to provide a helper class
keishi
2016/09/02 06:41:55
Strongifying all items at once is hard, and this p
| |
| 81 CrossThreadPersistent<CompositorProxyClientImpl> protect(it); | |
|
haraken
2016/08/22 14:24:44
I'm just curious but how did you find that you nee
keishi
2016/09/02 06:41:55
I think the only safe way to use CrossThreadWeakPe
haraken
2016/09/02 09:39:17
Ah, the DCHECK looks clever!
However, maybe would
keishi
2016/09/07 10:14:42
I was worried about this so I would love to do thi
| |
| 82 if (!protect && !insertPosition) { | |
| 83 insertPosition = ⁢ | |
| 84 #if !DCHECK_IS_ON() | |
| 85 break; | |
| 86 #endif | |
| 87 } | |
| 88 DCHECK_NE(protect, client); | |
| 89 } | |
| 90 if (insertPosition) | |
| 91 *insertPosition = client; | |
| 92 else | |
| 93 m_proxyClients.append(client); | |
| 79 setNeedsMutate(); | 94 setNeedsMutate(); |
| 80 } | 95 } |
| 81 | 96 |
| 82 void CompositorMutatorImpl::setNeedsMutate() | 97 void CompositorMutatorImpl::setNeedsMutate() |
| 83 { | 98 { |
| 84 TRACE_EVENT0("compositor-worker", "CompositorMutatorImpl::setNeedsMutate"); | 99 TRACE_EVENT0("compositor-worker", "CompositorMutatorImpl::setNeedsMutate"); |
| 85 m_client->setNeedsMutate(); | 100 m_client->setNeedsMutate(); |
| 86 } | 101 } |
| 87 | 102 |
| 88 } // namespace blink | 103 } // namespace blink |
| OLD | NEW |