Chromium Code Reviews| 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/deferred_gpu_command_service.h" | 10 #include "android_webview/browser/deferred_gpu_command_service.h" |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 137 base::AutoLock lock(lock_); | 137 base::AutoLock lock(lock_); |
| 138 request_draw_gl_cancelable_closure_.Reset(base::Bind( | 138 request_draw_gl_cancelable_closure_.Reset(base::Bind( |
| 139 &RenderThreadManager::ClientRequestDrawGLOnUI, base::Unretained(this))); | 139 &RenderThreadManager::ClientRequestDrawGLOnUI, base::Unretained(this))); |
| 140 request_draw_gl_closure_ = request_draw_gl_cancelable_closure_.callback(); | 140 request_draw_gl_closure_ = request_draw_gl_cancelable_closure_.callback(); |
| 141 } | 141 } |
| 142 | 142 |
| 143 void RenderThreadManager::ClientRequestDrawGLOnUI() { | 143 void RenderThreadManager::ClientRequestDrawGLOnUI() { |
| 144 DCHECK(ui_loop_->BelongsToCurrentThread()); | 144 DCHECK(ui_loop_->BelongsToCurrentThread()); |
| 145 ResetRequestDrawGLCallback(); | 145 ResetRequestDrawGLCallback(); |
| 146 g_request_draw_gl_tracker.Get().SetQueuedFunctorOnUi(this); | 146 g_request_draw_gl_tracker.Get().SetQueuedFunctorOnUi(this); |
| 147 if (!client_->RequestDrawGL(false)) { | 147 if (!client_->RequestInvokeGL(false)) { |
|
boliu
2016/04/20 16:49:09
Hmm... this should *almost* never happen now. Shou
| |
| 148 g_request_draw_gl_tracker.Get().ResetPending(); | 148 g_request_draw_gl_tracker.Get().ResetPending(); |
| 149 LOG(ERROR) << "Failed to request GL process. Deadlock likely"; | 149 LOG(ERROR) << "Failed to request GL process. Deadlock likely"; |
| 150 } | 150 } |
| 151 } | 151 } |
| 152 | 152 |
| 153 void RenderThreadManager::UpdateParentDrawConstraintsOnUI() { | 153 void RenderThreadManager::UpdateParentDrawConstraintsOnUI() { |
| 154 DCHECK(ui_loop_->BelongsToCurrentThread()); | 154 DCHECK(ui_loop_->BelongsToCurrentThread()); |
| 155 client_->OnParentDrawConstraintsUpdated(); | 155 client_->OnParentDrawConstraintsUpdated(); |
| 156 } | 156 } |
| 157 | 157 |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 320 DCHECK(ui_loop_->BelongsToCurrentThread()); | 320 DCHECK(ui_loop_->BelongsToCurrentThread()); |
| 321 | 321 |
| 322 InsideHardwareReleaseReset auto_inside_hardware_release_reset(this); | 322 InsideHardwareReleaseReset auto_inside_hardware_release_reset(this); |
| 323 | 323 |
| 324 client_->DetachFunctorFromView(); | 324 client_->DetachFunctorFromView(); |
| 325 | 325 |
| 326 // If the WebView gets onTrimMemory >= MODERATE twice in a row, the 2nd | 326 // If the WebView gets onTrimMemory >= MODERATE twice in a row, the 2nd |
| 327 // onTrimMemory will result in an unnecessary Render Thread DrawGL call. | 327 // onTrimMemory will result in an unnecessary Render Thread DrawGL call. |
| 328 bool hardware_initialized = HasFrameOnUI(); | 328 bool hardware_initialized = HasFrameOnUI(); |
| 329 if (hardware_initialized) { | 329 if (hardware_initialized) { |
| 330 bool draw_functor_succeeded = client_->RequestDrawGL(true); | 330 bool draw_functor_succeeded = client_->RequestInvokeGL(true); |
| 331 if (!draw_functor_succeeded) { | 331 if (!draw_functor_succeeded) { |
| 332 LOG(ERROR) << "Unable to free GL resources. Has the Window leaked?"; | 332 LOG(ERROR) << "Unable to free GL resources. Has the Window leaked?"; |
| 333 // Calling release on wrong thread intentionally. | 333 // Calling release on wrong thread intentionally. |
| 334 AwDrawGLInfo info; | 334 AwDrawGLInfo info; |
| 335 info.mode = AwDrawGLInfo::kModeProcess; | 335 info.mode = AwDrawGLInfo::kModeProcess; |
| 336 DrawGL(&info); | 336 DrawGL(&info); |
| 337 } | 337 } |
| 338 } | 338 } |
| 339 | 339 |
| 340 GLViewRendererManager* manager = GLViewRendererManager::GetInstance(); | 340 GLViewRendererManager* manager = GLViewRendererManager::GetInstance(); |
| 341 | 341 |
| 342 { | 342 { |
| 343 base::AutoLock lock(lock_); | 343 base::AutoLock lock(lock_); |
| 344 if (renderer_manager_key_ != manager->NullKey()) { | 344 if (renderer_manager_key_ != manager->NullKey()) { |
| 345 manager->Remove(renderer_manager_key_); | 345 manager->Remove(renderer_manager_key_); |
| 346 renderer_manager_key_ = manager->NullKey(); | 346 renderer_manager_key_ = manager->NullKey(); |
| 347 } | 347 } |
| 348 } | 348 } |
| 349 | 349 |
| 350 if (hardware_initialized) { | 350 if (hardware_initialized) { |
| 351 // Flush any invoke functors that's caused by ReleaseHardware. | 351 // Flush any invoke functors that's caused by ReleaseHardware. |
| 352 client_->RequestDrawGL(true); | 352 client_->RequestInvokeGL(true); |
| 353 } | 353 } |
| 354 } | 354 } |
| 355 | 355 |
| 356 bool RenderThreadManager::HasFrameOnUI() const { | 356 bool RenderThreadManager::HasFrameOnUI() const { |
| 357 base::AutoLock lock(lock_); | 357 base::AutoLock lock(lock_); |
| 358 return hardware_renderer_has_frame_ || child_frame_.get(); | 358 return hardware_renderer_has_frame_ || child_frame_.get(); |
| 359 } | 359 } |
| 360 | 360 |
| 361 bool RenderThreadManager::HasFrameForHardwareRendererOnRT() const { | 361 bool RenderThreadManager::HasFrameForHardwareRendererOnRT() const { |
| 362 base::AutoLock lock(lock_); | 362 base::AutoLock lock(lock_); |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 378 : render_thread_manager_(render_thread_manager) { | 378 : render_thread_manager_(render_thread_manager) { |
| 379 DCHECK(!render_thread_manager_->IsInsideHardwareRelease()); | 379 DCHECK(!render_thread_manager_->IsInsideHardwareRelease()); |
| 380 render_thread_manager_->SetInsideHardwareRelease(true); | 380 render_thread_manager_->SetInsideHardwareRelease(true); |
| 381 } | 381 } |
| 382 | 382 |
| 383 RenderThreadManager::InsideHardwareReleaseReset::~InsideHardwareReleaseReset() { | 383 RenderThreadManager::InsideHardwareReleaseReset::~InsideHardwareReleaseReset() { |
| 384 render_thread_manager_->SetInsideHardwareRelease(false); | 384 render_thread_manager_->SetInsideHardwareRelease(false); |
| 385 } | 385 } |
| 386 | 386 |
| 387 } // namespace android_webview | 387 } // namespace android_webview |
| OLD | NEW |