FLTK logo

[master] 90c7e6b - Fix issue #537 without damaging test/mandelbrot

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.commit  ]
 
Previous Message ]Next Message ]

[master] 90c7e6b - Fix issue #537 without damaging test/mandelbrot "ManoloFLTK" Dec 06, 2022  
 
commit 90c7e6bcb1fcd30f3230e51d2c057ffc3a48e796
Author:     ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
AuthorDate: Tue Dec 6 14:46:11 2022 +0100
Commit:     ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
CommitDate: Tue Dec 6 14:46:11 2022 +0100

    Fix issue #537 without damaging test/mandelbrot

 src/drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git src/drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx src/drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx
index eee3b0d..c054568 100644
--- src/drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx
+++ src/drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx
@@ -762,16 +762,21 @@ void Fl_Cairo_Graphics_Driver::draw_cached_pattern_(Fl_Image *img, cairo_pattern
   int Hs = Fl_Scalable_Graphics_Driver::floor(Y - cy + img->h(), s) - Ys;
   if (Ws == 0 || Hs == 0) return;
   cairo_save(cairo_);
-  cairo_rectangle(cairo_, X - 0.5, Y - 0.5, W + 0.5, H + 0.5);
-  cairo_clip(cairo_);
+  bool need_extend = (img->data_w() != Ws || img->data_h() != Hs || (W >= 2 && H >= 2));
+  if (need_extend || cx || cy || W < img->w() || H < img->h()) { // clip when necessary
+    cairo_rectangle(cairo_, X - 0.5, Y - 0.5, W + 0.5, H + 0.5);
+    cairo_clip(cairo_);
+  }
   // remove any scaling and the current "0.5" translation useful for lines but bad for images
   matrix.xx = matrix.yy = 1;
   matrix.x0 -= 0.5 * s; matrix.y0 -= 0.5 * s;
   cairo_set_matrix(cairo_, &matrix);
   if (img->d() >= 1) cairo_set_source(cairo_, pat);
-  cairo_pattern_set_filter(pat, Fl_RGB_Image::scaling_algorithm() == FL_RGB_SCALING_BILINEAR ?
+  if (need_extend) {
+    cairo_pattern_set_filter(pat, Fl_RGB_Image::scaling_algorithm() == FL_RGB_SCALING_BILINEAR ?
                            CAIRO_FILTER_GOOD : CAIRO_FILTER_FAST);
-  cairo_pattern_set_extend(pat, CAIRO_EXTEND_PAD);
+    cairo_pattern_set_extend(pat, CAIRO_EXTEND_PAD);
+  }
   cairo_matrix_init_scale(&matrix, double(img->data_w())/Ws, double(img->data_h())/Hs);
   cairo_matrix_translate(&matrix, -Xs , -Ys );
   cairo_pattern_set_matrix(pat, &matrix);
Direct Link to Message ]
 
     
Previous Message ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.