Chromium Code Reviews| 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 "content/browser/android/synchronous_compositor_browser_filter.h" | 14 #include "content/browser/android/synchronous_compositor_browser_filter.h" |
| 15 #include "content/browser/renderer_host/render_widget_host_view_android.h" | 15 #include "content/browser/renderer_host/render_widget_host_view_android.h" |
| 16 #include "content/browser/web_contents/web_contents_android.h" | 16 #include "content/browser/web_contents/web_contents_android.h" |
|
boliu
2016/11/08 16:50:47
can these two includes be removed now?
Jinsuk Kim
2016/11/08 17:18:30
Yes removed both.
| |
| 17 #include "content/browser/web_contents/web_contents_impl.h" | 17 #include "content/browser/web_contents/web_contents_impl.h" |
| 18 #include "content/common/android/sync_compositor_messages.h" | 18 #include "content/common/android/sync_compositor_messages.h" |
| 19 #include "content/common/android/sync_compositor_statics.h" | 19 #include "content/common/android/sync_compositor_statics.h" |
| 20 #include "content/public/browser/android/synchronous_compositor_client.h" | 20 #include "content/public/browser/android/synchronous_compositor_client.h" |
| 21 #include "content/public/browser/browser_thread.h" | 21 #include "content/public/browser/browser_thread.h" |
| 22 #include "content/public/browser/render_view_host.h" | 22 #include "content/public/browser/render_view_host.h" |
| 23 #include "content/public/common/content_switches.h" | 23 #include "content/public/common/content_switches.h" |
| 24 #include "ipc/ipc_sender.h" | 24 #include "ipc/ipc_sender.h" |
| 25 #include "third_party/skia/include/core/SkBitmap.h" | 25 #include "third_party/skia/include/core/SkBitmap.h" |
| 26 #include "third_party/skia/include/core/SkCanvas.h" | 26 #include "third_party/skia/include/core/SkCanvas.h" |
| 27 #include "third_party/skia/include/core/SkImageInfo.h" | 27 #include "third_party/skia/include/core/SkImageInfo.h" |
| 28 #include "third_party/skia/include/core/SkRect.h" | 28 #include "third_party/skia/include/core/SkRect.h" |
| 29 #include "ui/events/blink/did_overscroll_params.h" | 29 #include "ui/events/blink/did_overscroll_params.h" |
| 30 #include "ui/gfx/skia_util.h" | 30 #include "ui/gfx/skia_util.h" |
| 31 | 31 |
| 32 namespace content { | 32 namespace content { |
| 33 | 33 |
| 34 // static | 34 // static |
| 35 void SynchronousCompositor::SetClientForWebContents( | |
| 36 WebContents* contents, | |
| 37 SynchronousCompositorClient* client) { | |
| 38 DCHECK(contents); | |
| 39 DCHECK(client); | |
| 40 WebContentsAndroid* web_contents_android = | |
| 41 static_cast<WebContentsImpl*>(contents)->GetWebContentsAndroid(); | |
| 42 DCHECK(!web_contents_android->synchronous_compositor_client()); | |
| 43 web_contents_android->set_synchronous_compositor_client(client); | |
| 44 } | |
| 45 | |
| 46 // static | |
| 47 std::unique_ptr<SynchronousCompositorHost> SynchronousCompositorHost::Create( | 35 std::unique_ptr<SynchronousCompositorHost> SynchronousCompositorHost::Create( |
| 48 RenderWidgetHostViewAndroid* rwhva, | 36 RenderWidgetHostViewAndroid* rwhva) { |
| 49 WebContents* web_contents) { | 37 if (!rwhva->synchronous_compositor_client()) |
| 50 DCHECK(web_contents); | |
| 51 WebContentsAndroid* web_contents_android = | |
| 52 static_cast<WebContentsImpl*>(web_contents)->GetWebContentsAndroid(); | |
| 53 if (!web_contents_android->synchronous_compositor_client()) | |
| 54 return nullptr; // Not using sync compositing. | 38 return nullptr; // Not using sync compositing. |
| 55 | 39 |
| 56 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 40 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 57 bool use_in_proc_software_draw = | 41 bool use_in_proc_software_draw = |
| 58 command_line->HasSwitch(switches::kSingleProcess); | 42 command_line->HasSwitch(switches::kSingleProcess); |
| 59 return base::WrapUnique(new SynchronousCompositorHost( | 43 return base::WrapUnique(new SynchronousCompositorHost( |
| 60 rwhva, web_contents_android->synchronous_compositor_client(), | 44 rwhva, use_in_proc_software_draw)); |
| 61 use_in_proc_software_draw)); | |
| 62 } | 45 } |
| 63 | 46 |
| 64 SynchronousCompositorHost::SynchronousCompositorHost( | 47 SynchronousCompositorHost::SynchronousCompositorHost( |
| 65 RenderWidgetHostViewAndroid* rwhva, | 48 RenderWidgetHostViewAndroid* rwhva, |
| 66 SynchronousCompositorClient* client, | |
| 67 bool use_in_proc_software_draw) | 49 bool use_in_proc_software_draw) |
| 68 : rwhva_(rwhva), | 50 : rwhva_(rwhva), |
| 69 client_(client), | 51 client_(rwhva->synchronous_compositor_client()), |
| 70 ui_task_runner_(BrowserThread::GetTaskRunnerForThread(BrowserThread::UI)), | 52 ui_task_runner_(BrowserThread::GetTaskRunnerForThread(BrowserThread::UI)), |
| 71 process_id_(rwhva_->GetRenderWidgetHost()->GetProcess()->GetID()), | 53 process_id_(rwhva_->GetRenderWidgetHost()->GetProcess()->GetID()), |
| 72 routing_id_(rwhva_->GetRenderWidgetHost()->GetRoutingID()), | 54 routing_id_(rwhva_->GetRenderWidgetHost()->GetRoutingID()), |
| 73 sender_(rwhva_->GetRenderWidgetHost()), | 55 sender_(rwhva_->GetRenderWidgetHost()), |
| 74 use_in_process_zero_copy_software_draw_(use_in_proc_software_draw), | 56 use_in_process_zero_copy_software_draw_(use_in_proc_software_draw), |
| 75 bytes_limit_(0u), | 57 bytes_limit_(0u), |
| 76 renderer_param_version_(0u), | 58 renderer_param_version_(0u), |
| 77 need_animate_scroll_(false), | 59 need_animate_scroll_(false), |
| 78 need_invalidate_count_(0u), | 60 need_invalidate_count_(0u), |
| 79 did_activate_pending_tree_count_(0u) { | 61 did_activate_pending_tree_count_(0u) { |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 424 if (params.page_scale_factor) { | 406 if (params.page_scale_factor) { |
| 425 client_->UpdateRootLayerState( | 407 client_->UpdateRootLayerState( |
| 426 this, gfx::ScrollOffsetToVector2dF(params.total_scroll_offset), | 408 this, gfx::ScrollOffsetToVector2dF(params.total_scroll_offset), |
| 427 gfx::ScrollOffsetToVector2dF(params.max_scroll_offset), | 409 gfx::ScrollOffsetToVector2dF(params.max_scroll_offset), |
| 428 params.scrollable_size, params.page_scale_factor, | 410 params.scrollable_size, params.page_scale_factor, |
| 429 params.min_page_scale_factor, params.max_page_scale_factor); | 411 params.min_page_scale_factor, params.max_page_scale_factor); |
| 430 } | 412 } |
| 431 } | 413 } |
| 432 | 414 |
| 433 } // namespace content | 415 } // namespace content |
| OLD | NEW |