Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(147)

Side by Side Diff: content/browser/frame_host/render_widget_host_view_guest.cc

Issue 1199963011: Force new surface on BrowserPluginGuest reattach. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add blank lines where needed. Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 base::string16 RenderWidgetHostViewGuest::GetSelectedText() const { 197 base::string16 RenderWidgetHostViewGuest::GetSelectedText() const {
198 return platform_view_->GetSelectedText(); 198 return platform_view_->GetSelectedText();
199 } 199 }
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::ClearSurfaceIfNecessary() {
kenrb 2015/06/26 14:07:04 Is there any reason this can't move to RenderWidge
wjmaclean 2015/06/26 16:25:06 Done.
208 if (surface_factory_ && !surface_id_.is_null())
209 surface_factory_->Destroy(surface_id_);
210 surface_id_ = cc::SurfaceId();
211 }
212
207 void RenderWidgetHostViewGuest::OnSwapCompositorFrame( 213 void RenderWidgetHostViewGuest::OnSwapCompositorFrame(
208 uint32 output_surface_id, 214 uint32 output_surface_id,
209 scoped_ptr<cc::CompositorFrame> frame) { 215 scoped_ptr<cc::CompositorFrame> frame) {
210 if (!guest_) 216 if (!guest_ || !guest_->attached()) {
217 // We shouldn't hang on to a surface while we are detached.
218 ClearSurfaceIfNecessary();
211 return; 219 return;
220 }
212 221
213 last_scroll_offset_ = frame->metadata.root_scroll_offset; 222 last_scroll_offset_ = frame->metadata.root_scroll_offset;
214 // When not using surfaces, the frame just gets proxied to 223 // When not using surfaces, the frame just gets proxied to
215 // the embedder's renderer to be composited. 224 // the embedder's renderer to be composited.
216 if (!frame->delegated_frame_data || !use_surfaces_) { 225 if (!frame->delegated_frame_data || !use_surfaces_) {
217 guest_->SwapCompositorFrame(output_surface_id, 226 guest_->SwapCompositorFrame(output_surface_id,
218 host_->GetProcess()->GetID(), 227 host_->GetProcess()->GetID(),
219 host_->GetRoutingID(), 228 host_->GetRoutingID(),
220 frame.Pass()); 229 frame.Pass());
221 return; 230 return;
222 } 231 }
223 232
224 cc::RenderPass* root_pass = 233 cc::RenderPass* root_pass =
225 frame->delegated_frame_data->render_pass_list.back(); 234 frame->delegated_frame_data->render_pass_list.back();
226 235
227 gfx::Size frame_size = root_pass->output_rect.size(); 236 gfx::Size frame_size = root_pass->output_rect.size();
228 float scale_factor = frame->metadata.device_scale_factor; 237 float scale_factor = frame->metadata.device_scale_factor;
229 238
230 guest_->UpdateGuestSizeIfNecessary(frame_size, scale_factor); 239 guest_->UpdateGuestSizeIfNecessary(frame_size, scale_factor);
231 240
232 // Check whether we need to recreate the cc::Surface, which means the child 241 // 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. 242 // frame renderer has changed its output surface, or size, or scale factor.
234 if (output_surface_id != last_output_surface_id_ && surface_factory_) { 243 if (output_surface_id != last_output_surface_id_ && surface_factory_) {
235 surface_factory_->Destroy(surface_id_); 244 surface_factory_->Destroy(surface_id_);
236 surface_factory_.reset(); 245 surface_factory_.reset();
237 } 246 }
238 if (output_surface_id != last_output_surface_id_ || 247 if (output_surface_id != last_output_surface_id_ ||
239 frame_size != current_surface_size_ || 248 frame_size != current_surface_size_ ||
240 scale_factor != current_surface_scale_factor_) { 249 scale_factor != current_surface_scale_factor_ ||
241 if (surface_factory_ && !surface_id_.is_null()) 250 guest_->has_attached_since_surface_set()) {
242 surface_factory_->Destroy(surface_id_); 251 ClearSurfaceIfNecessary();
243 surface_id_ = cc::SurfaceId();
244 last_output_surface_id_ = output_surface_id; 252 last_output_surface_id_ = output_surface_id;
245 current_surface_size_ = frame_size; 253 current_surface_size_ = frame_size;
246 current_surface_scale_factor_ = scale_factor; 254 current_surface_scale_factor_ = scale_factor;
247 } 255 }
248 256
249 if (!surface_factory_) { 257 if (!surface_factory_) {
250 cc::SurfaceManager* manager = GetSurfaceManager(); 258 cc::SurfaceManager* manager = GetSurfaceManager();
251 surface_factory_ = make_scoped_ptr(new cc::SurfaceFactory(manager, this)); 259 surface_factory_ = make_scoped_ptr(new cc::SurfaceFactory(manager, this));
252 } 260 }
253 261
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
658 } 666 }
659 667
660 if (blink::WebInputEvent::isGestureEventType(event->type)) { 668 if (blink::WebInputEvent::isGestureEventType(event->type)) {
661 host_->ForwardGestureEvent( 669 host_->ForwardGestureEvent(
662 *static_cast<const blink::WebGestureEvent*>(event)); 670 *static_cast<const blink::WebGestureEvent*>(event));
663 return; 671 return;
664 } 672 }
665 } 673 }
666 674
667 } // namespace content 675 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698