Closed
Bug 1181863
Opened 9 years ago
Closed 9 years ago
Add a function similar to imgTools::DecodeImage which works off-main-thread
Categories
(Core :: Graphics: ImageLib, defect)
Core
Graphics: ImageLib
Tracking
()
RESOLVED
FIXED
mozilla42
Tracking | Status | |
---|---|---|
firefox42 | --- | fixed |
People
(Reporter: seth, Assigned: seth)
References
(Blocks 1 open bug)
Details
Attachments
(3 files, 3 obsolete files)
(deleted),
patch
|
tnikkel
:
review+
|
Details | Diff | Splinter Review |
(deleted),
patch
|
tnikkel
:
review+
|
Details | Diff | Splinter Review |
(deleted),
patch
|
tnikkel
:
review+
|
Details | Diff | Splinter Review |
It'd be much better if imgTools::DecodeImage worked off-main-thread, especially now that we have DOM interfaces like ImageBitmap that can trigger decoding in workers.
I think the best way to do this is to eliminate DecodeImage's dependency on RasterImage and just implement it directly against Decoder/DecodePool. That will require reducing the coupling between Decoder/DecodePool and RasterImage, but I don't think that will actually be a huge amount of work.
Assignee | ||
Updated•9 years ago
|
Summary: Make imgTools::DecodeImage work off-main-thread → Add a function similar to imgTools::DecodeImage which works off-main-thread
Assignee | ||
Comment 1•9 years ago
|
||
Finally, all the prerequisites are in place to implement this. Here's the patch.
Mostly pretty straightforward, although the code in imgTools::DecodeSurface() is
unfortunately a bit verbose because of the interaction with nsIInputStream.
Part 2 will follow with tests.
Attachment #8638865 -
Flags: review?(tnikkel)
Assignee | ||
Updated•9 years ago
|
Attachment #8638865 -
Attachment is obsolete: true
Attachment #8638865 -
Flags: review?(tnikkel)
Assignee | ||
Comment 2•9 years ago
|
||
In the interests of cleaner code, I've added a new part 1 which moves the code
that reads from an nsIInputStream into a SourceBuffer directly into the
SourceBuffer class. This allows RasterImage and the new method we're adding in
part 2 to share the same code.
Attachment #8640092 -
Flags: review?(tnikkel)
Assignee | ||
Comment 3•9 years ago
|
||
This version of part 2 is the same except that:
- It uses the new code added in part 1 to append from an nsIInputStream to a
SourceBuffer.
- I moved the new method from imgITools to ImageOps. Placing the new method on
imgITools seemed pointless because it's a C++-only method, and putting it
there requires an ugly boilerplate do_CreateInstance() call at every callsite.
Attachment #8640097 -
Flags: review?(tnikkel)
Assignee | ||
Comment 4•9 years ago
|
||
This part adds reasonably comprehensive tests for DecodeToSurface(). The patch
is a bit bigger than it otherwise might be because these are the first gtests in
ImageLib. I'd like to add many more in the long term, though, so I've tried to
keep things as reusable as possible.
Everything should be pretty straightforward - there are shared helper functions
and testcases in Common.h, with the testcases being implemented as data URIs.
Each of the tests loads one of these data URIs, packages up the resulting
nsIInputStream in a runnable, and runs DecodeToSurface() off-main-thread. We
then verify some basic properties of the surface, and walk over its data using
the IsSolidColor() function to verify that DecodeToSurface() produced the
results we expect. In this case, every test but the corrupt one is intended to
produce an all-green surface.
There's a slightly ugly thing happening here - I needed to force XPCOM to
initialize the image module at the beginning to ensure the right initialization
order - that's done in the ImageModuleAvailable test, as documented in the
comment there. Otherwise I got failures in the Necko code (!!). I don't like
this, but it doesn't seem worth resolving as part of this bug.
Attachment #8640102 -
Flags: review?(tnikkel)
Assignee | ||
Comment 5•9 years ago
|
||
Assignee | ||
Comment 6•9 years ago
|
||
Minor tweak here to make sure we use the right calling convention for the callback.
Attachment #8640849 -
Flags: review?(tnikkel)
Assignee | ||
Updated•9 years ago
|
Attachment #8640092 -
Attachment is obsolete: true
Attachment #8640092 -
Flags: review?(tnikkel)
Assignee | ||
Comment 7•9 years ago
|
||
I reworked the tests to load the testcase images from a file instead of using
data URIs, because MSVC has a 16k limit on string literals. =\
Really, this may be for the best, though. Having the testcase images in separate
files is definitely convenient.
Attachment #8640850 -
Flags: review?(tnikkel)
Assignee | ||
Updated•9 years ago
|
Attachment #8640102 -
Attachment is obsolete: true
Attachment #8640102 -
Flags: review?(tnikkel)
Assignee | ||
Comment 8•9 years ago
|
||
Updated•9 years ago
|
Attachment #8640849 -
Flags: review?(tnikkel) → review+
Updated•9 years ago
|
Attachment #8640097 -
Flags: review?(tnikkel) → review+
Updated•9 years ago
|
Attachment #8640850 -
Flags: review?(tnikkel) → review+
Assignee | ||
Comment 9•9 years ago
|
||
Comment 10•9 years ago
|
||
good-guy-ehsan |
Comment 11•9 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/3e8dd82cbf50
https://hg.mozilla.org/mozilla-central/rev/44dc3228c00b
https://hg.mozilla.org/mozilla-central/rev/4d7cd400d799
https://hg.mozilla.org/mozilla-central/rev/ca56c20306df
Status: NEW → RESOLVED
Closed: 9 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
•