Bug 35544

Summary: [OpenVG] Use masks to implement non-rectilinear clipping
Product: WebKit Reporter: Jakob Petsovits <jpetsovits>
Component: PlatformAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: eric, gns, krit, mario.bensi
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Other   
OS: All   
Bug Depends on:    
Bug Blocks: 33987    
Attachments:
Description Flags
Patch krit: review+

Description Jakob Petsovits 2010-03-01 14:03:51 PST
Rectilinear regions (a.k.a. upright rectangles) can be clipped in OpenVG using its scissoring functionality. For all other shapes (i.e. paths and rotated rectangles), we want mask clipping instead. Only OpenVG >= 1.1 provides the required functions for managing masks, so all the masking code in this patch is put into an #ifdef.

Mask layers (which are bitmaps of 1 or 8 bit depth per pixel) are a bit hairy because, unlike the other state that we're keeping track of, they can't easily be captured like colors, boolean enable-blah values, or stuff. Also, OpenVG implementations can optimize on the plain bitmap concept by storing masks and mask layers as set of paths. So we don't really want to read out mask layers in memory for context state storage, we keep them as native VGMaskLayer. That requires us to make sure the correct surface is current when the painter state is stored (which we didn't ensure before) so a bit of surface management code is added here as well.

vgRenderToMask() is affected by the current OpenVG path transformation, so we don't have to manually transform the path like we do for scissor rectangles. PainterOpenVG restricts the clipping modes to Intersect and Subtract, because additive clipping a.k.a. removing clip regions would require too much (and unnecessary) overhead for scissor rectangles which would need to be "unclipped" as well. Right now PainterOpenVG can only add clips but never remove them (except with restore()), and that's in line with GraphicsContext's functionality.
Comment 1 Jakob Petsovits 2010-03-01 14:05:54 PST
Created attachment 49749 [details]
Patch
Comment 2 Dirk Schulze 2010-03-09 11:21:27 PST
Comment on attachment 49749 [details]
Patch

lgtm r=me
Comment 3 Jakob Petsovits 2010-03-12 11:25:49 PST
Committed r55922: <http://trac.webkit.org/changeset/55922>
Comment 4 Eric Seidel (no email) 2010-03-12 18:17:29 PST
This appears to have broken the Gtk build:
http://build.webkit.org/builders/GTK%20Linux%2064-bit%20Debug/builds/3889
Comment 5 Dirk Schulze 2010-03-12 22:35:59 PST
(In reply to comment #4)
> This appears to have broken the Gtk build:
> http://build.webkit.org/builders/GTK%20Linux%2064-bit%20Debug/builds/3889

How? There is no core code touched and also no Gtk code. Only files in the openvg folder.
Comment 6 Dirk Schulze 2010-03-12 23:02:27 PST
(In reply to comment #4)
> This appears to have broken the Gtk build:
> http://build.webkit.org/builders/GTK%20Linux%2064-bit%20Debug/builds/3889

http://trac.webkit.org/changeset/55927 broke the gtk bots.