Open
Bug 510394
Opened 15 years ago
Updated 2 years ago
Add a way to get premultiplied data from a canvas
Categories
(Core :: Graphics, task)
Core
Graphics
Tracking
()
NEW
People
(Reporter: jrmuizel, Unassigned)
References
Details
(Keywords: perf, Whiteboard: [shumway])
Attachments
(2 files, 1 obsolete file)
(deleted),
patch
|
jrmuizel
:
review-
|
Details | Diff | Splinter Review |
(deleted),
text/html
|
Details |
get/putImageData on a canvas currently deal with non-premultiplied data. We store the data in a premultiplied form so there is a conversion cost any time these functions are called. It would be nice if authors could avoid this cost.
The best way to fix this is probably to add a format parameter to get/putImageData that specifies premultiplied data.
Comment 1•15 years ago
|
||
Please keep in mind that there are already optional parameters get/putImageData can have per the HTML5 draft...
Comment 2•13 years ago
|
||
This change sounds like a good mentored bug. If it's still relevant can you mentor this Jeff?
Updated•13 years ago
|
Whiteboard: followup
Updated•13 years ago
|
Whiteboard: followup → benwa_followup
Comment 3•13 years ago
|
||
Discussed with Jeff, we dont want to make this a mentored bug because we would like to suggest a web api for this once we see some applications bottle-necking on getImageData
Whiteboard: benwa_followup
Comment 4•11 years ago
|
||
We have a need for this in Shumway. We are currently implementing (Flash) filters, and they generally operate on premultiplied data, we thus have to premultiply before applying filters (after getImageData), and un-premultiply after (before putImageData). This is unfortunate because it reduces performance and precision (rounding).
Proposed API:
Add "premultipled" property to ImageData (Boolean, read-only)
Add optional "premultipled" arguments to:
- ImageData(data, sw, sh [,premultipled=false])
- ImageData createImageData(sw, sh [,premultipled=false]);
- ImageData getImageData(sx, sy, sw, sh [,premultipled=false]);
The resulting ImageData then contains non-premultiplied data (premultipled=false) or premultiplied data (premultipled=true). ImageData.premultipled is set accordingly.
Other methods respect ImageData.premultipled and operate accordingly (e.g., putImageData does not premultiply when ImageData.premultipled is true).
Comment 5•11 years ago
|
||
Implements the API i proposed in https://bugzilla.mozilla.org/show_bug.cgi?id=510394#c4 - (the only deviation being that i moz-prefixed ImageData.premultiplied -> ImageData.mozPremultiplied)
Attachment #8350987 -
Flags: review?(jmuizelaar)
Updated•11 years ago
|
Attachment #8350987 -
Flags: review?(jmuizelaar)
Comment 6•11 years ago
|
||
Implements the API i proposed in https://bugzilla.mozilla.org/show_bug.cgi?id=510394#c4 - (the only deviation being that i moz-prefixed ImageData.premultiplied -> ImageData.mozPremultiplied)
Attachment #8350987 -
Attachment is obsolete: true
Attachment #8350995 -
Flags: review?(jmuizelaar)
Comment 7•11 years ago
|
||
We are generally aiming to not add new prefixed DOM APIs. See <https://wiki.mozilla.org/WebAPI/ExposureGuidelines>. I assume the sr you were planning to request here would have caught that.
The right way to go about doing this is probably:
1) Raise a spec issue to add the functionality to the spec. Unless that's already been
done?
2) If you can't wait for the spec, implement the functionality as a separate function
(e.g. getImageDataPremultiplied/createImageDataPremultiplied) that's preffed off by
default but allowed in either the Shumway scope or if some pref is set (the latter so
that web developers can experiment with it as needed). That's assuming you ever plan
to expose it to the web.
This does make |new ImageData| a bit difficult, but you could use a static method on the ImageData interface, which is also preffed off by default...
Reporter | ||
Comment 8•11 years ago
|
||
Comment on attachment 8350995 [details] [diff] [review]
rev2
Review of attachment 8350995 [details] [diff] [review]:
-----------------------------------------------------------------
This seems to be a diff from the previous version. Also what bz said about standardization.
Attachment #8350995 -
Flags: review?(jmuizelaar) → review-
Comment 9•11 years ago
|
||
This would be useful for Shumway, but we would not need it if we got CSS/SVG Filters for Canvas (bug 927892).
OS: Mac OS X → All
Hardware: x86 → All
Whiteboard: [shumway]
Reporter | ||
Comment 10•11 years ago
|
||
One question to answer about this is what to do if the provided premultiplied data has values that are greater than the alpha values. The way we deal with this kind of data in the platform is undefined. i.e. Skia and cairo do different things.
Updated•10 years ago
|
Blocks: shumway-m4
Comment 11•10 years ago
|
||
We currently do premultiplication in JS. What is the maximum potential performance improvement? Milan recommends benchmarking with and without our JS premultiplication (even if the result looks bad during the test).
Assignee: nobody → mbebenita
Reporter | ||
Comment 12•10 years ago
|
||
One thing to note about exposing premultiplied data to js is that allows super luminescent pixels (where the alpha is less than the color value) this produces undefined results on some of our backends (notably skia). It's probably worth asking if we're comfortable with that.
Comment 13•10 years ago
|
||
Firefox 35 - unpremultiply 25ms, putImageData: 30ms ~ 16 fps.
Chrome 39 - unpremultiply 29ms, putImageData: 5ms ~ 30 fps.
This is all unnecessary overhead, and would completely disappear if we had a way to upload premultiplied data with putImageData.
Updated•10 years ago
|
Attachment #8494782 -
Attachment mime type: text/plain → text/html
Comment 14•9 years ago
|
||
This is still highly relevant for Shumway, but doesn't block us from shipping.
Updated•6 years ago
|
Type: defect → task
Comment 15•3 years ago
|
||
The bug assignee didn't login in Bugzilla in the last 7 months.
:bhood, could you have a look please?
For more information, please visit auto_nag documentation.
Assignee: mbebenita → nobody
Flags: needinfo?(bhood)
Updated•3 years ago
|
Flags: needinfo?(bhood)
Updated•2 years ago
|
Severity: normal → S3
You need to log in
before you can comment on or make changes to this bug.
Description
•