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

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

Issue 2484013002: Make SurfaceFactory lifetime match frame_sink_id_ registration in RWHVChildFrame (Closed)
Patch Set: Fix RenderWidgetHostViewGuest Created 4 years, 1 month 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
« no previous file with comments | « content/browser/frame_host/render_widget_host_view_child_frame.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "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 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 279
280 last_scroll_offset_ = frame.metadata.root_scroll_offset; 280 last_scroll_offset_ = frame.metadata.root_scroll_offset;
281 281
282 cc::RenderPass* root_pass = frame.render_pass_list.back().get(); 282 cc::RenderPass* root_pass = frame.render_pass_list.back().get();
283 283
284 gfx::Size frame_size = root_pass->output_rect.size(); 284 gfx::Size frame_size = root_pass->output_rect.size();
285 float scale_factor = frame.metadata.device_scale_factor; 285 float scale_factor = frame.metadata.device_scale_factor;
286 286
287 // Check whether we need to recreate the cc::Surface, which means the child 287 // Check whether we need to recreate the cc::Surface, which means the child
288 // frame renderer has changed its output surface, or size, or scale factor. 288 // frame renderer has changed its output surface, or size, or scale factor.
289 if (compositor_frame_sink_id != last_compositor_frame_sink_id_ &&
290 surface_factory_) {
291 surface_factory_->Destroy(local_frame_id_);
292 surface_factory_.reset();
293 }
294 if (compositor_frame_sink_id != last_compositor_frame_sink_id_ || 289 if (compositor_frame_sink_id != last_compositor_frame_sink_id_ ||
295 frame_size != current_surface_size_ || 290 frame_size != current_surface_size_ ||
296 scale_factor != current_surface_scale_factor_ || 291 scale_factor != current_surface_scale_factor_ ||
297 (guest_ && guest_->has_attached_since_surface_set())) { 292 (guest_ && guest_->has_attached_since_surface_set())) {
298 ClearCompositorSurfaceIfNecessary(); 293 ClearCompositorSurfaceIfNecessary();
294 // If the renderer changed its frame sink, reset the surface factory to
295 // avoid returning stale resources.
296 if (compositor_frame_sink_id != last_compositor_frame_sink_id_)
297 surface_factory_->Reset();
299 last_compositor_frame_sink_id_ = compositor_frame_sink_id; 298 last_compositor_frame_sink_id_ = compositor_frame_sink_id;
300 current_surface_size_ = frame_size; 299 current_surface_size_ = frame_size;
301 current_surface_scale_factor_ = scale_factor; 300 current_surface_scale_factor_ = scale_factor;
302 } 301 }
303 302
304 if (!surface_factory_) {
305 cc::SurfaceManager* manager = GetSurfaceManager();
306 surface_factory_ =
307 base::MakeUnique<cc::SurfaceFactory>(frame_sink_id_, manager, this);
308 }
309
310 if (local_frame_id_.is_null()) { 303 if (local_frame_id_.is_null()) {
311 local_frame_id_ = id_allocator_->GenerateId(); 304 local_frame_id_ = id_allocator_->GenerateId();
312 surface_factory_->Create(local_frame_id_); 305 surface_factory_->Create(local_frame_id_);
313 306
314 cc::SurfaceSequence sequence = 307 cc::SurfaceSequence sequence =
315 cc::SurfaceSequence(frame_sink_id_, next_surface_sequence_++); 308 cc::SurfaceSequence(frame_sink_id_, next_surface_sequence_++);
316 // The renderer process will satisfy this dependency when it creates a 309 // The renderer process will satisfy this dependency when it creates a
317 // SurfaceLayer. 310 // SurfaceLayer.
318 cc::SurfaceManager* manager = GetSurfaceManager(); 311 cc::SurfaceManager* manager = GetSurfaceManager();
319 cc::SurfaceId surface_id(frame_sink_id_, local_frame_id_); 312 cc::SurfaceId surface_id(frame_sink_id_, local_frame_id_);
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
688 gesture_event.data.scrollUpdate.inertialPhase == 681 gesture_event.data.scrollUpdate.inertialPhase ==
689 blink::WebGestureEvent::MomentumPhase) { 682 blink::WebGestureEvent::MomentumPhase) {
690 return; 683 return;
691 } 684 }
692 host_->ForwardGestureEvent(gesture_event); 685 host_->ForwardGestureEvent(gesture_event);
693 return; 686 return;
694 } 687 }
695 } 688 }
696 689
697 } // namespace content 690 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/render_widget_host_view_child_frame.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698