New issue
Advanced search Search tips

Issue 802308 link

Starred by 2 users

Issue metadata

Status: Fixed
Owner:
Closed: Jan 2018
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug

Blocking:
issue 770739



Sign in to add a comment

Transparent background colors don't work in screenshots (headless / devtools)

Project Member Reported by eseckler@chromium.org, Jan 16 2018

Issue description

When the background color is overridden to transparent colors using DevTools' Emulation.setBackgroundColorOverride and a screenshot is taken using Page.captureScreenshot, we notice two issues:

a) fully or semi-transparent colors result in opaque colors in the screenshot.
b) After a) is fixed, semi-transparent colors are applied twice: e.g. 0x05ff0000 becomes 0x0aff0000 in the screenshot.

I bisected these issues to, respectively:
a) https://codereview.chromium.org/2944633002/
b) https://chromium-review.googlesource.com/c/chromium/src/+/669646
 
Blocking: 770739
Project Member

Comment 2 by bugdroid1@chromium.org, Jan 17 2018

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

commit ca3a79f4be52712d198d2b6b759d795d972b3e5b
Author: Eric Seckler <eseckler@chromium.org>
Date: Wed Jan 17 10:56:49 2018

cc: Fix semi-transparent background colors in LayerTreeHostImpl.

Make LayerTreeHostImpl not draw SolidColorDrawQuads for semi-transparent
background colors. This restores the original behavior prior to
https://crrev.com/c/669646, where it was accidentally changed.

Bug:  802308 
Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.android:android_optional_gpu_tests_rel
Change-Id: Ib354c3a0baf869a1cd288165144f14528eeebebe
Reviewed-on: https://chromium-review.googlesource.com/868691
Reviewed-by: enne <enne@chromium.org>
Commit-Queue: Eric Seckler <eseckler@chromium.org>
Cr-Commit-Position: refs/heads/master@{#529700}
[modify] https://crrev.com/ca3a79f4be52712d198d2b6b759d795d972b3e5b/cc/trees/layer_tree_host_impl.cc
[modify] https://crrev.com/ca3a79f4be52712d198d2b6b759d795d972b3e5b/cc/trees/layer_tree_host_impl_unittest.cc

Above patch fixes b).

liyuqian@ tracked down the cause of a). The new PNG encoder that was enabled in the bisected patch respects the alpha type setting in the SkBitmap, whereas the original encoder didn't. It seems the compositor sets the SkBitmap's alpha type to kOpaque_SkAlphaType in PrepareTextureCopyOutputResult [1], whereas it needs to be kPremul_SkAlphaType in order to preserve the transparency.

[1] https://cs.chromium.org/chromium/src/content/browser/compositor/surface_utils.cc?gsn=PrepareTextureCopyOutputResult&l=82
Description: Show this description
Project Member

Comment 5 by bugdroid1@chromium.org, Jan 24 2018

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

commit 1c23636a3ceedb223e098f6504f3da664ac69f2a
Author: Eric Seckler <eseckler@chromium.org>
Date: Wed Jan 24 18:48:17 2018

compositing: Preserve alpha for texture copy requests.

This makes taking transparent screenshots possible again, see bug
linked below for details.

It fixes a DevTools integration test that was previously disabled.
This patch re-enables the test and adds a semi-transparency test to
prevent regression b) of  crbug.com/802308 .

Bug:  802308 
Change-Id: I69c8e8eac8cdf39359aa0dabff0a468f8e6903a0
Reviewed-on: https://chromium-review.googlesource.com/870320
Reviewed-by: danakj <danakj@chromium.org>
Reviewed-by: Yuri Wiitala <miu@chromium.org>
Reviewed-by: Fady Samuel <fsamuel@chromium.org>
Reviewed-by: Dmitry Gozman <dgozman@chromium.org>
Commit-Queue: Eric Seckler <eseckler@chromium.org>
Cr-Commit-Position: refs/heads/master@{#531625}
[modify] https://crrev.com/1c23636a3ceedb223e098f6504f3da664ac69f2a/content/browser/compositor/surface_utils.cc
[modify] https://crrev.com/1c23636a3ceedb223e098f6504f3da664ac69f2a/content/browser/devtools/protocol/devtools_protocol_browsertest.cc
[modify] https://crrev.com/1c23636a3ceedb223e098f6504f3da664ac69f2a/content/browser/renderer_host/render_widget_host_view_android.cc

Status: Fixed (was: Started)
Patch in #5 should address a).

Sign in to add a comment