Consider this my +1 in favor of a dedicated .colorMatrix attribute, preferably in the form of a Uint8Array or Float32Array instead of another *!@$ string.
SVG color matrices provide a superset of some very important rendering operations that show up a lot in game rendering. Right now to emulate them in canvas I have to use the CPU to split a source image into four 'channel' images and blend them iteratively to the canvas in additive mode in order to approximate the most common one (GL_MULTIPLY, effectively), which happens to be really slow in Firefox at present anyway because additive isn't optimized. Exposing color matrices would make it trivial to feed these through to the GPU (or to a fast software implementation). This workaround for the lack of colorMatrix accounts for a huge amount of CPU time in SPS profiles of some JSIL ports and increases memory usage too. I actually toyed with using temporary SVG images to approximate this in the past, and only abandoned it since SVG<->canvas interactions and loading SVG from data: URIs are both incredibly buggy in modern browsers. On Thu, Aug 8, 2013 at 2:01 PM, Robert O'Callahan <rob...@ocallahan.org>wrote: > Markus is moving with great speed and we should have the necessary Moz2D > support landed soonish. > > I think the biggest outstanding issue is how to spec the canvas API for > this. The most obvious approach to me is to add a "filter" attribute to > CanvasRenderingContext2D that takes a CSS filter value and applies it > during the compositing step of each drawing operation. Unfortunately CSS3 > filters doesn't have a value representing a general color matrix. You could > use "context.filter = "url(#mysvgColorMatrixFilter)" and set up the > corresponding <filter> element subtree in the document, but that's a bit > naff for JS users (and wouldn't work in Workers). The data: URL version of > that is even more naff and might also not work in Workers. > > So, we could choose between > a) Add CanvasRenderingContext2D.filter and a > color-matrix(N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N) CSS filter value. > b) Add CanvasRenderingContext2D.colorMatrix which allows direct setting of > a color matrix on the canvas, more like what Tobias suggested. This would > allow later adding CanvasRenderingContext2D.filter as a separate feature. > (If both were specified, both would be applied in some specified order.) > > Any thoughts? > > Rob > -- > Jtehsauts tshaei dS,o n" Wohfy Mdaon yhoaus eanuttehrotraiitny eovni > le atrhtohu gthot sf oirng iyvoeu rs ihnesa.r"t sS?o Whhei csha iids teoa > stiheer :p atroa lsyazye,d 'mYaonu,r "sGients uapr,e tfaokreg iyvoeunr, > 'm aotr atnod sgaoy ,h o'mGee.t" uTph eann dt hwea lmka'n? gBoutt uIp > waanndt wyeonut thoo mken.o w * > * > _______________________________________________ > dev-platform mailing list > dev-platform@lists.mozilla.org > https://lists.mozilla.org/listinfo/dev-platform > _______________________________________________ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform