Chromium Code Reviews| 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 "base/bind_helpers.h" | 5 #include "base/bind_helpers.h" |
| 6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "cc/surfaces/surface.h" | |
| 10 #include "cc/surfaces/surface_factory.h" | |
| 11 #include "cc/surfaces/surface_manager.h" | |
| 12 #include "cc/surfaces/surface_sequence.h" | |
| 9 #include "content/browser/browser_plugin/browser_plugin_guest.h" | 13 #include "content/browser/browser_plugin/browser_plugin_guest.h" |
| 14 #include "content/browser/compositor/surface_utils.h" | |
| 10 #include "content/browser/frame_host/render_widget_host_view_guest.h" | 15 #include "content/browser/frame_host/render_widget_host_view_guest.h" |
| 11 #include "content/browser/renderer_host/render_view_host_impl.h" | 16 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 12 #include "content/common/browser_plugin/browser_plugin_messages.h" | 17 #include "content/common/browser_plugin/browser_plugin_messages.h" |
| 13 #include "content/common/frame_messages.h" | 18 #include "content/common/frame_messages.h" |
| 14 #include "content/common/gpu/gpu_messages.h" | 19 #include "content/common/gpu/gpu_messages.h" |
| 15 #include "content/common/input/web_touch_event_traits.h" | 20 #include "content/common/input/web_touch_event_traits.h" |
| 16 #include "content/common/view_messages.h" | 21 #include "content/common/view_messages.h" |
| 17 #include "content/common/webplugin_geometry.h" | 22 #include "content/common/webplugin_geometry.h" |
| 18 #include "content/public/common/content_switches.h" | 23 #include "content/public/common/content_switches.h" |
| 19 #include "skia/ext/platform_canvas.h" | 24 #include "skia/ext/platform_canvas.h" |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 199 guest_->SetTooltipText(tooltip_text); | 204 guest_->SetTooltipText(tooltip_text); |
| 200 } | 205 } |
| 201 | 206 |
| 202 void RenderWidgetHostViewGuest::OnSwapCompositorFrame( | 207 void RenderWidgetHostViewGuest::OnSwapCompositorFrame( |
| 203 uint32 output_surface_id, | 208 uint32 output_surface_id, |
| 204 scoped_ptr<cc::CompositorFrame> frame) { | 209 scoped_ptr<cc::CompositorFrame> frame) { |
| 205 if (!guest_) | 210 if (!guest_) |
| 206 return; | 211 return; |
| 207 | 212 |
| 208 last_scroll_offset_ = frame->metadata.root_scroll_offset; | 213 last_scroll_offset_ = frame->metadata.root_scroll_offset; |
| 209 guest_->SwapCompositorFrame(output_surface_id, | 214 // When not using surfaces, the frame just gets proxied to |
| 210 host_->GetProcess()->GetID(), | 215 // the guest's renderer to be composited. |
|
kenrb
2015/06/10 20:43:39
It goes to the embedder's renderer, you mean?
wjmaclean
2015/06/10 21:05:02
Oops, yes.
Done.
| |
| 211 host_->GetRoutingID(), | 216 if (!frame->delegated_frame_data || !use_surfaces_) { |
| 212 frame.Pass()); | 217 guest_->SwapCompositorFrame(output_surface_id, |
| 218 host_->GetProcess()->GetID(), | |
| 219 host_->GetRoutingID(), | |
| 220 frame.Pass()); | |
| 221 } | |
| 222 | |
| 223 cc::RenderPass* root_pass = | |
| 224 frame->delegated_frame_data->render_pass_list.back(); | |
| 225 | |
| 226 gfx::Size frame_size = root_pass->output_rect.size(); | |
| 227 float scale_factor = frame->metadata.device_scale_factor; | |
| 228 | |
| 229 guest_->UpdateGuestSizeIfNecessary(frame_size, scale_factor); | |
| 230 | |
| 231 // Check whether we need to recreate the cc::Surface, which means the child | |
| 232 // frame renderer has changed its output surface, or size, or scale factor. | |
| 233 if (output_surface_id != last_output_surface_id_ && surface_factory_) { | |
| 234 surface_factory_->Destroy(surface_id_); | |
| 235 surface_factory_.reset(); | |
| 236 } | |
| 237 if (output_surface_id != last_output_surface_id_ || | |
| 238 frame_size != current_surface_size_ || | |
| 239 scale_factor != current_surface_scale_factor_) { | |
| 240 if (surface_factory_ && !surface_id_.is_null()) | |
| 241 surface_factory_->Destroy(surface_id_); | |
| 242 surface_id_ = cc::SurfaceId(); | |
| 243 last_output_surface_id_ = output_surface_id; | |
| 244 current_surface_size_ = frame_size; | |
| 245 current_surface_scale_factor_ = scale_factor; | |
| 246 } | |
| 247 | |
| 248 if (!surface_factory_) { | |
| 249 cc::SurfaceManager* manager = GetSurfaceManager(); | |
| 250 surface_factory_ = make_scoped_ptr(new cc::SurfaceFactory(manager, this)); | |
| 251 } | |
| 252 | |
| 253 if (surface_id_.is_null()) { | |
| 254 surface_id_ = id_allocator_->GenerateId(); | |
| 255 surface_factory_->Create(surface_id_); | |
| 256 | |
| 257 cc::SurfaceSequence sequence = cc::SurfaceSequence( | |
| 258 id_allocator_->id_namespace(), next_surface_sequence_++); | |
| 259 // The renderer process will satisfy this dependency when it creates a | |
| 260 // SurfaceLayer. | |
| 261 cc::SurfaceManager* manager = GetSurfaceManager(); | |
| 262 manager->GetSurfaceForId(surface_id_)->AddDestructionDependency(sequence); | |
| 263 guest_->SetChildFrameSurface(surface_id_, frame_size, scale_factor, | |
| 264 sequence); | |
| 265 } | |
| 266 | |
| 267 cc::SurfaceFactory::DrawCallback ack_callback = base::Bind( | |
| 268 &RenderWidgetHostViewChildFrame::SurfaceDrawn, | |
| 269 RenderWidgetHostViewChildFrame::AsWeakPtr(), output_surface_id); | |
| 270 ack_pending_count_++; | |
| 271 // If this value grows very large, something is going wrong. | |
| 272 DCHECK(ack_pending_count_ < 1000); | |
| 273 surface_factory_->SubmitFrame(surface_id_, frame.Pass(), ack_callback); | |
| 213 } | 274 } |
| 214 | 275 |
| 215 bool RenderWidgetHostViewGuest::OnMessageReceived(const IPC::Message& msg) { | 276 bool RenderWidgetHostViewGuest::OnMessageReceived(const IPC::Message& msg) { |
| 216 if (!platform_view_) { | 277 if (!platform_view_) { |
| 217 // In theory, we can get here if there's a delay between DestroyGuestView() | 278 // In theory, we can get here if there's a delay between DestroyGuestView() |
| 218 // being called and when our destructor is invoked. | 279 // being called and when our destructor is invoked. |
| 219 return false; | 280 return false; |
| 220 } | 281 } |
| 221 | 282 |
| 222 return platform_view_->OnMessageReceived(msg); | 283 return platform_view_->OnMessageReceived(msg); |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 382 } | 443 } |
| 383 | 444 |
| 384 void RenderWidgetHostViewGuest::GetScreenInfo(blink::WebScreenInfo* results) { | 445 void RenderWidgetHostViewGuest::GetScreenInfo(blink::WebScreenInfo* results) { |
| 385 if (!guest_) | 446 if (!guest_) |
| 386 return; | 447 return; |
| 387 RenderWidgetHostViewBase* embedder_view = GetOwnerRenderWidgetHostView(); | 448 RenderWidgetHostViewBase* embedder_view = GetOwnerRenderWidgetHostView(); |
| 388 if (embedder_view) | 449 if (embedder_view) |
| 389 embedder_view->GetScreenInfo(results); | 450 embedder_view->GetScreenInfo(results); |
| 390 } | 451 } |
| 391 | 452 |
| 392 uint32_t RenderWidgetHostViewGuest::GetSurfaceIdNamespace() { | |
| 393 // Compositing surfaces not supported. | |
| 394 return 0; | |
| 395 } | |
| 396 | |
| 397 #if defined(OS_MACOSX) | 453 #if defined(OS_MACOSX) |
| 398 void RenderWidgetHostViewGuest::SetActive(bool active) { | 454 void RenderWidgetHostViewGuest::SetActive(bool active) { |
| 399 platform_view_->SetActive(active); | 455 platform_view_->SetActive(active); |
| 400 } | 456 } |
| 401 | 457 |
| 402 void RenderWidgetHostViewGuest::SetWindowVisibility(bool visible) { | 458 void RenderWidgetHostViewGuest::SetWindowVisibility(bool visible) { |
| 403 platform_view_->SetWindowVisibility(visible); | 459 platform_view_->SetWindowVisibility(visible); |
| 404 } | 460 } |
| 405 | 461 |
| 406 void RenderWidgetHostViewGuest::WindowFrameChanged() { | 462 void RenderWidgetHostViewGuest::WindowFrameChanged() { |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 596 } | 652 } |
| 597 | 653 |
| 598 if (blink::WebInputEvent::isGestureEventType(event->type)) { | 654 if (blink::WebInputEvent::isGestureEventType(event->type)) { |
| 599 host_->ForwardGestureEvent( | 655 host_->ForwardGestureEvent( |
| 600 *static_cast<const blink::WebGestureEvent*>(event)); | 656 *static_cast<const blink::WebGestureEvent*>(event)); |
| 601 return; | 657 return; |
| 602 } | 658 } |
| 603 } | 659 } |
| 604 | 660 |
| 605 } // namespace content | 661 } // namespace content |
| OLD | NEW |