Commit 159ad145 authored by yiyix's avatar yiyix Committed by Commit Bot

cc: Reduce the SolidColorDrawQuad generated by chrome

Since PictureLayerImpl::AppendQuads and SolidColorLayerImpl
::AppendSolidQuads both use scale=1 for its shared quad state,
pages like chrome://about can generate ~200 SCDQ on hi dpi
phones (e.g. pixel 2).

SolidColorDrawQuads are cheap to draw. In this CL, I re-visited
the tile management and generate only 1 SolidColorDrawQuad.

I tested the performance on cc_scroll_200_layer_grid, and
thread_GPU_cpu_time_per_frame is improved to 2.215 from 2.754.

Performance result summary:
https://x20.corp.google.com/users/yi/yiyix/www/1%20solid%20color%20draw%20quad%20analysis

Bug: 879379

TBR=kbr@chromium.org

Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel;luci.chromium.try:linux_optional_gpu_tests_rel;luci.chromium.try:mac_optional_gpu_tests_rel;luci.chromium.try:win_optional_gpu_tests_rel;master.tryserver.blink:linux_trusty_blink_rel
Change-Id: I8deaf29d1f0ed8f2d052ff77c8673b4e39877ab6
Reviewed-on: https://chromium-review.googlesource.com/c/1258386
Commit-Queue: Yi Xu <yiyix@chromium.org>
Reviewed-by: default avatarenne <enne@chromium.org>
Cr-Commit-Position: refs/heads/master@{#598867}
parent c1bcc2b2
......@@ -3369,7 +3369,7 @@ TEST_F(PictureLayerImplTest, OcclusionOnSolidColorPictureLayer) {
{
SCOPED_TRACE("Scaled occlusion");
gfx::Rect occluded(300, 0, 400, 2000);
gfx::Rect occluded(300, 0, 2000, 2000);
impl.AppendQuadsWithOcclusion(active_layer(), occluded);
size_t partial_occluded_count = 0;
......@@ -3377,11 +3377,9 @@ TEST_F(PictureLayerImplTest, OcclusionOnSolidColorPictureLayer) {
&partial_occluded_count);
// Because of the implementation of test helper AppendQuadsWithOcclusion,
// the occlusion will have a scale transform resulted from the device scale
// factor. However, the AppendQuads function will try to tile a solid color
// layer ignoring the scale factor, and its visible layer bounds is 500x500.
// So we end up having 4 partially occluded quads.
EXPECT_EQ(4u, impl.quad_list().size());
EXPECT_EQ(4u, partial_occluded_count);
// factor. A single partially overlapped DrawQuad of 500x500 will be added.
EXPECT_EQ(1u, impl.quad_list().size());
EXPECT_EQ(1u, partial_occluded_count);
}
}
......@@ -3409,7 +3407,7 @@ TEST_F(PictureLayerImplTest, IgnoreOcclusionOnSolidColorMask) {
&partial_occluded_count);
// None of the quads shall be occluded because mask layers ignores
// occlusion.
EXPECT_EQ(16u, impl.quad_list().size());
EXPECT_EQ(1u, impl.quad_list().size());
EXPECT_EQ(0u, partial_occluded_count);
}
}
......
......@@ -13,10 +13,6 @@
namespace cc {
namespace {
const int kSolidQuadTileSize = 256;
}
SolidColorLayerImpl::SolidColorLayerImpl(LayerTreeImpl* tree_impl, int id)
: LayerImpl(tree_impl, id) {
}
......@@ -41,32 +37,12 @@ void SolidColorLayerImpl::AppendSolidQuads(
DCHECK_EQ(SkBlendMode::kSrcOver, shared_quad_state->blend_mode);
if (alpha < std::numeric_limits<float>::epsilon())
return;
// We create a series of smaller quads instead of just one large one so that
// the culler can reduce the total pixels drawn.
int right = visible_layer_rect.right();
int bottom = visible_layer_rect.bottom();
for (int x = visible_layer_rect.x(); x < visible_layer_rect.right();
x += kSolidQuadTileSize) {
for (int y = visible_layer_rect.y(); y < visible_layer_rect.bottom();
y += kSolidQuadTileSize) {
gfx::Rect quad_rect(x,
y,
std::min(right - x, kSolidQuadTileSize),
std::min(bottom - y, kSolidQuadTileSize));
gfx::Rect visible_quad_rect =
occlusion_in_layer_space.GetUnoccludedContentRect(quad_rect);
if (visible_quad_rect.IsEmpty())
continue;
append_quads_data->visible_layer_area +=
visible_quad_rect.width() * visible_quad_rect.height();
auto* quad =
render_pass->CreateAndAppendDrawQuad<viz::SolidColorDrawQuad>();
quad->SetNew(shared_quad_state, quad_rect, visible_quad_rect, color,
force_anti_aliasing_off);
}
}
gfx::Rect visible_quad_rect =
occlusion_in_layer_space.GetUnoccludedContentRect(visible_layer_rect);
auto* quad = render_pass->CreateAndAppendDrawQuad<viz::SolidColorDrawQuad>();
quad->SetNew(shared_quad_state, visible_layer_rect, visible_quad_rect, color,
force_anti_aliasing_off);
}
void SolidColorLayerImpl::AppendQuads(viz::RenderPass* render_pass,
......
......@@ -263,7 +263,7 @@ TEST(SolidColorLayerImplTest, Occlusion) {
LayerTestCommon::VerifyQuadsExactlyCoverRect(impl.quad_list(),
gfx::Rect(layer_size));
EXPECT_EQ(16u, impl.quad_list().size());
EXPECT_EQ(1u, impl.quad_list().size());
}
{
......@@ -277,15 +277,15 @@ TEST(SolidColorLayerImplTest, Occlusion) {
{
SCOPED_TRACE("Partial occlusion");
gfx::Rect occluded(200, 200, 256 * 3, 256 * 3);
gfx::Rect occluded(200, 0, 800, 1000);
impl.AppendQuadsWithOcclusion(solid_color_layer_impl, occluded);
size_t partially_occluded_count = 0;
LayerTestCommon::VerifyQuadsAreOccluded(
impl.quad_list(), occluded, &partially_occluded_count);
// 4 quads are completely occluded, 8 are partially occluded.
EXPECT_EQ(16u - 4u, impl.quad_list().size());
EXPECT_EQ(8u, partially_occluded_count);
EXPECT_EQ(1u, impl.quad_list().size());
EXPECT_EQ(1u, partially_occluded_count);
}
}
......
......@@ -138,3 +138,6 @@ class PixelExpectations(GpuTestExpectations):
['android', ('qualcomm', 'Adreno (TM) 420')], bug=883500)
self.Fail('Pixel_BackgroundImage',
['android', ('qualcomm', 'Adreno (TM) 430')], bug=883500)
# TODO(yiyix): remove expectation after rebaseline.
self.Fail("Pixel_CSS3DBlueBox", bug=879379)
......@@ -114,7 +114,7 @@ def DefaultPages(base_name):
'pixel_css3d.html',
base_name + '_CSS3DBlueBox',
test_rect=[0, 0, 300, 300],
revision=22),
revision=23),
PixelTestPage(
'pixel_webgl_aa_alpha.html',
......
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