Closed
Bug 1187546
Opened 10 years ago
Closed 10 years ago
Make it possible to ask image decoders to only decode the first frame
Categories
(Core :: Graphics: ImageLib, defect)
Core
Graphics: ImageLib
Tracking
()
RESOLVED
FIXED
mozilla42
| Tracking | Status | |
|---|---|---|
| firefox42 | --- | fixed |
People
(Reporter: seth, Assigned: seth)
References
Details
Attachments
(1 file, 2 obsolete files)
|
7.68 KB,
patch
|
tnikkel
:
review+
|
Details | Diff | Splinter Review |
Frequently, we only need the first frame of an animated image. Such cases include:
1. Decoding for ImageBitmap, where we will decode an image, grab a surface for the first frame, and just return that.
2. If we start playing back animated images through the media framework, we'll still need to be able to decode the first frame in the traditional way to support APIs like |canvas.drawImage|.
3. If we ever decide that we want to apply downscale-during-decode to the first frame of animated images in some situations, we'd need to be able to decode only the first frame.
Case 1 is an immediate need, and case 2 seems pretty likely to become an issue in the near future, so let's add an API to Decoder to allow callers to request that only the first frame be decoded.
| Assignee | ||
Comment 1•10 years ago
|
||
Here's the patch. It's surprisingly simple.
The only oddities are in the PNG implementation. There are two things worth noting:
- I don't love the idea of making a special magic number returned from setjmp()
indicate "this is a successful early return and doesn't indicate an error", as
this seems a bit fragile to me, so I decided to use an out-of-band boolean
instead.
- Note that we consider the "first frame" of an APNG to be the first
*non-hidden* frame. This is maintain consistency with what we'd do without
this patch. We don't even bother allocating a surface for the hidden frame,
which is just a backwards compatibility feature that enables an APNG to
provide a frame that's only displayed in PNG viewers that don't support APNG.
That means we'd never have used the hidden frame for e.g.
|canvas.drawImage()|, so we shouldn't produce that frame in a first-frame-only
decode either.
I've tested this code by forcing it on all the time and viewing animated GIFs
and APNGs on the web, and it works as intended. I won't be able to actually land
tests for it until bug 1181863, though, because right now it's not exposed
through any mechanism at all. The new code in bug 1181863 will use it and make
it testable, so tests will land there.
Attachment #8638860 -
Flags: review?(tnikkel)
| Assignee | ||
Comment 2•10 years ago
|
||
Minor tweak: we now properly propagate the first-frame-only flag to PNG-in-ICO.
Attachment #8638866 -
Flags: review?(tnikkel)
| Assignee | ||
Updated•10 years ago
|
Attachment #8638860 -
Attachment is obsolete: true
Attachment #8638860 -
Flags: review?(tnikkel)
| Assignee | ||
Comment 3•10 years ago
|
||
Once I wrote the tests for bug 1181863, I noticed a couple of issues with this
patch:
- There was an assertion in Decoder's destructor that we consumed all progress
and all invalidations generated by the decoder. I don't think this assertion
makes sense when we don't have an image, so I've modified the assertion to not
fire in that case.
- We needed to pass the fact that we're only decoding the first frame through
from nsICODecoder to the BMP decoder as well, because even though it has no
effect on the results in that case, we do trigger an assertion in Decoder if
we don't pass it through since the BMP decoder doesn't have an image.
With those changes made, everything looks good.
Attachment #8640021 -
Flags: review?(tnikkel)
| Assignee | ||
Updated•10 years ago
|
Attachment #8638866 -
Attachment is obsolete: true
Attachment #8638866 -
Flags: review?(tnikkel)
Comment 4•10 years ago
|
||
Comment on attachment 8640021 [details] [diff] [review]
Make it possible to ask image decoders to only decode the first frame
I don't know the internals of the decoders that well. Is there anyone who does?
Attachment #8640021 -
Flags: review?(tnikkel) → review+
| Assignee | ||
Comment 5•10 years ago
|
||
(In reply to Timothy Nikkel (:tn) from comment #4)
> Comment on attachment 8640021 [details] [diff] [review]
> Make it possible to ask image decoders to only decode the first frame
>
> I don't know the internals of the decoders that well. Is there anyone who
> does?
I'm not really sure. I think Jeff has some knowledge of them. Glenn is definitely the most knowledgeable person about the PNG decoder.
| Assignee | ||
Comment 6•10 years ago
|
||
Comment 7•10 years ago
|
||
Status: NEW → RESOLVED
Closed: 10 years ago
status-firefox42:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla42
You need to log in
before you can comment on or make changes to this bug.
Description
•