| 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/auto_reset.h" | 7 #include "base/auto_reset.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/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 | 202 |
| 203 return !!frame.get(); | 203 return !!frame.get(); |
| 204 } | 204 } |
| 205 | 205 |
| 206 void SynchronousCompositorImpl::UpdateFrameMetaData( | 206 void SynchronousCompositorImpl::UpdateFrameMetaData( |
| 207 const cc::CompositorFrameMetadata& frame_metadata) { | 207 const cc::CompositorFrameMetadata& frame_metadata) { |
| 208 RenderWidgetHostViewAndroid* rwhv = static_cast<RenderWidgetHostViewAndroid*>( | 208 RenderWidgetHostViewAndroid* rwhv = static_cast<RenderWidgetHostViewAndroid*>( |
| 209 contents_->GetRenderWidgetHostView()); | 209 contents_->GetRenderWidgetHostView()); |
| 210 if (rwhv) | 210 if (rwhv) |
| 211 rwhv->SynchronousFrameMetadata(frame_metadata); | 211 rwhv->SynchronousFrameMetadata(frame_metadata); |
| 212 DeliverMessages(); | 212 DeliverSwapMessages(); |
| 213 } | 213 } |
| 214 | 214 |
| 215 void SynchronousCompositorImpl::SetMemoryPolicy(size_t bytes_limit) { | 215 void SynchronousCompositorImpl::SetMemoryPolicy(size_t bytes_limit) { |
| 216 DCHECK(CalledOnValidThread()); | 216 DCHECK(CalledOnValidThread()); |
| 217 DCHECK(output_surface_); | 217 DCHECK(output_surface_); |
| 218 | 218 |
| 219 size_t current_bytes_limit = output_surface_->GetMemoryPolicy(); | 219 size_t current_bytes_limit = output_surface_->GetMemoryPolicy(); |
| 220 output_surface_->SetMemoryPolicy(bytes_limit); | 220 output_surface_->SetMemoryPolicy(bytes_limit); |
| 221 | 221 |
| 222 if (bytes_limit && !current_bytes_limit) { | 222 if (bytes_limit && !current_bytes_limit) { |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 rwhv->DidStopFlinging(); | 291 rwhv->DidStopFlinging(); |
| 292 } | 292 } |
| 293 | 293 |
| 294 InputEventAckState SynchronousCompositorImpl::HandleInputEvent( | 294 InputEventAckState SynchronousCompositorImpl::HandleInputEvent( |
| 295 const blink::WebInputEvent& input_event) { | 295 const blink::WebInputEvent& input_event) { |
| 296 DCHECK(CalledOnValidThread()); | 296 DCHECK(CalledOnValidThread()); |
| 297 return g_factory.Get().synchronous_input_event_filter()->HandleInputEvent( | 297 return g_factory.Get().synchronous_input_event_filter()->HandleInputEvent( |
| 298 contents_->GetRoutingID(), input_event); | 298 contents_->GetRoutingID(), input_event); |
| 299 } | 299 } |
| 300 | 300 |
| 301 void SynchronousCompositorImpl::DeliverMessages() { | 301 void SynchronousCompositorImpl::DeliverMessagesToRenderProcessHost( |
| 302 ScopedVector<IPC::Message> messages; | 302 const ScopedVector<IPC::Message>& messages) { |
| 303 output_surface_->GetMessagesToDeliver(&messages); | |
| 304 RenderProcessHost* rph = contents_->GetRenderProcessHost(); | 303 RenderProcessHost* rph = contents_->GetRenderProcessHost(); |
| 305 for (ScopedVector<IPC::Message>::const_iterator i = messages.begin(); | 304 for (ScopedVector<IPC::Message>::const_iterator i = messages.begin(); |
| 306 i != messages.end(); | 305 i != messages.end(); |
| 307 ++i) { | 306 ++i) { |
| 308 rph->OnMessageReceived(**i); | 307 rph->OnMessageReceived(**i); |
| 309 } | 308 } |
| 310 } | 309 } |
| 311 | 310 |
| 311 void SynchronousCompositorImpl::DeliverSwapMessages() { |
| 312 ScopedVector<IPC::Message> messages; |
| 313 output_surface_->GetSwapMessagesToDeliver(&messages); |
| 314 DeliverMessagesToRenderProcessHost(messages); |
| 315 } |
| 316 |
| 312 void SynchronousCompositorImpl::DidActivatePendingTree() { | 317 void SynchronousCompositorImpl::DidActivatePendingTree() { |
| 313 if (compositor_client_) | 318 if (compositor_client_) |
| 314 compositor_client_->DidUpdateContent(); | 319 compositor_client_->DidUpdateContent(); |
| 315 } | 320 } |
| 316 | 321 |
| 317 gfx::ScrollOffset SynchronousCompositorImpl::GetTotalScrollOffset() { | 322 gfx::ScrollOffset SynchronousCompositorImpl::GetTotalScrollOffset() { |
| 318 DCHECK(CalledOnValidThread()); | 323 DCHECK(CalledOnValidThread()); |
| 319 if (compositor_client_) { | 324 if (compositor_client_) { |
| 320 // TODO(miletus): Make GetTotalRootLayerScrollOffset return | 325 // TODO(miletus): Make GetTotalRootLayerScrollOffset return |
| 321 // ScrollOffset. crbug.com/414283. | 326 // ScrollOffset. crbug.com/414283. |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 g_factory.Get(); // Ensure it's initialized. | 373 g_factory.Get(); // Ensure it's initialized. |
| 369 SynchronousCompositorImpl::CreateForWebContents(contents); | 374 SynchronousCompositorImpl::CreateForWebContents(contents); |
| 370 } | 375 } |
| 371 SynchronousCompositorImpl* instance = | 376 SynchronousCompositorImpl* instance = |
| 372 SynchronousCompositorImpl::FromWebContents(contents); | 377 SynchronousCompositorImpl::FromWebContents(contents); |
| 373 DCHECK(instance); | 378 DCHECK(instance); |
| 374 instance->SetClient(client); | 379 instance->SetClient(client); |
| 375 } | 380 } |
| 376 | 381 |
| 377 } // namespace content | 382 } // namespace content |
| OLD | NEW |