| 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 "content/browser/frame_host/render_widget_host_view_guest.h" | 5 #include "content/browser/frame_host/render_widget_host_view_guest.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 platform_view_->SetNeedsBeginFrames(needs_begin_frames); | 255 platform_view_->SetNeedsBeginFrames(needs_begin_frames); |
| 256 } | 256 } |
| 257 | 257 |
| 258 void RenderWidgetHostViewGuest::SetTooltipText( | 258 void RenderWidgetHostViewGuest::SetTooltipText( |
| 259 const base::string16& tooltip_text) { | 259 const base::string16& tooltip_text) { |
| 260 if (guest_) | 260 if (guest_) |
| 261 guest_->SetTooltipText(tooltip_text); | 261 guest_->SetTooltipText(tooltip_text); |
| 262 } | 262 } |
| 263 | 263 |
| 264 void RenderWidgetHostViewGuest::OnSwapCompositorFrame( | 264 void RenderWidgetHostViewGuest::OnSwapCompositorFrame( |
| 265 uint32_t output_surface_id, | 265 uint32_t compositor_frame_sink_id, |
| 266 cc::CompositorFrame frame) { | 266 cc::CompositorFrame frame) { |
| 267 TRACE_EVENT0("content", "RenderWidgetHostViewGuest::OnSwapCompositorFrame"); | 267 TRACE_EVENT0("content", "RenderWidgetHostViewGuest::OnSwapCompositorFrame"); |
| 268 | 268 |
| 269 last_scroll_offset_ = frame.metadata.root_scroll_offset; | 269 last_scroll_offset_ = frame.metadata.root_scroll_offset; |
| 270 | 270 |
| 271 cc::RenderPass* root_pass = | 271 cc::RenderPass* root_pass = |
| 272 frame.delegated_frame_data->render_pass_list.back().get(); | 272 frame.delegated_frame_data->render_pass_list.back().get(); |
| 273 | 273 |
| 274 gfx::Size frame_size = root_pass->output_rect.size(); | 274 gfx::Size frame_size = root_pass->output_rect.size(); |
| 275 float scale_factor = frame.metadata.device_scale_factor; | 275 float scale_factor = frame.metadata.device_scale_factor; |
| 276 | 276 |
| 277 // Check whether we need to recreate the cc::Surface, which means the child | 277 // Check whether we need to recreate the cc::Surface, which means the child |
| 278 // frame renderer has changed its output surface, or size, or scale factor. | 278 // frame renderer has changed its output surface, or size, or scale factor. |
| 279 if (output_surface_id != last_output_surface_id_ && surface_factory_) { | 279 if (compositor_frame_sink_id != last_compositor_frame_sink_id_ && |
| 280 surface_factory_) { |
| 280 surface_factory_->Destroy(surface_id_); | 281 surface_factory_->Destroy(surface_id_); |
| 281 surface_factory_.reset(); | 282 surface_factory_.reset(); |
| 282 } | 283 } |
| 283 if (output_surface_id != last_output_surface_id_ || | 284 if (compositor_frame_sink_id != last_compositor_frame_sink_id_ || |
| 284 frame_size != current_surface_size_ || | 285 frame_size != current_surface_size_ || |
| 285 scale_factor != current_surface_scale_factor_ || | 286 scale_factor != current_surface_scale_factor_ || |
| 286 guest_->has_attached_since_surface_set()) { | 287 guest_->has_attached_since_surface_set()) { |
| 287 ClearCompositorSurfaceIfNecessary(); | 288 ClearCompositorSurfaceIfNecessary(); |
| 288 last_output_surface_id_ = output_surface_id; | 289 last_compositor_frame_sink_id_ = compositor_frame_sink_id; |
| 289 current_surface_size_ = frame_size; | 290 current_surface_size_ = frame_size; |
| 290 current_surface_scale_factor_ = scale_factor; | 291 current_surface_scale_factor_ = scale_factor; |
| 291 } | 292 } |
| 292 | 293 |
| 293 if (!surface_factory_) { | 294 if (!surface_factory_) { |
| 294 cc::SurfaceManager* manager = GetSurfaceManager(); | 295 cc::SurfaceManager* manager = GetSurfaceManager(); |
| 295 surface_factory_ = base::MakeUnique<cc::SurfaceFactory>(manager, this); | 296 surface_factory_ = base::MakeUnique<cc::SurfaceFactory>(manager, this); |
| 296 } | 297 } |
| 297 | 298 |
| 298 if (surface_id_.is_null()) { | 299 if (surface_id_.is_null()) { |
| 299 surface_id_ = id_allocator_->GenerateId(); | 300 surface_id_ = id_allocator_->GenerateId(); |
| 300 surface_factory_->Create(surface_id_); | 301 surface_factory_->Create(surface_id_); |
| 301 | 302 |
| 302 cc::SurfaceSequence sequence = cc::SurfaceSequence( | 303 cc::SurfaceSequence sequence = cc::SurfaceSequence( |
| 303 id_allocator_->client_id(), next_surface_sequence_++); | 304 id_allocator_->client_id(), next_surface_sequence_++); |
| 304 // The renderer process will satisfy this dependency when it creates a | 305 // The renderer process will satisfy this dependency when it creates a |
| 305 // SurfaceLayer. | 306 // SurfaceLayer. |
| 306 cc::SurfaceManager* manager = GetSurfaceManager(); | 307 cc::SurfaceManager* manager = GetSurfaceManager(); |
| 307 manager->GetSurfaceForId(surface_id_)->AddDestructionDependency(sequence); | 308 manager->GetSurfaceForId(surface_id_)->AddDestructionDependency(sequence); |
| 308 guest_->SetChildFrameSurface(surface_id_, frame_size, scale_factor, | 309 guest_->SetChildFrameSurface(surface_id_, frame_size, scale_factor, |
| 309 sequence); | 310 sequence); |
| 310 } | 311 } |
| 311 | 312 |
| 312 cc::SurfaceFactory::DrawCallback ack_callback = base::Bind( | 313 cc::SurfaceFactory::DrawCallback ack_callback = base::Bind( |
| 313 &RenderWidgetHostViewChildFrame::SurfaceDrawn, | 314 &RenderWidgetHostViewChildFrame::SurfaceDrawn, |
| 314 RenderWidgetHostViewChildFrame::AsWeakPtr(), output_surface_id); | 315 RenderWidgetHostViewChildFrame::AsWeakPtr(), compositor_frame_sink_id); |
| 315 ack_pending_count_++; | 316 ack_pending_count_++; |
| 316 // If this value grows very large, something is going wrong. | 317 // If this value grows very large, something is going wrong. |
| 317 DCHECK(ack_pending_count_ < 1000); | 318 DCHECK(ack_pending_count_ < 1000); |
| 318 surface_factory_->SubmitCompositorFrame(surface_id_, std::move(frame), | 319 surface_factory_->SubmitCompositorFrame(surface_id_, std::move(frame), |
| 319 ack_callback); | 320 ack_callback); |
| 320 | 321 |
| 321 ProcessFrameSwappedCallbacks(); | 322 ProcessFrameSwappedCallbacks(); |
| 322 | 323 |
| 323 // If after detaching we are sent a frame, we should finish processing it, and | 324 // If after detaching we are sent a frame, we should finish processing it, and |
| 324 // then we should clear the surface so that we are not holding resources we | 325 // then we should clear the surface so that we are not holding resources we |
| (...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 664 gesture_event.data.scrollUpdate.inertialPhase == | 665 gesture_event.data.scrollUpdate.inertialPhase == |
| 665 blink::WebGestureEvent::MomentumPhase) { | 666 blink::WebGestureEvent::MomentumPhase) { |
| 666 return; | 667 return; |
| 667 } | 668 } |
| 668 host_->ForwardGestureEvent(gesture_event); | 669 host_->ForwardGestureEvent(gesture_event); |
| 669 return; | 670 return; |
| 670 } | 671 } |
| 671 } | 672 } |
| 672 | 673 |
| 673 } // namespace content | 674 } // namespace content |
| OLD | NEW |