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 {
virtual void BrowserCompositorMacOnBeginFrame(base::TimeTicks frame_time) = 0;
virtual void OnFrameTokenChanged(uint32_t frame_token) = 0;
virtual void DestroyCompositorForShutdown() = 0;
virtual bool OnBrowserCompositorSurfaceIdChanged(
const viz::LocalSurfaceIdAllocation&
child_local_surface_id_allocation) = 0;
virtual bool OnBrowserCompositorSurfaceIdChanged() = 0;
virtual std::vector<viz::SurfaceId> CollectSurfaceIdsForEviction() = 0;
};
......@@ -62,7 +60,9 @@ class CONTENT_EXPORT BrowserCompositorMac : public DelegatedFrameHostClient,
// These will not return nullptr until Destroy is called.
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
// no valid frame is available.
......@@ -115,9 +115,6 @@ class CONTENT_EXPORT BrowserCompositorMac : public DelegatedFrameHostClient,
base::OnceCallback<void()> allocation_task);
const viz::LocalSurfaceId& GetRendererLocalSurfaceId();
base::TimeTicks GetRendererLocalSurfaceIdAllocationTime() const;
const viz::LocalSurfaceId& AllocateNewRendererLocalSurfaceId();
bool UpdateRendererLocalSurfaceIdFromChild(
const viz::LocalSurfaceIdAllocation& child_local_surface_id_allocation);
void TransformPointToRootSurface(gfx::PointF* point);
// Indicate that the recyclable compositor should be destroyed, and no future
......
......@@ -84,15 +84,12 @@ DelegatedFrameHost* BrowserCompositorMac::GetDelegatedFrameHost() {
return delegated_frame_host_.get();
}
bool BrowserCompositorMac::RequestRepaintForTesting() {
bool BrowserCompositorMac::ForceNewSurfaceId() {
dfh_local_surface_id_allocator_.GenerateId();
const viz::LocalSurfaceIdAllocation& new_local_surface_id_allocation =
dfh_local_surface_id_allocator_.GetCurrentLocalSurfaceIdAllocation();
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());
return client_->OnBrowserCompositorSurfaceIdChanged(
new_local_surface_id_allocation);
return client_->OnBrowserCompositorSurfaceIdChanged();
}
const gfx::CALayerParams* BrowserCompositorMac::GetLastCALayerParams() const {
......@@ -146,7 +143,7 @@ bool BrowserCompositorMac::UpdateSurfaceFromNSView(
if (needs_new_surface_id) {
dfh_local_surface_id_allocator_.GenerateId();
GetDelegatedFrameHost()->EmbedSurface(
delegated_frame_host_->EmbedSurface(
dfh_local_surface_id_allocator_.GetCurrentLocalSurfaceId(),
dfh_size_dip_, GetDeadlinePolicy(is_resize));
}
......@@ -176,12 +173,11 @@ void BrowserCompositorMac::UpdateSurfaceFromChild(
recyclable_compositor_->UpdateSurface(dfh_size_pixels_,
dfh_display_.device_scale_factor());
}
GetDelegatedFrameHost()->EmbedSurface(
delegated_frame_host_->EmbedSurface(
dfh_local_surface_id_allocator_.GetCurrentLocalSurfaceId(),
dfh_size_dip_, GetDeadlinePolicy(true /* is_resize */));
}
client_->OnBrowserCompositorSurfaceIdChanged(
child_local_surface_id_allocation);
client_->OnBrowserCompositorSurfaceIdChanged();
}
void BrowserCompositorMac::UpdateVSyncParameters(
......@@ -365,12 +361,10 @@ void BrowserCompositorMac::DidNavigate() {
// use the ID that was already provided.
if (!is_first_navigation_)
dfh_local_surface_id_allocator_.GenerateId();
const viz::LocalSurfaceIdAllocation& local_surface_id_allocation =
dfh_local_surface_id_allocator_.GetCurrentLocalSurfaceIdAllocation();
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());
client_->OnBrowserCompositorSurfaceIdChanged(local_surface_id_allocation);
client_->OnBrowserCompositorSurfaceIdChanged();
delegated_frame_host_->DidNavigate();
is_first_navigation_ = false;
}
......@@ -418,18 +412,6 @@ base::TimeTicks BrowserCompositorMac::GetRendererLocalSurfaceIdAllocationTime()
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) {
gfx::Transform transform_to_root;
if (parent_ui_layer_)
......
......@@ -392,9 +392,7 @@ class CONTENT_EXPORT RenderWidgetHostViewMac
void BrowserCompositorMacOnBeginFrame(base::TimeTicks frame_time) override;
void OnFrameTokenChanged(uint32_t frame_token) override;
void DestroyCompositorForShutdown() override;
bool OnBrowserCompositorSurfaceIdChanged(
const viz::LocalSurfaceIdAllocation& child_local_surface_id_allocation)
override;
bool OnBrowserCompositorSurfaceIdChanged() override;
std::vector<viz::SurfaceId> CollectSurfaceIdsForEviction() override;
// AcceleratedWidgetMacNSView implementation.
......
......@@ -97,15 +97,7 @@ void RenderWidgetHostViewMac::DestroyCompositorForShutdown() {
Destroy();
}
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());
}
bool RenderWidgetHostViewMac::OnBrowserCompositorSurfaceIdChanged() {
return host()->SynchronizeVisualProperties();
}
......@@ -815,13 +807,7 @@ void RenderWidgetHostViewMac::CopyFromSurface(
void RenderWidgetHostViewMac::EnsureSurfaceSynchronizedForLayoutTest() {
++latest_capture_sequence_number_;
browser_compositor_->AllocateNewRendererLocalSurfaceId();
if (auto* host = browser_compositor_->GetDelegatedFrameHost()) {
host->EmbedSurface(browser_compositor_->GetRendererLocalSurfaceId(),
browser_compositor_->GetRendererSize(),
cc::DeadlinePolicy::UseDefaultDeadline());
}
host()->SynchronizeVisualProperties();
browser_compositor_->ForceNewSurfaceId();
}
void RenderWidgetHostViewMac::SetNeedsBeginFrames(bool needs_begin_frames) {
......@@ -1082,7 +1068,7 @@ void RenderWidgetHostViewMac::ResetFallbackToFirstNavigationSurface() {
}
bool RenderWidgetHostViewMac::RequestRepaintForTesting() {
return browser_compositor_->RequestRepaintForTesting();
return browser_compositor_->ForceNewSurfaceId();
}
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