summaryrefslogtreecommitdiff
path: root/src/drivers/Xlib
diff options
context:
space:
mode:
authorManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2021-11-25 11:19:10 +0100
committerManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2021-11-25 11:19:10 +0100
commit2f506407327762ce30b4d895c856baa7f681d9bc (patch)
tree37fdd4fcd8df1ce57b1b33ca35464cd10a5cea26 /src/drivers/Xlib
parentbf470919f7ce9eff87789192e3643d13f3404a03 (diff)
X11+XRender platform: more accurate drawing of RGB images when GUI is scaled.
RGB images are now drawn to a size that exactly fit discretised rectangles when non integral GUI scaling values are used.
Diffstat (limited to 'src/drivers/Xlib')
-rw-r--r--src/drivers/Xlib/Fl_Xlib_Graphics_Driver_image.cxx16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_image.cxx b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_image.cxx
index 216f5826a..92ee52548 100644
--- a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_image.cxx
+++ b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_image.cxx
@@ -772,9 +772,15 @@ void Fl_Xlib_Graphics_Driver::draw_rgb(Fl_RGB_Image *rgb, int XP, int YP, int WP
if (!*Fl_Graphics_Driver::id(rgb)) {
cache(rgb);
}
- push_clip(XP, YP, WP, HP);
- int Wfull = rgb->w(), Hfull = rgb->h(), offset = 0;
- cache_size(rgb, Wfull, Hfull);
+ float s = scale();
+ int Xs = Fl_Scalable_Graphics_Driver::floor(XP - cx, s);
+ int Wfull = Fl_Scalable_Graphics_Driver::floor(XP - cx + rgb->w(), s) - Xs ;
+ int Ys = Fl_Scalable_Graphics_Driver::floor(YP - cy, s);
+ int Hfull = Fl_Scalable_Graphics_Driver::floor(YP - cy + rgb->h(), s) - Ys;
+ if (Wfull == 0 || Hfull == 0) return;
+ bool need_clip = (cx || cy || WP < rgb->w() || HP < rgb->h());
+ if (need_clip) push_clip(XP, YP, WP, HP);
+ int offset = 0;
if (Wfull > rgb->data_w() || Hfull > rgb->data_h()) {
// When enlarging while drawing with XRender, 1 pixel around target area seems unpainted,
// so we increase a bit the target area and move it 1 pixel to left and top.
@@ -783,9 +789,9 @@ void Fl_Xlib_Graphics_Driver::draw_rgb(Fl_RGB_Image *rgb, int XP, int YP, int WP
}
scale_and_render_pixmap( *Fl_Graphics_Driver::id(rgb), rgb->d(),
rgb->data_w() / double(Wfull), rgb->data_h() / double(Hfull),
- floor(XP-cx) + floor(offset_x_) - offset, floor(YP-cy) + floor(offset_y_) - offset,
+ Xs + this->floor(offset_x_) - offset, Ys + this->floor(offset_y_) - offset,
Wfull, Hfull);
- pop_clip();
+ if (need_clip) pop_clip();
}
/* Draws with Xrender an Fl_Offscreen with optional scaling and accounting for transparency if necessary.