OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CompositorProxyClientImpl_h |
| 6 #define CompositorProxyClientImpl_h |
| 7 |
| 8 #include "core/dom/CompositorProxyClient.h" |
| 9 |
| 10 #include "wtf/Noncopyable.h" |
| 11 |
| 12 #include <map> |
| 13 #include <set> |
| 14 #include <vector> |
| 15 |
| 16 namespace blink { |
| 17 |
| 18 class CompositorMutableStateProvider; |
| 19 class CompositorMutatorImpl; |
| 20 class CompositorProxy; |
| 21 class CompositorWorkerGlobalScope; |
| 22 class WorkerGlobalScope; |
| 23 |
| 24 class CompositorProxyClientImpl : public CompositorProxyClient { |
| 25 WTF_MAKE_NONCOPYABLE(CompositorProxyClientImpl); |
| 26 |
| 27 public: |
| 28 explicit CompositorProxyClientImpl(CompositorMutatorImpl*); |
| 29 ~CompositorProxyClientImpl() override; |
| 30 |
| 31 bool mutate(double timeNow, CompositorMutableStateProvider*); |
| 32 |
| 33 // CompositorProxyClient: |
| 34 void registerCompositorProxy(CompositorProxy*) override; |
| 35 void unregisterCompositorProxy(CompositorProxy*) override; |
| 36 void requestSync(CompositorProxy*) override; |
| 37 |
| 38 void setGlobalScope(WorkerGlobalScope*) override; |
| 39 void requestMutation() override; |
| 40 |
| 41 private: |
| 42 void willStartCompositorFrameCallbacks(CompositorMutableStateProvider*); |
| 43 bool executeAnimationFrameCallbacks(double time); |
| 44 |
| 45 CompositorMutatorImpl* m_mutator; |
| 46 |
| 47 // TODO(vollick): These could use wtf containers, but this would force us to |
| 48 // oilpan-ify CompositorProxyImpl and, transitively, a lot more stuff. |
| 49 // Particularly problematic in that stuff is the rAF task which must be |
| 50 // created outside of a safe point and whose ownership is passed between |
| 51 // threads. The code as it stands is correct and the raw pointers here have |
| 52 // the right semantics. Namely, they should not be traced (i.e., they do not |
| 53 // hide memory that should be visible to oilpan), they do not retain the |
| 54 // CompositorProxies (their lifetime is managed by oilpan), they will |
| 55 // continue to be valid during the lifetime of the CompositorProxies (since |
| 56 // oilpan is not a compacting GC), and we do not want oilpan to take action |
| 57 // to clear out these collections or update weak pointers when the objects |
| 58 // are destroyed (we handle that ourselves via disconnection). In short, we |
| 59 // do not need oilpan to do management for us because we're handling it |
| 60 // ourself and we need to handle it ourself because of our unique |
| 61 // multi-threaded requirements. |
| 62 typedef std::vector<CompositorProxy*> ProxyVector; |
| 63 typedef std::map<uint64_t, ProxyVector> ProxyMap; |
| 64 ProxyMap m_proxies; |
| 65 HashSet<uint64_t> m_requiresSync; |
| 66 |
| 67 CompositorWorkerGlobalScope* m_globalScope; |
| 68 bool m_executingAnimationFrameCallbacks; |
| 69 bool m_requestedAnimationFrameCallbacks; |
| 70 }; |
| 71 |
| 72 } // namespace blink |
| 73 |
| 74 #endif // CompositorProxyClientImpl_h |
OLD | NEW |