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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/frame_host/render_widget_host_view_guest.cc
diff --git a/content/browser/frame_host/render_widget_host_view_guest.cc b/content/browser/frame_host/render_widget_host_view_guest.cc
index 48ec3e287564e7d4223d350fb0dedbc504ab76a3..8ab20c1d4c73b99ed133145ecc2d6cfd5653890d 100644
--- a/content/browser/frame_host/render_widget_host_view_guest.cc
+++ b/content/browser/frame_host/render_widget_host_view_guest.cc
@@ -286,27 +286,20 @@ void RenderWidgetHostViewGuest::OnSwapCompositorFrame(
// Check whether we need to recreate the cc::Surface, which means the child
// frame renderer has changed its output surface, or size, or scale factor.
- if (compositor_frame_sink_id != last_compositor_frame_sink_id_ &&
- surface_factory_) {
- surface_factory_->Destroy(local_frame_id_);
- surface_factory_.reset();
- }
if (compositor_frame_sink_id != last_compositor_frame_sink_id_ ||
frame_size != current_surface_size_ ||
scale_factor != current_surface_scale_factor_ ||
(guest_ && guest_->has_attached_since_surface_set())) {
ClearCompositorSurfaceIfNecessary();
+ // If the renderer changed its frame sink, reset the surface factory to
+ // avoid returning stale resources.
+ if (compositor_frame_sink_id != last_compositor_frame_sink_id_)
+ surface_factory_->Reset();
last_compositor_frame_sink_id_ = compositor_frame_sink_id;
current_surface_size_ = frame_size;
current_surface_scale_factor_ = scale_factor;
}
- if (!surface_factory_) {
- cc::SurfaceManager* manager = GetSurfaceManager();
- surface_factory_ =
- base::MakeUnique<cc::SurfaceFactory>(frame_sink_id_, manager, this);
- }
-
if (local_frame_id_.is_null()) {
local_frame_id_ = id_allocator_->GenerateId();
surface_factory_->Create(local_frame_id_);
« 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