Commit 2f074de1 authored by Ricardo Quesada's avatar Ricardo Quesada Committed by Commit Bot

viz: Update damage_rect when candidate doesn't get promoted

Update Underlay candidates' damage_rect even if they don't get promoted
to overlays. At the moment they do have the damage_rect updated when
they get promoted. But not otherwise. There is corner case when the
damage_rect is must be updated redarless whether the candidate gets
promoted.

This CL fixes that.
And also fixes some "git cl lint" warnings (missing #include <vector>)

BUG=b:116355420
BUG=b:117341940
TEST=viz_unittests --gtest_filter=UnderlayTest*

Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel
Change-Id: Ic543d844c09f47c845cfe0103f0462f5f67a9dbc
Reviewed-on: https://chromium-review.googlesource.com/c/1286275
Commit-Queue: Ricardo Quesada <ricardoq@chromium.org>
Reviewed-by: default avatarDaniele Castagna <dcastagna@chromium.org>
Cr-Commit-Position: refs/heads/master@{#602387}
parent fbaf2801
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
#include "components/viz/service/display/overlay_processor.h" #include "components/viz/service/display/overlay_processor.h"
#include <vector>
#include "base/metrics/histogram_macros.h" #include "base/metrics/histogram_macros.h"
#include "base/trace_event/trace_event.h" #include "base/trace_event/trace_event.h"
#include "build/build_config.h" #include "build/build_config.h"
...@@ -179,6 +181,9 @@ void OverlayProcessor::ProcessForOverlays( ...@@ -179,6 +181,9 @@ void OverlayProcessor::ProcessForOverlays(
break; break;
} }
if (!successful_strategy && !previous_frame_underlay_rect.IsEmpty())
damage_rect->Union(previous_frame_underlay_rect);
UMA_HISTOGRAM_ENUMERATION("Viz.DisplayCompositor.OverlayStrategy", UMA_HISTOGRAM_ENUMERATION("Viz.DisplayCompositor.OverlayStrategy",
successful_strategy successful_strategy
? successful_strategy->GetUMAEnum() ? successful_strategy->GetUMAEnum()
......
...@@ -1964,6 +1964,49 @@ TEST_F(UnderlayTest, UpdateDamageWhenChangingUnderlays) { ...@@ -1964,6 +1964,49 @@ TEST_F(UnderlayTest, UpdateDamageWhenChangingUnderlays) {
EXPECT_EQ(kOverlayRect, damage_rect_); EXPECT_EQ(kOverlayRect, damage_rect_);
} }
TEST_F(UnderlayTest, UpdateDamageRectWhenNoPromotion) {
// In the first pass there is an overlay promotion and the expected damage
// size should be unchanged.
// In the second pass there is no overlay promotion, but the damage should be
// the union of the damage_rect with CreateRenderPass's output_rect which is
// {0, 0, 256, 256}.
bool has_fullscreen_candidate[] = {true, false};
gfx::Rect damages[] = {gfx::Rect(0, 0, 32, 32), gfx::Rect(0, 0, 312, 16)};
gfx::Rect expected_damages[] = {gfx::Rect(0, 0, 32, 32),
gfx::Rect(0, 0, 312, 256)};
size_t expected_candidate_size[] = {1, 0};
for (int i = 0; i < 2; ++i) {
std::unique_ptr<RenderPass> pass = CreateRenderPass();
if (has_fullscreen_candidate[i]) {
CreateFullscreenCandidateQuad(
resource_provider_.get(), child_resource_provider_.get(),
child_provider_.get(), pass->shared_quad_state_list.back(),
pass.get());
}
gfx::Rect damage_rect{damages[i]};
// Add something behind it.
CreateFullscreenOpaqueQuad(resource_provider_.get(),
pass->shared_quad_state_list.back(), pass.get());
OverlayCandidateList candidate_list;
OverlayProcessor::FilterOperationsMap render_pass_filters;
OverlayProcessor::FilterOperationsMap render_pass_background_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_background_filters, &candidate_list,
nullptr, nullptr, &damage_rect, &content_bounds_);
EXPECT_EQ(expected_damages[i], damage_rect);
ASSERT_EQ(expected_candidate_size[i], candidate_list.size());
}
}
TEST_F(UnderlayCastTest, NoOverlayContentBounds) { TEST_F(UnderlayCastTest, NoOverlayContentBounds) {
std::unique_ptr<RenderPass> pass = CreateRenderPass(); std::unique_ptr<RenderPass> pass = CreateRenderPass();
......
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