summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--FL/Fl_Graphics_Driver.H5
-rw-r--r--src/Fl_Graphics_Driver.cxx9
2 files changed, 10 insertions, 4 deletions
diff --git a/FL/Fl_Graphics_Driver.H b/FL/Fl_Graphics_Driver.H
index 24246621c..2ac70ba03 100644
--- a/FL/Fl_Graphics_Driver.H
+++ b/FL/Fl_Graphics_Driver.H
@@ -413,10 +413,7 @@ class FL_EXPORT Fl_Scalable_Graphics_Driver : public Fl_Graphics_Driver {
Fl_Fontsize fontsize_; // scale-independent font size value
public:
Fl_Scalable_Graphics_Driver();
- // 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); }
+ static int floor(int x, float s);
inline int floor(int x) { return Fl_Scalable_Graphics_Driver::floor(x, scale()); }
protected:
int line_width_;
diff --git a/src/Fl_Graphics_Driver.cxx b/src/Fl_Graphics_Driver.cxx
index 50889bccf..95716530a 100644
--- a/src/Fl_Graphics_Driver.cxx
+++ b/src/Fl_Graphics_Driver.cxx
@@ -759,6 +759,15 @@ void Fl_Scalable_Graphics_Driver::rect(int x, int y, int w, int h)
}
}
+// 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.
+int Fl_Scalable_Graphics_Driver::floor(int x, float s) {
+ if (s == 1) return x;
+ int retval = int(abs(x) * s + 0.001f);
+ return (x >= 0 ? retval : -retval);
+}
+
void Fl_Scalable_Graphics_Driver::rectf(int x, int y, int w, int h)
{
if (w <= 0 || h <= 0) return;