diff options
| author | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2021-02-24 14:52:36 +0100 |
|---|---|---|
| committer | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2021-02-24 14:52:47 +0100 |
| commit | bef46b5cb82464713a117b9bdb920735d1b7de37 (patch) | |
| tree | e645da2fdd342a8a8a41c90b54b2e96e29d849a0 /src/drivers/GDI/Fl_GDI_Graphics_Driver.H | |
| parent | 9f84fd05e8090c3b7554c965d15ac5c41a0d4852 (diff) | |
Improve precision of GUI scaling for Windows platform.
Diffstat (limited to 'src/drivers/GDI/Fl_GDI_Graphics_Driver.H')
| -rw-r--r-- | src/drivers/GDI/Fl_GDI_Graphics_Driver.H | 18 |
1 files changed, 14 insertions, 4 deletions
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); }; |
