From bef46b5cb82464713a117b9bdb920735d1b7de37 Mon Sep 17 00:00:00 2001 From: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> Date: Wed, 24 Feb 2021 14:52:36 +0100 Subject: Improve precision of GUI scaling for Windows platform. --- src/drivers/GDI/Fl_GDI_Graphics_Driver.H | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'src/drivers/GDI/Fl_GDI_Graphics_Driver.H') diff --git a/src/drivers/GDI/Fl_GDI_Graphics_Driver.H b/src/drivers/GDI/Fl_GDI_Graphics_Driver.H index e2a29da4c..d322bc8af 100644 --- a/src/drivers/GDI/Fl_GDI_Graphics_Driver.H +++ b/src/drivers/GDI/Fl_GDI_Graphics_Driver.H @@ -58,6 +58,11 @@ public: char can_do_alpha_blending(); virtual void gc(void *ctxt) { gc_ = (HDC)ctxt; global_gc(); } virtual void *gc() {return gc_;} + // This function aims to compute accurately int(x * s) in + // presence of rounding errors existing with floating point numbers + // and that sometimes differ between 32 and 64 bits. + static inline int floor(int x, float s) { return int(x * s + 0.001f); } + inline int floor(int x) { return Fl_GDI_Graphics_Driver::floor(x, scale()); } // --- bitmap stuff Fl_Bitmask create_bitmask(int w, int h, const uchar *array); @@ -96,14 +101,18 @@ public: protected: void transformed_vertex0(float x, float y); void fixloop(); - virtual void point_unscaled(float x, float y); + virtual void point(int x, int y); virtual void rect(int x, int y, int w, int h); void focus_rect(int x, int y, int w, int h); - void rectf_unscaled(float x, float y, float w, float h); + virtual void rectf(int x, int y, int w, int h); virtual void line_unscaled(float x, float y, float x1, float y1); virtual void line_unscaled(float x, float y, float x1, float y1, float x2, float y2); - virtual void xyline_unscaled(float x, float y, float x1); - virtual void yxline_unscaled(float x, float y, float y1); + virtual void xyline(int x, int y, int x1); + virtual void xyline(int x, int y, int x1, int y2); + virtual void xyline(int x, int y, int x1, int y2, int x3); + virtual void yxline(int x, int y, int y1); + virtual void yxline(int x, int y, int y1, int x2); + virtual void yxline(int x, int y, int y1, int x2, int y3); virtual void loop_unscaled(float x0, float y0, float x1, float y1, float x2, float y2); virtual void loop_unscaled(float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3); virtual void polygon_unscaled(float x0, float y0, float x1, float y1, float x2, float y2); @@ -144,6 +153,7 @@ protected: virtual void font_name(int num, const char *name); void global_gc(); virtual void overlay_rect(int x, int y, int w , int h); + virtual void cache_size(Fl_Image *img, int &width, int &height); }; -- cgit v1.2.3