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