Commit 7484c173 authored by Bo Liu's avatar Bo Liu Committed by Commit Bot

viz: Skip emitting render pass quad with empty visible rect

Fixed: 1096736
Change-Id: I18f84514dafc627b728c1665b2888b492f3eaf65
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2254080Reviewed-by: default avatarweiliangc <weiliangc@chromium.org>
Commit-Queue: Bo <boliu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#780901}
parent f0be2fce
...@@ -682,14 +682,23 @@ void SurfaceAggregator::EmitSurfaceContent( ...@@ -682,14 +682,23 @@ void SurfaceAggregator::EmitSurfaceContent(
// We can't produce content outside of |quad_rect|, so clip the visible // We can't produce content outside of |quad_rect|, so clip the visible
// rect if necessary. // rect if necessary.
quad_visible_rect.Intersect(quad_rect); quad_visible_rect.Intersect(quad_rect);
auto* quad = dest_pass->CreateAndAppendDrawQuad<RenderPassDrawQuad>();
RenderPassId remapped_pass_id = RemapPassId(last_pass.id, surface_id); RenderPassId remapped_pass_id = RemapPassId(last_pass.id, surface_id);
quad->SetNew(shared_quad_state, quad_rect, quad_visible_rect, if (quad_visible_rect.IsEmpty()) {
remapped_pass_id, 0, gfx::RectF(), gfx::Size(), dest_pass_list_->erase(
gfx::Vector2dF(), gfx::PointF(), tex_coord_rect, std::remove_if(
/*force_anti_aliasing_off=*/false, dest_pass_list_->begin(), dest_pass_list_->end(),
/* backdrop_filter_quality*/ 1.0f); [&remapped_pass_id](const std::unique_ptr<RenderPass>& pass) {
return pass->id == remapped_pass_id;
}),
dest_pass_list_->end());
} else {
auto* quad = dest_pass->CreateAndAppendDrawQuad<RenderPassDrawQuad>();
quad->SetNew(shared_quad_state, quad_rect, quad_visible_rect,
remapped_pass_id, 0, gfx::RectF(), gfx::Size(),
gfx::Vector2dF(), gfx::PointF(), tex_coord_rect,
/*force_anti_aliasing_off=*/false,
/* backdrop_filter_quality*/ 1.0f);
}
} }
referenced_surfaces_.erase(surface_id); referenced_surfaces_.erase(surface_id);
......
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
#include <memory> #include <memory>
#include <string> #include <string>
#include <unordered_map> #include <unordered_map>
#include <utility>
#include <vector>
#include "base/containers/flat_map.h" #include "base/containers/flat_map.h"
#include "base/containers/flat_set.h" #include "base/containers/flat_set.h"
......
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
#include <stddef.h> #include <stddef.h>
#include <stdint.h> #include <stdint.h>
#include <algorithm>
#include <map>
#include <set> #include <set>
#include <utility> #include <utility>
#include <vector> #include <vector>
...@@ -6598,6 +6600,63 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, AllowMerge) { ...@@ -6598,6 +6600,63 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, AllowMerge) {
} }
} }
// Check that if a non-merged surface is invisible, its entire render pass is
// skipped.
TEST_F(SurfaceAggregatorValidSurfaceTest, SkipInvisibleSurface) {
// Child surface.
gfx::Rect child_rect(5, 5);
ParentLocalSurfaceIdAllocator child_allocator;
child_allocator.GenerateId();
LocalSurfaceId child_local_surface_id =
child_allocator.GetCurrentLocalSurfaceIdAllocation().local_surface_id();
SurfaceId child_surface_id(child_sink_->frame_sink_id(),
child_local_surface_id);
{
std::vector<Quad> child_quads = {
Quad::SolidColorQuad(SK_ColorGREEN, child_rect)};
// Offset child output rect so it's outside the root visible rect.
gfx::Rect output_rect(SurfaceSize());
output_rect.Offset(output_rect.width(), output_rect.height());
std::vector<Pass> child_passes = {Pass(child_quads, 1, output_rect)};
CompositorFrame child_frame = MakeEmptyCompositorFrame();
AddPasses(&child_frame.render_pass_list, child_passes,
&child_frame.metadata.referenced_surfaces);
child_sink_->SubmitCompositorFrame(child_local_surface_id,
std::move(child_frame));
}
gfx::Rect root_rect(SurfaceSize());
auto pass = RenderPass::Create();
pass->SetNew(1, root_rect, root_rect, gfx::Transform());
auto* sqs = pass->CreateAndAppendSharedQuadState();
sqs->opacity = 1.f;
// Disallow merge.
auto* surface_quad = pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>();
surface_quad->SetAll(sqs, child_rect, child_rect,
/*needs_blending=*/false,
SurfaceRange(base::nullopt, child_surface_id),
SK_ColorWHITE,
/*stretch_content_to_fill_bounds=*/false,
/*is_reflection=*/false,
/*allow_merge=*/false);
CompositorFrame frame =
CompositorFrameBuilder().AddRenderPass(std::move(pass)).Build();
root_sink_->SubmitCompositorFrame(root_local_surface_id_, std::move(frame));
SurfaceId root_surface_id(root_sink_->frame_sink_id(),
root_local_surface_id_);
CompositorFrame aggregated_frame = AggregateFrame(root_surface_id);
// Merging not allowed, but child rect should be dropped.
EXPECT_EQ(1u, aggregated_frame.render_pass_list.size());
}
// Verify that a SurfaceDrawQuad's root RenderPass has correct texture // Verify that a SurfaceDrawQuad's root RenderPass has correct texture
// parameters if being drawn via RPDQ. // parameters if being drawn via RPDQ.
TEST_F(SurfaceAggregatorValidSurfaceTest, RenderPassDoesNotFillSurface) { TEST_F(SurfaceAggregatorValidSurfaceTest, RenderPassDoesNotFillSurface) {
......
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