| 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 1b064e30b2d30837b37c40caf07625b429c62631..9226d9acc74af76d3fd5799e68b8be150b85ef5c 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
|
| @@ -41,6 +41,7 @@ namespace content {
|
| RenderWidgetHostViewChildFrame::RenderWidgetHostViewChildFrame(
|
| RenderWidgetHost* widget_host)
|
| : host_(RenderWidgetHostImpl::From(widget_host)),
|
| + surface_client_id_(AllocateSurfaceClientId()),
|
| next_surface_sequence_(1u),
|
| last_output_surface_id_(0),
|
| current_surface_scale_factor_(1.f),
|
| @@ -50,7 +51,9 @@ RenderWidgetHostViewChildFrame::RenderWidgetHostViewChildFrame(
|
| observing_begin_frame_source_(false),
|
| parent_surface_client_id_(0),
|
| weak_factory_(this) {
|
| - id_allocator_ = CreateSurfaceIdAllocator();
|
| + cc::SurfaceManager* manager = GetSurfaceManager();
|
| + surface_factory_ = base::WrapUnique(
|
| + new cc::SurfaceFactory(surface_client_id_, manager, this));
|
| RegisterSurfaceNamespaceId();
|
|
|
| host_->SetView(this);
|
| @@ -67,15 +70,7 @@ void RenderWidgetHostViewChildFrame::SetCrossProcessFrameConnector(
|
| return;
|
|
|
| if (frame_connector_) {
|
| - if (parent_surface_client_id_) {
|
| - GetSurfaceManager()->UnregisterSurfaceNamespaceHierarchy(
|
| - parent_surface_client_id_, GetSurfaceClientId());
|
| - }
|
| - // Unregister the client here, as it is not guaranteed in tests that the
|
| - // destructor will be called.
|
| - GetSurfaceManager()->UnregisterSurfaceFactoryClient(
|
| - id_allocator_->client_id());
|
| -
|
| + surface_factory_.reset();
|
| parent_surface_client_id_ = 0;
|
|
|
| // After the RenderWidgetHostViewChildFrame loses the frame_connector, it
|
| @@ -87,15 +82,15 @@ void RenderWidgetHostViewChildFrame::SetCrossProcessFrameConnector(
|
| }
|
| frame_connector_ = frame_connector;
|
| if (frame_connector_) {
|
| - GetSurfaceManager()->RegisterSurfaceFactoryClient(
|
| - id_allocator_->client_id(), this);
|
| + cc::SurfaceManager* manager = GetSurfaceManager();
|
| + surface_factory_.reset(
|
| + new cc::SurfaceFactory(surface_client_id_, manager, this));
|
| RenderWidgetHostViewBase* parent_view =
|
| frame_connector_->GetParentRenderWidgetHostView();
|
| if (parent_view) {
|
| parent_surface_client_id_ = parent_view->GetSurfaceClientId();
|
| DCHECK_NE(parent_surface_client_id_, 0u);
|
| - GetSurfaceManager()->RegisterSurfaceNamespaceHierarchy(
|
| - parent_surface_client_id_, GetSurfaceClientId());
|
| + surface_factory_->SetParent(parent_surface_client_id_);
|
| }
|
| }
|
| }
|
| @@ -357,6 +352,7 @@ void RenderWidgetHostViewChildFrame::SurfaceDrawn(uint32_t output_surface_id,
|
|
|
| void RenderWidgetHostViewChildFrame::OnSwapCompositorFrame(
|
| uint32_t output_surface_id,
|
| + const cc::SurfaceId& surface_id,
|
| cc::CompositorFrame frame) {
|
| TRACE_EVENT0("content",
|
| "RenderWidgetHostViewChildFrame::OnSwapCompositorFrame");
|
| @@ -371,39 +367,40 @@ void RenderWidgetHostViewChildFrame::OnSwapCompositorFrame(
|
|
|
| gfx::Size frame_size = root_pass->output_rect.size();
|
| float scale_factor = frame.metadata.device_scale_factor;
|
| + current_surface_scale_factor_ = scale_factor;
|
| + current_surface_size_ = frame_size;
|
|
|
| // 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 (output_surface_id != last_output_surface_id_ && surface_factory_) {
|
| - surface_factory_->Destroy(surface_id_);
|
| - surface_factory_.reset();
|
| - }
|
| - if (output_surface_id != last_output_surface_id_ ||
|
| - frame_size != current_surface_size_ ||
|
| - scale_factor != current_surface_scale_factor_) {
|
| - ClearCompositorSurfaceIfNecessary();
|
| + if (output_surface_id != last_output_surface_id_) {
|
| + if (surface_factory_)
|
| + surface_factory_->DestroyAll();
|
| last_output_surface_id_ = output_surface_id;
|
| - current_surface_size_ = frame_size;
|
| - current_surface_scale_factor_ = scale_factor;
|
| }
|
|
|
| if (!surface_factory_) {
|
| cc::SurfaceManager* manager = GetSurfaceManager();
|
| - surface_factory_ = base::WrapUnique(new cc::SurfaceFactory(manager, this));
|
| + surface_factory_ = base::WrapUnique(
|
| + new cc::SurfaceFactory(surface_client_id_, manager, this));
|
| }
|
|
|
| - if (surface_id_.is_null()) {
|
| - surface_id_ = id_allocator_->GenerateId();
|
| - surface_factory_->Create(surface_id_);
|
| -
|
| - cc::SurfaceSequence sequence = cc::SurfaceSequence(
|
| - id_allocator_->client_id(), next_surface_sequence_++);
|
| - // The renderer process will satisfy this dependency when it creates a
|
| - // SurfaceLayer.
|
| - cc::SurfaceManager* manager = GetSurfaceManager();
|
| - manager->GetSurfaceForId(surface_id_)->AddDestructionDependency(sequence);
|
| - frame_connector_->SetChildFrameSurface(surface_id_, frame_size,
|
| - scale_factor, sequence);
|
| + if (surface_id_ != surface_id) {
|
| + if (!surface_id_.is_null())
|
| + surface_factory_->Destroy(surface_id_);
|
| +
|
| + surface_id_ = surface_id;
|
| + if (!surface_id.is_null()) {
|
| + surface_factory_->Create(surface_id);
|
| +
|
| + cc::SurfaceSequence sequence =
|
| + cc::SurfaceSequence(surface_client_id_, next_surface_sequence_++);
|
| + // The renderer process will satisfy this dependency when it creates a
|
| + // SurfaceLayer.
|
| + cc::SurfaceManager* manager = GetSurfaceManager();
|
| + manager->GetSurfaceForId(surface_id_)->AddDestructionDependency(sequence);
|
| + frame_connector_->SetChildFrameSurface(surface_id, frame_size,
|
| + scale_factor, sequence);
|
| + }
|
| }
|
|
|
| cc::SurfaceFactory::DrawCallback ack_callback =
|
| @@ -476,7 +473,7 @@ bool RenderWidgetHostViewChildFrame::IsMouseLocked() {
|
| }
|
|
|
| uint32_t RenderWidgetHostViewChildFrame::GetSurfaceClientId() {
|
| - return id_allocator_->client_id();
|
| + return surface_client_id_;
|
| }
|
|
|
| void RenderWidgetHostViewChildFrame::ProcessKeyboardEvent(
|
|
|