diff --git a/src/drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx b/src/drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx index 6aed1d51a..7b2417616 100644 --- a/src/drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx +++ b/src/drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx @@ -761,26 +761,18 @@ 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_); - if (cx || cy || W < img->w() || H < img->h()) { // clip when necessary - cairo_rectangle(cairo_, X-0.5, Y-0.5, W+1, H+1); - cairo_clip(cairo_); - } + 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); - int offset = 0; - if (Ws >= img->data_w()*1.09 || Hs >= img->data_h()*1.09) { - // When enlarging while drawing, 1 pixel around target area seems unpainted, - // so we increase a bit the target area and move it int(s) pixels to left and top. - Ws = (img->w()+2)*s, Hs = (img->h()+2)*s; - offset = int(s); - } - -//fprintf(stderr,"WHs=%dx%d dataWH=%dx%d s=%.1f offset=%d\n",Ws,Hs,img->data_w(),img->data_h(),s,offset); + 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_matrix_init_scale(&matrix, double(img->data_w())/Ws, double(img->data_h())/Hs); - cairo_matrix_translate(&matrix, -Xs + offset, -Ys + offset); + cairo_matrix_translate(&matrix, -Xs , -Ys ); cairo_pattern_set_matrix(pat, &matrix); if (img->d() >= 1) cairo_paint(cairo_); else cairo_mask(cairo_, pat);