Chromium Code Reviews| Index: android_webview/browser/shared_renderer_state.cc |
| diff --git a/android_webview/browser/shared_renderer_state.cc b/android_webview/browser/shared_renderer_state.cc |
| index 3483d630e7cb1eafbc02f812d0998902487aae1c..e597bed9f96dd074f90289544a425c2724747afd 100644 |
| --- a/android_webview/browser/shared_renderer_state.cc |
| +++ b/android_webview/browser/shared_renderer_state.cc |
| @@ -10,9 +10,14 @@ |
| namespace android_webview { |
| -DrawGLInput::DrawGLInput() : frame_id(0), width(0), height(0) {} |
| +DrawGLInput::DrawGLInput() : width(0), height(0) { |
| +} |
| -DrawGLResult::DrawGLResult() : frame_id(0), clip_contains_visible_rect(false) {} |
| +DrawGLInput::~DrawGLInput() { |
| +} |
| + |
| +DrawGLResult::DrawGLResult() : clip_contains_visible_rect(false) { |
| +} |
| SharedRendererState::SharedRendererState( |
| scoped_refptr<base::MessageLoopProxy> ui_loop, |
| @@ -23,7 +28,8 @@ SharedRendererState::SharedRendererState( |
| ui_thread_weak_ptr_(weak_factory_on_ui_thread_.GetWeakPtr()), |
| compositor_(NULL), |
| memory_policy_dirty_(false), |
| - hardware_initialized_(false) { |
| + hardware_initialized_(false), |
| + share_context_(NULL) { |
| DCHECK(ui_loop_->BelongsToCurrentThread()); |
| DCHECK(client_on_ui_); |
| } |
| @@ -76,14 +82,15 @@ SharedRendererState::GetMemoryPolicy() const { |
| return memory_policy_; |
| } |
| -void SharedRendererState::SetDrawGLInput(const DrawGLInput& input) { |
| +void SharedRendererState::SetDrawGLInput(scoped_ptr<DrawGLInput> input) { |
| base::AutoLock lock(lock_); |
| - draw_gl_input_ = input; |
| + DCHECK(!draw_gl_input_.get()); |
| + draw_gl_input_ = input.Pass(); |
| } |
| -DrawGLInput SharedRendererState::GetDrawGLInput() const { |
| +scoped_ptr<DrawGLInput> SharedRendererState::PassDrawGLInput() { |
| base::AutoLock lock(lock_); |
| - return draw_gl_input_; |
| + return draw_gl_input_.Pass(); |
| } |
| void SharedRendererState::ClearClosureQueue() { |
| @@ -119,6 +126,16 @@ bool SharedRendererState::IsHardwareInitialized() const { |
| return hardware_initialized_; |
| } |
| +void SharedRendererState::SetSharedContext(gpu::GLInProcessContext* context) { |
| + DCHECK(!share_context_ || !context); |
| + share_context_ = context; |
|
no sievers
2014/05/20 20:48:26
This looks like it might not be thread-safe. Set/G
boliu
2014/05/21 01:33:26
Ehh...that's because I forgot the lock :p
Fixed.
|
| +} |
| + |
| +gpu::GLInProcessContext* SharedRendererState::GetSharedContext() const { |
| + DCHECK(share_context_); |
| + return share_context_; |
| +} |
| + |
| void SharedRendererState::SetMemoryPolicyDirty(bool is_dirty) { |
| base::AutoLock lock(lock_); |
| memory_policy_dirty_ = is_dirty; |
| @@ -129,4 +146,28 @@ bool SharedRendererState::IsMemoryPolicyDirty() const { |
| return memory_policy_dirty_; |
| } |
| +void SharedRendererState::ReturnResources( |
| + const cc::TransferableResourceArray& input) { |
| + base::AutoLock lock(lock_); |
| + cc::TransferableResource::ReturnResources(input, &returned_resources_); |
| +} |
| + |
| +void SharedRendererState::InsertReturnedResources( |
| + const cc::ReturnedResourceArray& resources) { |
| + base::AutoLock lock(lock_); |
| + returned_resources_.insert( |
| + returned_resources_.end(), resources.begin(), resources.end()); |
| +} |
| + |
| +void SharedRendererState::SwapReturnedResources( |
| + cc::ReturnedResourceArray* resources) { |
| + base::AutoLock lock(lock_); |
| + resources->swap(returned_resources_); |
| +} |
| + |
| +bool SharedRendererState::ReturnedResourcesEmpty() const { |
| + base::AutoLock lock(lock_); |
| + return returned_resources_.empty(); |
| +} |
| + |
| } // namespace android_webview |