Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/browser/android/in_process/synchronous_compositor_impl.h" | 5 #include "content/browser/android/in_process/synchronous_compositor_impl.h" |
| 6 | 6 |
| 7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "cc/input/input_handler.h" | 9 #include "cc/input/input_handler.h" |
| 10 #include "content/browser/android/in_process/synchronous_compositor_factory_impl .h" | 10 #include "content/browser/android/in_process/synchronous_compositor_factory_impl .h" |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 249 ++i) { | 249 ++i) { |
| 250 rph->OnMessageReceived(**i); | 250 rph->OnMessageReceived(**i); |
| 251 } | 251 } |
| 252 } | 252 } |
| 253 | 253 |
| 254 void SynchronousCompositorImpl::DidActivatePendingTree() { | 254 void SynchronousCompositorImpl::DidActivatePendingTree() { |
| 255 if (compositor_client_) | 255 if (compositor_client_) |
| 256 compositor_client_->DidUpdateContent(); | 256 compositor_client_->DidUpdateContent(); |
| 257 } | 257 } |
| 258 | 258 |
| 259 gfx::Vector2dF SynchronousCompositorImpl::GetTotalScrollOffset() { | 259 gfx::ScrollOffset SynchronousCompositorImpl::GetTotalScrollOffset() { |
| 260 DCHECK(CalledOnValidThread()); | 260 DCHECK(CalledOnValidThread()); |
| 261 if (compositor_client_) | 261 if (compositor_client_) { |
| 262 return compositor_client_->GetTotalRootLayerScrollOffset(); | 262 return gfx::ScrollOffset( |
| 263 return gfx::Vector2dF(); | 263 compositor_client_->GetTotalRootLayerScrollOffset()); |
| 264 } | |
| 265 return gfx::ScrollOffset(); | |
| 264 } | 266 } |
| 265 | 267 |
| 266 bool SynchronousCompositorImpl::IsExternalFlingActive() const { | 268 bool SynchronousCompositorImpl::IsExternalFlingActive() const { |
| 267 DCHECK(CalledOnValidThread()); | 269 DCHECK(CalledOnValidThread()); |
| 268 if (compositor_client_) | 270 if (compositor_client_) |
| 269 return compositor_client_->IsExternalFlingActive(); | 271 return compositor_client_->IsExternalFlingActive(); |
| 270 return false; | 272 return false; |
| 271 } | 273 } |
| 272 | 274 |
| 273 void SynchronousCompositorImpl::UpdateRootLayerState( | 275 void SynchronousCompositorImpl::UpdateRootLayerState( |
| 274 const gfx::Vector2dF& total_scroll_offset, | 276 const gfx::ScrollOffset& total_scroll_offset, |
| 275 const gfx::Vector2dF& max_scroll_offset, | 277 const gfx::ScrollOffset& max_scroll_offset, |
| 276 const gfx::SizeF& scrollable_size, | 278 const gfx::SizeF& scrollable_size, |
| 277 float page_scale_factor, | 279 float page_scale_factor, |
| 278 float min_page_scale_factor, | 280 float min_page_scale_factor, |
| 279 float max_page_scale_factor) { | 281 float max_page_scale_factor) { |
| 280 DCHECK(CalledOnValidThread()); | 282 DCHECK(CalledOnValidThread()); |
| 281 if (!compositor_client_) | 283 if (!compositor_client_) |
| 282 return; | 284 return; |
| 283 | 285 |
| 284 compositor_client_->UpdateRootLayerState(total_scroll_offset, | 286 compositor_client_->UpdateRootLayerState(total_scroll_offset.ToVector2dF(), |
|
danakj
2014/09/25 22:01:27
these look like they should stay ScrollOffsets?
Yufeng Shen (Slow to review)
2014/09/26 20:19:08
Done.
| |
| 285 max_scroll_offset, | 287 max_scroll_offset.ToVector2dF(), |
| 286 scrollable_size, | 288 scrollable_size, |
| 287 page_scale_factor, | 289 page_scale_factor, |
| 288 min_page_scale_factor, | 290 min_page_scale_factor, |
| 289 max_page_scale_factor); | 291 max_page_scale_factor); |
| 290 } | 292 } |
| 291 | 293 |
| 292 // Not using base::NonThreadSafe as we want to enforce a more exacting threading | 294 // Not using base::NonThreadSafe as we want to enforce a more exacting threading |
| 293 // requirement: SynchronousCompositorImpl() must only be used on the UI thread. | 295 // requirement: SynchronousCompositorImpl() must only be used on the UI thread. |
| 294 bool SynchronousCompositorImpl::CalledOnValidThread() const { | 296 bool SynchronousCompositorImpl::CalledOnValidThread() const { |
| 295 return BrowserThread::CurrentlyOn(BrowserThread::UI); | 297 return BrowserThread::CurrentlyOn(BrowserThread::UI); |
| 296 } | 298 } |
| 297 | 299 |
| 298 // static | 300 // static |
| 299 void SynchronousCompositor::SetClientForWebContents( | 301 void SynchronousCompositor::SetClientForWebContents( |
| 300 WebContents* contents, | 302 WebContents* contents, |
| 301 SynchronousCompositorClient* client) { | 303 SynchronousCompositorClient* client) { |
| 302 DCHECK(contents); | 304 DCHECK(contents); |
| 303 if (client) { | 305 if (client) { |
| 304 g_factory.Get(); // Ensure it's initialized. | 306 g_factory.Get(); // Ensure it's initialized. |
| 305 SynchronousCompositorImpl::CreateForWebContents(contents); | 307 SynchronousCompositorImpl::CreateForWebContents(contents); |
| 306 } | 308 } |
| 307 if (SynchronousCompositorImpl* instance = | 309 if (SynchronousCompositorImpl* instance = |
| 308 SynchronousCompositorImpl::FromWebContents(contents)) { | 310 SynchronousCompositorImpl::FromWebContents(contents)) { |
| 309 instance->SetClient(client); | 311 instance->SetClient(client); |
| 310 } | 312 } |
| 311 } | 313 } |
| 312 | 314 |
| 313 } // namespace content | 315 } // namespace content |
| OLD | NEW |