Commit 5dea8c2f authored by Saman Sami's avatar Saman Sami Committed by Commit Bot

Don't update the surface range at every activation

Updating the fallback lowerbound is not necessary anymore and will just
waste time by causing an unnecessary commit and draw.

Bug: 870456
Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel
Change-Id: Icd553c179c5a2eb98c1608524d9c1caf42a27835
Reviewed-on: https://chromium-review.googlesource.com/1226366
Commit-Queue: Saman Sami <samans@chromium.org>
Reviewed-by: default avatarKhushal <khushalsagar@chromium.org>
Reviewed-by: default avatarFady Samuel <fsamuel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#594380}
parent e10714dc
...@@ -132,15 +132,6 @@ static HitTestRegionList CreateHitTestData(const CompositorFrame& frame) { ...@@ -132,15 +132,6 @@ static HitTestRegionList CreateHitTestData(const CompositorFrame& frame) {
const SurfaceDrawQuad* surface_quad = const SurfaceDrawQuad* surface_quad =
SurfaceDrawQuad::MaterialCast(quad); SurfaceDrawQuad::MaterialCast(quad);
// Skip the quad if the FrameSinkId between fallback and primary is not
// the same, because we don't know which FrameSinkId would be used to
// draw this quad.
if (surface_quad->surface_range.start() &&
surface_quad->surface_range.start()->frame_sink_id() !=
surface_quad->surface_range.end().frame_sink_id()) {
continue;
}
// Skip the quad if the transform is not invertible (i.e. it will not // Skip the quad if the transform is not invertible (i.e. it will not
// be able to receive events). // be able to receive events).
gfx::Transform target_to_quad_transform; gfx::Transform target_to_quad_transform;
......
...@@ -149,7 +149,7 @@ void DelegatedFrameHost::ProcessCopyOutputRequest( ...@@ -149,7 +149,7 @@ void DelegatedFrameHost::ProcessCopyOutputRequest(
} }
bool DelegatedFrameHost::CanCopyFromCompositingSurface() const { bool DelegatedFrameHost::CanCopyFromCompositingSurface() const {
return HasFallbackSurface() && active_device_scale_factor_ != 0.f; return active_device_scale_factor_ != 0.f;
} }
bool DelegatedFrameHost::TransformPointToLocalCoordSpaceLegacy( bool DelegatedFrameHost::TransformPointToLocalCoordSpaceLegacy(
...@@ -330,8 +330,6 @@ void DelegatedFrameHost::OnFirstSurfaceActivation( ...@@ -330,8 +330,6 @@ void DelegatedFrameHost::OnFirstSurfaceActivation(
return; return;
} }
client_->DelegatedFrameHostGetLayer()->SetFallbackSurfaceId(
surface_info.id());
active_local_surface_id_ = surface_info.id().local_surface_id(); active_local_surface_id_ = surface_info.id().local_surface_id();
active_device_scale_factor_ = surface_info.device_scale_factor(); active_device_scale_factor_ = surface_info.device_scale_factor();
......
...@@ -1698,8 +1698,6 @@ bool RenderWidgetHostViewAura::TransformPointToCoordSpaceForView( ...@@ -1698,8 +1698,6 @@ bool RenderWidgetHostViewAura::TransformPointToCoordSpaceForView(
// In TransformPointToLocalCoordSpace() there is a Point-to-Pixel conversion, // In TransformPointToLocalCoordSpace() there is a Point-to-Pixel conversion,
// but it is not necessary here because the final target view is responsible // but it is not necessary here because the final target view is responsible
// for converting before computing the final transform. // for converting before computing the final transform.
if (!HasFallbackSurface())
return false;
return target_view->TransformPointToLocalCoordSpace( return target_view->TransformPointToLocalCoordSpace(
point, GetCurrentSurfaceId(), transformed_point, source); point, GetCurrentSurfaceId(), transformed_point, source);
} }
......
...@@ -3428,8 +3428,7 @@ TEST_F(RenderWidgetHostViewAuraSurfaceSynchronizationTest, ...@@ -3428,8 +3428,7 @@ TEST_F(RenderWidgetHostViewAuraSurfaceSynchronizationTest,
EXPECT_FALSE(view_->HasFallbackSurface()); EXPECT_FALSE(view_->HasFallbackSurface());
} }
// This test verifies that the primary SurfaceId is populated on resize and // This test verifies that the primary SurfaceId is populated on resize.
// the fallback SurfaceId is populated in OnFirstSurfaceActivation.
TEST_F(RenderWidgetHostViewAuraSurfaceSynchronizationTest, SurfaceChanges) { TEST_F(RenderWidgetHostViewAuraSurfaceSynchronizationTest, SurfaceChanges) {
// Early out because DelegatedFrameHost is not used in mash. // Early out because DelegatedFrameHost is not used in mash.
if (features::IsMultiProcessMash()) if (features::IsMultiProcessMash())
...@@ -3445,25 +3444,8 @@ TEST_F(RenderWidgetHostViewAuraSurfaceSynchronizationTest, SurfaceChanges) { ...@@ -3445,25 +3444,8 @@ TEST_F(RenderWidgetHostViewAuraSurfaceSynchronizationTest, SurfaceChanges) {
view_->SetSize(gfx::Size(300, 300)); view_->SetSize(gfx::Size(300, 300));
ASSERT_TRUE(view_->HasPrimarySurface()); ASSERT_TRUE(view_->HasPrimarySurface());
EXPECT_EQ(gfx::Size(300, 300), view_->window_->layer()->size()); EXPECT_EQ(gfx::Size(300, 300), view_->window_->layer()->size());
EXPECT_FALSE(view_->HasFallbackSurface());
EXPECT_EQ(gfx::Size(300, 300), EXPECT_EQ(gfx::Size(300, 300),
view_->delegated_frame_host_->CurrentFrameSizeInDipForTesting()); view_->delegated_frame_host_->CurrentFrameSizeInDipForTesting());
// Resizing should update the primary SurfaceId.
view_->SetSize(gfx::Size(400, 400));
EXPECT_EQ(gfx::Size(400, 400), view_->window_->layer()->size());
EXPECT_EQ(nullptr, view_->window_->layer()->GetFallbackSurfaceId());
EXPECT_EQ(gfx::Size(400, 400),
view_->delegated_frame_host_->CurrentFrameSizeInDipForTesting());
// Fallback SurfaceId should be updated in OnFirstSurfaceActivation.
// Submitting a CompositorFrame should update the fallback SurfaceId
viz::SurfaceId surface_id(view_->GetFrameSinkId(),
view_->GetLocalSurfaceId());
view_->delegated_frame_host_->OnFirstSurfaceActivation(
viz::SurfaceInfo(surface_id, 1.f, gfx::Size(400, 400)));
EXPECT_EQ(gfx::Size(400, 400), view_->window_->layer()->size());
EXPECT_EQ(surface_id, *view_->window_->layer()->GetFallbackSurfaceId());
} }
// This test verifies that the primary SurfaceId is updated on device scale // This test verifies that the primary SurfaceId is updated on device scale
...@@ -3660,7 +3642,8 @@ TEST_F(RenderWidgetHostViewAuraSurfaceSynchronizationTest, ...@@ -3660,7 +3642,8 @@ TEST_F(RenderWidgetHostViewAuraSurfaceSynchronizationTest,
// Make [1] hidden, resize it. It should drop its frame. // Make [1] hidden, resize it. It should drop its frame.
views[1]->Hide(); views[1]->Hide();
EXPECT_TRUE(views[1]->HasFallbackSurface()); // TODO(samans): Fix this expectation once https://crbug.com/878372 is fixed.
EXPECT_FALSE(views[1]->HasFallbackSurface());
gfx::Size size2(200, 200); gfx::Size size2(200, 200);
views[1]->SetSize(size2); views[1]->SetSize(size2);
EXPECT_FALSE(views[1]->HasFallbackSurface()); EXPECT_FALSE(views[1]->HasFallbackSurface());
...@@ -5933,7 +5916,9 @@ TEST_F(RenderWidgetHostViewAuraSurfaceSynchronizationTest, ...@@ -5933,7 +5916,9 @@ TEST_F(RenderWidgetHostViewAuraSurfaceSynchronizationTest,
viz::LocalSurfaceId id1 = view_->GetLocalSurfaceId(); viz::LocalSurfaceId id1 = view_->GetLocalSurfaceId();
view_->delegated_frame_host_->OnFirstSurfaceActivation(viz::SurfaceInfo( view_->delegated_frame_host_->OnFirstSurfaceActivation(viz::SurfaceInfo(
viz::SurfaceId(view_->GetFrameSinkId(), id1), 1, gfx::Size(20, 20))); viz::SurfaceId(view_->GetFrameSinkId(), id1), 1, gfx::Size(20, 20)));
EXPECT_TRUE(view_->window_->layer()->GetFallbackSurfaceId()->is_valid()); // TODO(samans): Fix these expectations once https://crbug.com/878372 is
// fixed.
EXPECT_FALSE(view_->window_->layer()->GetFallbackSurfaceId());
view_->Hide(); view_->Hide();
view_->SetSize(gfx::Size(54, 32)); view_->SetSize(gfx::Size(54, 32));
view_->Show(); view_->Show();
...@@ -5956,10 +5941,12 @@ TEST_F(RenderWidgetHostViewAuraSurfaceSynchronizationTest, ...@@ -5956,10 +5941,12 @@ TEST_F(RenderWidgetHostViewAuraSurfaceSynchronizationTest,
viz::LocalSurfaceId id1 = view_->GetLocalSurfaceId(); viz::LocalSurfaceId id1 = view_->GetLocalSurfaceId();
view_->delegated_frame_host_->OnFirstSurfaceActivation(viz::SurfaceInfo( view_->delegated_frame_host_->OnFirstSurfaceActivation(viz::SurfaceInfo(
viz::SurfaceId(view_->GetFrameSinkId(), id1), 1, gfx::Size(20, 20))); viz::SurfaceId(view_->GetFrameSinkId(), id1), 1, gfx::Size(20, 20)));
EXPECT_TRUE(view_->window_->layer()->GetFallbackSurfaceId()->is_valid()); // TODO(samans): Fix these expectations once https://crbug.com/878372 is
// fixed.
EXPECT_FALSE(view_->window_->layer()->GetFallbackSurfaceId());
view_->Hide(); view_->Hide();
view_->Show(); view_->Show();
EXPECT_TRUE(view_->window_->layer()->GetFallbackSurfaceId()->is_valid()); EXPECT_FALSE(view_->window_->layer()->GetFallbackSurfaceId());
} }
// Check that TakeFallbackContentFrom() copies the fallback SurfaceId and // Check that TakeFallbackContentFrom() copies the fallback SurfaceId and
...@@ -5984,16 +5971,10 @@ TEST_F(RenderWidgetHostViewAuraSurfaceSynchronizationTest, ...@@ -5984,16 +5971,10 @@ TEST_F(RenderWidgetHostViewAuraSurfaceSynchronizationTest,
view2->GetNativeView(), parent_view_->GetNativeView()->GetRootWindow(), view2->GetNativeView(), parent_view_->GetNativeView()->GetRootWindow(),
gfx::Rect()); gfx::Rect());
// Set fallback for the first view. // Call TakeFallbackContentFrom(). The second view should obtain a fallback
viz::LocalSurfaceId id = view_->GetLocalSurfaceId(); // from the first view.
view_->delegated_frame_host_->OnFirstSurfaceActivation(viz::SurfaceInfo(
viz::SurfaceId(view_->GetFrameSinkId(), id), 1, gfx::Size(20, 20)));
EXPECT_TRUE(view_->window_->layer()->GetFallbackSurfaceId()->is_valid());
// Call TakeFallbackContentFrom(). The second view should now have the same
// fallback as the first view.
view2->TakeFallbackContentFrom(view_); view2->TakeFallbackContentFrom(view_);
EXPECT_EQ(*view_->window_->layer()->GetFallbackSurfaceId(), EXPECT_EQ(view_->window_->layer()->GetPrimarySurfaceId()->ToSmallestId(),
*view2->window_->layer()->GetFallbackSurfaceId()); *view2->window_->layer()->GetFallbackSurfaceId());
DestroyView(view2); DestroyView(view2);
......
...@@ -1259,8 +1259,6 @@ bool RenderWidgetHostViewMac::TransformPointToCoordSpaceForView( ...@@ -1259,8 +1259,6 @@ bool RenderWidgetHostViewMac::TransformPointToCoordSpaceForView(
return true; return true;
} }
if (!HasFallbackSurface())
return false;
return target_view->TransformPointToLocalCoordSpace( return target_view->TransformPointToLocalCoordSpace(
point, GetCurrentSurfaceId(), transformed_point, source); point, GetCurrentSurfaceId(), transformed_point, source);
} }
......
...@@ -177,9 +177,7 @@ void DelegatedFrameHostAndroid::CopyFromCompositingSurface( ...@@ -177,9 +177,7 @@ void DelegatedFrameHostAndroid::CopyFromCompositingSurface(
} }
bool DelegatedFrameHostAndroid::CanCopyFromCompositingSurface() const { bool DelegatedFrameHostAndroid::CanCopyFromCompositingSurface() const {
return content_layer_ && content_layer_->fallback_surface_id() && return pending_local_surface_id_.is_valid() && view_->GetWindowAndroid() &&
content_layer_->fallback_surface_id()->is_valid() &&
view_->GetWindowAndroid() &&
view_->GetWindowAndroid()->GetCompositor(); view_->GetWindowAndroid()->GetCompositor();
} }
...@@ -405,7 +403,6 @@ void DelegatedFrameHostAndroid::OnFirstSurfaceActivation( ...@@ -405,7 +403,6 @@ void DelegatedFrameHostAndroid::OnFirstSurfaceActivation(
return; return;
} }
content_layer_->SetFallbackSurfaceId(surface_info.id());
active_local_surface_id_ = surface_info.id().local_surface_id(); active_local_surface_id_ = surface_info.id().local_surface_id();
active_device_scale_factor_ = surface_info.device_scale_factor(); active_device_scale_factor_ = surface_info.device_scale_factor();
...@@ -465,9 +462,7 @@ void DelegatedFrameHostAndroid::ProcessCopyOutputRequest( ...@@ -465,9 +462,7 @@ void DelegatedFrameHostAndroid::ProcessCopyOutputRequest(
} }
viz::SurfaceId DelegatedFrameHostAndroid::SurfaceId() const { viz::SurfaceId DelegatedFrameHostAndroid::SurfaceId() const {
return content_layer_ && content_layer_->fallback_surface_id() return viz::SurfaceId(frame_sink_id_, active_local_surface_id_);
? *content_layer_->fallback_surface_id()
: viz::SurfaceId();
} }
bool DelegatedFrameHostAndroid::HasPrimarySurface() const { bool DelegatedFrameHostAndroid::HasPrimarySurface() const {
......
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