[Webkit-unassigned] [Bug 90375] Parallel image decoders

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Wed Aug 1 16:44:10 PDT 2012


https://bugs.webkit.org/show_bug.cgi?id=90375





--- Comment #53 from Hin-Chung Lam <hclam at google.com>  2012-08-01 16:44:06 PST ---
Now that I tried to remove currentFrameHasAlpha, I found the results not satisfactory. The reason is I need to disable some optimizations to achieve this, which might upset users that rely on this API.

I think it's better to keep Image::currentFrameHasAlpha() but change the implementation in BitmapImage. Like the patch I drafted BitmapImage shouldn't call ensureFrameIsCached() to decode a frame and return the result. Instead BitmapImage should just return the value of ImageSource::frameHasAlphaAtIndex() which calls into the image decoder to answer the call.

Yes it has the problem that you mentioned before, e.g.

image->currentFrameHasAlpha() // return true
... some time later ...
NativeImagePtr* image = image->nativeImageForCurrentFrame(); // image doesn't have alpha

However it really doesn't matter, assuming an image has alpha is safe. Look at ImageSourceCG.cpp for example, it shows that currentFrameHasAlpha() doesn't need to return the correct value.

bool ImageSource::frameHasAlphaAtIndex(size_t)
{
    if (!m_decoder)
        return false;

    CFStringRef imageType = CGImageSourceGetType(m_decoder);

    // Return false if there is no image type or the image type is JPEG, because
    // JPEG does not support alpha transparency.
    if (!imageType || CFEqual(imageType, CFSTR("public.jpeg")))
        return false;

    // FIXME: Could return false for other non-transparent image formats.
    // FIXME: Could maybe return false for a GIF Frame if we have enough info in the GIF properties dictionary
    // to determine whether or not a transparent color was defined.
    return true;
}

Instead it is enough for currentFrameHasAlpha to return the best guess. By calling directly into each image decoder we can answer this call good enough, until the image is fully decoded.

So I suggest the first step is to remove decoding caused by currentFrameHasAlpha, this way nativeImageForCurrentFrame being the only public method that triggers image decoding.

frameIsCompleteAtIndex and frameDurationAtIndex are for GIF animation, I would consider them a separate problem.

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list