Use SkCodec internally in GIFImageDecoder

Desktop / Chromium - cblume [chromium.org] - 17 August 2017 14:19 UTC

Previously, GIFImageDecoder used GIFImageReader internally. SkCodec uses a modified version of that class (SkGifImageReader; adapted in crrev.com/2045293002). SkCodec provides the following benefits:- SIMD optimized code for writing pixels- an API that allows the client to handle caching- flexibility regarding the required frame to use- the ability to decode scaled versions of images- subset decoding (i.e. issue 468914) (not fully implemented for GIF)- the ability to decode to half-width float format

In addition, this patch enables sharing code between Android, Skia, and Chromium. This means that new features/bug fixes in Android benefit Chromium and vice versa.

For larger images (above ~60x60), the SIMD optimizations show a much bigger benefit (up to 24% in one case). For most images, decoding speed is about the same. Images with many frames that contain tiny update regions are a hair slower. The mean decode time across all tested images showed an improvement. Raw performance numbers can be found here: https://docs.google.com/spreadsheets/d/1JqCPdYmbasOwKRdvuG6ZI4gwq9dPvnJA9oDquh7SxOQ/edit?usp=sharing

GIFImageDecoder still handles the cached frames currently, but this change will allow future changes in Blink to make wiser caching Decisions (such as keeping all frames of a 3-frame animation if those frames are small). Full road map: https://docs.google.com/a/chromium.org/document/d/1T06pxiff3oy8KDqWGqWL-_nZqUJ8AMppouPQ_DLrvpk/edit?usp=sharing

This results in some behavior changes:- SkCodec does not check the alpha of each pixel during decode (for speed and simplicity). As a result, GIFImageDecoder no longer corrects opacity or the required frame after decoding a frame. No performance penalty has been observed for incorrectly leaving a frame marked as having transparency.- SkCodec guesses transparency based on the presence of a transparent index (in addition to being subset) and uses this to potentially determine an earlier required frame.

BUG=715812

Review-Url: https://codereview.chromium.org/2565323003 Cr-Commit-Position: refs/heads/master@{#495230}

4fed334 Use SkCodec internally in GIFImageDecoder
skia/BUILD.gn | 29 +
third_party/WebKit/Source/platform/BUILD.gn | 5 +-
.../Source/platform/image-decoders/ImageDecoder.h | 13 +-
.../Source/platform/image-decoders/ImageFrame.cpp | 15 +-
.../Source/platform/image-decoders/ImageFrame.h | 2 +-
.../platform/image-decoders/SegmentStream.cpp | 102 +++
.../Source/platform/image-decoders/SegmentStream.h | 51 ++
.../platform/image-decoders/SegmentStreamTest.cpp | 702 ++++++++++++++++
.../image-decoders/gif/GIFImageDecoder.cpp | 438 +++++-----
.../platform/image-decoders/gif/GIFImageDecoder.h | 54 +-
.../image-decoders/gif/GIFImageDecoderTest.cpp | 30 +-
.../platform/image-decoders/gif/GIFImageReader.cpp | 900 ---------------------
.../platform/image-decoders/gif/GIFImageReader.h | 371 ---------
13 files changed, 1179 insertions(+), 1533 deletions(-)

Upstream: git.chromium.org


  • Share