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