995b467563
Bug: 932080 Bug: b/142252770 An ICO file has a directory of images that are stored later in the file. The directory contains the offset and size of the images. SkIcoCodec uses these to create embedded SkPng/SkBmpCodecs. The old implementation allocated a block of memory for each image and copied the stream into those blocks so that the embedded SkCodecs could independently read their encoded data. Although SkIcoCodec checks for null, this still allows large (albeit temporary - since we'll discard them if the stream does not contain enough data to fill them) allocations and the potential for over- commit. Instead, read the entire stream into a contiguous buffer. If the stream is already actually a buffer, just use that directly. In this case, the new code will do less work. Otherwise, the memory we allocate is limited by the size of the stream. Note that this is a behavior change for a stream that contains two consecutive ICOs, where the client expects to be able to read the second one later. This was an issue for PNGs on Android (b/34073812), but I suspect no one is relying on this behavior for ICO. Update Codec_end test to remove the ICO test. Alternatives to consider: - only buffer the individual encoded images. This will allow us to continue passing the Codec_end test. - lazily read the embedded streams. Currently we read their start to verify they are valid images (at least in the header) and read their actual sizes and bit-depths, which could differ from that listed in the directory. We use those to make a guess at the "best" image to use. An image with mismatched sizes may now decode differently. Change-Id: I30e5f6c8c2e5a0fa135348f61efe151a7f5d4756 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/277058 Auto-Submit: Leon Scroggins <scroggo@google.com> Commit-Queue: Derek Sollenberger <djsollen@google.com> Reviewed-by: Derek Sollenberger <djsollen@google.com> |
||
---|---|---|
animations | ||
bench | ||
bin | ||
build/fuchsia | ||
build_overrides | ||
client_utils/android | ||
dm | ||
docker | ||
docs/examples | ||
example | ||
experimental | ||
fuzz | ||
gm | ||
gn | ||
include | ||
infra | ||
modules | ||
platform_tools | ||
resources | ||
samplecode | ||
site | ||
specs | ||
src | ||
tests | ||
third_party | ||
tools | ||
.clang-format | ||
.clang-tidy | ||
.gitignore | ||
.gn | ||
AUTHORS | ||
BUILD.gn | ||
codereview.settings | ||
CONTRIBUTING | ||
CQ_COMMITTERS | ||
DEPS | ||
go.mod | ||
go.sum | ||
LICENSE | ||
OWNERS | ||
PRESUBMIT.py | ||
public.bzl | ||
README | ||
README.chromium | ||
RELEASE_NOTES.txt | ||
whitespace.txt |
Skia is a complete 2D graphic library for drawing Text, Geometries, and Images. See full details, and build instructions, at https://skia.org.