New issue
Advanced search Search tips

Issue 919866 link

Starred by 1 user

Issue metadata

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



Sign in to add a comment

Make skia::ImageOperations::Resize() support unpremultiplied alpha

Project Member Reported by kylec...@chromium.org, Jan 8

Issue description

The current implementation of skia::ImageOperations::Resize() doesn't seem to support unpremultipled alpha correctly. In  https://crbug.com/829517  a webcursor image with transparency becomes fully opaque after it's resized. If I convert the SkBitmap to premultiplied alpha before calling ImageOperations::Resize() then it works as expected.

bungeman@ suggested checking if SkImage::scalePixels() would handle unpremultiplied alpha correctly and it seems to. I'm not sure if ImageOperations::Resize() could be rewritten to use SkImage::scalePixels() instead of BGRAConvolve2D()?

There is also a different enum used to select the resize quality/algorithm, ResizeMethod vs SkFilterQuality, along with general performance concerns. ImageOperations::Resize() is pretty widely used in Chrome.
 
Project Member

Comment 1 by bugdroid1@chromium.org, Jan 16 (6 days ago)

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

commit ba5cf7b3d18065b934e9a55e2380450f28ad585a
Author: kylechar <kylechar@chromium.org>
Date: Wed Jan 16 14:39:37 2019

Fix web cursor transparency when scaled.

Custom web cursors with transparency were not displaying correctly when
scaled, for example when device scale factor is not 1.0. The cursor
would become fully opaque after scaling.

The helper function skia::ImageOperations::Resize() doesn't appear to
handle the alpha channel correctly with unpremultiplied alpha SkBitmaps.
SkPixmap::scaleImage() does support unpremultiplied alpha SkBitmaps so
use that instead. I filed https://crbug.com/919866 to see if
skia::ImageOperations::Resize() could just use SkPixmap::scaleImage() at
some point.

Also add a test for ScaleAndRotateCursorBitmapAndHotpoint(). There was
already a test that only ran with X11 and premultiplied alpha SkBitmap.
Make the test run on all platforms and parameterize it to run with both
alpha types.

Bug:  829517 , 919866
Change-Id: I12213b03a2569240cf4206869906fb0834217155
Reviewed-on: https://chromium-review.googlesource.com/c/1400356
Commit-Queue: kylechar <kylechar@chromium.org>
Reviewed-by: Scott Violet <sky@chromium.org>
Reviewed-by: Mike Klein <mtklein@chromium.org>
Reviewed-by: Sadrul Chowdhury <sadrul@chromium.org>
Cr-Commit-Position: refs/heads/master@{#623233}
[modify] https://crrev.com/ba5cf7b3d18065b934e9a55e2380450f28ad585a/content/test/content_test_suite.cc
[modify] https://crrev.com/ba5cf7b3d18065b934e9a55e2380450f28ad585a/content/test/content_test_suite.h
[modify] https://crrev.com/ba5cf7b3d18065b934e9a55e2380450f28ad585a/ui/base/BUILD.gn
[delete] https://crrev.com/71423ee1ddfe6dc0efa722e23408d9662d97f2f6/ui/base/cursor/cursor_loader_x11_unittest.cc
[modify] https://crrev.com/ba5cf7b3d18065b934e9a55e2380450f28ad585a/ui/base/cursor/cursor_util.cc
[add] https://crrev.com/ba5cf7b3d18065b934e9a55e2380450f28ad585a/ui/base/cursor/cursor_util_unittest.cc

Sign in to add a comment