| 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/shared_renderer_state.h" | 5 #include "android_webview/browser/shared_renderer_state.h" |
| 6 | 6 |
| 7 #include "android_webview/browser/browser_view_renderer_client.h" | 7 #include "android_webview/browser/browser_view_renderer_client.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "cc/output/compositor_frame.h" |
| 11 #include "content/public/browser/android/synchronous_compositor.h" |
| 10 | 12 |
| 11 namespace android_webview { | 13 namespace android_webview { |
| 12 | 14 |
| 13 DrawGLInput::DrawGLInput() : width(0), height(0) { | 15 DrawGLInput::DrawGLInput() : width(0), height(0) { |
| 14 } | 16 } |
| 15 | 17 |
| 16 DrawGLInput::~DrawGLInput() { | 18 DrawGLInput::~DrawGLInput() { |
| 17 } | 19 } |
| 18 | 20 |
| 19 SharedRendererState::SharedRendererState( | 21 SharedRendererState::SharedRendererState( |
| (...skipping 24 matching lines...) Expand all Loading... |
| 44 } | 46 } |
| 45 } | 47 } |
| 46 | 48 |
| 47 void SharedRendererState::ClientRequestDrawGLOnUIThread() { | 49 void SharedRendererState::ClientRequestDrawGLOnUIThread() { |
| 48 DCHECK(ui_loop_->BelongsToCurrentThread()); | 50 DCHECK(ui_loop_->BelongsToCurrentThread()); |
| 49 if (!client_on_ui_->RequestDrawGL(NULL, false)) { | 51 if (!client_on_ui_->RequestDrawGL(NULL, false)) { |
| 50 LOG(ERROR) << "Failed to request GL process. Deadlock likely"; | 52 LOG(ERROR) << "Failed to request GL process. Deadlock likely"; |
| 51 } | 53 } |
| 52 } | 54 } |
| 53 | 55 |
| 56 void SharedRendererState::ClientPostInvalidate() { |
| 57 if (ui_loop_->BelongsToCurrentThread()) { |
| 58 ClientPostInvalidateOnUIThread(); |
| 59 } else { |
| 60 ui_loop_->PostTask( |
| 61 FROM_HERE, |
| 62 base::Bind(&SharedRendererState::ClientPostInvalidateOnUIThread, |
| 63 ui_thread_weak_ptr_)); |
| 64 } |
| 65 } |
| 66 |
| 67 void SharedRendererState::ClientPostInvalidateOnUIThread() { |
| 68 DCHECK(ui_loop_->BelongsToCurrentThread()); |
| 69 client_on_ui_->PostInvalidate(); |
| 70 } |
| 71 |
| 54 void SharedRendererState::SetDrawGLInput(scoped_ptr<DrawGLInput> input) { | 72 void SharedRendererState::SetDrawGLInput(scoped_ptr<DrawGLInput> input) { |
| 55 base::AutoLock lock(lock_); | 73 base::AutoLock lock(lock_); |
| 56 DCHECK(!draw_gl_input_.get()); | 74 DCHECK(!draw_gl_input_.get()); |
| 57 draw_gl_input_ = input.Pass(); | 75 draw_gl_input_ = input.Pass(); |
| 58 } | 76 } |
| 59 | 77 |
| 60 scoped_ptr<DrawGLInput> SharedRendererState::PassDrawGLInput() { | 78 scoped_ptr<DrawGLInput> SharedRendererState::PassDrawGLInput() { |
| 61 base::AutoLock lock(lock_); | 79 base::AutoLock lock(lock_); |
| 62 return draw_gl_input_.Pass(); | 80 return draw_gl_input_.Pass(); |
| 63 } | 81 } |
| 64 | 82 |
| 83 void SharedRendererState::PostExternalMatrixToChildCompositor( |
| 84 const gfx::Transform& transform) { |
| 85 base::AutoLock lock(lock_); |
| 86 parent_transform_ = transform; |
| 87 |
| 88 ClientPostInvalidate(); |
| 89 } |
| 90 |
| 91 const gfx::Transform& SharedRendererState::ParentTransform() const { |
| 92 base::AutoLock lock(lock_); |
| 93 return parent_transform_; |
| 94 } |
| 95 |
| 65 void SharedRendererState::SetHardwareAllowed(bool allowed) { | 96 void SharedRendererState::SetHardwareAllowed(bool allowed) { |
| 66 base::AutoLock lock(lock_); | 97 base::AutoLock lock(lock_); |
| 67 hardware_allowed_ = allowed; | 98 hardware_allowed_ = allowed; |
| 68 } | 99 } |
| 69 | 100 |
| 70 bool SharedRendererState::IsHardwareAllowed() const { | 101 bool SharedRendererState::IsHardwareAllowed() const { |
| 71 base::AutoLock lock(lock_); | 102 base::AutoLock lock(lock_); |
| 72 return hardware_allowed_; | 103 return hardware_allowed_; |
| 73 } | 104 } |
| 74 | 105 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 97 base::AutoLock lock(lock_); | 128 base::AutoLock lock(lock_); |
| 98 resources->swap(returned_resources_); | 129 resources->swap(returned_resources_); |
| 99 } | 130 } |
| 100 | 131 |
| 101 bool SharedRendererState::ReturnedResourcesEmpty() const { | 132 bool SharedRendererState::ReturnedResourcesEmpty() const { |
| 102 base::AutoLock lock(lock_); | 133 base::AutoLock lock(lock_); |
| 103 return returned_resources_.empty(); | 134 return returned_resources_.empty(); |
| 104 } | 135 } |
| 105 | 136 |
| 106 } // namespace android_webview | 137 } // namespace android_webview |
| OLD | NEW |