Closed Bug 982480 Opened 11 years ago Closed 11 years ago

Add support for the alpha option to the canvas context options

Categories

(Core :: Graphics: Canvas2D, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla30
Tracking Status
relnote-firefox --- 30+
relnote-b2g --- ?

People

(Reporter: cabanier, Assigned: cabanier)

References

(Blocks 1 open bug)

Details

(Keywords: dev-doc-complete, relnote)

Attachments

(1 file, 6 obsolete files)

WhatWG proposal is here: http://wiki.whatwg.org/wiki/CanvasOpaque Summary The proposed API is to allow developers to request an opaque backing store for 2D Canvas. This mirrors existing functionality in WebGL. From the discussions on WhatWG and webkit-dev, Mozilla has expressed public support, and has provided feedback to guide the proposal into its current form. Chrome has already implemented this feature and it is being used by some Google products Chrome bug: https://code.google.com/p/chromium/issues/detail?id=234297
Assignee: nobody → cabanier
Blocks: 631640
Attachment #8389608 - Flags: review?(roc)
Attached patch Added implementation + test case (obsolete) — Splinter Review
- Fixed logic so size is set before the options. - changed interface so context is queried for opaque-ness - made sure that if context is opaque, it is always created (since it should display as black)
Attachment #8389608 - Attachment is obsolete: true
Attachment #8389608 - Flags: review?(roc)
Attachment #8390088 - Flags: review?(roc)
Comment on attachment 8390088 [details] [diff] [review] Added implementation + test case Review of attachment 8390088 [details] [diff] [review]: ----------------------------------------------------------------- ::: content/canvas/src/CanvasRenderingContext2D.cpp @@ +1065,5 @@ > // Use software when there is going to be a lot of readback > mForceSoftware = attributes.mWillReadFrequently; > } > > + SetIsOpaque(attributes.mAlpha == false); !attributes.mAlpha ::: content/canvas/test/test_canvas.html @@ +21582,5 @@ > +<script type="text/javascript"> > + > +function test_opaque() { > + var c = document.getElementById("c688"); > + var ctx = c.getContext("2d", {alpha: true}); Shouldn't this be "alpha:false"?
Attachment #8390088 - Flags: review?(roc) → review-
Comment on attachment 8390088 [details] [diff] [review] Added implementation + test case Review of attachment 8390088 [details] [diff] [review]: ----------------------------------------------------------------- ::: content/canvas/test/test_canvas.html @@ +21582,5 @@ > +<script type="text/javascript"> > + > +function test_opaque() { > + var c = document.getElementById("c688"); > + var ctx = c.getContext("2d", {alpha: true}); yes! How did this pass the try bots? I will run them again.
Attached patch Added implementation + test case (obsolete) — Splinter Review
Fixed test case. Also fixed getImageData as not all platforms set the alpha channel to 255.
Attachment #8390088 - Attachment is obsolete: true
Attachment #8390713 - Flags: review?(roc)
Attached patch Added implementation + test case (obsolete) — Splinter Review
removed obsolete comment
Attachment #8390713 - Attachment is obsolete: true
Attachment #8390713 - Flags: review?(roc)
Attachment #8390979 - Flags: review?(roc)
Keywords: dev-doc-needed
Keywords: checkin-needed
patching file content/canvas/src/CanvasRenderingContext2D.cpp bad hunk #3 @@ -3802,16 +3808,41 @@ CanvasRenderingContext2D::GetImageDataAr (17 16 41 41)
Keywords: checkin-needed
Attached patch Added implementation + test case (obsolete) — Splinter Review
Attachment #8390979 - Attachment is obsolete: true
Keywords: checkin-needed
Attachment #8391277 - Attachment is obsolete: true
successful try run: https://tbpl.mozilla.org/?tree=Try&rev=fc25121a3260 everything is green this time. Sorry about not noticing the failures earlier.
Attachment #8391801 - Attachment is obsolete: true
Keywords: checkin-needed
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla30
Rik, thanks for implementing this!
relnote-firefox: --- → ?
relnote-b2g: --- → ?
Keywords: relnote
Added in the release notes with the title "Support for the alpha option to the canvas context options"
Is the performance of the code following this comment important?: // XXX Is there some useful swizzle MMX we can use here? http://dxr.mozilla.org/mozilla-central/source/content/canvas/src/CanvasRenderingContext2D.cpp#3918 I just happened to notice it when auditing code for an unrelated reason. The answer: yes. I came up with one back in grad school (late in the last millenium), though I've never done anything with it. There are probably better ways now with MMX2 or something, but I just thought I'd check.
Actually, I'm not sure my algorithm will apply here. This looks like a simpler problem. Well, with an extra conversion to unpremultiplied alpha.
(In reply to Steve Fink [:sfink] from comment #23) > Actually, I'm not sure my algorithm will apply here. This looks like a > simpler problem. Well, with an extra conversion to unpremultiplied alpha. Yes, it seems that there should be a routine somewhere in the codebase that can do this quickly. Of course, storing premultiplied data is wrong to begin with so this shouldn't be necessary :-)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: