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::PostExternalDrawConstraintsToChildCompositor( |
| 84 const ParentCompositorDrawConstraints& parent_draw_constraints) { |
| 85 base::AutoLock lock(lock_); |
| 86 parent_draw_constraints_ = parent_draw_constraints; |
| 87 |
| 88 ClientPostInvalidate(); |
| 89 } |
| 90 |
| 91 const ParentCompositorDrawConstraints& |
| 92 SharedRendererState::ParentDrawConstraints() const { |
| 93 base::AutoLock lock(lock_); |
| 94 return parent_draw_constraints_; |
| 95 } |
| 96 |
65 void SharedRendererState::SetHardwareAllowed(bool allowed) { | 97 void SharedRendererState::SetHardwareAllowed(bool allowed) { |
66 base::AutoLock lock(lock_); | 98 base::AutoLock lock(lock_); |
67 hardware_allowed_ = allowed; | 99 hardware_allowed_ = allowed; |
68 } | 100 } |
69 | 101 |
70 bool SharedRendererState::IsHardwareAllowed() const { | 102 bool SharedRendererState::IsHardwareAllowed() const { |
71 base::AutoLock lock(lock_); | 103 base::AutoLock lock(lock_); |
72 return hardware_allowed_; | 104 return hardware_allowed_; |
73 } | 105 } |
74 | 106 |
(...skipping 22 matching lines...) Expand all Loading... |
97 base::AutoLock lock(lock_); | 129 base::AutoLock lock(lock_); |
98 resources->swap(returned_resources_); | 130 resources->swap(returned_resources_); |
99 } | 131 } |
100 | 132 |
101 bool SharedRendererState::ReturnedResourcesEmpty() const { | 133 bool SharedRendererState::ReturnedResourcesEmpty() const { |
102 base::AutoLock lock(lock_); | 134 base::AutoLock lock(lock_); |
103 return returned_resources_.empty(); | 135 return returned_resources_.empty(); |
104 } | 136 } |
105 | 137 |
106 } // namespace android_webview | 138 } // namespace android_webview |
OLD | NEW |