New issue
Advanced search Search tips

Issue 917058 link

Starred by 2 users

Issue metadata

Status: Started
Owner:
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug

Blocked on:
issue swiftshader:122



Sign in to add a comment

SolidColorAnalyzer is too conservative regarding translucent shapes

Project Member Reported by andrescj@chromium.org, Dec 20

Issue description

In the rendering.desktop:blur_rotating_background performance story, there are two foreground divs that end up in their own layers. They are translucent, and it was expected that they would be drawn as solid color quads. Instead, they are drawn as texture quads.

The SolidColorAnalyzer seems too conservative regarding translucency (see [1]). If we can make it accept translucent shapes as solid colors without sacrificing correctness, we can avoid these texture quads.

[1] https://cs.chromium.org/chromium/src/cc/paint/solid_color_analyzer.cc?l=31&rcl=ed81626c1f9783216c831147552ccd438e7cceab
 
Blockedon: swiftshader:122
Project Member

Comment 2 by bugdroid1@chromium.org, Jan 16

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/9068d6b446f88797d411a080983f36deb83d3892

commit 9068d6b446f88797d411a080983f36deb83d3892
Author: Andres Calderon Jaramillo <andrescj@chromium.org>
Date: Wed Jan 16 01:26:18 2019

Allow translucent shapes to be detected as solid colors.

This CL modifies the SolidColorAnalyzer so that a color is not required
to be opaque to be considered solid. The motivation is that in the
rendering.desktop:blur_rotating_background story, the two blurring
foregrounds were being drawn as texture quads because they are
translucent. With this CL, they can be drawn as solid color quads thus
avoiding textures.

The initial change (patchset #3) was relatively simple: remove the
alpha == 255 restriction from the IsSolidColor() function and possibly
do a manual SrcOver alpha blend in case, e.g., a translucent drawRect is
done on top of another drawRect. The blend code was adapted from
ui/gfx/color_utils.cc::AlphaBlend().

Unfortunately, this caused some web_tests failures (see patchset #4).
Although the differences are not visible, two of the tests are not shown
in Gerrit because they could not be rebaselined since they're reftests:
compositing/background-color/background-color-alpha.html and
virtual/stable/compositing/background-color/background-color-alpha.html.
My exploration suggested rounding problems in the alpha
premultiplication prior to setting the solid color uniform in the GL
shader, so I changed the PremultipliedColor() function in gl_renderer.cc
to use a similar premultiplication logic as
SkARGB32_Blitter::SkARGB32_Blitter [1], and now all relevant web_tests
pass (see patchset #5).

After this, there were some unit test failures in cc and viz. I
addressed the cc failures by making FakeRasterSource::CreateFilled()
return a non-solid-color raster source to ensure that picture layers
using it can have tilings. I addressed the viz failure by rebaselining
the failed test as the visual difference is very little (there is a
difference but it's hard to appreciate in Gerrit). While fixing these
failures, I discovered a bug in my previous solid color code changes
where a raster source was incorrectly being detected as solid color in
certain cases. I fixed that bug and added test cases. All this was done
as of patchset #8.

[1] https://cs.chromium.org/chromium/src/third_party/skia/src/core/SkBlitter_ARGB32.cpp?l=676-680&rcl=ccb0a307c136760e0b0c33c4f66c3e58a3f98334

Bug: 917058
Test: foregrounds in the story are now drawn as solid color quads.
Change-Id: I6d70ccb7c28b356cfbc81a856a17192b6d743933
Reviewed-on: https://chromium-review.googlesource.com/c/1387385
Commit-Queue: Andres Calderon Jaramillo <andrescj@chromium.org>
Reviewed-by: Daniele Castagna <dcastagna@chromium.org>
Reviewed-by: enne <enne@chromium.org>
Cr-Commit-Position: refs/heads/master@{#622972}
[modify] https://crrev.com/9068d6b446f88797d411a080983f36deb83d3892/cc/paint/solid_color_analyzer.cc
[modify] https://crrev.com/9068d6b446f88797d411a080983f36deb83d3892/cc/paint/solid_color_analyzer_unittest.cc
[modify] https://crrev.com/9068d6b446f88797d411a080983f36deb83d3892/cc/test/fake_raster_source.cc
[modify] https://crrev.com/9068d6b446f88797d411a080983f36deb83d3892/components/viz/service/display/gl_renderer.cc
[modify] https://crrev.com/9068d6b446f88797d411a080983f36deb83d3892/components/viz/test/data/translucent_rectangles.png

Sign in to add a comment