Commit eb64f04d authored by Christopher Cameron's avatar Christopher Cameron Committed by Commit Bot

RenderWidgetHostViewMac: Remove redundant calls

The function OnBrowserCompositorSurfaceIdChanged made redundant calls
to
- BrowserCompositorMac::UpdateRendererLocalSurfaceIdFromChild
  - Every caller of this function had just updated the surface id
- DelegatedFrameHost::EmbedSurface
  - Every caller of this function had also just called EmbedSurface

In RenderWidgetHostViewMac, merge RequestRepaintForTesting and
EnsureSurfaceSynchronizedForLayoutTest because they do the same
thing, and make them call BrowserCompositorMac::ForceNewSurfaceId.

Delete several BrowserCompositorMac functions that were only needed
due to poor organization: RequestRepaintForTesting,
AllocateNewRendererLocalSurfaceId, and
UpdateRendererLocalSurfaceIdFromChild.

Bug: 897156
Change-Id: I0bb2d6645bb8c9b4e91a469c17c1415dac7293e1
Reviewed-on: https://chromium-review.googlesource.com/c/1317032
Commit-Queue: ccameron <ccameron@chromium.org>
Reviewed-by: default avatarFady Samuel <fsamuel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#605891}
parent 522abbc3
...@@ -34,9 +34,7 @@ class BrowserCompositorMacClient { ...@@ -34,9 +34,7 @@ class BrowserCompositorMacClient {
virtual void BrowserCompositorMacOnBeginFrame(base::TimeTicks frame_time) = 0; virtual void BrowserCompositorMacOnBeginFrame(base::TimeTicks frame_time) = 0;
virtual void OnFrameTokenChanged(uint32_t frame_token) = 0; virtual void OnFrameTokenChanged(uint32_t frame_token) = 0;
virtual void DestroyCompositorForShutdown() = 0; virtual void DestroyCompositorForShutdown() = 0;
virtual bool OnBrowserCompositorSurfaceIdChanged( virtual bool OnBrowserCompositorSurfaceIdChanged() = 0;
const viz::LocalSurfaceIdAllocation&
child_local_surface_id_allocation) = 0;
virtual std::vector<viz::SurfaceId> CollectSurfaceIdsForEviction() = 0; virtual std::vector<viz::SurfaceId> CollectSurfaceIdsForEviction() = 0;
}; };
...@@ -62,7 +60,9 @@ class CONTENT_EXPORT BrowserCompositorMac : public DelegatedFrameHostClient, ...@@ -62,7 +60,9 @@ class CONTENT_EXPORT BrowserCompositorMac : public DelegatedFrameHostClient,
// These will not return nullptr until Destroy is called. // These will not return nullptr until Destroy is called.
DelegatedFrameHost* GetDelegatedFrameHost(); DelegatedFrameHost* GetDelegatedFrameHost();
bool RequestRepaintForTesting(); // Force a new surface id to be allocated. Returns true if the
// RenderWidgetHostImpl sent the resulting surface id to the renderer.
bool ForceNewSurfaceId();
// Return the parameters of the most recently received frame, or nullptr if // Return the parameters of the most recently received frame, or nullptr if
// no valid frame is available. // no valid frame is available.
...@@ -115,9 +115,6 @@ class CONTENT_EXPORT BrowserCompositorMac : public DelegatedFrameHostClient, ...@@ -115,9 +115,6 @@ class CONTENT_EXPORT BrowserCompositorMac : public DelegatedFrameHostClient,
base::OnceCallback<void()> allocation_task); base::OnceCallback<void()> allocation_task);
const viz::LocalSurfaceId& GetRendererLocalSurfaceId(); const viz::LocalSurfaceId& GetRendererLocalSurfaceId();
base::TimeTicks GetRendererLocalSurfaceIdAllocationTime() const; base::TimeTicks GetRendererLocalSurfaceIdAllocationTime() const;
const viz::LocalSurfaceId& AllocateNewRendererLocalSurfaceId();
bool UpdateRendererLocalSurfaceIdFromChild(
const viz::LocalSurfaceIdAllocation& child_local_surface_id_allocation);
void TransformPointToRootSurface(gfx::PointF* point); void TransformPointToRootSurface(gfx::PointF* point);
// Indicate that the recyclable compositor should be destroyed, and no future // Indicate that the recyclable compositor should be destroyed, and no future
......
...@@ -84,15 +84,12 @@ DelegatedFrameHost* BrowserCompositorMac::GetDelegatedFrameHost() { ...@@ -84,15 +84,12 @@ DelegatedFrameHost* BrowserCompositorMac::GetDelegatedFrameHost() {
return delegated_frame_host_.get(); return delegated_frame_host_.get();
} }
bool BrowserCompositorMac::RequestRepaintForTesting() { bool BrowserCompositorMac::ForceNewSurfaceId() {
dfh_local_surface_id_allocator_.GenerateId(); dfh_local_surface_id_allocator_.GenerateId();
const viz::LocalSurfaceIdAllocation& new_local_surface_id_allocation =
dfh_local_surface_id_allocator_.GetCurrentLocalSurfaceIdAllocation();
delegated_frame_host_->EmbedSurface( delegated_frame_host_->EmbedSurface(
new_local_surface_id_allocation.local_surface_id(), dfh_size_dip_, dfh_local_surface_id_allocator_.GetCurrentLocalSurfaceId(), dfh_size_dip_,
cc::DeadlinePolicy::UseExistingDeadline()); cc::DeadlinePolicy::UseExistingDeadline());
return client_->OnBrowserCompositorSurfaceIdChanged( return client_->OnBrowserCompositorSurfaceIdChanged();
new_local_surface_id_allocation);
} }
const gfx::CALayerParams* BrowserCompositorMac::GetLastCALayerParams() const { const gfx::CALayerParams* BrowserCompositorMac::GetLastCALayerParams() const {
...@@ -146,7 +143,7 @@ bool BrowserCompositorMac::UpdateSurfaceFromNSView( ...@@ -146,7 +143,7 @@ bool BrowserCompositorMac::UpdateSurfaceFromNSView(
if (needs_new_surface_id) { if (needs_new_surface_id) {
dfh_local_surface_id_allocator_.GenerateId(); dfh_local_surface_id_allocator_.GenerateId();
GetDelegatedFrameHost()->EmbedSurface( delegated_frame_host_->EmbedSurface(
dfh_local_surface_id_allocator_.GetCurrentLocalSurfaceId(), dfh_local_surface_id_allocator_.GetCurrentLocalSurfaceId(),
dfh_size_dip_, GetDeadlinePolicy(is_resize)); dfh_size_dip_, GetDeadlinePolicy(is_resize));
} }
...@@ -176,12 +173,11 @@ void BrowserCompositorMac::UpdateSurfaceFromChild( ...@@ -176,12 +173,11 @@ void BrowserCompositorMac::UpdateSurfaceFromChild(
recyclable_compositor_->UpdateSurface(dfh_size_pixels_, recyclable_compositor_->UpdateSurface(dfh_size_pixels_,
dfh_display_.device_scale_factor()); dfh_display_.device_scale_factor());
} }
GetDelegatedFrameHost()->EmbedSurface( delegated_frame_host_->EmbedSurface(
dfh_local_surface_id_allocator_.GetCurrentLocalSurfaceId(), dfh_local_surface_id_allocator_.GetCurrentLocalSurfaceId(),
dfh_size_dip_, GetDeadlinePolicy(true /* is_resize */)); dfh_size_dip_, GetDeadlinePolicy(true /* is_resize */));
} }
client_->OnBrowserCompositorSurfaceIdChanged( client_->OnBrowserCompositorSurfaceIdChanged();
child_local_surface_id_allocation);
} }
void BrowserCompositorMac::UpdateVSyncParameters( void BrowserCompositorMac::UpdateVSyncParameters(
...@@ -365,12 +361,10 @@ void BrowserCompositorMac::DidNavigate() { ...@@ -365,12 +361,10 @@ void BrowserCompositorMac::DidNavigate() {
// use the ID that was already provided. // use the ID that was already provided.
if (!is_first_navigation_) if (!is_first_navigation_)
dfh_local_surface_id_allocator_.GenerateId(); dfh_local_surface_id_allocator_.GenerateId();
const viz::LocalSurfaceIdAllocation& local_surface_id_allocation =
dfh_local_surface_id_allocator_.GetCurrentLocalSurfaceIdAllocation();
delegated_frame_host_->EmbedSurface( delegated_frame_host_->EmbedSurface(
local_surface_id_allocation.local_surface_id(), dfh_size_dip_, dfh_local_surface_id_allocator_.GetCurrentLocalSurfaceId(), dfh_size_dip_,
cc::DeadlinePolicy::UseExistingDeadline()); cc::DeadlinePolicy::UseExistingDeadline());
client_->OnBrowserCompositorSurfaceIdChanged(local_surface_id_allocation); client_->OnBrowserCompositorSurfaceIdChanged();
delegated_frame_host_->DidNavigate(); delegated_frame_host_->DidNavigate();
is_first_navigation_ = false; is_first_navigation_ = false;
} }
...@@ -418,18 +412,6 @@ base::TimeTicks BrowserCompositorMac::GetRendererLocalSurfaceIdAllocationTime() ...@@ -418,18 +412,6 @@ base::TimeTicks BrowserCompositorMac::GetRendererLocalSurfaceIdAllocationTime()
return dfh_local_surface_id_allocator_.allocation_time(); return dfh_local_surface_id_allocator_.allocation_time();
} }
const viz::LocalSurfaceId&
BrowserCompositorMac::AllocateNewRendererLocalSurfaceId() {
dfh_local_surface_id_allocator_.GenerateId();
return dfh_local_surface_id_allocator_.GetCurrentLocalSurfaceId();
}
bool BrowserCompositorMac::UpdateRendererLocalSurfaceIdFromChild(
const viz::LocalSurfaceIdAllocation& child_local_surface_id_allocation) {
return dfh_local_surface_id_allocator_.UpdateFromChild(
child_local_surface_id_allocation);
}
void BrowserCompositorMac::TransformPointToRootSurface(gfx::PointF* point) { void BrowserCompositorMac::TransformPointToRootSurface(gfx::PointF* point) {
gfx::Transform transform_to_root; gfx::Transform transform_to_root;
if (parent_ui_layer_) if (parent_ui_layer_)
......
...@@ -392,9 +392,7 @@ class CONTENT_EXPORT RenderWidgetHostViewMac ...@@ -392,9 +392,7 @@ class CONTENT_EXPORT RenderWidgetHostViewMac
void BrowserCompositorMacOnBeginFrame(base::TimeTicks frame_time) override; void BrowserCompositorMacOnBeginFrame(base::TimeTicks frame_time) override;
void OnFrameTokenChanged(uint32_t frame_token) override; void OnFrameTokenChanged(uint32_t frame_token) override;
void DestroyCompositorForShutdown() override; void DestroyCompositorForShutdown() override;
bool OnBrowserCompositorSurfaceIdChanged( bool OnBrowserCompositorSurfaceIdChanged() override;
const viz::LocalSurfaceIdAllocation& child_local_surface_id_allocation)
override;
std::vector<viz::SurfaceId> CollectSurfaceIdsForEviction() override; std::vector<viz::SurfaceId> CollectSurfaceIdsForEviction() override;
// AcceleratedWidgetMacNSView implementation. // AcceleratedWidgetMacNSView implementation.
......
...@@ -97,15 +97,7 @@ void RenderWidgetHostViewMac::DestroyCompositorForShutdown() { ...@@ -97,15 +97,7 @@ void RenderWidgetHostViewMac::DestroyCompositorForShutdown() {
Destroy(); Destroy();
} }
bool RenderWidgetHostViewMac::OnBrowserCompositorSurfaceIdChanged( bool RenderWidgetHostViewMac::OnBrowserCompositorSurfaceIdChanged() {
const viz::LocalSurfaceIdAllocation& child_local_surface_id_allocation) {
browser_compositor_->UpdateRendererLocalSurfaceIdFromChild(
child_local_surface_id_allocation);
if (auto* host = browser_compositor_->GetDelegatedFrameHost()) {
host->EmbedSurface(browser_compositor_->GetRendererLocalSurfaceId(),
browser_compositor_->GetRendererSize(),
cc::DeadlinePolicy::UseDefaultDeadline());
}
return host()->SynchronizeVisualProperties(); return host()->SynchronizeVisualProperties();
} }
...@@ -815,13 +807,7 @@ void RenderWidgetHostViewMac::CopyFromSurface( ...@@ -815,13 +807,7 @@ void RenderWidgetHostViewMac::CopyFromSurface(
void RenderWidgetHostViewMac::EnsureSurfaceSynchronizedForLayoutTest() { void RenderWidgetHostViewMac::EnsureSurfaceSynchronizedForLayoutTest() {
++latest_capture_sequence_number_; ++latest_capture_sequence_number_;
browser_compositor_->AllocateNewRendererLocalSurfaceId(); browser_compositor_->ForceNewSurfaceId();
if (auto* host = browser_compositor_->GetDelegatedFrameHost()) {
host->EmbedSurface(browser_compositor_->GetRendererLocalSurfaceId(),
browser_compositor_->GetRendererSize(),
cc::DeadlinePolicy::UseDefaultDeadline());
}
host()->SynchronizeVisualProperties();
} }
void RenderWidgetHostViewMac::SetNeedsBeginFrames(bool needs_begin_frames) { void RenderWidgetHostViewMac::SetNeedsBeginFrames(bool needs_begin_frames) {
...@@ -1082,7 +1068,7 @@ void RenderWidgetHostViewMac::ResetFallbackToFirstNavigationSurface() { ...@@ -1082,7 +1068,7 @@ void RenderWidgetHostViewMac::ResetFallbackToFirstNavigationSurface() {
} }
bool RenderWidgetHostViewMac::RequestRepaintForTesting() { bool RenderWidgetHostViewMac::RequestRepaintForTesting() {
return browser_compositor_->RequestRepaintForTesting(); return browser_compositor_->ForceNewSurfaceId();
} }
void RenderWidgetHostViewMac::TransformPointToRootSurface(gfx::PointF* point) { void RenderWidgetHostViewMac::TransformPointToRootSurface(gfx::PointF* point) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment