diff options
author | nyamatongwe <devnull@localhost> | 2010-11-05 18:35:33 +1100 |
---|---|---|
committer | nyamatongwe <devnull@localhost> | 2010-11-05 18:35:33 +1100 |
commit | db26221bb09b7bbbbc48f452803d7b8252a301e0 (patch) | |
tree | 4596ad3ab325d4b4d5b4a1fa3b3a6db4d91a9ac1 | |
parent | 3a91f50e3957346d868a5fee9d87e87a47778fd3 (diff) | |
download | scintilla-mirror-db26221bb09b7bbbbc48f452803d7b8252a301e0.tar.gz |
Make Cairo line drawing more compatible with GDK by not drawing last
pixel when this is easy.
-rw-r--r-- | gtk/PlatGTK.cxx | 22 |
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 |