When filling a path with a shading color, the path is being intersected with the clipping path in gx_default_fill_path, then converts into a (big) path, then intersect with the shading BBox and with the path's bbox in gs_shading_fill_path. A better way is to account the shading BBox in gx_default_fill_path, and then execute a part of gs_shading_fill_path except its clipping part. We already tried a similar optimization, but we got an unexpected raster difference - the coverage area become smallar in a part of pixel. Probably fill_adjust was not properly accounted when compute a clipping.
Another related patch is http://ghostscript.com/pipermail/gs-cvs/2006-November/006911.html Strongly speaking, it is not related to imagemask, but to filling a path. We mention it here because it affects same test document.
Please disregard the last comment. It is unintentionally misplaced.
The test case is 09-47L.
Bumping the priority sinse it's a part of the current project.
The bug description is some obsolete. gs_shading_fill_path is not relevant now. Both intersections are now done in gx_default_fill_path (the second one - with calling gx_dc_pattern2_clip_with_bbox). But exchanging the order of intersections still would be useful. So the wanted change is local to gx_default_fill_path. Should first intersect pcpath or rect with shading bbox, then with path (if the latter is not NULL).
Patch to HEAD : http://ghostscript.com/pipermail/gs-cvs/2008-January/008093.html It closes the problem but the code needs some cleanup - see the explanation is the log message. Keeping the bug open until the cleanup is done.
More patches : http://ghostscript.com/pipermail/gs-cvs/2008-January/008094.html http://ghostscript.com/pipermail/gs-cvs/2008-January/008096.html Now closing.