| 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" | 9 #include "cc/surfaces/surface.h" |
| 10 #include "cc/surfaces/surface_factory.h" | 10 #include "cc/surfaces/surface_factory.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 output_surface_id, | 208 uint32 output_surface_id, |
| 209 scoped_ptr<cc::CompositorFrame> frame) { | 209 scoped_ptr<cc::CompositorFrame> frame) { |
| 210 if (!guest_) | 210 if (!guest_ || !guest_->attached()) { |
| 211 // We shouldn't hang on to a surface while we are detached. |
| 212 ClearCompositorSurfaceIfNecessary(); |
| 211 return; | 213 return; |
| 214 } |
| 212 | 215 |
| 213 last_scroll_offset_ = frame->metadata.root_scroll_offset; | 216 last_scroll_offset_ = frame->metadata.root_scroll_offset; |
| 214 // When not using surfaces, the frame just gets proxied to | 217 // When not using surfaces, the frame just gets proxied to |
| 215 // the embedder's renderer to be composited. | 218 // the embedder's renderer to be composited. |
| 216 if (!frame->delegated_frame_data || !use_surfaces_) { | 219 if (!frame->delegated_frame_data || !use_surfaces_) { |
| 217 guest_->SwapCompositorFrame(output_surface_id, | 220 guest_->SwapCompositorFrame(output_surface_id, |
| 218 host_->GetProcess()->GetID(), | 221 host_->GetProcess()->GetID(), |
| 219 host_->GetRoutingID(), | 222 host_->GetRoutingID(), |
| 220 frame.Pass()); | 223 frame.Pass()); |
| 221 return; | 224 return; |
| 222 } | 225 } |
| 223 | 226 |
| 224 cc::RenderPass* root_pass = | 227 cc::RenderPass* root_pass = |
| 225 frame->delegated_frame_data->render_pass_list.back(); | 228 frame->delegated_frame_data->render_pass_list.back(); |
| 226 | 229 |
| 227 gfx::Size frame_size = root_pass->output_rect.size(); | 230 gfx::Size frame_size = root_pass->output_rect.size(); |
| 228 float scale_factor = frame->metadata.device_scale_factor; | 231 float scale_factor = frame->metadata.device_scale_factor; |
| 229 | 232 |
| 230 guest_->UpdateGuestSizeIfNecessary(frame_size, scale_factor); | 233 guest_->UpdateGuestSizeIfNecessary(frame_size, scale_factor); |
| 231 | 234 |
| 232 // Check whether we need to recreate the cc::Surface, which means the child | 235 // Check whether we need to recreate the cc::Surface, which means the child |
| 233 // frame renderer has changed its output surface, or size, or scale factor. | 236 // frame renderer has changed its output surface, or size, or scale factor. |
| 234 if (output_surface_id != last_output_surface_id_ && surface_factory_) { | 237 if (output_surface_id != last_output_surface_id_ && surface_factory_) { |
| 235 surface_factory_->Destroy(surface_id_); | 238 surface_factory_->Destroy(surface_id_); |
| 236 surface_factory_.reset(); | 239 surface_factory_.reset(); |
| 237 } | 240 } |
| 238 if (output_surface_id != last_output_surface_id_ || | 241 if (output_surface_id != last_output_surface_id_ || |
| 239 frame_size != current_surface_size_ || | 242 frame_size != current_surface_size_ || |
| 240 scale_factor != current_surface_scale_factor_) { | 243 scale_factor != current_surface_scale_factor_ || |
| 241 if (surface_factory_ && !surface_id_.is_null()) | 244 guest_->has_attached_since_surface_set()) { |
| 242 surface_factory_->Destroy(surface_id_); | 245 ClearCompositorSurfaceIfNecessary(); |
| 243 surface_id_ = cc::SurfaceId(); | |
| 244 last_output_surface_id_ = output_surface_id; | 246 last_output_surface_id_ = output_surface_id; |
| 245 current_surface_size_ = frame_size; | 247 current_surface_size_ = frame_size; |
| 246 current_surface_scale_factor_ = scale_factor; | 248 current_surface_scale_factor_ = scale_factor; |
| 247 } | 249 } |
| 248 | 250 |
| 249 if (!surface_factory_) { | 251 if (!surface_factory_) { |
| 250 cc::SurfaceManager* manager = GetSurfaceManager(); | 252 cc::SurfaceManager* manager = GetSurfaceManager(); |
| 251 surface_factory_ = make_scoped_ptr(new cc::SurfaceFactory(manager, this)); | 253 surface_factory_ = make_scoped_ptr(new cc::SurfaceFactory(manager, this)); |
| 252 } | 254 } |
| 253 | 255 |
| (...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 658 } | 660 } |
| 659 | 661 |
| 660 if (blink::WebInputEvent::isGestureEventType(event->type)) { | 662 if (blink::WebInputEvent::isGestureEventType(event->type)) { |
| 661 host_->ForwardGestureEvent( | 663 host_->ForwardGestureEvent( |
| 662 *static_cast<const blink::WebGestureEvent*>(event)); | 664 *static_cast<const blink::WebGestureEvent*>(event)); |
| 663 return; | 665 return; |
| 664 } | 666 } |
| 665 } | 667 } |
| 666 | 668 |
| 667 } // namespace content | 669 } // namespace content |
| OLD | NEW |