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

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

Issue 2388753003: Introduce cc::LocalFrameId and use in SurfaceFactory (Closed)
Patch Set: Fix exo_unittests Created 4 years, 2 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 "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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 return; 105 return;
106 // Make sure the size of this view matches the size of the WebContentsView. 106 // Make sure the size of this view matches the size of the WebContentsView.
107 // The two sizes may fall out of sync if we switch RenderWidgetHostViews, 107 // The two sizes may fall out of sync if we switch RenderWidgetHostViews,
108 // resize, and then switch page, as is the case with interstitial pages. 108 // resize, and then switch page, as is the case with interstitial pages.
109 // NOTE: |guest_| is NULL in unit tests. 109 // NOTE: |guest_| is NULL in unit tests.
110 if (guest_) { 110 if (guest_) {
111 SetSize(guest_->web_contents()->GetViewBounds().size()); 111 SetSize(guest_->web_contents()->GetViewBounds().size());
112 // Since we were last shown, our renderer may have had a different surface 112 // Since we were last shown, our renderer may have had a different surface
113 // set (e.g. showing an interstitial), so we resend our current surface to 113 // set (e.g. showing an interstitial), so we resend our current surface to
114 // the renderer. 114 // the renderer.
115 if (!surface_id_.is_null()) { 115 if (!local_frame_id_.is_null()) {
116 cc::SurfaceSequence sequence = 116 cc::SurfaceSequence sequence =
117 cc::SurfaceSequence(frame_sink_id_, next_surface_sequence_++); 117 cc::SurfaceSequence(frame_sink_id_, next_surface_sequence_++);
118 cc::SurfaceId surface_id(frame_sink_id_, local_frame_id_);
118 GetSurfaceManager() 119 GetSurfaceManager()
119 ->GetSurfaceForId(surface_id_) 120 ->GetSurfaceForId(surface_id)
120 ->AddDestructionDependency(sequence); 121 ->AddDestructionDependency(sequence);
121 guest_->SetChildFrameSurface(surface_id_, current_surface_size_, 122 guest_->SetChildFrameSurface(surface_id, current_surface_size_,
122 current_surface_scale_factor_, 123 current_surface_scale_factor_, sequence);
123 sequence);
124 } 124 }
125 } 125 }
126 host_->WasShown(ui::LatencyInfo()); 126 host_->WasShown(ui::LatencyInfo());
127 } 127 }
128 128
129 void RenderWidgetHostViewGuest::Hide() { 129 void RenderWidgetHostViewGuest::Hide() {
130 // |guest_| is NULL during test. 130 // |guest_| is NULL during test.
131 if ((guest_ && guest_->is_in_destruction()) || host_->is_hidden()) 131 if ((guest_ && guest_->is_in_destruction()) || host_->is_hidden())
132 return; 132 return;
133 host_->WasHidden(); 133 host_->WasHidden();
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 cc::RenderPass* root_pass = 271 cc::RenderPass* root_pass =
272 frame.delegated_frame_data->render_pass_list.back().get(); 272 frame.delegated_frame_data->render_pass_list.back().get();
273 273
274 gfx::Size frame_size = root_pass->output_rect.size(); 274 gfx::Size frame_size = root_pass->output_rect.size();
275 float scale_factor = frame.metadata.device_scale_factor; 275 float scale_factor = frame.metadata.device_scale_factor;
276 276
277 // Check whether we need to recreate the cc::Surface, which means the child 277 // Check whether we need to recreate the cc::Surface, which means the child
278 // frame renderer has changed its output surface, or size, or scale factor. 278 // frame renderer has changed its output surface, or size, or scale factor.
279 if (compositor_frame_sink_id != last_compositor_frame_sink_id_ && 279 if (compositor_frame_sink_id != last_compositor_frame_sink_id_ &&
280 surface_factory_) { 280 surface_factory_) {
281 surface_factory_->Destroy(surface_id_); 281 surface_factory_->Destroy(local_frame_id_);
282 surface_factory_.reset(); 282 surface_factory_.reset();
283 } 283 }
284 if (compositor_frame_sink_id != last_compositor_frame_sink_id_ || 284 if (compositor_frame_sink_id != last_compositor_frame_sink_id_ ||
285 frame_size != current_surface_size_ || 285 frame_size != current_surface_size_ ||
286 scale_factor != current_surface_scale_factor_ || 286 scale_factor != current_surface_scale_factor_ ||
287 (guest_ && guest_->has_attached_since_surface_set())) { 287 (guest_ && guest_->has_attached_since_surface_set())) {
288 ClearCompositorSurfaceIfNecessary(); 288 ClearCompositorSurfaceIfNecessary();
289 last_compositor_frame_sink_id_ = compositor_frame_sink_id; 289 last_compositor_frame_sink_id_ = compositor_frame_sink_id;
290 current_surface_size_ = frame_size; 290 current_surface_size_ = frame_size;
291 current_surface_scale_factor_ = scale_factor; 291 current_surface_scale_factor_ = scale_factor;
292 } 292 }
293 293
294 if (!surface_factory_) { 294 if (!surface_factory_) {
295 cc::SurfaceManager* manager = GetSurfaceManager(); 295 cc::SurfaceManager* manager = GetSurfaceManager();
296 surface_factory_ = 296 surface_factory_ =
297 base::MakeUnique<cc::SurfaceFactory>(frame_sink_id_, manager, this); 297 base::MakeUnique<cc::SurfaceFactory>(frame_sink_id_, manager, this);
298 } 298 }
299 299
300 if (surface_id_.is_null()) { 300 if (local_frame_id_.is_null()) {
301 surface_id_ = id_allocator_->GenerateId(); 301 local_frame_id_ = id_allocator_->GenerateId();
302 surface_factory_->Create(surface_id_); 302 surface_factory_->Create(local_frame_id_);
303 303
304 cc::SurfaceSequence sequence = 304 cc::SurfaceSequence sequence =
305 cc::SurfaceSequence(frame_sink_id_, next_surface_sequence_++); 305 cc::SurfaceSequence(frame_sink_id_, next_surface_sequence_++);
306 // The renderer process will satisfy this dependency when it creates a 306 // The renderer process will satisfy this dependency when it creates a
307 // SurfaceLayer. 307 // SurfaceLayer.
308 cc::SurfaceManager* manager = GetSurfaceManager(); 308 cc::SurfaceManager* manager = GetSurfaceManager();
309 manager->GetSurfaceForId(surface_id_)->AddDestructionDependency(sequence); 309 cc::SurfaceId surface_id(frame_sink_id_, local_frame_id_);
310 manager->GetSurfaceForId(surface_id)->AddDestructionDependency(sequence);
310 // TODO(wjmaclean): I'm not sure what it means to create a surface id 311 // TODO(wjmaclean): I'm not sure what it means to create a surface id
311 // without setting it on the child, though since we will in this case be 312 // without setting it on the child, though since we will in this case be
312 // guaranteed to call ClearCompositorSurfaceIfNecessary() below, I suspect 313 // guaranteed to call ClearCompositorSurfaceIfNecessary() below, I suspect
313 // skipping SetChildFrameSurface() here is irrelevant. 314 // skipping SetChildFrameSurface() here is irrelevant.
314 if (guest_ && !guest_->is_in_destruction()) { 315 if (guest_ && !guest_->is_in_destruction()) {
315 guest_->SetChildFrameSurface(surface_id_, frame_size, scale_factor, 316 guest_->SetChildFrameSurface(surface_id, frame_size, scale_factor,
316 sequence); 317 sequence);
317 } 318 }
318 } 319 }
319 320
320 cc::SurfaceFactory::DrawCallback ack_callback = base::Bind( 321 cc::SurfaceFactory::DrawCallback ack_callback = base::Bind(
321 &RenderWidgetHostViewChildFrame::SurfaceDrawn, 322 &RenderWidgetHostViewChildFrame::SurfaceDrawn,
322 RenderWidgetHostViewChildFrame::AsWeakPtr(), compositor_frame_sink_id); 323 RenderWidgetHostViewChildFrame::AsWeakPtr(), compositor_frame_sink_id);
323 ack_pending_count_++; 324 ack_pending_count_++;
324 // If this value grows very large, something is going wrong. 325 // If this value grows very large, something is going wrong.
325 DCHECK(ack_pending_count_ < 1000); 326 DCHECK(ack_pending_count_ < 1000);
326 surface_factory_->SubmitCompositorFrame(surface_id_, std::move(frame), 327 surface_factory_->SubmitCompositorFrame(local_frame_id_, std::move(frame),
327 ack_callback); 328 ack_callback);
328 329
329 ProcessFrameSwappedCallbacks(); 330 ProcessFrameSwappedCallbacks();
330 331
331 // If after detaching we are sent a frame, we should finish processing it, and 332 // If after detaching we are sent a frame, we should finish processing it, and
332 // then we should clear the surface so that we are not holding resources we 333 // then we should clear the surface so that we are not holding resources we
333 // no longer need. 334 // no longer need.
334 if (!guest_ || !guest_->attached()) 335 if (!guest_ || !guest_->attached())
335 ClearCompositorSurfaceIfNecessary(); 336 ClearCompositorSurfaceIfNecessary();
336 } 337 }
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
677 gesture_event.data.scrollUpdate.inertialPhase == 678 gesture_event.data.scrollUpdate.inertialPhase ==
678 blink::WebGestureEvent::MomentumPhase) { 679 blink::WebGestureEvent::MomentumPhase) {
679 return; 680 return;
680 } 681 }
681 host_->ForwardGestureEvent(gesture_event); 682 host_->ForwardGestureEvent(gesture_event);
682 return; 683 return;
683 } 684 }
684 } 685 }
685 686
686 } // namespace content 687 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698