]> git.sesse.net Git - vlc/blobdiff - modules/gui/skins2/utils/bezier.cpp
* skins/utils/bezier.cpp: Fixed a bug in the computation of the size of a
[vlc] / modules / gui / skins2 / utils / bezier.cpp
index 595d3306c01331492bc5a3c51696bcff631dc1ad..5110b0e9d009bf2b2c4dd209e2af64f488433cb7 100644 (file)
@@ -2,7 +2,7 @@
  * bezier.cpp
  *****************************************************************************
  * Copyright (C) 2003 VideoLAN
- * $Id: bezier.cpp,v 1.4 2004/03/02 21:45:15 ipkiss Exp $
+ * $Id$
  *
  * Authors: Cyril Deguet     <asmax@via.ecp.fr>
  *          Olivier Teulière <ipkiss@via.ecp.fr>
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  *****************************************************************************/
 
+#include <vlc/vlc.h>
 #include "bezier.hpp"
 #include <math.h>
 
+#ifndef HAVE_LRINTF
+#   define lrintf(a) (int)rint(a)
+#endif
 
 Bezier::Bezier( intf_thread_t *p_intf, const vector<float> &rAbscissas,
                 const vector<float> &rOrdinates, Flag_t flag )
@@ -129,9 +133,9 @@ int Bezier::getWidth() const
     int width = 0;
     for( int i = 0; i < m_nbPoints; i++ )
     {
-        if( m_leftVect[i] > width )
+        if( m_leftVect[i] >= width )
         {
-            width = m_leftVect[i];
+            width = m_leftVect[i] + 1;
         }
     }
     return width;
@@ -143,9 +147,9 @@ int Bezier::getHeight() const
     int height = 0;
     for( int i = 0; i < m_nbPoints; i++ )
     {
-        if( m_topVect[i] > height )
+        if( m_topVect[i] >= height )
         {
-            height = m_topVect[i];
+            height = m_topVect[i] + 1;
         }
     }
     return height;
@@ -189,10 +193,8 @@ void Bezier::computePoint( float t, int &x, int &y ) const
         yPos += m_pty[i] * coeff;
     }
 
-    // Float cast to avoid strange truncatures
-    // XXX: not very nice...
-    x = (int)(float)xPos;
-    y = (int)(float)yPos;
+    x = lrintf(xPos);
+    y = lrintf(yPos);
 }
 
 
@@ -210,4 +212,3 @@ inline float Bezier::power( float x, int n ) const
     else
         return 1;
 }
-