Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(145)

Side by Side Diff: content/renderer/render_thread_impl.cc

Issue 1408123005: Android Webview IPC-based sync compositing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: send FrameAct Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/renderer/render_thread_impl.h" 5 #include "content/renderer/render_thread_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <map> 9 #include <map>
10 #include <vector> 10 #include <vector>
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 #include "third_party/WebKit/public/web/WebView.h" 152 #include "third_party/WebKit/public/web/WebView.h"
153 #include "third_party/icu/source/i18n/unicode/timezone.h" 153 #include "third_party/icu/source/i18n/unicode/timezone.h"
154 #include "third_party/mojo/src/mojo/public/cpp/bindings/strong_binding.h" 154 #include "third_party/mojo/src/mojo/public/cpp/bindings/strong_binding.h"
155 #include "third_party/skia/include/core/SkGraphics.h" 155 #include "third_party/skia/include/core/SkGraphics.h"
156 #include "ui/base/layout.h" 156 #include "ui/base/layout.h"
157 #include "ui/base/ui_base_switches.h" 157 #include "ui/base/ui_base_switches.h"
158 #include "v8/include/v8.h" 158 #include "v8/include/v8.h"
159 159
160 #if defined(OS_ANDROID) 160 #if defined(OS_ANDROID)
161 #include <cpu-features.h> 161 #include <cpu-features.h>
162 #include "content/renderer/android/synchronous_compositor_external_begin_frame_s ource.h"
162 #include "content/renderer/android/synchronous_compositor_factory.h" 163 #include "content/renderer/android/synchronous_compositor_factory.h"
164 #include "content/renderer/android/synchronous_compositor_filter.h"
163 #include "content/renderer/media/android/renderer_demuxer_android.h" 165 #include "content/renderer/media/android/renderer_demuxer_android.h"
164 #endif 166 #endif
165 167
166 #if defined(OS_MACOSX) 168 #if defined(OS_MACOSX)
167 #include "base/mac/mac_util.h" 169 #include "base/mac/mac_util.h"
168 #include "content/renderer/theme_helper_mac.h" 170 #include "content/renderer/theme_helper_mac.h"
169 #include "content/renderer/webscrollbarbehavior_impl_mac.h" 171 #include "content/renderer/webscrollbarbehavior_impl_mac.h"
170 #endif 172 #endif
171 173
172 #if defined(OS_POSIX) 174 #if defined(OS_POSIX)
(...skipping 677 matching lines...) Expand 10 before | Expand all | Expand 10 after
850 852
851 // Shutdown the file thread if it's running. 853 // Shutdown the file thread if it's running.
852 if (file_thread_) 854 if (file_thread_)
853 file_thread_->Stop(); 855 file_thread_->Stop();
854 856
855 if (compositor_message_filter_.get()) { 857 if (compositor_message_filter_.get()) {
856 RemoveFilter(compositor_message_filter_.get()); 858 RemoveFilter(compositor_message_filter_.get());
857 compositor_message_filter_ = NULL; 859 compositor_message_filter_ = NULL;
858 } 860 }
859 861
862 #if defined(OS_ANDROID)
863 if (sync_compositor_message_filter_.get()) {
dcheng 2015/11/04 09:47:41 Nit: no .get()
boliu 2015/11/04 16:52:05 Done.
864 RemoveFilter(sync_compositor_message_filter_.get());
865 sync_compositor_message_filter_ = NULL;
dcheng 2015/11/04 09:47:41 Nit: nullptr
boliu 2015/11/04 16:52:05 Done.
866 }
867 #endif
868
860 media_thread_.reset(); 869 media_thread_.reset();
861 870
862 compositor_thread_.reset(); 871 compositor_thread_.reset();
863 872
864 // AudioMessageFilter may be accessed on |media_thread_|, so shutdown after. 873 // AudioMessageFilter may be accessed on |media_thread_|, so shutdown after.
865 RemoveFilter(audio_message_filter_.get()); 874 RemoveFilter(audio_message_filter_.get());
866 audio_message_filter_ = NULL; 875 audio_message_filter_ = NULL;
867 876
868 raster_worker_pool_->Shutdown(); 877 raster_worker_pool_->Shutdown();
869 878
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
1122 1131
1123 main_input_callback_.Reset( 1132 main_input_callback_.Reset(
1124 base::Bind(base::IgnoreResult(&RenderThreadImpl::OnMessageReceived), 1133 base::Bind(base::IgnoreResult(&RenderThreadImpl::OnMessageReceived),
1125 base::Unretained(this))); 1134 base::Unretained(this)));
1126 1135
1127 SetResourceDispatchTaskQueue(renderer_scheduler_->LoadingTaskRunner()); 1136 SetResourceDispatchTaskQueue(renderer_scheduler_->LoadingTaskRunner());
1128 1137
1129 bool enable = !command_line.HasSwitch(switches::kDisableThreadedCompositing); 1138 bool enable = !command_line.HasSwitch(switches::kDisableThreadedCompositing);
1130 if (enable) { 1139 if (enable) {
1131 #if defined(OS_ANDROID) 1140 #if defined(OS_ANDROID)
1132 if (SynchronousCompositorFactory* factory = 1141 SynchronousCompositorFactory* sync_compositor_factory =
1133 SynchronousCompositorFactory::GetInstance()) 1142 SynchronousCompositorFactory::GetInstance();
1134 compositor_task_runner_ = factory->GetCompositorTaskRunner(); 1143 bool using_ipc_sync_compositing =
1144 base::CommandLine::ForCurrentProcess()->HasSwitch(
1145 switches::kIPCSyncCompositing);
1146 DCHECK(!sync_compositor_factory || !using_ipc_sync_compositing);
1147
1148 if (sync_compositor_factory) {
1149 compositor_task_runner_ =
1150 sync_compositor_factory->GetCompositorTaskRunner();
1151 }
1135 #endif 1152 #endif
1136 if (!compositor_task_runner_.get()) { 1153 if (!compositor_task_runner_.get()) {
1137 compositor_thread_.reset(new base::Thread("Compositor")); 1154 compositor_thread_.reset(new base::Thread("Compositor"));
1138 base::Thread::Options compositor_thread_options; 1155 base::Thread::Options compositor_thread_options;
1139 #if defined(OS_ANDROID) 1156 #if defined(OS_ANDROID)
1140 compositor_thread_options.priority = base::ThreadPriority::DISPLAY; 1157 compositor_thread_options.priority = base::ThreadPriority::DISPLAY;
1141 #endif 1158 #endif
1142 compositor_thread_->StartWithOptions(compositor_thread_options); 1159 compositor_thread_->StartWithOptions(compositor_thread_options);
1143 compositor_task_runner_ = compositor_thread_->task_runner(); 1160 compositor_task_runner_ = compositor_thread_->task_runner();
1144 compositor_task_runner_->PostTask( 1161 compositor_task_runner_->PostTask(
1145 FROM_HERE, 1162 FROM_HERE,
1146 base::Bind(base::IgnoreResult(&ThreadRestrictions::SetIOAllowed), 1163 base::Bind(base::IgnoreResult(&ThreadRestrictions::SetIOAllowed),
1147 false)); 1164 false));
1148 } 1165 }
1149 1166
1150 InputHandlerManagerClient* input_handler_manager_client = NULL; 1167 InputHandlerManagerClient* input_handler_manager_client = NULL;
1151 #if defined(OS_ANDROID) 1168 #if defined(OS_ANDROID)
1152 if (SynchronousCompositorFactory* factory = 1169 if (using_ipc_sync_compositing) {
1153 SynchronousCompositorFactory::GetInstance()) { 1170 sync_compositor_message_filter_ =
1154 input_handler_manager_client = factory->GetInputHandlerManagerClient(); 1171 new SynchronousCompositorFilter(compositor_task_runner_);
1172 AddFilter(sync_compositor_message_filter_.get());
1173 input_handler_manager_client = sync_compositor_message_filter_.get();
1174 } else if (sync_compositor_factory) {
1175 input_handler_manager_client =
1176 sync_compositor_factory->GetInputHandlerManagerClient();
1155 } 1177 }
1156 #endif 1178 #endif
1157 if (!input_handler_manager_client) { 1179 if (!input_handler_manager_client) {
1158 scoped_refptr<InputEventFilter> compositor_input_event_filter( 1180 scoped_refptr<InputEventFilter> compositor_input_event_filter(
1159 new InputEventFilter(main_input_callback_.callback(), 1181 new InputEventFilter(main_input_callback_.callback(),
1160 main_thread_compositor_task_runner_, 1182 main_thread_compositor_task_runner_,
1161 compositor_task_runner_)); 1183 compositor_task_runner_));
1162 input_handler_manager_client = compositor_input_event_filter.get(); 1184 input_handler_manager_client = compositor_input_event_filter.get();
1163 input_event_filter_ = compositor_input_event_filter; 1185 input_event_filter_ = compositor_input_event_filter;
1164 } 1186 }
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
1531 1553
1532 cc::ContextProvider* RenderThreadImpl::GetSharedMainThreadContextProvider() { 1554 cc::ContextProvider* RenderThreadImpl::GetSharedMainThreadContextProvider() {
1533 return SharedMainThreadContextProvider().get(); 1555 return SharedMainThreadContextProvider().get();
1534 } 1556 }
1535 1557
1536 scoped_ptr<cc::BeginFrameSource> 1558 scoped_ptr<cc::BeginFrameSource>
1537 RenderThreadImpl::CreateExternalBeginFrameSource(int routing_id) { 1559 RenderThreadImpl::CreateExternalBeginFrameSource(int routing_id) {
1538 #if defined(OS_ANDROID) 1560 #if defined(OS_ANDROID)
1539 if (SynchronousCompositorFactory* factory = 1561 if (SynchronousCompositorFactory* factory =
1540 SynchronousCompositorFactory::GetInstance()) { 1562 SynchronousCompositorFactory::GetInstance()) {
1563 DCHECK(!sync_compositor_message_filter_.get());
1541 return factory->CreateExternalBeginFrameSource(routing_id); 1564 return factory->CreateExternalBeginFrameSource(routing_id);
1565 } else if (sync_compositor_message_filter_.get()) {
1566 return make_scoped_ptr(new SynchronousCompositorExternalBeginFrameSource(
1567 routing_id, sync_compositor_message_filter_.get()));
1542 } 1568 }
1543 #endif 1569 #endif
1544 return make_scoped_ptr(new CompositorExternalBeginFrameSource( 1570 return make_scoped_ptr(new CompositorExternalBeginFrameSource(
1545 compositor_message_filter_.get(), sync_message_filter(), routing_id)); 1571 compositor_message_filter_.get(), sync_message_filter(), routing_id));
1546 } 1572 }
1547 1573
1548 cc::TaskGraphRunner* RenderThreadImpl::GetTaskGraphRunner() { 1574 cc::TaskGraphRunner* RenderThreadImpl::GetTaskGraphRunner() {
1549 return raster_worker_pool_->GetTaskGraphRunner(); 1575 return raster_worker_pool_->GetTaskGraphRunner();
1550 } 1576 }
1551 1577
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after
2002 } 2028 }
2003 2029
2004 void RenderThreadImpl::PendingRenderFrameConnect::OnConnectionError() { 2030 void RenderThreadImpl::PendingRenderFrameConnect::OnConnectionError() {
2005 size_t erased = 2031 size_t erased =
2006 RenderThreadImpl::current()->pending_render_frame_connects_.erase( 2032 RenderThreadImpl::current()->pending_render_frame_connects_.erase(
2007 routing_id_); 2033 routing_id_);
2008 DCHECK_EQ(1u, erased); 2034 DCHECK_EQ(1u, erased);
2009 } 2035 }
2010 2036
2011 } // namespace content 2037 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698