The issue lies in details how floating point scaled coordinates are converted
to integer values and its impact on the drawing of large SVG images.
This commit fixes the X11 platform.
The macOS platform is immune because drawing uses floating point
coordinates.
The Windows platform still needs fixing.
@ -210,6 +211,10 @@ void Fl_Graphics_Driver::cache_size(int &width, int &height)
@@ -210,6 +211,10 @@ void Fl_Graphics_Driver::cache_size(int &width, int &height)
width=(width+1)*scale();
height=(height+1)*scale();
}
if(img->d()==4&&((Fl_RGB_Image*)img)->as_svg_image()){// check for SVG image
Fl_SVG_Image*svg=(Fl_SVG_Image*)img;
svg->cache_size(width,height);
}
}
/** Draws an Fl_Pixmap object using this graphics driver.
@ -223,7 +228,7 @@ void Fl_Graphics_Driver::draw_pixmap(Fl_Pixmap *pxm, int XP, int YP, int WP, int
@@ -223,7 +228,7 @@ void Fl_Graphics_Driver::draw_pixmap(Fl_Pixmap *pxm, int XP, int YP, int WP, int
}
// to allow rescale at runtime
intw2=pxm->w(),h2=pxm->h();
cache_size(w2,h2);// after this, w2 x h2 is size of desired cached image
cache_size(pxm,w2,h2);// after this, w2 x h2 is size of desired cached image
int*pw,*ph;
cache_w_h(pxm,pw,ph);// after this, *pw x *ph is current size of cached form of bitmap
if(*id(pxm)&&(*pw!=w2||*ph!=h2)){
@ -256,7 +261,7 @@ void Fl_Graphics_Driver::draw_bitmap(Fl_Bitmap *bm, int XP, int YP, int WP, int
@@ -256,7 +261,7 @@ void Fl_Graphics_Driver::draw_bitmap(Fl_Bitmap *bm, int XP, int YP, int WP, int
return;
}
intw2=bm->w(),h2=bm->h();
cache_size(w2,h2);// after this, w2 x h2 is size of desired cached image
cache_size(bm,w2,h2);// after this, w2 x h2 is size of desired cached image
int*pw,*ph;
cache_w_h(bm,pw,ph);// after this, *pw x *ph is current size of cached form of bitmap
if(*id(bm)&&(*pw!=w2||*ph!=h2)){
@ -296,7 +301,7 @@ void Fl_Graphics_Driver::draw_rgb(Fl_RGB_Image *img, int XP, int YP, int WP, int
@@ -296,7 +301,7 @@ void Fl_Graphics_Driver::draw_rgb(Fl_RGB_Image *img, int XP, int YP, int WP, int
intw2,h2,*pw,*ph;
if(need_scaled_drawing){
w2=img->w();h2=img->h();
cache_size(w2,h2);
cache_size(img,w2,h2);
}else{
w2=img->data_w();h2=img->data_h();
}// after this, w2 x h2 is desired cached image size
@ -246,7 +257,7 @@ void Fl_SVG_Image::draw(int X, int Y, int W, int H, int cx, int cy) {
@@ -246,7 +257,7 @@ void Fl_SVG_Image::draw(int X, int Y, int W, int H, int cx, int cy) {
@ -538,7 +538,7 @@ void Fl_GDI_Graphics_Driver::draw_rgb(Fl_RGB_Image *rgb, int XP, int YP, int WP,
@@ -538,7 +538,7 @@ void Fl_GDI_Graphics_Driver::draw_rgb(Fl_RGB_Image *rgb, int XP, int YP, int WP,
@ -764,9 +764,9 @@ void Fl_Xlib_Graphics_Driver::draw_rgb(Fl_RGB_Image *rgb, int XP, int YP, int WP
@@ -764,9 +764,9 @@ void Fl_Xlib_Graphics_Driver::draw_rgb(Fl_RGB_Image *rgb, int XP, int YP, int WP