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