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 | 10 |
11 namespace android_webview { | 11 namespace android_webview { |
12 | 12 |
13 DrawGLInput::DrawGLInput() : frame_id(0), width(0), height(0) {} | 13 DrawGLInput::DrawGLInput() : frame_id(0), width(0), height(0) {} |
14 | 14 |
| 15 DrawGLInput::~DrawGLInput() {} |
| 16 |
15 DrawGLResult::DrawGLResult() : frame_id(0), clip_contains_visible_rect(false) {} | 17 DrawGLResult::DrawGLResult() : frame_id(0), clip_contains_visible_rect(false) {} |
16 | 18 |
| 19 DrawGLResult::~DrawGLResult() {} |
| 20 |
17 SharedRendererState::SharedRendererState( | 21 SharedRendererState::SharedRendererState( |
18 scoped_refptr<base::MessageLoopProxy> ui_loop, | 22 scoped_refptr<base::MessageLoopProxy> ui_loop, |
19 BrowserViewRendererClient* client) | 23 BrowserViewRendererClient* client) |
20 : ui_loop_(ui_loop), | 24 : ui_loop_(ui_loop), |
21 client_on_ui_(client), | 25 client_on_ui_(client), |
22 weak_factory_on_ui_thread_(this), | 26 weak_factory_on_ui_thread_(this), |
23 ui_thread_weak_ptr_(weak_factory_on_ui_thread_.GetWeakPtr()), | 27 ui_thread_weak_ptr_(weak_factory_on_ui_thread_.GetWeakPtr()), |
24 compositor_(NULL), | 28 compositor_(NULL), |
25 memory_policy_dirty_(false), | 29 memory_policy_dirty_(false), |
26 hardware_initialized_(false) { | 30 hardware_initialized_(false) { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 memory_policy_dirty_ = true; | 73 memory_policy_dirty_ = true; |
70 } | 74 } |
71 } | 75 } |
72 | 76 |
73 content::SynchronousCompositorMemoryPolicy | 77 content::SynchronousCompositorMemoryPolicy |
74 SharedRendererState::GetMemoryPolicy() const { | 78 SharedRendererState::GetMemoryPolicy() const { |
75 base::AutoLock lock(lock_); | 79 base::AutoLock lock(lock_); |
76 return memory_policy_; | 80 return memory_policy_; |
77 } | 81 } |
78 | 82 |
79 void SharedRendererState::SetDrawGLInput(const DrawGLInput& input) { | 83 scoped_ptr<DrawGLInput> SharedRendererState::SetDrawGLInput(scoped_ptr<DrawGLInp
ut> input) { |
80 base::AutoLock lock(lock_); | 84 base::AutoLock lock(lock_); |
81 draw_gl_input_ = input; | 85 scoped_ptr<DrawGLInput> old_input = draw_gl_input_.Pass(); |
| 86 draw_gl_input_ = input.Pass(); |
| 87 return old_input.Pass(); |
82 } | 88 } |
83 | 89 |
84 DrawGLInput SharedRendererState::GetDrawGLInput() const { | 90 scoped_ptr<DrawGLInput> SharedRendererState::PassDrawGLInput() { |
85 base::AutoLock lock(lock_); | 91 base::AutoLock lock(lock_); |
86 return draw_gl_input_; | 92 return draw_gl_input_.Pass(); |
87 } | 93 } |
88 | 94 |
89 void SharedRendererState::ClearClosureQueue() { | 95 void SharedRendererState::ClearClosureQueue() { |
90 base::AutoLock lock(lock_); | 96 base::AutoLock lock(lock_); |
91 std::queue<base::Closure> empty; | 97 std::queue<base::Closure> empty; |
92 std::swap(closure_queue_, empty); | 98 std::swap(closure_queue_, empty); |
93 } | 99 } |
94 | 100 |
95 void SharedRendererState::AppendClosure(const base::Closure& closure) { | 101 void SharedRendererState::AppendClosure(const base::Closure& closure) { |
96 base::AutoLock lock(lock_); | 102 base::AutoLock lock(lock_); |
(...skipping 25 matching lines...) Expand all Loading... |
122 void SharedRendererState::SetMemoryPolicyDirty(bool is_dirty) { | 128 void SharedRendererState::SetMemoryPolicyDirty(bool is_dirty) { |
123 base::AutoLock lock(lock_); | 129 base::AutoLock lock(lock_); |
124 memory_policy_dirty_ = is_dirty; | 130 memory_policy_dirty_ = is_dirty; |
125 } | 131 } |
126 | 132 |
127 bool SharedRendererState::IsMemoryPolicyDirty() const { | 133 bool SharedRendererState::IsMemoryPolicyDirty() const { |
128 base::AutoLock lock(lock_); | 134 base::AutoLock lock(lock_); |
129 return memory_policy_dirty_; | 135 return memory_policy_dirty_; |
130 } | 136 } |
131 | 137 |
| 138 void SharedRendererState::ReturnResources( |
| 139 const cc::TransferableResourceArray& input) { |
| 140 base::AutoLock lock(lock_); |
| 141 cc::TransferableResource::ReturnResources(input, &returned_resources_); |
| 142 } |
| 143 |
| 144 void SharedRendererState::InsertReturnedResources( |
| 145 const cc::ReturnedResourceArray& resources) { |
| 146 base::AutoLock lock(lock_); |
| 147 returned_resources_.insert( |
| 148 returned_resources_.end(), resources.begin(), resources.end()); |
| 149 } |
| 150 |
| 151 void SharedRendererState::SwapReturnedResources( |
| 152 cc::ReturnedResourceArray* resources) { |
| 153 base::AutoLock lock(lock_); |
| 154 resources->swap(returned_resources_); |
| 155 } |
| 156 |
| 157 bool SharedRendererState::ReturnedResourcesEmpty() const { |
| 158 base::AutoLock lock(lock_); |
| 159 return returned_resources_.empty(); |
| 160 } |
| 161 |
132 } // namespace android_webview | 162 } // namespace android_webview |
OLD | NEW |