OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/browser/android/in_process/synchronous_compositor_impl.h" | 5 #include "content/browser/android/in_process/synchronous_compositor_impl.h" |
6 | 6 |
7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "content/browser/android/in_process/synchronous_input_event_filter.h" |
9 #include "content/public/browser/android/synchronous_compositor_client.h" | 10 #include "content/public/browser/android/synchronous_compositor_client.h" |
10 #include "content/public/browser/browser_thread.h" | 11 #include "content/public/browser/browser_thread.h" |
11 #include "content/public/browser/render_process_host.h" | 12 #include "content/public/browser/render_process_host.h" |
12 #include "content/public/browser/render_view_host.h" | 13 #include "content/public/browser/render_view_host.h" |
13 #include "content/renderer/android/synchronous_compositor_factory.h" | 14 #include "content/renderer/android/synchronous_compositor_factory.h" |
14 | 15 |
15 namespace content { | 16 namespace content { |
16 | 17 |
17 namespace { | 18 namespace { |
18 | 19 |
(...skipping 23 matching lines...) Expand all Loading... |
42 GetCompositorMessageLoop() OVERRIDE { | 43 GetCompositorMessageLoop() OVERRIDE { |
43 return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI); | 44 return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI); |
44 } | 45 } |
45 | 46 |
46 virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface( | 47 virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface( |
47 int routing_id) OVERRIDE { | 48 int routing_id) OVERRIDE { |
48 scoped_ptr<SynchronousCompositorOutputSurface> output_surface( | 49 scoped_ptr<SynchronousCompositorOutputSurface> output_surface( |
49 new SynchronousCompositorOutputSurface(routing_id)); | 50 new SynchronousCompositorOutputSurface(routing_id)); |
50 return output_surface.PassAs<cc::OutputSurface>(); | 51 return output_surface.PassAs<cc::OutputSurface>(); |
51 } | 52 } |
| 53 |
| 54 virtual InputHandlerManagerClient* GetInputHandlerManagerClient() OVERRIDE { |
| 55 return synchronous_input_event_filter(); |
| 56 } |
| 57 |
| 58 SynchronousInputEventFilter* synchronous_input_event_filter() { |
| 59 return &synchronous_input_event_filter_; |
| 60 } |
| 61 |
| 62 private: |
| 63 SynchronousInputEventFilter synchronous_input_event_filter_; |
52 }; | 64 }; |
53 | 65 |
54 base::LazyInstance<SynchronousCompositorFactoryImpl>::Leaky g_factory = | 66 base::LazyInstance<SynchronousCompositorFactoryImpl>::Leaky g_factory = |
55 LAZY_INSTANCE_INITIALIZER; | 67 LAZY_INSTANCE_INITIALIZER; |
56 | 68 |
57 } // namespace | 69 } // namespace |
58 | 70 |
59 DEFINE_WEB_CONTENTS_USER_DATA_KEY(SynchronousCompositorImpl); | 71 DEFINE_WEB_CONTENTS_USER_DATA_KEY(SynchronousCompositorImpl); |
60 | 72 |
61 // static | 73 // static |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 compositor_client_ = NULL; | 144 compositor_client_ = NULL; |
133 } | 145 } |
134 } | 146 } |
135 | 147 |
136 void SynchronousCompositorImpl::SetContinuousInvalidate(bool enable) { | 148 void SynchronousCompositorImpl::SetContinuousInvalidate(bool enable) { |
137 DCHECK(CalledOnValidThread()); | 149 DCHECK(CalledOnValidThread()); |
138 if (compositor_client_) | 150 if (compositor_client_) |
139 compositor_client_->SetContinuousInvalidate(enable); | 151 compositor_client_->SetContinuousInvalidate(enable); |
140 } | 152 } |
141 | 153 |
| 154 InputEventAckState SynchronousCompositorImpl::HandleInputEvent( |
| 155 const WebKit::WebInputEvent& input_event) { |
| 156 DCHECK(CalledOnValidThread()); |
| 157 return g_factory.Get().synchronous_input_event_filter()->HandleInputEvent( |
| 158 routing_id_, &input_event); |
| 159 } |
| 160 |
142 // Not using base::NonThreadSafe as we want to enforce a more exacting threading | 161 // Not using base::NonThreadSafe as we want to enforce a more exacting threading |
143 // requirement: SynchronousCompositorImpl() must only be used on the UI thread. | 162 // requirement: SynchronousCompositorImpl() must only be used on the UI thread. |
144 bool SynchronousCompositorImpl::CalledOnValidThread() const { | 163 bool SynchronousCompositorImpl::CalledOnValidThread() const { |
145 return BrowserThread::CurrentlyOn(BrowserThread::UI); | 164 return BrowserThread::CurrentlyOn(BrowserThread::UI); |
146 } | 165 } |
147 | 166 |
148 // static | 167 // static |
149 void SynchronousCompositor::SetClientForWebContents( | 168 void SynchronousCompositor::SetClientForWebContents( |
150 WebContents* contents, | 169 WebContents* contents, |
151 SynchronousCompositorClient* client) { | 170 SynchronousCompositorClient* client) { |
152 DCHECK(contents); | 171 DCHECK(contents); |
153 if (client) { | 172 if (client) { |
154 g_factory.Get(); // Ensure it's initialized. | 173 g_factory.Get(); // Ensure it's initialized. |
155 SynchronousCompositorImpl::CreateForWebContents(contents); | 174 SynchronousCompositorImpl::CreateForWebContents(contents); |
156 } | 175 } |
157 if (SynchronousCompositorImpl* instance = | 176 if (SynchronousCompositorImpl* instance = |
158 SynchronousCompositorImpl::FromWebContents(contents)) { | 177 SynchronousCompositorImpl::FromWebContents(contents)) { |
159 instance->SetClient(client); | 178 instance->SetClient(client); |
160 } | 179 } |
161 } | 180 } |
162 | 181 |
163 } // namespace content | 182 } // namespace content |
OLD | NEW |