diff options
| author | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2022-10-05 08:52:30 +0200 |
|---|---|---|
| committer | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2022-10-05 08:52:30 +0200 |
| commit | 206d9b17e0e2c2a66c3352787b067ab172dad778 (patch) | |
| tree | a2877f4e9fed8fc005bb1b6380d4705d580f8f20 /src | |
| parent | 5646522985896c21ff24c2552f9111091371c547 (diff) | |
Fix issue #509: Cairo drawing: unexpected behaviour
This commit fixes " "drawing an fl_pie() with dimension 1x1".
But it does not change "drawing fl_line() with begin position = end position does not show"
because the same behaviour is observed with Windows and macOS.
Diffstat (limited to 'src')
| -rw-r--r-- | src/drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx b/src/drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx index 3d61bd64c..ebe7c515a 100644 --- a/src/drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx +++ b/src/drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx @@ -122,11 +122,22 @@ void Fl_Cairo_Graphics_Driver::rect(int x, int y, int w, int h) { surface_needs_commit(); } +static bool need_antialias_none(cairo_t *cairo_, int style) { + cairo_matrix_t matrix; + cairo_get_matrix(cairo_, &matrix); + double width = cairo_get_line_width(cairo_) * matrix.xx; + bool needit = (style == FL_SOLID && width < 1.5); + if (needit) cairo_set_antialias(cairo_, CAIRO_ANTIALIAS_NONE); + return needit; +} + void Fl_Cairo_Graphics_Driver::line(int x1, int y1, int x2, int y2) { cairo_new_path(cairo_); cairo_move_to(cairo_, x1, y1); cairo_line_to(cairo_, x2, y2); + bool needit = need_antialias_none(cairo_, linestyle_); cairo_stroke(cairo_); + if (needit) cairo_set_antialias(cairo_, CAIRO_ANTIALIAS_DEFAULT); surface_needs_commit(); } @@ -135,7 +146,9 @@ void Fl_Cairo_Graphics_Driver::line(int x0, int y0, int x1, int y1, int x2, int cairo_move_to(cairo_, x0, y0); cairo_line_to(cairo_, x1, y1); cairo_line_to(cairo_, x2, y2); + bool needit = need_antialias_none(cairo_, linestyle_); cairo_stroke(cairo_); + if (needit) cairo_set_antialias(cairo_, CAIRO_ANTIALIAS_DEFAULT); surface_needs_commit(); } @@ -477,12 +490,11 @@ void Fl_Cairo_Graphics_Driver::pie(int x, int y, int w, int h, double a1, double cairo_save(cairo_); begin_polygon(); cairo_translate(cairo_, x + w/2.0 -0.5 , y + h/2.0 - 0.5); - cairo_scale(cairo_, (w-1)/2.0 , (h-1)/2.0); + cairo_scale(cairo_, w/2.0 , h/2.0); vertex(0,0); arc(0.0,0.0, 1, a2, a1); end_polygon(); cairo_restore(cairo_); - surface_needs_commit(); } void Fl_Cairo_Graphics_Driver::end_points() { |
