aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authornyamatongwe <unknown>2010-11-05 18:35:33 +1100
committernyamatongwe <unknown>2010-11-05 18:35:33 +1100
commit4f9c510fbf9591767f3b54b6f0600664a9153e71 (patch)
tree0b0984fc706834329f3c9b47bad4f863eaf454c9
parent4ecdef0b2a77ca753be3397bc4e41d05c5e72376 (diff)
downloadscintilla-mirror-4f9c510fbf9591767f3b54b6f0600664a9153e71.tar.gz
Make Cairo line drawing more compatible with GDK by not drawing last
pixel when this is easy.
-rw-r--r--gtk/PlatGTK.cxx22
1 files changed, 20 insertions, 2 deletions
diff --git a/gtk/PlatGTK.cxx b/gtk/PlatGTK.cxx
index 4a6d76308..1139b1b97 100644
--- a/gtk/PlatGTK.cxx
+++ b/gtk/PlatGTK.cxx
@@ -1019,10 +1019,28 @@ void SurfaceImpl::MoveTo(int x_, int y_) {
void SurfaceImpl::LineTo(int x_, int y_) {
#ifdef USE_CAIRO
// Lines draw their end position, unlike Win32 or GDK with GDK_CAP_NOT_LAST.
- // Could try to move back one pixel, possibly only for simple cases like horizontal and vertical
+ // For simple cases, move back one pixel from end.
if (context) {
cairo_move_to(context, x + 0.5, y + 0.5);
- cairo_line_to(context, x_ + 0.5, y_ + 0.5);
+ int xdiff = x_ - x;
+ int xdelta = 0;
+ if (xdiff < 0)
+ xdelta = -1;
+ else if (xdiff > 0)
+ xdelta = 1;
+ int ydiff = y_ - y;
+ int ydelta = 0;
+ if (ydiff < 0)
+ ydelta = -1;
+ else if (ydiff > 0)
+ ydelta = 1;
+ if ((abs(xdiff) == abs(ydiff)) || (xdiff == 0) || (ydiff == 0)) {
+ // Horizontal, vertical or 45 degree slope
+ cairo_line_to(context, x_ + 0.5 - xdelta, y_ + 0.5 - ydelta);
+ } else {
+ // Line has a different slope so difficult to avoid last pixel
+ cairo_line_to(context, x_ + 0.5, y_ + 0.5);
+ }
cairo_stroke(context);
}
#else