Commit f213924a authored by Mark Yacoub's avatar Mark Yacoub Committed by Commit Bot

Revert "Skip promoting SingleOnTop Overlay when contents don't change"

This reverts commit b4fd0cc9.

Reason for revert: The Squid app uses SingleOnTop for overlay without changing the resource_id. This revert will undo the fix for the other apps, but they're lower priority.

Original change's description:
> Skip promoting SingleOnTop Overlay when contents don't change
>
> If a candidate content has not changed for 3 frames, do not promote it as
> Single On Top overlay as it can be just be flattened, allowing other
> strategies to kick in if possible.
>
> Bug: 885180
> Test: SingleOverlayOnTopTest.DoNotPromoteIfPreviouslyPromoted
> Change-Id: I516dab628c129fe9fae09c713e2783a6ce889c56
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1521591
> Commit-Queue: Mark Yacoub <markyacoub@google.com>
> Reviewed-by: Daniele Castagna <dcastagna@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#645367}

TBR=dcastagna@chromium.org,markyacoub@google.com

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: 885180
Change-Id: I799bd22f06a56d86844a63d5ac346f41bcfb8707
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1635931Reviewed-by: default avatarDaniele Castagna <dcastagna@chromium.org>
Commit-Queue: Mark Yacoub <markyacoub@google.com>
Cr-Commit-Position: refs/heads/master@{#664734}
parent c98e7a23
......@@ -35,15 +35,6 @@ bool OverlayStrategySingleOnTop::Attempt(
if (OverlayCandidate::FromDrawQuad(resource_provider, output_color_matrix,
*it, &candidate) &&
!OverlayCandidate::IsOccluded(candidate, quad_list->cbegin(), it)) {
// If the candidate has been promoted previously and has not changed
// (resource ID is the same) for 3 frames, do not use it as Overlay as
// flattening it to the main fb will be more power efficient when the
// contents don't change.
if (candidate.resource_id == previous_frame_resource_id_ &&
++same_resource_id_frames_count_ >
kMaxFrameCandidateWithSameResourceId) {
continue;
}
if (candidate.display_rect.size().GetArea() >
best_candidate.display_rect.size().GetArea()) {
best_candidate = candidate;
......@@ -54,17 +45,10 @@ bool OverlayStrategySingleOnTop::Attempt(
if (best_quad_it == quad_list->end())
return false;
if (TryOverlay(quad_list, candidate_list, best_candidate, best_quad_it)) {
if (previous_frame_resource_id_ != best_candidate.resource_id) {
previous_frame_resource_id_ = best_candidate.resource_id;
same_resource_id_frames_count_ = 1;
}
if (TryOverlay(quad_list, candidate_list, best_candidate, best_quad_it))
return true;
} else {
previous_frame_resource_id_ = kInvalidResourceId;
same_resource_id_frames_count_ = 0;
return false;
}
return false;
}
bool OverlayStrategySingleOnTop::TryOverlay(
......
......@@ -31,8 +31,6 @@ class VIZ_SERVICE_EXPORT OverlayStrategySingleOnTop
OverlayStrategy GetUMAEnum() const override;
private:
static constexpr size_t kMaxFrameCandidateWithSameResourceId = 3;
bool TryOverlay(QuadList* quad_list,
OverlayCandidateList* candidate_list,
const OverlayCandidate& candidate,
......@@ -40,9 +38,6 @@ class VIZ_SERVICE_EXPORT OverlayStrategySingleOnTop
OverlayCandidateValidator* capability_checker_; // Weak.
ResourceId previous_frame_resource_id_ = kInvalidResourceId;
size_t same_resource_id_frames_count_ = 0;
DISALLOW_COPY_AND_ASSIGN(OverlayStrategySingleOnTop);
};
......
......@@ -1582,70 +1582,6 @@ TEST_F(SingleOverlayOnTopTest, RejectTransparentColorOnTopWithoutBlending) {
EXPECT_EQ(0U, candidate_list.size());
}
TEST_F(SingleOverlayOnTopTest, DoNotPromoteIfContentsDontChange) {
// Resource ID for the repeated quads. Value should be equivalent to
// OverlayStrategySingleOnTop::kMaxFrameCandidateWithSameResourceId.
constexpr size_t kFramesSkippedBeforeNotPromoting = 3;
ResourceId previous_resource_id;
for (size_t i = 0; i < 3 + kFramesSkippedBeforeNotPromoting; ++i) {
std::unique_ptr<RenderPass> pass = CreateRenderPass();
RenderPass* main_pass = pass.get();
ResourceId resource_id;
if (i == 0 || i == 1) {
// Create a unique resource only for the first 2 frames.
resource_id = CreateResource(
resource_provider_.get(), child_resource_provider_.get(),
child_provider_.get(), pass->output_rect.size(),
true /*is_overlay_candidate*/);
previous_resource_id = resource_id;
} else {
// Starting the 3rd frame, they should have the same resource ID.
resource_id = previous_resource_id;
}
// Create a quad with the resource ID selected above.
TextureDrawQuad* original_quad =
main_pass->CreateAndAppendDrawQuad<TextureDrawQuad>();
float vertex_opacity[4] = {1.0f, 1.0f, 1.0f, 1.0f};
original_quad->SetNew(
pass->shared_quad_state_list.back(), pass->output_rect,
pass->output_rect, false /*needs_blending*/, resource_id,
false /*premultiplied_alpha*/, kUVTopLeft, kUVBottomRight,
SK_ColorTRANSPARENT, vertex_opacity, false /*flipped*/,
false /*nearest_neighbor*/, false /*secure_output_only*/,
ui::ProtectedVideoType::kClear);
original_quad->set_resource_size_in_pixels(pass->output_rect.size());
// Add something behind it.
CreateFullscreenOpaqueQuad(resource_provider_.get(),
pass->shared_quad_state_list.back(), main_pass);
// Check for potential candidates.
OverlayCandidateList candidate_list;
OverlayProcessor::FilterOperationsMap render_pass_filters;
OverlayProcessor::FilterOperationsMap render_pass_backdrop_filters;
RenderPassList pass_list;
pass_list.push_back(std::move(pass));
overlay_processor_->ProcessForOverlays(
resource_provider_.get(), &pass_list, GetIdentityColorMatrix(),
render_pass_filters, render_pass_backdrop_filters, &candidate_list,
nullptr, nullptr, &damage_rect_, &content_bounds_);
if (i <= kFramesSkippedBeforeNotPromoting) {
EXPECT_EQ(1U, candidate_list.size());
// Check that the right resource id got extracted.
EXPECT_EQ(resource_id, candidate_list.back().resource_id);
// Check that the quad is gone.
EXPECT_EQ(1U, main_pass->quad_list.size());
} else {
// Check nothing has been promoted.
EXPECT_EQ(2U, main_pass->quad_list.size());
}
}
}
TEST_F(UnderlayTest, OverlayLayerUnderMainLayer) {
AddExpectedRectToOverlayValidator(gfx::RectF(kOverlayBottomRightRect));
......
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