| 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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 const gfx::Transform& transform, | 120 const gfx::Transform& transform, |
| 121 gfx::Rect viewport, | 121 gfx::Rect viewport, |
| 122 gfx::Rect clip) { | 122 gfx::Rect clip) { |
| 123 DCHECK(CalledOnValidThread()); | 123 DCHECK(CalledOnValidThread()); |
| 124 DCHECK(output_surface_); | 124 DCHECK(output_surface_); |
| 125 | 125 |
| 126 scoped_ptr<cc::CompositorFrame> frame = | 126 scoped_ptr<cc::CompositorFrame> frame = |
| 127 output_surface_->DemandDrawHw(surface_size, transform, viewport, clip); | 127 output_surface_->DemandDrawHw(surface_size, transform, viewport, clip); |
| 128 if (frame.get()) | 128 if (frame.get()) |
| 129 UpdateFrameMetaData(frame->metadata); | 129 UpdateFrameMetaData(frame->metadata); |
| 130 |
| 130 return frame.Pass(); | 131 return frame.Pass(); |
| 131 } | 132 } |
| 132 | 133 |
| 133 void SynchronousCompositorImpl::ReturnResources( | 134 void SynchronousCompositorImpl::ReturnResources( |
| 134 const cc::CompositorFrameAck& frame_ack) { | 135 const cc::CompositorFrameAck& frame_ack) { |
| 135 DCHECK(CalledOnValidThread()); | 136 DCHECK(CalledOnValidThread()); |
| 136 output_surface_->ReturnResources(frame_ack); | 137 output_surface_->ReturnResources(frame_ack); |
| 137 } | 138 } |
| 138 | 139 |
| 139 bool SynchronousCompositorImpl::DemandDrawSw(SkCanvas* canvas) { | 140 bool SynchronousCompositorImpl::DemandDrawSw(SkCanvas* canvas) { |
| 140 DCHECK(CalledOnValidThread()); | 141 DCHECK(CalledOnValidThread()); |
| 141 DCHECK(output_surface_); | 142 DCHECK(output_surface_); |
| 142 | 143 |
| 143 scoped_ptr<cc::CompositorFrame> frame = output_surface_->DemandDrawSw(canvas); | 144 scoped_ptr<cc::CompositorFrame> frame = output_surface_->DemandDrawSw(canvas); |
| 144 if (frame.get()) | 145 if (frame.get()) |
| 145 UpdateFrameMetaData(frame->metadata); | 146 UpdateFrameMetaData(frame->metadata); |
| 146 return !!frame.get(); | 147 return !!frame.get(); |
| 147 } | 148 } |
| 148 | 149 |
| 149 void SynchronousCompositorImpl::UpdateFrameMetaData( | 150 void SynchronousCompositorImpl::UpdateFrameMetaData( |
| 150 const cc::CompositorFrameMetadata& frame_metadata) { | 151 const cc::CompositorFrameMetadata& frame_metadata) { |
| 151 RenderWidgetHostViewAndroid* rwhv = static_cast<RenderWidgetHostViewAndroid*>( | 152 RenderWidgetHostViewAndroid* rwhv = static_cast<RenderWidgetHostViewAndroid*>( |
| 152 contents_->GetRenderWidgetHostView()); | 153 contents_->GetRenderWidgetHostView()); |
| 153 if (rwhv) | 154 if (rwhv) |
| 154 rwhv->SynchronousFrameMetadata(frame_metadata); | 155 rwhv->SynchronousFrameMetadata(frame_metadata); |
| 156 DeliverMessages(); |
| 155 } | 157 } |
| 156 | 158 |
| 157 void SynchronousCompositorImpl::SetMemoryPolicy( | 159 void SynchronousCompositorImpl::SetMemoryPolicy( |
| 158 const SynchronousCompositorMemoryPolicy& policy) { | 160 const SynchronousCompositorMemoryPolicy& policy) { |
| 159 DCHECK(CalledOnValidThread()); | 161 DCHECK(CalledOnValidThread()); |
| 160 DCHECK(output_surface_); | 162 DCHECK(output_surface_); |
| 161 | 163 |
| 162 output_surface_->SetMemoryPolicy(policy); | 164 output_surface_->SetMemoryPolicy(policy); |
| 163 } | 165 } |
| 164 | 166 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 compositor_client_->SetContinuousInvalidate(enable); | 226 compositor_client_->SetContinuousInvalidate(enable); |
| 225 } | 227 } |
| 226 | 228 |
| 227 InputEventAckState SynchronousCompositorImpl::HandleInputEvent( | 229 InputEventAckState SynchronousCompositorImpl::HandleInputEvent( |
| 228 const blink::WebInputEvent& input_event) { | 230 const blink::WebInputEvent& input_event) { |
| 229 DCHECK(CalledOnValidThread()); | 231 DCHECK(CalledOnValidThread()); |
| 230 return g_factory.Get().synchronous_input_event_filter()->HandleInputEvent( | 232 return g_factory.Get().synchronous_input_event_filter()->HandleInputEvent( |
| 231 contents_->GetRoutingID(), input_event); | 233 contents_->GetRoutingID(), input_event); |
| 232 } | 234 } |
| 233 | 235 |
| 236 void SynchronousCompositorImpl::DeliverMessages() { |
| 237 ScopedVector<IPC::Message> messages; |
| 238 output_surface_->GetMessagesToDeliver(&messages); |
| 239 RenderProcessHost* rph = contents_->GetRenderProcessHost(); |
| 240 for (ScopedVector<IPC::Message>::const_iterator i = messages.begin(); |
| 241 i != messages.end(); |
| 242 ++i) { |
| 243 rph->OnMessageReceived(**i); |
| 244 } |
| 245 } |
| 246 |
| 234 void SynchronousCompositorImpl::DidActivatePendingTree() { | 247 void SynchronousCompositorImpl::DidActivatePendingTree() { |
| 235 if (compositor_client_) | 248 if (compositor_client_) |
| 236 compositor_client_->DidUpdateContent(); | 249 compositor_client_->DidUpdateContent(); |
| 237 } | 250 } |
| 238 | 251 |
| 239 gfx::Vector2dF SynchronousCompositorImpl::GetTotalScrollOffset() { | 252 gfx::Vector2dF SynchronousCompositorImpl::GetTotalScrollOffset() { |
| 240 DCHECK(CalledOnValidThread()); | 253 DCHECK(CalledOnValidThread()); |
| 241 if (compositor_client_) | 254 if (compositor_client_) |
| 242 return compositor_client_->GetTotalRootLayerScrollOffset(); | 255 return compositor_client_->GetTotalRootLayerScrollOffset(); |
| 243 return gfx::Vector2dF(); | 256 return gfx::Vector2dF(); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 g_factory.Get(); // Ensure it's initialized. | 297 g_factory.Get(); // Ensure it's initialized. |
| 285 SynchronousCompositorImpl::CreateForWebContents(contents); | 298 SynchronousCompositorImpl::CreateForWebContents(contents); |
| 286 } | 299 } |
| 287 if (SynchronousCompositorImpl* instance = | 300 if (SynchronousCompositorImpl* instance = |
| 288 SynchronousCompositorImpl::FromWebContents(contents)) { | 301 SynchronousCompositorImpl::FromWebContents(contents)) { |
| 289 instance->SetClient(client); | 302 instance->SetClient(client); |
| 290 } | 303 } |
| 291 } | 304 } |
| 292 | 305 |
| 293 } // namespace content | 306 } // namespace content |
| OLD | NEW |