Bug 167461 - Draw2D Clip regions should obey fill rules
Summary: Draw2D Clip regions should obey fill rules
Status: RESOLVED FIXED
Alias: None
Product: GEF
Classification: Tools
Component: GEF-Legacy Draw2d (show other bugs)
Version: 3.2   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 3.5.0 (Galileo) M1   Edit
Assignee: Lidija Grahek CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-12-11 13:12 EST by Ian Bull CLA
Modified: 2008-10-15 13:27 EDT (History)
3 users (show)

See Also:


Attachments
Screenshot of the problem (13.39 KB, image/jpeg)
2006-12-11 13:13 EST, Ian Bull CLA
no flags Details
Snippet showing the problem (1.55 KB, text/x-java)
2007-01-15 14:52 EST, Ian Bull CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ian Bull CLA 2006-12-11 13:12:03 EST
Sorry if this isn't really a bug, but since we are supposed to use clip regions to  use gradient fills, it seems like one.

Problem:  If you want to fill something using a gradient fill you must first clip the region and then fill the bounding box will fillGradient. However, since clipping does not obey the fill rules, there are some figures you cannot properly fill.  Clipping always seems to use the EvenOdd rule, but if a path crosses back on itself this will leave holes in clip.

It would be great if the clip regions on the GC obeyed the fill rules setting.

I will attach a screen-shot to show you what I mean.
Comment 1 Ian Bull CLA 2006-12-11 13:13:28 EST
Created attachment 55416 [details]
Screenshot of the problem

Here is a screenshot that shows the problem.  Note:  I have only tried this on GTK+.
Comment 2 Silenio Quarti CLA 2007-01-15 13:04:52 EST
Please could you provide your testcase? Thanks!
Comment 3 Ian Bull CLA 2007-01-15 14:20:20 EST
Opps.. :)  It works great in SWT.  The power of a snippet!

It is actually the graphics class in Draw2D.  I assumed that the rules were just passed through to SWT. It seems that draw2D only sets the fill rules before the fill method is called, so if you set the fill rule and do a clip, the rule is not updated.

I am reassigning this to Draw2D and I will attach a Draw2D snippet in a second.

Comment 4 Ian Bull CLA 2007-01-15 14:52:16 EST
Created attachment 56925 [details]
Snippet showing the problem

This snippet shows how SWTGraphics does not update the fill rule until after a fill method is called.  It should also be updated when setClip is called since clipping obeys fill rules.
Comment 5 Ian Bull CLA 2007-01-15 16:50:33 EST
This can actually be fixed by calling checkGC() when setClip is called.  This should be safe to call here right?  Do you want me to create a patch?

Cheers,
ian
Comment 6 Randy Hudson CLA 2008-07-25 12:49:07 EDT
I've delivered a change that is less expensive than calling checkGC(), and probably safe enough to be considered for 3.4.1.

Anthony/Lidija/Ian, check if the change works for you and figure out whether you want to backport to 3.4.1.  If there's no need to backport, we can probably resolve as fixed.

WORKAROUND for pre-3.5:
Ian, another way to achieve the same results without encountering the bug in existing releases is to call:

Path path = ...;
Pattern pattern = new Pattern([[color 1, color 2, top of path, bottom of path]]);
graphics.setBackgroundPattern(pattern);
pattern.dispose();
graphics.fillPath(path);

In fact, this is better in several ways because you have the option of enabling anti-aliasing, and/or outlining the path (drawPath(path));
Comment 7 Lidija Grahek CLA 2008-07-28 09:24:53 EDT
(In reply to comment #6)
Seems to be working fine.

Comment 8 Lidija Grahek CLA 2008-09-10 14:41:17 EDT
Fixed, see comment #6