Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 360978

Summary: [Canvas] Consider using SVG instead of HTML5 Canvas for rendering
Product: [RT] RAP Reporter: Tim Buschtoens <tbuschto>
Component: RWTAssignee: Project Inbox <rap-inbox>
Status: RESOLVED WONTFIX QA Contact:
Severity: enhancement    
Priority: P3 CC: austin.riddle, tbuschto
Version: 1.5   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description Tim Buschtoens CLA 2011-10-14 10:31:15 EDT
Currently GC is rendered in RAP using VML in IE and HTML5-Canvas in all other browser. It would be relatively easy to support SVG instead of/in addition to Canvas.

Arguments for using SVG:
- Much more similar to VML (to which there is no alternative in ie7/8), dropping canvas would therefore make further development on GC simpler.
- Would allow for simple fix for Bug 317437 - [GC] support for lines styles.
- Would allow for propper drawText implementation, which is currently very limited and can only be drawn on top of everyting else.
- Would allow for enhanced features not present on SWT, like the ability to delete/replace previoulsy drawn shapes. I tried this with the VML-version, where it dramatically improved performance for my usecase. 

Arguments against using SVG:
- A bit slower than Canvas. (But still MUCH faster than VML).
- IE9 supports Canvas (and SVG), therefore VML might be less of a problem in the future.
- Supporting both at the same time and use as needed would be possible, but make the code even more complex.
- clearRect could still not be supported, as its only possible in HTML5 canvas.

The ability to change only parts of a canvas can be very important for improving overall performance, as it allows to reduce the amount of drawing operations that need to be transmitted to and executed on the client. Basically there are two ways to support this: Either propperly supporting clearRect or using the "undo/replace" feature i came up with after switching SVG. 

Since only canvas-based browser can support clearRect, and they are very fast already, this seems to be the less attractive option, unless we simply ignore ie7/8.
Comment 1 Tim Buschtoens CLA 2011-10-20 05:31:05 EDT
On correction: clearRect is not a feature of GC, but of HTML-Canvas. Clipping is the feature that can't be supported in VML (or SVG). Or, to be more precise, it could very well be supported, but my understanding would be that all newly drawn content is only covering the old contant, meaning the number of shapes in DOM would steadily increase, which espicially in IE impacts the performance very, very badly.
Comment 2 Tim Buschtoens CLA 2012-01-20 05:46:36 EST
An alternative would be to allow/use several HTML-canvases/GCs per Canvas/Widget (which would not be SWT compatible, but probably a new RWT-only widget), so one can use different layers for different shapes. This would allow partial redrawing aswell.
Comment 3 Tim Buschtoens CLA 2012-02-01 04:56:05 EST
With the new protocol using HTML-Canvas syntax, this becomes increasingly unpractical. It also seems that multiple HTML-canvases would not be signigicantly more expensive that SVG-shapes, so using these for a "layers" feature would be a good option.