[Webkit-unassigned] [Bug 117454] add canvas mask support for Cairo

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Mon Jun 10 18:07:23 PDT 2013


https://bugs.webkit.org/show_bug.cgi?id=117454





--- Comment #1 from arno. <arno at renevier.net>  2013-06-10 18:05:58 PST ---
Created an attachment (id=204270)
 --> (https://bugs.webkit.org/attachment.cgi?id=204270&action=review)
wip patch

WIP patch.
canvas mask api is based on Core Graphics API[1] This means that a call to mask will set the mask for all consecutive drawing operations.

On the contrary, cairo_mask is a drawing operation.

Currently, svg mask is supported by creating a new group and painting current surface on it (in order to allow proper composition). Then, during the actual drawing, the surface is popped and the actual cairo_mask_surface call is performed.

We can extend that by wrapping all drawing calls by a group creation/paint when there is an active mask. This would be a bit slow, but in the basic case (just a few drawing calls with a mask), that may not be a problem.

I tried to apply the mask only when a paint was needed (by implementing paintRenderingResultsToCanvas for 2d context, in order to tell the GraphicsContext that a real paint was needed). But I realize this would not work because cairo_push_group and cairo_pop_group call respectively cairo_save and cairo_restore. And it's not possible to call cairo_restore an a newly created group. So, things such as:

ctx.mask();
ctx.globalCompositeOperation = 'abcd';
ctx.resetMask();

would not have worked correctly.

Therefore, the tricky part of the patch is to detect all cairo drawing calls which may be called from canvas, in order to wrap them in the cairo_push_group/cairo_pop_group operations.

[1]: https://developer.apple.com/library/mac/#documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/dq_images/dq_images.html#//apple_ref/doc/uid/TP30001066-CH212-TPXREF101

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.


More information about the webkit-unassigned mailing list