| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "android_webview/browser/render_thread_manager.h" | 5 #include "android_webview/browser/render_thread_manager.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "android_webview/browser/child_frame.h" | 9 #include "android_webview/browser/child_frame.h" |
| 10 #include "android_webview/browser/compositor_frame_producer.h" | 10 #include "android_webview/browser/compositor_frame_producer.h" |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 hardware_renderer_has_frame_(false), | 97 hardware_renderer_has_frame_(false), |
| 98 inside_hardware_release_(false), | 98 inside_hardware_release_(false), |
| 99 weak_factory_on_ui_thread_(this) { | 99 weak_factory_on_ui_thread_(this) { |
| 100 DCHECK(ui_loop_->BelongsToCurrentThread()); | 100 DCHECK(ui_loop_->BelongsToCurrentThread()); |
| 101 DCHECK(client_); | 101 DCHECK(client_); |
| 102 ui_thread_weak_ptr_ = weak_factory_on_ui_thread_.GetWeakPtr(); | 102 ui_thread_weak_ptr_ = weak_factory_on_ui_thread_.GetWeakPtr(); |
| 103 ResetRequestInvokeGLCallback(); | 103 ResetRequestInvokeGLCallback(); |
| 104 } | 104 } |
| 105 | 105 |
| 106 RenderThreadManager::~RenderThreadManager() { | 106 RenderThreadManager::~RenderThreadManager() { |
| 107 LOG(WARNING) << "XXX " << __PRETTY_FUNCTION__; |
| 107 DCHECK(ui_loop_->BelongsToCurrentThread()); | 108 DCHECK(ui_loop_->BelongsToCurrentThread()); |
| 108 if (compositor_frame_producer_) { | 109 if (compositor_frame_producer_) { |
| 109 compositor_frame_producer_->OnCompositorFrameConsumerWillDestroy(); | 110 compositor_frame_producer_->RemoveCompositorFrameConsumer(this); |
| 110 } | 111 } |
| 111 DCHECK(!hardware_renderer_.get()); | 112 DCHECK(!hardware_renderer_.get()); |
| 112 } | 113 } |
| 113 | 114 |
| 114 void RenderThreadManager::ClientRequestInvokeGL(bool for_idle) { | 115 void RenderThreadManager::ClientRequestInvokeGL(bool for_idle) { |
| 115 if (ui_loop_->BelongsToCurrentThread()) { | 116 if (ui_loop_->BelongsToCurrentThread()) { |
| 116 if (!g_request_invoke_gl_tracker.Get().ShouldRequestOnUiThread(this)) | 117 if (!g_request_invoke_gl_tracker.Get().ShouldRequestOnUiThread(this)) |
| 117 return; | 118 return; |
| 118 ClientRequestInvokeGLOnUI(); | 119 ClientRequestInvokeGLOnUI(); |
| 119 } else { | 120 } else { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 g_request_invoke_gl_tracker.Get().SetQueuedFunctorOnUi(this); | 152 g_request_invoke_gl_tracker.Get().SetQueuedFunctorOnUi(this); |
| 152 if (!client_->RequestInvokeGL(false)) { | 153 if (!client_->RequestInvokeGL(false)) { |
| 153 g_request_invoke_gl_tracker.Get().ResetPending(); | 154 g_request_invoke_gl_tracker.Get().ResetPending(); |
| 154 LOG(ERROR) << "Failed to request GL process. Deadlock likely"; | 155 LOG(ERROR) << "Failed to request GL process. Deadlock likely"; |
| 155 } | 156 } |
| 156 } | 157 } |
| 157 | 158 |
| 158 void RenderThreadManager::UpdateParentDrawConstraintsOnUI() { | 159 void RenderThreadManager::UpdateParentDrawConstraintsOnUI() { |
| 159 DCHECK(ui_loop_->BelongsToCurrentThread()); | 160 DCHECK(ui_loop_->BelongsToCurrentThread()); |
| 160 if (compositor_frame_producer_) { | 161 if (compositor_frame_producer_) { |
| 161 compositor_frame_producer_->OnParentDrawConstraintsUpdated(); | 162 compositor_frame_producer_->OnParentDrawConstraintsUpdated(this); |
| 162 } | 163 } |
| 163 } | 164 } |
| 164 | 165 |
| 165 void RenderThreadManager::SetScrollOffsetOnUI(gfx::Vector2d scroll_offset) { | 166 void RenderThreadManager::SetScrollOffsetOnUI(gfx::Vector2d scroll_offset) { |
| 166 base::AutoLock lock(lock_); | 167 base::AutoLock lock(lock_); |
| 167 scroll_offset_ = scroll_offset; | 168 scroll_offset_ = scroll_offset; |
| 168 } | 169 } |
| 169 | 170 |
| 170 gfx::Vector2d RenderThreadManager::GetScrollOffsetOnRT() { | 171 gfx::Vector2d RenderThreadManager::GetScrollOffsetOnRT() { |
| 171 base::AutoLock lock(lock_); | 172 base::AutoLock lock(lock_); |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 } | 356 } |
| 356 | 357 |
| 357 if (hardware_initialized) { | 358 if (hardware_initialized) { |
| 358 // Flush any invoke functors that's caused by ReleaseHardware. | 359 // Flush any invoke functors that's caused by ReleaseHardware. |
| 359 client_->RequestInvokeGL(true); | 360 client_->RequestInvokeGL(true); |
| 360 } | 361 } |
| 361 } | 362 } |
| 362 | 363 |
| 363 void RenderThreadManager::SetCompositorFrameProducer( | 364 void RenderThreadManager::SetCompositorFrameProducer( |
| 364 CompositorFrameProducer* compositor_frame_producer) { | 365 CompositorFrameProducer* compositor_frame_producer) { |
| 366 DCHECK(compositor_frame_producer == compositor_frame_producer_ || |
| 367 compositor_frame_producer_ == nullptr || |
| 368 compositor_frame_producer == nullptr); |
| 365 compositor_frame_producer_ = compositor_frame_producer; | 369 compositor_frame_producer_ = compositor_frame_producer; |
| 366 } | 370 } |
| 367 | 371 |
| 368 bool RenderThreadManager::HasFrameOnUI() const { | 372 bool RenderThreadManager::HasFrameOnUI() const { |
| 369 base::AutoLock lock(lock_); | 373 base::AutoLock lock(lock_); |
| 370 return hardware_renderer_has_frame_ || child_frame_.get(); | 374 return hardware_renderer_has_frame_ || child_frame_.get(); |
| 371 } | 375 } |
| 372 | 376 |
| 373 bool RenderThreadManager::HasFrameForHardwareRendererOnRT() const { | 377 bool RenderThreadManager::HasFrameForHardwareRendererOnRT() const { |
| 374 base::AutoLock lock(lock_); | 378 base::AutoLock lock(lock_); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 390 : render_thread_manager_(render_thread_manager) { | 394 : render_thread_manager_(render_thread_manager) { |
| 391 DCHECK(!render_thread_manager_->IsInsideHardwareRelease()); | 395 DCHECK(!render_thread_manager_->IsInsideHardwareRelease()); |
| 392 render_thread_manager_->SetInsideHardwareRelease(true); | 396 render_thread_manager_->SetInsideHardwareRelease(true); |
| 393 } | 397 } |
| 394 | 398 |
| 395 RenderThreadManager::InsideHardwareReleaseReset::~InsideHardwareReleaseReset() { | 399 RenderThreadManager::InsideHardwareReleaseReset::~InsideHardwareReleaseReset() { |
| 396 render_thread_manager_->SetInsideHardwareRelease(false); | 400 render_thread_manager_->SetInsideHardwareRelease(false); |
| 397 } | 401 } |
| 398 | 402 |
| 399 } // namespace android_webview | 403 } // namespace android_webview |
| OLD | NEW |