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/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
11 #include "cc/input/input_handler.h" | 11 #include "cc/input/input_handler.h" |
12 #include "content/browser/android/in_process/synchronous_compositor_external_beg
in_frame_source.h" | 12 #include "content/browser/android/in_process/synchronous_compositor_external_beg
in_frame_source.h" |
13 #include "content/browser/android/in_process/synchronous_compositor_factory_impl
.h" | 13 #include "content/browser/android/in_process/synchronous_compositor_factory_impl
.h" |
14 #include "content/browser/android/in_process/synchronous_compositor_registry.h" | 14 #include "content/browser/android/in_process/synchronous_compositor_registry.h" |
15 #include "content/browser/android/in_process/synchronous_input_event_filter.h" | 15 #include "content/browser/android/in_process/synchronous_input_event_filter.h" |
| 16 #include "content/browser/gpu/gpu_process_host.h" |
16 #include "content/browser/renderer_host/render_widget_host_view_android.h" | 17 #include "content/browser/renderer_host/render_widget_host_view_android.h" |
17 #include "content/common/input/did_overscroll_params.h" | 18 #include "content/common/input/did_overscroll_params.h" |
18 #include "content/common/input_messages.h" | 19 #include "content/common/input_messages.h" |
19 #include "content/public/browser/android/synchronous_compositor_client.h" | 20 #include "content/public/browser/android/synchronous_compositor_client.h" |
20 #include "content/public/browser/browser_thread.h" | 21 #include "content/public/browser/browser_thread.h" |
21 #include "content/public/browser/render_process_host.h" | 22 #include "content/public/browser/render_process_host.h" |
22 #include "content/public/browser/render_view_host.h" | 23 #include "content/public/browser/render_view_host.h" |
23 #include "ui/gl/gl_surface.h" | 24 #include "ui/gl/gl_surface.h" |
24 | 25 |
25 namespace content { | 26 namespace content { |
(...skipping 11 matching lines...) Expand all Loading... |
37 | 38 |
38 int id = it.GetCurrentValue()->GetID(); | 39 int id = it.GetCurrentValue()->GetID(); |
39 it.Advance(); | 40 it.Advance(); |
40 DCHECK(it.IsAtEnd()); // Not multiprocess compatible. | 41 DCHECK(it.IsAtEnd()); // Not multiprocess compatible. |
41 return id; | 42 return id; |
42 } | 43 } |
43 | 44 |
44 base::LazyInstance<SynchronousCompositorFactoryImpl>::Leaky g_factory = | 45 base::LazyInstance<SynchronousCompositorFactoryImpl>::Leaky g_factory = |
45 LAZY_INSTANCE_INITIALIZER; | 46 LAZY_INSTANCE_INITIALIZER; |
46 | 47 |
| 48 base::Thread* CreateInProcessGpuThreadForSynchronousCompositor( |
| 49 const InProcessChildThreadParams& params) { |
| 50 return g_factory.Get().CreateInProcessGpuThread(params); |
| 51 } |
| 52 |
47 } // namespace | 53 } // namespace |
48 | 54 |
49 DEFINE_WEB_CONTENTS_USER_DATA_KEY(SynchronousCompositorImpl); | 55 DEFINE_WEB_CONTENTS_USER_DATA_KEY(SynchronousCompositorImpl); |
50 | 56 |
51 // static | 57 // static |
52 SynchronousCompositorImpl* SynchronousCompositorImpl::FromID(int process_id, | 58 SynchronousCompositorImpl* SynchronousCompositorImpl::FromID(int process_id, |
53 int routing_id) { | 59 int routing_id) { |
54 if (g_factory == nullptr) | 60 if (g_factory == nullptr) |
55 return nullptr; | 61 return nullptr; |
56 RenderViewHost* rvh = RenderViewHost::FromID(process_id, routing_id); | 62 RenderViewHost* rvh = RenderViewHost::FromID(process_id, routing_id); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 | 131 |
126 // Setting the delegate causes UpdateRootLayerState immediately so do it | 132 // Setting the delegate causes UpdateRootLayerState immediately so do it |
127 // after setting the client. | 133 // after setting the client. |
128 input_handler_->SetRootLayerScrollOffsetDelegate(this); | 134 input_handler_->SetRootLayerScrollOffsetDelegate(this); |
129 } | 135 } |
130 | 136 |
131 // static | 137 // static |
132 void SynchronousCompositor::SetGpuService( | 138 void SynchronousCompositor::SetGpuService( |
133 scoped_refptr<gpu::InProcessCommandBuffer::Service> service) { | 139 scoped_refptr<gpu::InProcessCommandBuffer::Service> service) { |
134 g_factory.Get().SetDeferredGpuService(service); | 140 g_factory.Get().SetDeferredGpuService(service); |
| 141 GpuProcessHost::RegisterGpuMainThreadFactory( |
| 142 CreateInProcessGpuThreadForSynchronousCompositor); |
135 } | 143 } |
136 | 144 |
137 // static | 145 // static |
138 void SynchronousCompositor::SetRecordFullDocument(bool record_full_document) { | 146 void SynchronousCompositor::SetRecordFullDocument(bool record_full_document) { |
139 g_factory.Get().SetRecordFullDocument(record_full_document); | 147 g_factory.Get().SetRecordFullDocument(record_full_document); |
140 } | 148 } |
141 | 149 |
142 void SynchronousCompositorImpl::DidInitializeRendererObjects( | 150 void SynchronousCompositorImpl::DidInitializeRendererObjects( |
143 SynchronousCompositorOutputSurface* output_surface, | 151 SynchronousCompositorOutputSurface* output_surface, |
144 SynchronousCompositorExternalBeginFrameSource* begin_frame_source, | 152 SynchronousCompositorExternalBeginFrameSource* begin_frame_source, |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 g_factory.Get(); // Ensure it's initialized. | 407 g_factory.Get(); // Ensure it's initialized. |
400 SynchronousCompositorImpl::CreateForWebContents(contents); | 408 SynchronousCompositorImpl::CreateForWebContents(contents); |
401 } | 409 } |
402 SynchronousCompositorImpl* instance = | 410 SynchronousCompositorImpl* instance = |
403 SynchronousCompositorImpl::FromWebContents(contents); | 411 SynchronousCompositorImpl::FromWebContents(contents); |
404 DCHECK(instance); | 412 DCHECK(instance); |
405 instance->SetClient(client); | 413 instance->SetClient(client); |
406 } | 414 } |
407 | 415 |
408 } // namespace content | 416 } // namespace content |
OLD | NEW |