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 "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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 200 | 200 |
| 201 void RenderWidgetHostViewGuest::SetTooltipText( | 201 void RenderWidgetHostViewGuest::SetTooltipText( |
| 202 const base::string16& tooltip_text) { | 202 const base::string16& tooltip_text) { |
| 203 if (guest_) | 203 if (guest_) |
| 204 guest_->SetTooltipText(tooltip_text); | 204 guest_->SetTooltipText(tooltip_text); |
| 205 } | 205 } |
| 206 | 206 |
| 207 void RenderWidgetHostViewGuest::OnSwapCompositorFrame( | 207 void RenderWidgetHostViewGuest::OnSwapCompositorFrame( |
| 208 uint32_t output_surface_id, | 208 uint32_t output_surface_id, |
| 209 scoped_ptr<cc::CompositorFrame> frame) { | 209 scoped_ptr<cc::CompositorFrame> frame) { |
| 210 if (!guest_ || !guest_->attached()) { | 210 // If after detaching we are sent a frame, we should finish processing it, and |
| 211 // We shouldn't hang on to a surface while we are detached. | 211 // then we should clear the surface so that we are not holding resources we |
| 212 ClearCompositorSurfaceIfNecessary(); | 212 // no longer need. |
| 213 return; | 213 bool should_clear_compositor_surface_on_exit = !guest_ || !guest_->attached(); |
|
wjmaclean
2016/03/08 16:13:06
We don't actually need to declare a var for this i
| |
| 214 } | |
| 215 | 214 |
| 216 last_scroll_offset_ = frame->metadata.root_scroll_offset; | 215 last_scroll_offset_ = frame->metadata.root_scroll_offset; |
| 217 | 216 |
| 218 cc::RenderPass* root_pass = | 217 cc::RenderPass* root_pass = |
| 219 frame->delegated_frame_data->render_pass_list.back().get(); | 218 frame->delegated_frame_data->render_pass_list.back().get(); |
| 220 | 219 |
| 221 gfx::Size frame_size = root_pass->output_rect.size(); | 220 gfx::Size frame_size = root_pass->output_rect.size(); |
| 222 float scale_factor = frame->metadata.device_scale_factor; | 221 float scale_factor = frame->metadata.device_scale_factor; |
| 223 | 222 |
| 224 // Check whether we need to recreate the cc::Surface, which means the child | 223 // Check whether we need to recreate the cc::Surface, which means the child |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 259 cc::SurfaceFactory::DrawCallback ack_callback = base::Bind( | 258 cc::SurfaceFactory::DrawCallback ack_callback = base::Bind( |
| 260 &RenderWidgetHostViewChildFrame::SurfaceDrawn, | 259 &RenderWidgetHostViewChildFrame::SurfaceDrawn, |
| 261 RenderWidgetHostViewChildFrame::AsWeakPtr(), output_surface_id); | 260 RenderWidgetHostViewChildFrame::AsWeakPtr(), output_surface_id); |
| 262 ack_pending_count_++; | 261 ack_pending_count_++; |
| 263 // If this value grows very large, something is going wrong. | 262 // If this value grows very large, something is going wrong. |
| 264 DCHECK(ack_pending_count_ < 1000); | 263 DCHECK(ack_pending_count_ < 1000); |
| 265 surface_factory_->SubmitCompositorFrame(surface_id_, std::move(frame), | 264 surface_factory_->SubmitCompositorFrame(surface_id_, std::move(frame), |
| 266 ack_callback); | 265 ack_callback); |
| 267 | 266 |
| 268 ProcessFrameSwappedCallbacks(); | 267 ProcessFrameSwappedCallbacks(); |
| 268 | |
| 269 if (should_clear_compositor_surface_on_exit) | |
| 270 ClearCompositorSurfaceIfNecessary(); | |
| 269 } | 271 } |
| 270 | 272 |
| 271 bool RenderWidgetHostViewGuest::OnMessageReceived(const IPC::Message& msg) { | 273 bool RenderWidgetHostViewGuest::OnMessageReceived(const IPC::Message& msg) { |
| 272 if (!platform_view_) { | 274 if (!platform_view_) { |
| 273 // In theory, we can get here if there's a delay between DestroyGuestView() | 275 // In theory, we can get here if there's a delay between DestroyGuestView() |
| 274 // being called and when our destructor is invoked. | 276 // being called and when our destructor is invoked. |
| 275 return false; | 277 return false; |
| 276 } | 278 } |
| 277 | 279 |
| 278 return platform_view_->OnMessageReceived(msg); | 280 return platform_view_->OnMessageReceived(msg); |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 628 if (gesture_event.type == blink::WebInputEvent::GestureScrollUpdate && | 630 if (gesture_event.type == blink::WebInputEvent::GestureScrollUpdate && |
| 629 gesture_event.data.scrollUpdate.inertial) { | 631 gesture_event.data.scrollUpdate.inertial) { |
| 630 return; | 632 return; |
| 631 } | 633 } |
| 632 host_->ForwardGestureEvent(gesture_event); | 634 host_->ForwardGestureEvent(gesture_event); |
| 633 return; | 635 return; |
| 634 } | 636 } |
| 635 } | 637 } |
| 636 | 638 |
| 637 } // namespace content | 639 } // namespace content |
| OLD | NEW |