in components/image_fetcher the callback API to retrieve an image is:
base::Callback<void(const GURL&, const SkBitmap*)>
SKBitmap is not a good choice for an image. Fetched images have metadata that are completely lost when converted to SKbitmap (Scale is the big one, but any other metdata is also an issue). In addition, on iOS an SkBitmap is not exploitable as is, it needs to be imaged into a backing store. This means that on iOS, fetching a PNG at 3X with this API will retrieve the bits from the network, make an UIImage out of it by decompressing and imaging, extract an SkBitmap, pass it along, and when the bitmap is wanted on a screen it is retransformed into a UIImage, at 1x. All this makes fetching an image an expensive proposition.
I would suggest to change this API to
base::Callback<void(const GURL&, const SkImage*)>
SkImage can encapsulate any native representation, and can be bridged to and from SkBitmap if needed (but this should be avoided on iOS at all cost).
Note that SkImage is *not* thread safe. It simply refcount its representations and this refcount is not safe across thread boundary.
There are two implementations of the interface, one in ios/ the other one in chrome/. Those should probably move to the component as well.
It is important to know that the iOS implementation also does WebP transcoding (WebP is not supported natively by UIImage) by encapsulating a completely unrelated class unfortunately also named image_fetcher, but located in ios/net/. That one doesn't need to change probably.
Comment 1 by treib@chromium.org
, May 10 2016