Closed
Bug 982480
Opened 9 years ago
Closed 9 years ago
Add support for the alpha option to the canvas context options
Categories
(Core :: Graphics: Canvas2D, defect)
Core
Graphics: Canvas2D
Tracking
()
RESOLVED
FIXED
mozilla30
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 | ||
Updated•9 years ago
|
Assignee: nobody → cabanier
Assignee | ||
Comment 1•9 years ago
|
||
try build: https://tbpl.mozilla.org/?tree=Try&rev=58ca1bee505c
Assignee | ||
Updated•9 years ago
|
Attachment #8389608 -
Flags: review?(roc)
Assignee | ||
Comment 2•9 years ago
|
||
- 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-
Assignee | ||
Comment 4•9 years ago
|
||
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.
Assignee | ||
Comment 5•9 years ago
|
||
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)
Assignee | ||
Comment 6•9 years ago
|
||
try run: https://tbpl.mozilla.org/?tree=Try&rev=843ce14f1be2
Assignee | ||
Comment 7•9 years ago
|
||
removed obsolete comment
Attachment #8390713 -
Attachment is obsolete: true
Attachment #8390713 -
Flags: review?(roc)
Attachment #8390979 -
Flags: review?(roc)
Assignee | ||
Updated•9 years ago
|
Keywords: dev-doc-needed
Attachment #8390979 -
Flags: review?(roc) → review+
Assignee | ||
Updated•9 years ago
|
Keywords: checkin-needed
Comment 8•9 years ago
|
||
patching file content/canvas/src/CanvasRenderingContext2D.cpp bad hunk #3 @@ -3802,16 +3808,41 @@ CanvasRenderingContext2D::GetImageDataAr (17 16 41 41)
Keywords: checkin-needed
Assignee | ||
Comment 9•9 years ago
|
||
Attachment #8390979 -
Attachment is obsolete: true
Assignee | ||
Updated•9 years ago
|
Keywords: checkin-needed
Comment 10•9 years ago
|
||
https://hg.mozilla.org/integration/mozilla-inbound/rev/9a2aab98a8d0
Flags: in-testsuite+
Keywords: checkin-needed
Comment 11•9 years ago
|
||
Backed out for D2D reftest failures. https://hg.mozilla.org/integration/mozilla-inbound/rev/e182de48f628 https://tbpl.mozilla.org/php/getParsedLog.php?id=36214643&tree=Mozilla-Inbound
Comment 12•9 years ago
|
||
And WinXP mochitest-1 failures. https://tbpl.mozilla.org/php/getParsedLog.php?id=36214670&tree=Mozilla-Inbound
Assignee | ||
Comment 13•9 years ago
|
||
Attachment #8391277 -
Attachment is obsolete: true
Assignee | ||
Comment 14•9 years ago
|
||
try run: https://tbpl.mozilla.org/?tree=Try&rev=391307a4c8d3
Assignee | ||
Comment 15•9 years ago
|
||
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
Assignee | ||
Updated•9 years ago
|
Keywords: checkin-needed
Comment 16•9 years ago
|
||
https://hg.mozilla.org/integration/mozilla-inbound/rev/e25f1c48cf0c
Keywords: checkin-needed
Comment 17•9 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/e25f1c48cf0c
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla30
Rik, thanks for implementing this!
Assignee | ||
Updated•9 years ago
|
Assignee | ||
Comment 20•9 years ago
|
||
See http://blogs.adobe.com/webplatform/2014/04/01/new-canvas-features/ for a description of the feature.
Comment 21•9 years ago
|
||
Added in the release notes with the title "Support for the alpha option to the canvas context options"
Comment 22•9 years ago
|
||
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.
Comment 23•9 years ago
|
||
Actually, I'm not sure my algorithm will apply here. This looks like a simpler problem. Well, with an extra conversion to unpremultiplied alpha.
Assignee | ||
Comment 24•9 years ago
|
||
(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 :-)
Comment 25•9 years ago
|
||
Added "alpha" context attribute to the reference: https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement.getContext Release notes: https://developer.mozilla.org/en-US/Firefox/Releases/30#Interfaces.2FAPIs.2FDOM
Keywords: dev-doc-needed → dev-doc-complete
You need to log in
before you can comment on or make changes to this bug.
Description
•