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

Unified Diff: content/browser/frame_host/render_widget_host_view_child_frame.cc

Issue 2633303003: Clean up RenderWidgetHostView(ChildFrame and Guest) compositing code (Closed)
Patch Set: Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/frame_host/render_widget_host_view_child_frame.cc
diff --git a/content/browser/frame_host/render_widget_host_view_child_frame.cc b/content/browser/frame_host/render_widget_host_view_child_frame.cc
index 0c6bc7dfc596be8f20b7b401f2c0f0d4648e4ff0..47ac1cea1cf98380aadbe9cfa4cfdb05d209392e 100644
--- a/content/browser/frame_host/render_widget_host_view_child_frame.cc
+++ b/content/browser/frame_host/render_widget_host_view_child_frame.cc
@@ -18,7 +18,6 @@
#include "cc/surfaces/surface.h"
#include "cc/surfaces/surface_factory.h"
#include "cc/surfaces/surface_manager.h"
-#include "cc/surfaces/surface_sequence.h"
#include "content/browser/accessibility/browser_accessibility_manager.h"
#include "content/browser/browser_plugin/browser_plugin_guest.h"
#include "content/browser/compositor/surface_utils.h"
@@ -374,35 +373,29 @@ void RenderWidgetHostViewChildFrame::SurfaceDrawn(
ack_pending_count_--;
}
-void RenderWidgetHostViewChildFrame::OnSwapCompositorFrame(
+bool RenderWidgetHostViewChildFrame::ShouldRecreateSurface(
uint32_t compositor_frame_sink_id,
- cc::CompositorFrame frame) {
- TRACE_EVENT0("content",
- "RenderWidgetHostViewChildFrame::OnSwapCompositorFrame");
+ const cc::CompositorFrame& frame) {
+ gfx::Size new_frame_size = frame.render_pass_list.back()->output_rect.size();
+ float new_scale_factor = frame.metadata.device_scale_factor;
- last_scroll_offset_ = frame.metadata.root_scroll_offset;
-
- if (!frame_connector_)
- return;
-
- cc::RenderPass* root_pass = frame.render_pass_list.back().get();
-
- gfx::Size frame_size = root_pass->output_rect.size();
- float scale_factor = frame.metadata.device_scale_factor;
+ return compositor_frame_sink_id != last_compositor_frame_sink_id_ ||
+ new_frame_size != current_surface_size_ ||
+ new_scale_factor != current_surface_scale_factor_;
+}
- // Check whether we need to recreate the cc::Surface, which means the child
- // frame renderer has changed its frame sink, or size, or scale factor.
- if (compositor_frame_sink_id != last_compositor_frame_sink_id_ ||
- frame_size != current_surface_size_ ||
- scale_factor != current_surface_scale_factor_) {
+void RenderWidgetHostViewChildFrame::ProcessCompositorFrame(
+ uint32_t compositor_frame_sink_id,
+ cc::CompositorFrame frame) {
+ if (ShouldRecreateSurface(compositor_frame_sink_id, frame)) {
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;
+ current_surface_size_ = frame.render_pass_list.back()->output_rect.size();
+ current_surface_scale_factor_ = frame.metadata.device_scale_factor;
}
bool allocated_new_local_frame_id = false;
@@ -428,13 +421,29 @@ void RenderWidgetHostViewChildFrame::OnSwapCompositorFrame(
cc::SurfaceManager* manager = GetSurfaceManager();
manager->GetSurfaceForId(cc::SurfaceId(frame_sink_id_, local_frame_id_))
->AddDestructionDependency(sequence);
- frame_connector_->SetChildFrameSurface(
- cc::SurfaceId(frame_sink_id_, local_frame_id_), frame_size,
- scale_factor, sequence);
+ SendSurfaceInfoToChild(sequence);
}
ProcessFrameSwappedCallbacks();
}
+void RenderWidgetHostViewChildFrame::SendSurfaceInfoToChild(
+ const cc::SurfaceSequence& sequence) {
+ frame_connector_->SetChildFrameSurface(
+ cc::SurfaceId(frame_sink_id_, local_frame_id_), current_surface_size_,
+ current_surface_scale_factor_, sequence);
+}
+
+void RenderWidgetHostViewChildFrame::OnSwapCompositorFrame(
+ uint32_t compositor_frame_sink_id,
+ cc::CompositorFrame frame) {
+ TRACE_EVENT0("content",
+ "RenderWidgetHostViewChildFrame::OnSwapCompositorFrame");
+ last_scroll_offset_ = frame.metadata.root_scroll_offset;
+ if (!frame_connector_)
+ return;
+ ProcessCompositorFrame(compositor_frame_sink_id, std::move(frame));
+}
+
void RenderWidgetHostViewChildFrame::ProcessFrameSwappedCallbacks() {
// We only use callbacks once, therefore we make a new list for registration
// before we start, and discard the old list entries when we are done.

Powered by Google App Engine
This is Rietveld 408576698