[whatwg] Canvas resetClip() API
rashmi.shyam at gmail.com
Mon Oct 7 20:55:16 PDT 2013
This is regarding the resetClip() API for canvas. Please take a look at my
patches to the bug https://bugs.webkit.org/show_bug.cgi?id=82801.
resetClip() can be implemented in Cairo, without any overhead, since Cairo
I tried to implement the API in CG, using the below approach :- (Please
check https://bugs.webkit.org/show_bug.cgi?id=82801#c9 )
When resetClip() is called,
1. Save the imageData from canvas imageBuffer
2. Save the GraphicsContextState
3. Clear the canvas buffer. This will delete the buffer and
4. Copy the saved imageData to a new imageBuffer
5. Set the graphicsContextState to the saved state.
GraphicsContextState does not have information about any clip.
The drawback with the above approach is that clipping-region cannot be
restored since it is not part of the GraphicsContextState or
Currently clipping-region is not saved in GraphicsContextState or
CanvasRenderingContext2D::State. If clipping-region is somehow saved
in GraphicsContextState and CanvasRenderingContext2D::State then,
through step#5, clipping region can also be restored.
Below is an example which will not work in CG (But, Works perfectly in
Cairo), if clipping-region is not saved in GraphicsContextState and
...; // draw with no clip
...; // draw with a clip (This draw does not contain any clip)
More information about the whatwg