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