- From: Rashmi Shyamasundar <rashmi.shyam@gmail.com>
- Date: Tue, 8 Oct 2013 09:27:11 +0530
- To: whatwg@whatwg.org
Hi All, 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 supports resetClip. I tried to implement the API in CG, using the below approach :- (Please check https://bugs.webkit.org/show_bug.cgi?id=82801#c9 ) Steps :- 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 GraphicsContextStateSaver. 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 CanvasRenderingContext2D::State. 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 CanvasRenderingContext2D::State :- ctx.clip(); ctx.save(); ctx.resetClip(); ...; // draw with no clip ctx.restore(); ...; // draw with a clip (This draw does not contain any clip) Thanks, Rashmi
Received on Tuesday, 8 October 2013 03:57:36 UTC