Bug 65207

Summary: [Chromium] Canvas 2D putImageData method is slow with GPU acceleration enabled
Product: WebKit Reporter: Justin Novosad <junov>
Component: Layout and RenderingAssignee: Nobody <webkit-unassigned>
Status: RESOLVED DUPLICATE    
Severity: Normal CC: bsalomon, schenney, scottmg, senorblanco, vangelis
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
URL: http://jsperf.com/fillrect-vs-putimagedata

Justin Novosad
Reported 2011-07-26 14:04:28 PDT
putImageData is slow for several reasons: 1) A new texture is allocated on the GPU every time a putImageData is called. It would be preferable to use a texture from a pool of recyclable textures.(functionality already available in skia) 2) RGBA to BGRA swizzling is done on the CPU. Swizzling is free on the GPU 3) Alpha pre-multiplication is performed on the CPU. The GPU can do it faster 4) A temporary copy of thepixel data ismade in RAM for the purposes of swizzling, premultiplication and image cropping. The transient copy could be eliminated by writing directly to the transfer buffer. Benchmark: http://jsperf.com/fillrect-vs-putimagedata Results for putImageData test with Chrome 13.0.782.99 beta On HP Z600, linux, nVidia Quadro FX 380 software canvas: 1,870,324 Ops per second GPU-accelerated canvas: 19,751 Ops per second (ouch!)
Attachments
Scott Graham
Comment 1 2011-07-26 14:47:07 PDT
The large delta looks to be gone in 14.x.
Justin Novosad
Comment 2 2011-07-27 11:04:37 PDT
As a matter of fact, performance is more or less on par between gpu and software implementations in Chrome 14. This is because item 1) was recently implemented in Skia. However Items 2) 3) and 4) are still valid optimization opportunities that will require changes in WebKit code. With those improvements, the GPU-accelerated implementation should eventually be even faster.
Stephen Chenney
Comment 3 2013-04-09 16:12:26 PDT
*** This bug has been marked as a duplicate of bug 65622 ***
Note You need to log in before you can comment on or make changes to this bug.