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 CC_TREES_THREADED_CHANNEL_H_ | |
6 #define CC_TREES_THREADED_CHANNEL_H_ | |
7 | |
8 #include "base/memory/ref_counted.h" | |
9 #include "base/memory/scoped_ptr.h" | |
10 #include "cc/base/cc_export.h" | |
11 #include "cc/trees/channel_impl.h" | |
12 #include "cc/trees/channel_main.h" | |
13 #include "cc/trees/proxy_impl.h" | |
14 #include "cc/trees/proxy_main.h" | |
15 #include "cc/trees/thread_proxy.h" | |
16 | |
17 namespace base { | |
18 class SingleThreadTaskRunner; | |
19 } | |
20 | |
21 namespace cc { | |
22 class ChannelImpl; | |
23 class ChannelMain; | |
24 class ProxyImpl; | |
25 class ProxyMain; | |
26 class ThreadProxy; | |
27 | |
28 // An implementation of ChannelMain and ChannelImpl that sends commands between | |
weiliangc
2015/09/25 19:42:46
This comment is awesome! Thanks. :)
Khushal
2015/09/25 20:48:03
Thanks! :)
| |
29 // ProxyMain and ProxyImpl across thread boundaries. | |
30 // | |
31 // LayerTreeHost creates ThreadedChannel and passes the ownership to ProxyMain. | |
32 // The object life cycle and communication across threads is as follows: | |
33 // | |
34 // | |
35 // Main Thread | Impl Thread | |
36 // LayerTreeHost->InitializeProxy | | |
37 // | | | |
38 // ProxyMain->Start() | | |
39 // | ThreadedChannel | |
40 // --------------------------------------------------------------------------- | |
41 // ChannelMain::InitializeImpl ---PostTask---> ThreadedChannel:: | |
42 // InitializeImplOnImplThread | |
43 // | | |
44 // ProxyImpl::Create | |
45 // | | |
46 // ProxyImpl->Initialize() | |
47 // . | |
48 // . | |
49 // ProxyImpl::ScheduledActionBegin | |
50 // OutputSurfaceCreation | |
51 // | | |
52 // ChannelImpl::RequestNewOutputSurface | |
53 // ---------------------------------------------------------------------------- | |
54 // | | |
55 // ProxyMain->RequestNewOutputSurface()<----PostTask-------- | |
56 // . | |
57 // . | |
58 // ProxyMain->LayerTreeHostClosed | |
59 // | | |
60 // --------------------------------------------------------------------------- | |
61 // ChannelMain::SetLayerTreeClosedOnImpl---PostTask---> ProxyImpl-> | |
62 // SetLayerTreeClosed | |
63 // ---------------------------------------------------------------------------- | |
64 | |
65 class CC_EXPORT ThreadedChannel : public ChannelMain, public ChannelImpl { | |
66 public: | |
67 static scoped_ptr<ThreadedChannel> Create( | |
68 // TODO(khushalsagar): Make this ProxyMain* and write the initialization | |
69 // sequence. Currently ThreadProxy implements both so we pass the pointer | |
70 // and set ProxyImpl. | |
71 ThreadProxy* thread_proxy, | |
72 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | |
73 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner); | |
74 | |
75 ~ThreadedChannel() override; | |
76 | |
77 // ChannelMain Implementation | |
78 void SetThrottleFrameProductionOnImpl(bool throttle) override; | |
79 void SetLayerTreeHostClientReadyOnImpl() override; | |
80 | |
81 // ChannelImpl Implementation | |
82 void DidCompleteSwapBuffers() override; | |
83 | |
84 protected: | |
85 ThreadedChannel(ThreadProxy* thread_proxy, | |
86 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | |
87 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner); | |
88 | |
89 private: | |
90 base::SingleThreadTaskRunner* MainThreadTaskRunner() const; | |
91 base::SingleThreadTaskRunner* ImplThreadTaskRunner() const; | |
92 | |
93 ProxyMain* proxy_main_; | |
94 | |
95 ProxyImpl* proxy_impl_; | |
96 | |
97 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; | |
98 | |
99 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner_; | |
100 | |
101 DISALLOW_COPY_AND_ASSIGN(ThreadedChannel); | |
102 }; | |
103 | |
104 } // namespace cc | |
105 | |
106 #endif // CC_TREES_THREADED_CHANNEL_H_ | |
OLD | NEW |