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

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

Issue 2096493002: Make cc::CompositorFrames movable [Part 1 of 2] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed Dana's nits Created 4 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 "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 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 } 223 }
224 224
225 void RenderWidgetHostViewGuest::SetTooltipText( 225 void RenderWidgetHostViewGuest::SetTooltipText(
226 const base::string16& tooltip_text) { 226 const base::string16& tooltip_text) {
227 if (guest_) 227 if (guest_)
228 guest_->SetTooltipText(tooltip_text); 228 guest_->SetTooltipText(tooltip_text);
229 } 229 }
230 230
231 void RenderWidgetHostViewGuest::OnSwapCompositorFrame( 231 void RenderWidgetHostViewGuest::OnSwapCompositorFrame(
232 uint32_t output_surface_id, 232 uint32_t output_surface_id,
233 std::unique_ptr<cc::CompositorFrame> frame) { 233 cc::CompositorFrame frame) {
234 TRACE_EVENT0("content", "RenderWidgetHostViewGuest::OnSwapCompositorFrame"); 234 TRACE_EVENT0("content", "RenderWidgetHostViewGuest::OnSwapCompositorFrame");
235 235
236 last_scroll_offset_ = frame->metadata.root_scroll_offset; 236 last_scroll_offset_ = frame.metadata.root_scroll_offset;
237 237
238 cc::RenderPass* root_pass = 238 cc::RenderPass* root_pass =
239 frame->delegated_frame_data->render_pass_list.back().get(); 239 frame.delegated_frame_data->render_pass_list.back().get();
240 240
241 gfx::Size frame_size = root_pass->output_rect.size(); 241 gfx::Size frame_size = root_pass->output_rect.size();
242 float scale_factor = frame->metadata.device_scale_factor; 242 float scale_factor = frame.metadata.device_scale_factor;
243 243
244 // Check whether we need to recreate the cc::Surface, which means the child 244 // Check whether we need to recreate the cc::Surface, which means the child
245 // frame renderer has changed its output surface, or size, or scale factor. 245 // frame renderer has changed its output surface, or size, or scale factor.
246 if (output_surface_id != last_output_surface_id_ && surface_factory_) { 246 if (output_surface_id != last_output_surface_id_ && surface_factory_) {
247 surface_factory_->Destroy(surface_id_); 247 surface_factory_->Destroy(surface_id_);
248 surface_factory_.reset(); 248 surface_factory_.reset();
249 } 249 }
250 if (output_surface_id != last_output_surface_id_ || 250 if (output_surface_id != last_output_surface_id_ ||
251 frame_size != current_surface_size_ || 251 frame_size != current_surface_size_ ||
252 scale_factor != current_surface_scale_factor_ || 252 scale_factor != current_surface_scale_factor_ ||
(...skipping 22 matching lines...) Expand all
275 guest_->SetChildFrameSurface(surface_id_, frame_size, scale_factor, 275 guest_->SetChildFrameSurface(surface_id_, frame_size, scale_factor,
276 sequence); 276 sequence);
277 } 277 }
278 278
279 cc::SurfaceFactory::DrawCallback ack_callback = base::Bind( 279 cc::SurfaceFactory::DrawCallback ack_callback = base::Bind(
280 &RenderWidgetHostViewChildFrame::SurfaceDrawn, 280 &RenderWidgetHostViewChildFrame::SurfaceDrawn,
281 RenderWidgetHostViewChildFrame::AsWeakPtr(), output_surface_id); 281 RenderWidgetHostViewChildFrame::AsWeakPtr(), output_surface_id);
282 ack_pending_count_++; 282 ack_pending_count_++;
283 // If this value grows very large, something is going wrong. 283 // If this value grows very large, something is going wrong.
284 DCHECK(ack_pending_count_ < 1000); 284 DCHECK(ack_pending_count_ < 1000);
285 surface_factory_->SubmitCompositorFrame(surface_id_, std::move(frame), 285 std::unique_ptr<cc::CompositorFrame> frame_copy(new cc::CompositorFrame);
286 *frame_copy = std::move(frame);
287 surface_factory_->SubmitCompositorFrame(surface_id_, std::move(frame_copy),
286 ack_callback); 288 ack_callback);
287 289
288 ProcessFrameSwappedCallbacks(); 290 ProcessFrameSwappedCallbacks();
289 291
290 // If after detaching we are sent a frame, we should finish processing it, and 292 // If after detaching we are sent a frame, we should finish processing it, and
291 // then we should clear the surface so that we are not holding resources we 293 // then we should clear the surface so that we are not holding resources we
292 // no longer need. 294 // no longer need.
293 if (!guest_ || !guest_->attached()) 295 if (!guest_ || !guest_->attached())
294 ClearCompositorSurfaceIfNecessary(); 296 ClearCompositorSurfaceIfNecessary();
295 } 297 }
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 gesture_event.data.scrollUpdate.inertialPhase == 594 gesture_event.data.scrollUpdate.inertialPhase ==
593 blink::WebGestureEvent::MomentumPhase) { 595 blink::WebGestureEvent::MomentumPhase) {
594 return; 596 return;
595 } 597 }
596 host_->ForwardGestureEvent(gesture_event); 598 host_->ForwardGestureEvent(gesture_event);
597 return; 599 return;
598 } 600 }
599 } 601 }
600 602
601 } // namespace content 603 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698