| 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 #include "content/browser/android/synchronous_compositor_base.h" |
| 6 |
| 7 #include "base/command_line.h" |
| 8 #include "base/supports_user_data.h" |
| 9 #include "content/browser/android/in_process/synchronous_compositor_impl.h" |
| 10 #include "content/browser/android/synchronous_compositor_host.h" |
| 11 #include "content/browser/gpu/gpu_process_host.h" |
| 12 #include "content/browser/web_contents/web_contents_android.h" |
| 13 #include "content/browser/web_contents/web_contents_impl.h" |
| 14 #include "content/gpu/in_process_gpu_thread.h" |
| 15 #include "content/public/common/content_switches.h" |
| 16 |
| 17 namespace content { |
| 18 |
| 19 class SynchronousCompositorClient; |
| 20 |
| 21 namespace { |
| 22 |
| 23 gpu::SyncPointManager* g_sync_point_manager = nullptr; |
| 24 |
| 25 base::Thread* CreateInProcessGpuThreadForSynchronousCompositor( |
| 26 const InProcessChildThreadParams& params) { |
| 27 DCHECK(g_sync_point_manager); |
| 28 return new InProcessGpuThread(params, g_sync_point_manager); |
| 29 } |
| 30 |
| 31 } // namespace |
| 32 |
| 33 void SynchronousCompositor::SetGpuService( |
| 34 scoped_refptr<gpu::InProcessCommandBuffer::Service> service) { |
| 35 DCHECK(!g_sync_point_manager); |
| 36 g_sync_point_manager = service->sync_point_manager(); |
| 37 GpuProcessHost::RegisterGpuMainThreadFactory( |
| 38 CreateInProcessGpuThreadForSynchronousCompositor); |
| 39 |
| 40 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 41 switches::kIPCSyncCompositing)) { |
| 42 SynchronousCompositorImpl::SetGpuServiceInProc(service); |
| 43 } |
| 44 } |
| 45 |
| 46 // static |
| 47 void SynchronousCompositor::SetClientForWebContents( |
| 48 WebContents* contents, |
| 49 SynchronousCompositorClient* client) { |
| 50 DCHECK(contents); |
| 51 DCHECK(client); |
| 52 WebContentsAndroid* web_contents_android = |
| 53 static_cast<WebContentsImpl*>(contents)->GetWebContentsAndroid(); |
| 54 DCHECK(!web_contents_android->synchronous_compositor_client()); |
| 55 web_contents_android->set_synchronous_compositor_client(client); |
| 56 } |
| 57 |
| 58 // static |
| 59 scoped_ptr<SynchronousCompositorBase> SynchronousCompositorBase::Create( |
| 60 RenderWidgetHostViewAndroid* rwhva, |
| 61 WebContents* web_contents) { |
| 62 DCHECK(web_contents); |
| 63 WebContentsAndroid* web_contents_android = |
| 64 static_cast<WebContentsImpl*>(web_contents)->GetWebContentsAndroid(); |
| 65 if (!web_contents_android->synchronous_compositor_client()) |
| 66 return nullptr; // Not using sync compositing. |
| 67 |
| 68 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 69 switches::kIPCSyncCompositing)) { |
| 70 return make_scoped_ptr(new SynchronousCompositorHost( |
| 71 rwhva, web_contents_android->synchronous_compositor_client())); |
| 72 } |
| 73 return make_scoped_ptr(new SynchronousCompositorImpl( |
| 74 rwhva, web_contents_android->synchronous_compositor_client())); |
| 75 } |
| 76 |
| 77 } // namespace content |
| OLD | NEW |