OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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/synchronous_compositor_host.h" | 5 #include "content/browser/android/synchronous_compositor_host.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/containers/hash_tables.h" | 10 #include "base/containers/hash_tables.h" |
11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
12 #include "base/memory/shared_memory.h" | 12 #include "base/memory/shared_memory.h" |
13 #include "base/trace_event/trace_event_argument.h" | 13 #include "base/trace_event/trace_event_argument.h" |
14 #include "cc/output/compositor_frame_ack.h" | 14 #include "cc/output/compositor_frame_ack.h" |
15 #include "content/browser/android/in_process/synchronous_compositor_renderer_sta
tics.h" | 15 #include "content/browser/android/in_process/synchronous_compositor_renderer_sta
tics.h" |
16 #include "content/browser/gpu/gpu_process_host.h" | |
17 #include "content/browser/renderer_host/render_widget_host_view_android.h" | 16 #include "content/browser/renderer_host/render_widget_host_view_android.h" |
18 #include "content/browser/web_contents/web_contents_android.h" | 17 #include "content/browser/web_contents/web_contents_android.h" |
19 #include "content/browser/web_contents/web_contents_impl.h" | 18 #include "content/browser/web_contents/web_contents_impl.h" |
20 #include "content/common/android/sync_compositor_messages.h" | 19 #include "content/common/android/sync_compositor_messages.h" |
21 #include "content/gpu/in_process_gpu_thread.h" | |
22 #include "content/public/browser/android/synchronous_compositor_client.h" | 20 #include "content/public/browser/android/synchronous_compositor_client.h" |
23 #include "content/public/browser/browser_thread.h" | 21 #include "content/public/browser/browser_thread.h" |
24 #include "content/public/browser/render_view_host.h" | 22 #include "content/public/browser/render_view_host.h" |
25 #include "content/public/common/content_switches.h" | 23 #include "content/public/common/content_switches.h" |
26 #include "ipc/ipc_sender.h" | 24 #include "ipc/ipc_sender.h" |
27 #include "third_party/skia/include/core/SkBitmap.h" | 25 #include "third_party/skia/include/core/SkBitmap.h" |
28 #include "third_party/skia/include/core/SkCanvas.h" | 26 #include "third_party/skia/include/core/SkCanvas.h" |
29 #include "third_party/skia/include/core/SkImageInfo.h" | 27 #include "third_party/skia/include/core/SkImageInfo.h" |
30 #include "third_party/skia/include/core/SkRect.h" | 28 #include "third_party/skia/include/core/SkRect.h" |
31 #include "ui/gfx/skia_util.h" | 29 #include "ui/gfx/skia_util.h" |
32 | 30 |
33 namespace content { | 31 namespace content { |
34 | 32 |
35 namespace { | |
36 | |
37 base::LazyInstance<scoped_refptr<gpu::InProcessCommandBuffer::Service>> | |
38 g_gpu_service = LAZY_INSTANCE_INITIALIZER; | |
39 | |
40 base::Thread* CreateInProcessGpuThreadForSynchronousCompositor( | |
41 const InProcessChildThreadParams& params, | |
42 const gpu::GpuPreferences& gpu_preferences) { | |
43 DCHECK(g_gpu_service.Get()); | |
44 return new InProcessGpuThread(params, gpu_preferences, | |
45 g_gpu_service.Get()->sync_point_manager()); | |
46 } | |
47 | |
48 } // namespace | |
49 | |
50 void SynchronousCompositor::SetGpuService( | |
51 scoped_refptr<gpu::InProcessCommandBuffer::Service> service) { | |
52 DCHECK(!g_gpu_service.Get()); | |
53 g_gpu_service.Get() = service; | |
54 GpuProcessHost::RegisterGpuMainThreadFactory( | |
55 CreateInProcessGpuThreadForSynchronousCompositor); | |
56 } | |
57 | |
58 // static | 33 // static |
59 void SynchronousCompositor::SetClientForWebContents( | 34 void SynchronousCompositor::SetClientForWebContents( |
60 WebContents* contents, | 35 WebContents* contents, |
61 SynchronousCompositorClient* client) { | 36 SynchronousCompositorClient* client) { |
62 DCHECK(contents); | 37 DCHECK(contents); |
63 DCHECK(client); | 38 DCHECK(client); |
64 WebContentsAndroid* web_contents_android = | 39 WebContentsAndroid* web_contents_android = |
65 static_cast<WebContentsImpl*>(contents)->GetWebContentsAndroid(); | 40 static_cast<WebContentsImpl*>(contents)->GetWebContentsAndroid(); |
66 DCHECK(!web_contents_android->synchronous_compositor_client()); | 41 DCHECK(!web_contents_android->synchronous_compositor_client()); |
67 web_contents_android->set_synchronous_compositor_client(client); | 42 web_contents_android->set_synchronous_compositor_client(client); |
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
514 params.scrollable_size, params.page_scale_factor, | 489 params.scrollable_size, params.page_scale_factor, |
515 params.min_page_scale_factor, params.max_page_scale_factor); | 490 params.min_page_scale_factor, params.max_page_scale_factor); |
516 } | 491 } |
517 } | 492 } |
518 | 493 |
519 void SynchronousCompositorHost::UpdateNeedsBeginFrames() { | 494 void SynchronousCompositorHost::UpdateNeedsBeginFrames() { |
520 rwhva_->OnSetNeedsBeginFrames(is_active_ && need_begin_frame_); | 495 rwhva_->OnSetNeedsBeginFrames(is_active_ && need_begin_frame_); |
521 } | 496 } |
522 | 497 |
523 } // namespace content | 498 } // namespace content |
OLD | NEW |