Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1002)

Issue 2756463003: Remove opaque alpha channel special case (Closed)

Created:
3 years, 9 months ago by cblume
Modified:
3 years, 3 months ago
CC:
blink-reviews, chromium-reviews, jzern, kinuko+watch, skal, urvang, aelias_OOO_until_Jul13
Target Ref:
refs/heads/master
Project:
chromium
Visibility:
Public.

Description

Remove opaque alpha channel special case The image decoders which support alpha have a special case to handle situations where the alpha channel is unused. This can come up from a handful of cases but the net effect is we are detecting if the image was actually opaque, despite the image being encoded to say that it wasn't. Some scenarios where this could happen are: 1.) a gif frame's palette includes transparency but no pixels use that transparent palette entry, 2.) an animation frame completely covering the previous frame & having no transparent pixels, and 3.) an animation frame partially covering a previous frame, but the previous frame containing no visible transparent pixels. Scenario #1 is O(n) over the frame's pixel data. After timing [1], we see that the image decodes slow down marginally because setting the alpha bit was effectively prefetching memory. Raster times were slower for small images and faster for large images. [1] Requires @google.com account https://docs.google.com/a/google.com/spreadsheets/d/1kzJmvn7hEONCcMlwi4sZnTSz9QxpaI_GQEziQgryJc0/edit?usp=sharing R=scroggo@chromium.org BUG=702059

Patch Set 1 #

Total comments: 2

Patch Set 2 : Fixing first-pixel alpha case #

Total comments: 2

Patch Set 3 : Rebasing #

Patch Set 4 : Updating tests to not assume opaque detection #

Patch Set 5 : Rebasing #

Patch Set 6 : Hopefully this rebase works #

Patch Set 7 : Fix gif detecting if a frame claims to have transparency #

Total comments: 9

Patch Set 8 : Rebasing #

Patch Set 9 : Code review comments #

Total comments: 10

Patch Set 10 : Correct comments #

Patch Set 11 : Check that the transparent pixel index is within range #

Patch Set 12 : Fix build #

Patch Set 13 : Fix IsAlphaSupported returning the inverse #

Total comments: 16

Patch Set 14 : Fix mistake where variables were incorrectly pulled out of a branch #

Patch Set 15 : Clarify comment for test_gif #

Patch Set 16 : Correct inverted conditional. Add DCHECK for assumed condition #

Patch Set 17 : Remove redundant conditional #

Total comments: 14

Patch Set 18 : Clarify comment #

Patch Set 19 : Only set bmp alpha when we detect actual alpha #

Total comments: 1

Patch Set 20 : Checking if JPEGImageDecoder::OutputScanlines()'s SetHasAlpha(true) is under test #

Unified diffs Side-by-side diffs Delta from patch set Stats (+41 lines, -118 lines) Patch
M third_party/WebKit/Source/platform/graphics/DeferredImageDecoderTest.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 2 chunks +8 lines, -3 lines 0 comments Download
M third_party/WebKit/Source/platform/image-decoders/ImageDecoder.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 1 chunk +0 lines, -12 lines 0 comments Download
M third_party/WebKit/Source/platform/image-decoders/ImageDecoder.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 1 chunk +0 lines, -51 lines 0 comments Download
M third_party/WebKit/Source/platform/image-decoders/bmp/BMPImageReader.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1 chunk +4 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/platform/image-decoders/bmp/BMPImageReader.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 2 chunks +16 lines, -15 lines 0 comments Download
M third_party/WebKit/Source/platform/image-decoders/gif/GIFImageDecoder.h View 1 2 3 4 5 6 7 8 9 1 chunk +0 lines, -5 lines 0 comments Download
M third_party/WebKit/Source/platform/image-decoders/gif/GIFImageDecoder.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 4 chunks +10 lines, -10 lines 0 comments Download
M third_party/WebKit/Source/platform/image-decoders/gif/GIFImageDecoderTest.cpp View 1 2 3 4 5 6 7 8 9 1 chunk +1 line, -1 line 0 comments Download
M third_party/WebKit/Source/platform/image-decoders/png/PNGImageDecoder.h View 1 2 3 4 5 6 7 1 chunk +0 lines, -1 line 0 comments Download
M third_party/WebKit/Source/platform/image-decoders/png/PNGImageDecoder.cpp View 1 2 3 4 5 6 7 8 9 10 11 6 chunks +1 line, -16 lines 0 comments Download
M third_party/WebKit/Source/platform/image-decoders/webp/WEBPImageDecoder.cpp View 1 2 3 4 5 6 7 8 9 1 chunk +1 line, -2 lines 0 comments Download

Messages

Total messages: 99 (59 generated)
Peter Kasting
This CL mixes three separate changes: (1) zeroFillPixelData() should call setHasAlpha(true), and WebP/JPEG do not ...
3 years, 9 months ago (2017-03-16 04:37:14 UTC) #7
cblume
+Matt -- If I remember correctly, we saw there is no longer a speed benefit ...
3 years, 9 months ago (2017-03-16 09:36:47 UTC) #10
msarett
> +Matt -- If I remember correctly, we saw there is no longer a speed ...
3 years, 9 months ago (2017-03-16 14:04:14 UTC) #13
Peter Kasting
https://codereview.chromium.org/2756463003/diff/20001/third_party/WebKit/Source/platform/image-decoders/bmp/BMPImageReader.cpp File third_party/WebKit/Source/platform/image-decoders/bmp/BMPImageReader.cpp (right): https://codereview.chromium.org/2756463003/diff/20001/third_party/WebKit/Source/platform/image-decoders/bmp/BMPImageReader.cpp#newcode825 third_party/WebKit/Source/platform/image-decoders/bmp/BMPImageReader.cpp:825: } else I'm still confused. If you really want ...
3 years, 9 months ago (2017-03-16 19:43:27 UTC) #14
cblume
https://codereview.chromium.org/2756463003/diff/20001/third_party/WebKit/Source/platform/image-decoders/bmp/BMPImageReader.cpp File third_party/WebKit/Source/platform/image-decoders/bmp/BMPImageReader.cpp (right): https://codereview.chromium.org/2756463003/diff/20001/third_party/WebKit/Source/platform/image-decoders/bmp/BMPImageReader.cpp#newcode825 third_party/WebKit/Source/platform/image-decoders/bmp/BMPImageReader.cpp:825: } else On 2017/03/16 19:43:27, Peter Kasting wrote: > ...
3 years, 9 months ago (2017-03-16 20:39:45 UTC) #15
Peter Kasting
On 2017/03/16 20:39:45, cblume wrote: > https://codereview.chromium.org/2756463003/diff/20001/third_party/WebKit/Source/platform/image-decoders/bmp/BMPImageReader.cpp > File third_party/WebKit/Source/platform/image-decoders/bmp/BMPImageReader.cpp > (right): > > https://codereview.chromium.org/2756463003/diff/20001/third_party/WebKit/Source/platform/image-decoders/bmp/BMPImageReader.cpp#newcode825 ...
3 years, 9 months ago (2017-03-16 22:36:35 UTC) #16
cblume
On 2017/03/16 22:36:35, Peter Kasting wrote: > On 2017/03/16 20:39:45, cblume wrote: > > > ...
3 years, 9 months ago (2017-03-16 23:07:50 UTC) #17
Peter Kasting
On 2017/03/16 23:07:50, cblume wrote: > On 2017/03/16 22:36:35, Peter Kasting wrote: > > On ...
3 years, 9 months ago (2017-03-17 00:47:49 UTC) #18
cblume
On 2017/03/17 00:47:49, Peter Kasting wrote: > > An alternative interpretation is this patch is ...
3 years, 9 months ago (2017-03-17 20:53:15 UTC) #19
Peter Kasting
On 2017/03/17 20:53:15, cblume wrote: > On 2017/03/17 00:47:49, Peter Kasting wrote: > > > ...
3 years, 9 months ago (2017-03-17 21:12:15 UTC) #20
Stephen White
On 2017/03/16 14:04:14, msarett wrote: > > +Matt -- If I remember correctly, we saw ...
3 years, 9 months ago (2017-03-21 14:00:40 UTC) #21
cblume
There were some tests that were failing because they expected the special case of opaque ...
3 years, 9 months ago (2017-03-21 19:27:34 UTC) #28
Peter Kasting
On 2017/03/21 19:27:34, cblume wrote: > What I do NOT want to get rid of ...
3 years, 9 months ago (2017-03-21 19:36:40 UTC) #31
cblume
On 2017/03/21 19:36:40, Peter Kasting wrote: > On 2017/03/21 19:27:34, cblume wrote: > > What ...
3 years, 9 months ago (2017-03-21 21:13:37 UTC) #32
cblume
I've fixed the gif decoder to set the transparency to what is claimed in the ...
3 years, 9 months ago (2017-03-22 16:57:34 UTC) #41
msarett1
On 2017/03/22 16:57:34, cblume wrote: > I've fixed the gif decoder to set the transparency ...
3 years, 9 months ago (2017-03-22 17:04:07 UTC) #42
Peter Kasting
Looks like this probably needs a rebase. Main issue in terms of doing what you ...
3 years, 9 months ago (2017-03-22 23:37:47 UTC) #43
cblume
I'm working on measuring the timing for this. My measurements right now are surprising. When ...
3 years, 7 months ago (2017-05-04 09:41:38 UTC) #44
scroggo_chromium
On 2017/05/04 09:41:38, cblume wrote: > I'm working on measuring the timing for this. > ...
3 years, 7 months ago (2017-05-04 13:15:38 UTC) #46
cblume
https://codereview.chromium.org/2756463003/diff/120001/third_party/WebKit/Source/platform/image-decoders/gif/GIFImageDecoder.cpp File third_party/WebKit/Source/platform/image-decoders/gif/GIFImageDecoder.cpp (left): https://codereview.chromium.org/2756463003/diff/120001/third_party/WebKit/Source/platform/image-decoders/gif/GIFImageDecoder.cpp#oldcode172 third_party/WebKit/Source/platform/image-decoders/gif/GIFImageDecoder.cpp:172: m_currentBufferSawAlpha = true; I confirmed this line is making ...
3 years, 7 months ago (2017-05-05 00:05:20 UTC) #47
cblume
https://codereview.chromium.org/2756463003/diff/120001/third_party/WebKit/Source/platform/image-decoders/ImageFrame.cpp File third_party/WebKit/Source/platform/image-decoders/ImageFrame.cpp (right): https://codereview.chromium.org/2756463003/diff/120001/third_party/WebKit/Source/platform/image-decoders/ImageFrame.cpp#newcode81 third_party/WebKit/Source/platform/image-decoders/ImageFrame.cpp:81: setHasAlpha(true); On 2017/03/22 23:37:46, Peter Kasting wrote: > Seems ...
3 years, 7 months ago (2017-05-08 10:28:03 UTC) #52
scroggo_chromium
https://codereview.chromium.org/2756463003/diff/160001/third_party/WebKit/Source/platform/graphics/DeferredImageDecoderTest.cpp File third_party/WebKit/Source/platform/graphics/DeferredImageDecoderTest.cpp (right): https://codereview.chromium.org/2756463003/diff/160001/third_party/WebKit/Source/platform/graphics/DeferredImageDecoderTest.cpp#newcode355 third_party/WebKit/Source/platform/graphics/DeferredImageDecoderTest.cpp:355: // After decoding, the frame is known to be ...
3 years, 7 months ago (2017-05-08 14:56:36 UTC) #57
cblume
Shoot. I combined a rebase and changes. Sorry. https://codereview.chromium.org/2756463003/diff/160001/third_party/WebKit/Source/platform/graphics/DeferredImageDecoderTest.cpp File third_party/WebKit/Source/platform/graphics/DeferredImageDecoderTest.cpp (right): https://codereview.chromium.org/2756463003/diff/160001/third_party/WebKit/Source/platform/graphics/DeferredImageDecoderTest.cpp#newcode355 third_party/WebKit/Source/platform/graphics/DeferredImageDecoderTest.cpp:355: // ...
3 years, 7 months ago (2017-05-25 06:52:36 UTC) #62
cblume
https://codereview.chromium.org/2756463003/diff/160001/third_party/WebKit/Source/platform/image-decoders/gif/GIFImageDecoder.cpp File third_party/WebKit/Source/platform/image-decoders/gif/GIFImageDecoder.cpp (right): https://codereview.chromium.org/2756463003/diff/160001/third_party/WebKit/Source/platform/image-decoders/gif/GIFImageDecoder.cpp#newcode195 third_party/WebKit/Source/platform/image-decoders/gif/GIFImageDecoder.cpp:195: buffer.SetHasAlpha(transparent_pixel != kNotFound); On 2017/05/08 14:56:36, scroggo_chromium wrote: > ...
3 years, 7 months ago (2017-05-25 07:47:04 UTC) #63
cblume
https://codereview.chromium.org/2756463003/diff/160001/third_party/WebKit/Source/platform/image-decoders/bmp/BMPImageReader.h File third_party/WebKit/Source/platform/image-decoders/bmp/BMPImageReader.h (right): https://codereview.chromium.org/2756463003/diff/160001/third_party/WebKit/Source/platform/image-decoders/bmp/BMPImageReader.h#newcode247 third_party/WebKit/Source/platform/image-decoders/bmp/BMPImageReader.h:247: return GetComponent(pixel, 3); On 2017/05/08 14:56:36, scroggo_chromium wrote: > ...
3 years, 7 months ago (2017-05-25 09:45:37 UTC) #64
scroggo_chromium
https://codereview.chromium.org/2756463003/diff/240001/third_party/WebKit/Source/platform/graphics/DeferredImageDecoderTest.cpp File third_party/WebKit/Source/platform/graphics/DeferredImageDecoderTest.cpp (right): https://codereview.chromium.org/2756463003/diff/240001/third_party/WebKit/Source/platform/graphics/DeferredImageDecoderTest.cpp#newcode362 third_party/WebKit/Source/platform/graphics/DeferredImageDecoderTest.cpp:362: // When the file is a PNG (test_gif is ...
3 years, 6 months ago (2017-05-30 19:45:17 UTC) #69
cblume
https://codereview.chromium.org/2756463003/diff/160001/third_party/WebKit/Source/platform/image-decoders/bmp/BMPImageReader.cpp File third_party/WebKit/Source/platform/image-decoders/bmp/BMPImageReader.cpp (right): https://codereview.chromium.org/2756463003/diff/160001/third_party/WebKit/Source/platform/image-decoders/bmp/BMPImageReader.cpp#newcode821 third_party/WebKit/Source/platform/image-decoders/bmp/BMPImageReader.cpp:821: seen_zero_alpha_pixel_ = true; On 2017/05/08 14:56:36, scroggo_chromium wrote: > ...
3 years, 6 months ago (2017-05-30 23:37:34 UTC) #71
cblume
https://codereview.chromium.org/2756463003/diff/240001/third_party/WebKit/Source/platform/graphics/DeferredImageDecoderTest.cpp File third_party/WebKit/Source/platform/graphics/DeferredImageDecoderTest.cpp (right): https://codereview.chromium.org/2756463003/diff/240001/third_party/WebKit/Source/platform/graphics/DeferredImageDecoderTest.cpp#newcode362 third_party/WebKit/Source/platform/graphics/DeferredImageDecoderTest.cpp:362: // When the file is a PNG (test_gif is ...
3 years, 6 months ago (2017-05-30 23:42:13 UTC) #73
cblume
https://codereview.chromium.org/2756463003/diff/240001/third_party/WebKit/Source/platform/image-decoders/bmp/BMPImageReader.cpp File third_party/WebKit/Source/platform/image-decoders/bmp/BMPImageReader.cpp (right): https://codereview.chromium.org/2756463003/diff/240001/third_party/WebKit/Source/platform/image-decoders/bmp/BMPImageReader.cpp#newcode149 third_party/WebKit/Source/platform/image-decoders/bmp/BMPImageReader.cpp:149: ((info_header_.bi_bit_count < 16) || IsAlphaSupported() || On 2017/05/30 19:45:17, ...
3 years, 6 months ago (2017-05-30 23:45:14 UTC) #74
cblume
https://codereview.chromium.org/2756463003/diff/240001/third_party/WebKit/Source/platform/image-decoders/gif/GIFImageDecoder.cpp File third_party/WebKit/Source/platform/image-decoders/gif/GIFImageDecoder.cpp (right): https://codereview.chromium.org/2756463003/diff/240001/third_party/WebKit/Source/platform/image-decoders/gif/GIFImageDecoder.cpp#newcode199 third_party/WebKit/Source/platform/image-decoders/gif/GIFImageDecoder.cpp:199: buffer.SetHasAlpha(transparent_pixel != kNotFound && On 2017/05/30 19:45:17, scroggo_chromium wrote: ...
3 years, 6 months ago (2017-05-30 23:47:13 UTC) #75
scroggo_chromium
> Remove opaque alpha channel special case > > The image decoders which support alpha ...
3 years, 6 months ago (2017-05-31 14:27:50 UTC) #80
cblume
https://codereview.chromium.org/2756463003/diff/320001/third_party/WebKit/Source/platform/graphics/DeferredImageDecoderTest.cpp File third_party/WebKit/Source/platform/graphics/DeferredImageDecoderTest.cpp (right): https://codereview.chromium.org/2756463003/diff/320001/third_party/WebKit/Source/platform/graphics/DeferredImageDecoderTest.cpp#newcode362 third_party/WebKit/Source/platform/graphics/DeferredImageDecoderTest.cpp:362: // The PNG file used by this test (when ...
3 years, 6 months ago (2017-05-31 18:09:05 UTC) #81
cblume
https://codereview.chromium.org/2756463003/diff/320001/third_party/WebKit/Source/platform/image-decoders/bmp/BMPImageReader.cpp File third_party/WebKit/Source/platform/image-decoders/bmp/BMPImageReader.cpp (right): https://codereview.chromium.org/2756463003/diff/320001/third_party/WebKit/Source/platform/image-decoders/bmp/BMPImageReader.cpp#newcode831 third_party/WebKit/Source/platform/image-decoders/bmp/BMPImageReader.cpp:831: } else { On 2017/05/31 14:27:50, scroggo_chromium wrote: > ...
3 years, 6 months ago (2017-05-31 19:40:37 UTC) #84
cblume
https://codereview.chromium.org/2756463003/diff/320001/third_party/WebKit/Source/platform/image-decoders/gif/GIFImageDecoder.cpp File third_party/WebKit/Source/platform/image-decoders/gif/GIFImageDecoder.cpp (right): https://codereview.chromium.org/2756463003/diff/320001/third_party/WebKit/Source/platform/image-decoders/gif/GIFImageDecoder.cpp#newcode186 third_party/WebKit/Source/platform/image-decoders/gif/GIFImageDecoder.cpp:186: // Initialize the frame if necessary. Some GIFs insert ...
3 years, 6 months ago (2017-05-31 20:35:06 UTC) #85
cblume
https://codereview.chromium.org/2756463003/diff/320001/third_party/WebKit/Source/platform/image-decoders/png/PNGImageDecoder.cpp File third_party/WebKit/Source/platform/image-decoders/png/PNGImageDecoder.cpp (right): https://codereview.chromium.org/2756463003/diff/320001/third_party/WebKit/Source/platform/image-decoders/png/PNGImageDecoder.cpp#newcode272 third_party/WebKit/Source/platform/image-decoders/png/PNGImageDecoder.cpp:272: has_alpha_channel_ = (channels == 4); On 2017/05/31 14:27:50, scroggo_chromium ...
3 years, 6 months ago (2017-05-31 21:05:29 UTC) #90
scroggo_chromium
> The first case is O(n) for the size of the color palette. After timing ...
3 years, 6 months ago (2017-05-31 21:12:15 UTC) #91
cblume
On 2017/05/31 21:12:15, scroggo_chromium wrote: > > The first case is O(n) for the size ...
3 years, 6 months ago (2017-05-31 21:51:18 UTC) #94
scroggo_chromium
> I would be happy to switch directly to SkGifCodec without this intermediate. > In ...
3 years, 6 months ago (2017-06-01 12:14:07 UTC) #97
cblume
There is an interesting update here. I still consider this patch abandoned since it will ...
3 years, 4 months ago (2017-08-10 20:52:12 UTC) #98
Peter Kasting
3 years, 3 months ago (2017-08-29 03:58:50 UTC) #99
Message was sent while issue was closed.
Marking closed since patch is abandoned.

Powered by Google App Engine
This is Rietveld 408576698