Added FixedStrokeExtents() to correct Rectangle returned by StrokeExtents #50

Merged
merged 1 commit into from Dec 27, 2012

Conversation

Projects
None yet
2 participants
@don-mccomb
Contributor

don-mccomb commented Dec 10, 2012

The Cairo.Context.StrokeExtents() method returns a rectangle in which the X & Y coordinates of the bottom-right corner are incorrectly specified in the width and height members. In the previous code only CairoExtensions.GetBounds(Path) was correcting for this. As a result of this Cairo bug, when you drew a very small line in the middle of the image with the PaintBrush tool, Pinta would invalidate the entire bottom-right corner of the image. In most cases this would not be a big deal, but I thought it worth fixing none-the-less.
If some time in the future the bug is fixed in Cairo, would there be consequences for a version of Pinta with this fix? Should we perform a test during program startup to check if the fix is required?
After fixing the issue, it was found that when drawing with a small brush width, the corners of the invalidation rectangle were being clipped to short, so I added an Inflate(1, 1) to PlainBrush. This is a bit of a hack and I'd prefer not to have it, but oh well...

@cameronwhite

This comment has been minimized.

Show comment Hide comment
@cameronwhite

cameronwhite Dec 12, 2012

Owner

This looks like a bug with the Cairo wrapper (line 581 of https://github.com/mono/gtk-sharp/blob/master/cairo/Context.cs), not with Cairo itself, so we should probably send a pull request with a fix to https://github.com/mono/gtk-sharp

I suppose we could just make FixedStrokeExtents directly call the cairo_stroke_extents native method, since that would avoid any issues with detecting whether Context.StrokeExtents is working correctly in future versions of the cairo wrapper.

Owner

cameronwhite commented Dec 12, 2012

This looks like a bug with the Cairo wrapper (line 581 of https://github.com/mono/gtk-sharp/blob/master/cairo/Context.cs), not with Cairo itself, so we should probably send a pull request with a fix to https://github.com/mono/gtk-sharp

I suppose we could just make FixedStrokeExtents directly call the cairo_stroke_extents native method, since that would avoid any issues with detecting whether Context.StrokeExtents is working correctly in future versions of the cairo wrapper.

@cameronwhite

This comment has been minimized.

Show comment Hide comment
@cameronwhite

cameronwhite Dec 23, 2012

Owner

I've sent a pull request upstream with a fix for this issue: mono/gtk-sharp#56

Owner

cameronwhite commented Dec 23, 2012

I've sent a pull request upstream with a fix for this issue: mono/gtk-sharp#56

@cameronwhite

This comment has been minimized.

Show comment Hide comment
@cameronwhite

cameronwhite Dec 27, 2012

Owner

The patch was accepted upstream, but it doesn't look like it will be included in the GTK# 2.12.x branch due to the compatibility issues. So, I think it should be safe to use FixedStrokeExtents, and then remove it once we (eventually) port Pinta to GTK3.

Owner

cameronwhite commented Dec 27, 2012

The patch was accepted upstream, but it doesn't look like it will be included in the GTK# 2.12.x branch due to the compatibility issues. So, I think it should be safe to use FixedStrokeExtents, and then remove it once we (eventually) port Pinta to GTK3.

cameronwhite added a commit that referenced this pull request Dec 27, 2012

Merge pull request #50 from don-mccomb/FixedStrokeExtents
Added FixedStrokeExtents() to correct Rectangle returned by StrokeExtents

@cameronwhite cameronwhite merged commit 7d992a6 into PintaProject:master Dec 27, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment