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

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

Issue 2485473003: Remove SurfaceFactory::Create and SurfaceFactory::Destroy (Closed)
Patch Set: up Created 4 years 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 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 ClearCompositorSurfaceIfNecessary(); 299 ClearCompositorSurfaceIfNecessary();
300 // If the renderer changed its frame sink, reset the surface factory to 300 // If the renderer changed its frame sink, reset the surface factory to
301 // avoid returning stale resources. 301 // avoid returning stale resources.
302 if (compositor_frame_sink_id != last_compositor_frame_sink_id_) 302 if (compositor_frame_sink_id != last_compositor_frame_sink_id_)
303 surface_factory_->Reset(); 303 surface_factory_->Reset();
304 last_compositor_frame_sink_id_ = compositor_frame_sink_id; 304 last_compositor_frame_sink_id_ = compositor_frame_sink_id;
305 current_surface_size_ = frame_size; 305 current_surface_size_ = frame_size;
306 current_surface_scale_factor_ = scale_factor; 306 current_surface_scale_factor_ = scale_factor;
307 } 307 }
308 308
309 bool allocated_new_local_frame_id = false;
309 if (!local_frame_id_.is_valid()) { 310 if (!local_frame_id_.is_valid()) {
310 local_frame_id_ = id_allocator_->GenerateId(); 311 local_frame_id_ = id_allocator_->GenerateId();
311 surface_factory_->Create(local_frame_id_); 312 allocated_new_local_frame_id = true;
313 }
312 314
315 cc::SurfaceFactory::DrawCallback ack_callback = base::Bind(
316 &RenderWidgetHostViewChildFrame::SurfaceDrawn,
317 RenderWidgetHostViewChildFrame::AsWeakPtr(), compositor_frame_sink_id);
318 ack_pending_count_++;
319 // If this value grows very large, something is going wrong.
320 DCHECK(ack_pending_count_ < 1000);
321 surface_factory_->SubmitCompositorFrame(local_frame_id_, std::move(frame),
322 ack_callback);
323
324 if (allocated_new_local_frame_id) {
313 cc::SurfaceSequence sequence = 325 cc::SurfaceSequence sequence =
314 cc::SurfaceSequence(frame_sink_id_, next_surface_sequence_++); 326 cc::SurfaceSequence(frame_sink_id_, next_surface_sequence_++);
315 // The renderer process will satisfy this dependency when it creates a 327 // The renderer process will satisfy this dependency when it creates a
316 // SurfaceLayer. 328 // SurfaceLayer.
317 cc::SurfaceManager* manager = GetSurfaceManager(); 329 cc::SurfaceManager* manager = GetSurfaceManager();
318 cc::SurfaceId surface_id(frame_sink_id_, local_frame_id_); 330 cc::SurfaceId surface_id(frame_sink_id_, local_frame_id_);
319 manager->GetSurfaceForId(surface_id)->AddDestructionDependency(sequence); 331 manager->GetSurfaceForId(surface_id)->AddDestructionDependency(sequence);
320 // TODO(wjmaclean): I'm not sure what it means to create a surface id 332 // TODO(wjmaclean): I'm not sure what it means to create a surface id
321 // without setting it on the child, though since we will in this case be 333 // without setting it on the child, though since we will in this case be
322 // guaranteed to call ClearCompositorSurfaceIfNecessary() below, I suspect 334 // guaranteed to call ClearCompositorSurfaceIfNecessary() below, I suspect
323 // skipping SetChildFrameSurface() here is irrelevant. 335 // skipping SetChildFrameSurface() here is irrelevant.
324 if (guest_ && !guest_->is_in_destruction()) { 336 if (guest_ && !guest_->is_in_destruction()) {
325 guest_->SetChildFrameSurface(surface_id, frame_size, scale_factor, 337 guest_->SetChildFrameSurface(surface_id, frame_size, scale_factor,
326 sequence); 338 sequence);
327 } 339 }
328 } 340 }
329
330 cc::SurfaceFactory::DrawCallback ack_callback = base::Bind(
331 &RenderWidgetHostViewChildFrame::SurfaceDrawn,
332 RenderWidgetHostViewChildFrame::AsWeakPtr(), compositor_frame_sink_id);
333 ack_pending_count_++;
334 // If this value grows very large, something is going wrong.
335 DCHECK(ack_pending_count_ < 1000);
336 surface_factory_->SubmitCompositorFrame(local_frame_id_, std::move(frame),
337 ack_callback);
338
339 ProcessFrameSwappedCallbacks(); 341 ProcessFrameSwappedCallbacks();
340 342
341 // If after detaching we are sent a frame, we should finish processing it, and 343 // If after detaching we are sent a frame, we should finish processing it, and
342 // then we should clear the surface so that we are not holding resources we 344 // then we should clear the surface so that we are not holding resources we
343 // no longer need. 345 // no longer need.
344 if (!guest_ || !guest_->attached()) 346 if (!guest_ || !guest_->attached())
345 ClearCompositorSurfaceIfNecessary(); 347 ClearCompositorSurfaceIfNecessary();
346 } 348 }
347 349
348 bool RenderWidgetHostViewGuest::OnMessageReceived(const IPC::Message& msg) { 350 bool RenderWidgetHostViewGuest::OnMessageReceived(const IPC::Message& msg) {
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
687 gesture_event.data.scrollUpdate.inertialPhase == 689 gesture_event.data.scrollUpdate.inertialPhase ==
688 blink::WebGestureEvent::MomentumPhase) { 690 blink::WebGestureEvent::MomentumPhase) {
689 return; 691 return;
690 } 692 }
691 host_->ForwardGestureEvent(gesture_event); 693 host_->ForwardGestureEvent(gesture_event);
692 return; 694 return;
693 } 695 }
694 } 696 }
695 697
696 } // namespace content 698 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698