| 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/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 base::LazyInstance<internal::RequestDrawGLTracker> g_request_draw_gl_tracker = | 65 base::LazyInstance<internal::RequestDrawGLTracker> g_request_draw_gl_tracker = |
| 66 LAZY_INSTANCE_INITIALIZER; | 66 LAZY_INSTANCE_INITIALIZER; |
| 67 | 67 |
| 68 } | 68 } |
| 69 | 69 |
| 70 SharedRendererState::SharedRendererState( | 70 SharedRendererState::SharedRendererState( |
| 71 scoped_refptr<base::MessageLoopProxy> ui_loop, | 71 scoped_refptr<base::MessageLoopProxy> ui_loop, |
| 72 BrowserViewRendererClient* client) | 72 BrowserViewRendererClient* client) |
| 73 : ui_loop_(ui_loop), | 73 : ui_loop_(ui_loop), |
| 74 client_on_ui_(client), | 74 client_on_ui_(client), |
| 75 force_commit_(false), |
| 75 inside_hardware_release_(false), | 76 inside_hardware_release_(false), |
| 76 needs_force_invalidate_on_next_draw_gl_(false), | 77 needs_force_invalidate_on_next_draw_gl_(false), |
| 77 weak_factory_on_ui_thread_(this) { | 78 weak_factory_on_ui_thread_(this) { |
| 78 DCHECK(ui_loop_->BelongsToCurrentThread()); | 79 DCHECK(ui_loop_->BelongsToCurrentThread()); |
| 79 DCHECK(client_on_ui_); | 80 DCHECK(client_on_ui_); |
| 80 ui_thread_weak_ptr_ = weak_factory_on_ui_thread_.GetWeakPtr(); | 81 ui_thread_weak_ptr_ = weak_factory_on_ui_thread_.GetWeakPtr(); |
| 81 ResetRequestDrawGLCallback(); | 82 ResetRequestDrawGLCallback(); |
| 82 } | 83 } |
| 83 | 84 |
| 84 SharedRendererState::~SharedRendererState() { | 85 SharedRendererState::~SharedRendererState() { |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 base::AutoLock lock(lock_); | 139 base::AutoLock lock(lock_); |
| 139 return scroll_offset_; | 140 return scroll_offset_; |
| 140 } | 141 } |
| 141 | 142 |
| 142 bool SharedRendererState::HasCompositorFrame() const { | 143 bool SharedRendererState::HasCompositorFrame() const { |
| 143 base::AutoLock lock(lock_); | 144 base::AutoLock lock(lock_); |
| 144 return compositor_frame_.get(); | 145 return compositor_frame_.get(); |
| 145 } | 146 } |
| 146 | 147 |
| 147 void SharedRendererState::SetCompositorFrame( | 148 void SharedRendererState::SetCompositorFrame( |
| 148 scoped_ptr<cc::CompositorFrame> frame) { | 149 scoped_ptr<cc::CompositorFrame> frame, bool force_commit) { |
| 149 base::AutoLock lock(lock_); | 150 base::AutoLock lock(lock_); |
| 150 DCHECK(!compositor_frame_.get()); | 151 DCHECK(!compositor_frame_.get()); |
| 151 compositor_frame_ = frame.Pass(); | 152 compositor_frame_ = frame.Pass(); |
| 153 force_commit_ = force_commit; |
| 152 } | 154 } |
| 153 | 155 |
| 154 scoped_ptr<cc::CompositorFrame> SharedRendererState::PassCompositorFrame() { | 156 scoped_ptr<cc::CompositorFrame> SharedRendererState::PassCompositorFrame() { |
| 155 base::AutoLock lock(lock_); | 157 base::AutoLock lock(lock_); |
| 156 return compositor_frame_.Pass(); | 158 return compositor_frame_.Pass(); |
| 157 } | 159 } |
| 158 | 160 |
| 161 bool SharedRendererState::ForceCommit() const { |
| 162 base::AutoLock lock(lock_); |
| 163 return force_commit_; |
| 164 } |
| 165 |
| 159 bool SharedRendererState::UpdateDrawConstraints( | 166 bool SharedRendererState::UpdateDrawConstraints( |
| 160 const ParentCompositorDrawConstraints& parent_draw_constraints) { | 167 const ParentCompositorDrawConstraints& parent_draw_constraints) { |
| 161 base::AutoLock lock(lock_); | 168 base::AutoLock lock(lock_); |
| 162 if (needs_force_invalidate_on_next_draw_gl_ || | 169 if (needs_force_invalidate_on_next_draw_gl_ || |
| 163 !parent_draw_constraints_.Equals(parent_draw_constraints)) { | 170 !parent_draw_constraints_.Equals(parent_draw_constraints)) { |
| 164 parent_draw_constraints_ = parent_draw_constraints; | 171 parent_draw_constraints_ = parent_draw_constraints; |
| 165 return true; | 172 return true; |
| 166 } | 173 } |
| 167 | 174 |
| 168 return false; | 175 return false; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 : shared_renderer_state_(shared_renderer_state) { | 238 : shared_renderer_state_(shared_renderer_state) { |
| 232 DCHECK(!shared_renderer_state_->IsInsideHardwareRelease()); | 239 DCHECK(!shared_renderer_state_->IsInsideHardwareRelease()); |
| 233 shared_renderer_state_->SetInsideHardwareRelease(true); | 240 shared_renderer_state_->SetInsideHardwareRelease(true); |
| 234 } | 241 } |
| 235 | 242 |
| 236 InsideHardwareReleaseReset::~InsideHardwareReleaseReset() { | 243 InsideHardwareReleaseReset::~InsideHardwareReleaseReset() { |
| 237 shared_renderer_state_->SetInsideHardwareRelease(false); | 244 shared_renderer_state_->SetInsideHardwareRelease(false); |
| 238 } | 245 } |
| 239 | 246 |
| 240 } // namespace android_webview | 247 } // namespace android_webview |
| OLD | NEW |