gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] gnash ChangeLog backend/render_handler_ogl.cpp ...


From: Zou Lunkai
Subject: [Gnash-commit] gnash ChangeLog backend/render_handler_ogl.cpp ...
Date: Tue, 10 Jun 2008 08:17:46 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Zou Lunkai <zoulunkai>  08/06/10 08:17:46

Modified files:
        .              : ChangeLog 
        backend        : render_handler_ogl.cpp 
        libbase        : utility.h 
        server         : fill_style.cpp matrix.cpp matrix.h text.cpp 
        testsuite/server: MatrixTest.cpp 

Log message:
        * server/matrix.{h,cpp}: more cleanups, drop some unncessary interfaces.
        * server/text.cpp, server/fill_style.cpp: synchronization with the new 
concatenate_scale().
        * utility.h: add a FloatToFixed16() function.
        * backend/render_handler_ogl.cpp: fix building with patch from 
bug#23515.
        * testsuite/server/MatrixTest.cpp: drop some useless tests.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.6880&r2=1.6881
http://cvs.savannah.gnu.org/viewcvs/gnash/backend/render_handler_ogl.cpp?cvsroot=gnash&r1=1.115&r2=1.116
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/utility.h?cvsroot=gnash&r1=1.57&r2=1.58
http://cvs.savannah.gnu.org/viewcvs/gnash/server/fill_style.cpp?cvsroot=gnash&r1=1.35&r2=1.36
http://cvs.savannah.gnu.org/viewcvs/gnash/server/matrix.cpp?cvsroot=gnash&r1=1.34&r2=1.35
http://cvs.savannah.gnu.org/viewcvs/gnash/server/matrix.h?cvsroot=gnash&r1=1.22&r2=1.23
http://cvs.savannah.gnu.org/viewcvs/gnash/server/text.cpp?cvsroot=gnash&r1=1.52&r2=1.53
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/server/MatrixTest.cpp?cvsroot=gnash&r1=1.13&r2=1.14

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.6880
retrieving revision 1.6881
diff -u -b -r1.6880 -r1.6881
--- ChangeLog   10 Jun 2008 07:14:29 -0000      1.6880
+++ ChangeLog   10 Jun 2008 08:17:44 -0000      1.6881
@@ -1,3 +1,11 @@
+2008-06-10 Zou Lunkai <address@hidden>
+       
+       * server/matrix.{h,cpp}: more cleanups, drop some unncessary interfaces.
+    * server/text.cpp, server/fill_style.cpp: synchronization with the new 
concatenate_scale().
+    * utility.h: add a FloatToFixed16() function.
+    * backend/render_handler_ogl.cpp: fix building with patch from bug#23515.
+    * testsuite/server/MatrixTest.cpp: drop some useless tests. 
+       
 2008-06-10 Sandro Santilli <address@hidden>
 
        * libbase/LoadThread.{cpp,h}: take the IOChannel input at construction

Index: backend/render_handler_ogl.cpp
===================================================================
RCS file: /sources/gnash/gnash/backend/render_handler_ogl.cpp,v
retrieving revision 1.115
retrieving revision 1.116
diff -u -b -r1.115 -r1.116
--- backend/render_handler_ogl.cpp      5 Jun 2008 03:26:31 -0000       1.115
+++ backend/render_handler_ogl.cpp      10 Jun 2008 08:17:45 -0000      1.116
@@ -992,7 +992,7 @@
     
     std::vector<line_style> dummy_ls;
     
-    draw_subshape(path_vec, matrix::identity, dummy_cx, 1.0, dummy_fs, 
dummy_ls);
+    draw_subshape(path_vec, matrix(), dummy_cx, 1.0, dummy_fs, dummy_ls);
   }
   
   virtual void disable_mask()

Index: libbase/utility.h
===================================================================
RCS file: /sources/gnash/gnash/libbase/utility.h,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -b -r1.57 -r1.58
--- libbase/utility.h   6 Jun 2008 23:04:09 -0000       1.57
+++ libbase/utility.h   10 Jun 2008 08:17:45 -0000      1.58
@@ -138,8 +138,14 @@
 
 inline boost::int32_t Fixed16Mul(boost::int32_t a, boost::int32_t b)
 {
-    return static_cast<boost::int32_t>(
-            static_cast<boost::int64_t>(a) * static_cast<boost::int64_t>(b) >> 
16);
+    // There might be overflows, but we don't care in our specific case.
+    return (boost::int32_t)((boost::int64_t)a * (boost::int64_t)b >> 16);
+}
+
+inline boost::int32_t FloatToFixed16(float a)
+{
+    // There might be overflows, but we don't care in our specific case.
+    return (boost::int32_t)(a * 65536.0f);
 }
 
 }

Index: server/fill_style.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/fill_style.cpp,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -b -r1.35 -r1.36
--- server/fill_style.cpp       9 Jun 2008 10:18:21 -0000       1.35
+++ server/fill_style.cpp       10 Jun 2008 08:17:45 -0000      1.36
@@ -117,12 +117,12 @@
         if (m_type == SWF::FILL_LINEAR_GRADIENT)
         {
             m_gradient_matrix.concatenate_translation(128.f, 0.f);
-            m_gradient_matrix.concatenate_scale(1.0f / 128.0f);
+            m_gradient_matrix.concatenate_scale(1.0f/128, 1.0f/128);
         }
         else // FILL_RADIAL_GRADIENT or FILL_FOCAL_GRADIENT
         {
             m_gradient_matrix.concatenate_translation(32.f, 32.f);
-            m_gradient_matrix.concatenate_scale(1.0f / 512.0f);
+            m_gradient_matrix.concatenate_scale(1.0f/512, 1.0f/512);
         }
 
         matrix m;

Index: server/matrix.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/matrix.cpp,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -b -r1.34 -r1.35
--- server/matrix.cpp   9 Jun 2008 10:18:22 -0000       1.34
+++ server/matrix.cpp   10 Jun 2008 08:17:46 -0000      1.35
@@ -78,8 +78,8 @@
        if (translate_nbits > 0)
        {
                in.ensureBits(translate_nbits*2);
-               tx = (float) in.read_sint(translate_nbits);
-               ty = (float) in.read_sint(translate_nbits);
+        tx = in.read_sint(translate_nbits);
+        ty = in.read_sint(translate_nbits);
        }
 }
 
@@ -102,7 +102,7 @@
 matrix::concatenate(const matrix& m)
 // Concatenate m's transform onto ours.  When
 // transforming points, m happens first, then our
-// original xform.
+// original matrix.
 {
        matrix  t;
        t.sx =  Fixed16Mul(sx, m.sx)  + Fixed16Mul(shy, m.shx);
@@ -128,24 +128,14 @@
 
 
 void
-matrix::concatenate_scale(float scale)
-// Concatenate a uniform scale onto the front of our
-// matrix.  When transforming points, the scale
-// happens first, then our original xform.
-{
-       sx *= utility::infinite_to_fzero(scale);
-       shy *= utility::infinite_to_fzero(scale);
-       shx *= utility::infinite_to_fzero(scale);
-       sy *= utility::infinite_to_fzero(scale);
-}
-
-void   
-matrix::concatenate_scales(float x, float y)
-// Just like concatenate_scale() but with different scales for x/y
-{
-       matrix m2; 
-    m2.set_scale_rotation(x, y, 0);
-       concatenate(m2);
+matrix::concatenate_scale(float xscale, float yscale)
+// Concatenate scales to our matrix. When transforming points, these 
+// scales happen first, then our matirx.
+{
+    sx  = Fixed16Mul(sx, FloatToFixed16(xscale));
+    shy = Fixed16Mul(shy,FloatToFixed16(yscale));
+    shx = Fixed16Mul(shx,FloatToFixed16(xscale));
+    sy  = Fixed16Mul(sy, FloatToFixed16(yscale));
 }
 
 void
@@ -169,26 +159,30 @@
 {
        float   cos_angle = cosf(angle);
        float   sin_angle = sinf(angle);
-       sx  = 65536.0f * x_scale * cos_angle;
-       shy = 65536.0f * y_scale * -sin_angle;
-       shx = 65536.0f * x_scale * sin_angle;
-       sy  = 65536.0f * y_scale * cos_angle;
+    sx  = FloatToFixed16(x_scale * cos_angle);
+    shy = FloatToFixed16(y_scale * -sin_angle);
+    shx = FloatToFixed16(x_scale * sin_angle);
+    sy  = FloatToFixed16(y_scale * cos_angle);
 }
 
 void
 matrix::set_x_scale(float xscale)
 {
-       float rotation = get_rotation();
-       float yscale = get_y_scale();
-       set_scale_rotation(xscale, yscale, rotation);
+    float angle = get_rotation();
+    float cos_v = cosf(angle);
+    float sin_v = sinf(angle);
+    sx  =  FloatToFixed16(xscale * cos_v);
+    shx =  FloatToFixed16(xscale * sin_v);
 }
 
 void
 matrix::set_y_scale(float yscale)
 {
-       float rotation = get_rotation();
-       float xscale = get_x_scale();
-       set_scale_rotation(xscale, yscale, rotation);
+    float angle = get_rotation();
+    float cos_v = cosf(angle);
+    float sin_v = sinf(angle);
+    shy =  - FloatToFixed16(yscale * sin_v);
+    sy  =  FloatToFixed16(yscale * cos_v);
 }
 
 void
@@ -207,6 +201,17 @@
 }
 
 void
+matrix::transform(point &p) const
+{
+    //boost::int32_t x = Fixed16Mul(sx,  p.x) + Fixed16Mul(shy, p.y) + tx;
+    //boost::int32_t y = Fixed16Mul(shx, p.x) + Fixed16Mul(sy,  p.y) + ty;
+    float x = sx / 65536.0f * p.x + shy/ 65536.0f * p.y + tx;
+    float y = shx/ 65536.0f * p.x + sy / 65536.0f * p.y + ty;
+    p.x = x;
+    p.y = y;
+}
+
+void
 matrix::transform(point* result, const point& p) const
 // Transform point 'p' by our matrix.  Put the result in *result.
 {
@@ -242,16 +247,6 @@
     r.expandTo(p3.x, p3.y);
 }
 
-void
-matrix::transform_vector(point* result, const point& v) const
-// Transform vector 'v' by our matrix. Doesn't apply translation.
-// Put the result in *result.
-{
-       assert(result);
-
-       result->x = Fixed16Mul(sx, v.x) + Fixed16Mul(shy, v.y);
-       result->y = Fixed16Mul(sy, v.x) + Fixed16Mul(shx, v.y);
-}
 
 void
 matrix::transform_by_inverse(point* result, const point& p) const
@@ -310,14 +305,6 @@
 }
 
 
-bool
-matrix::does_flip() const
-// Return true if this matrix reverses handedness.
-{
-    return ((boost::int64_t)sx * sy) < ((boost::int64_t)shx * shy);
-}
-
-
 boost::int64_t
 matrix::get_determinant() const
 // Return the 32.32 fixed point determinant of this matrix.

Index: server/matrix.h
===================================================================
RCS file: /sources/gnash/gnash/server/matrix.h,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -b -r1.22 -r1.23
--- server/matrix.h     9 Jun 2008 10:18:22 -0000       1.22
+++ server/matrix.h     10 Jun 2008 08:17:46 -0000      1.23
@@ -93,7 +93,7 @@
        void    concatenate_scale(float s);
 
        /// Just like concatenate_scale() but with different scales for x/y 
-       void    concatenate_scales(float x, float y);
+       void    concatenate_scale(float x, float y);
 
        /// Set this matrix to a blend of m1 and m2, parameterized by t.
        void    set_lerp(const matrix& m1, const matrix& m2, float t);
@@ -137,6 +137,9 @@
        // temp hack, should drop..
        void    read(SWFStream* in) { read(*in); }
 
+    /// Transform a given point by our matrix
+    void    transform(point &p) const;
+    
        /// Transform point 'p' by our matrix. 
        //
        /// Put the result in *result.
@@ -193,9 +196,6 @@
        /// Set this matrix to the inverse of the given matrix.
        void    set_inverse(const matrix& m);
 
-       /// Return true if this matrix reverses handedness.
-       bool    does_flip() const;      
-
        /// return the magnitude scale of our x coord output
        float   get_x_scale() const;
 
@@ -241,3 +241,4 @@
 // mode: C++
 // indent-tabs-mode: t
 // End:
+// 

Index: server/text.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/text.cpp,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -b -r1.52 -r1.53
--- server/text.cpp     9 Jun 2008 10:18:23 -0000       1.52
+++ server/text.cpp     10 Jun 2008 08:17:46 -0000      1.53
@@ -145,7 +145,7 @@
                                        
                                mat = base_matrix;
                                mat.concatenate_translation(x, y);
-                               mat.concatenate_scale(scale);
+                               mat.concatenate_scale(scale, scale);
 
                                if (index == -1)
                                {

Index: testsuite/server/MatrixTest.cpp
===================================================================
RCS file: /sources/gnash/gnash/testsuite/server/MatrixTest.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- testsuite/server/MatrixTest.cpp     5 Jun 2008 03:26:32 -0000       1.13
+++ testsuite/server/MatrixTest.cpp     10 Jun 2008 08:17:46 -0000      1.14
@@ -70,7 +70,6 @@
        check_equals(identity.get_rotation(), 0);
        check_equals(identity.get_x_translation(), 0);
        check_equals(identity.get_y_translation(), 0);
-       check( ! identity.does_flip() );
 
        // The inverse of identity is still the identity
        matrix invert;
@@ -88,7 +87,6 @@
        check_equals(m1.get_rotation(), 0);
        check_equals(m1.get_x_translation(), 0);
        check_equals(m1.get_y_translation(), 0);
-       check(!m1.does_flip());
 
        m1.set_scale(1.5, 2.5);
        check_equals(D(m1.get_x_scale()), 1.5);
@@ -150,21 +148,21 @@
        // Test concatenation
        //---------------------------------------------
 
-       m1.concatenate_scale(2);
+       m1.concatenate_scale(2, 2);
        check_equals(D(m1.get_x_scale()), 2);
        check_equals(D(m1.get_y_scale()), 4);
        check_equals(D(m1.get_rotation()), 2);
        check_equals(m1.get_x_translation(), 5);
        check_equals(m1.get_y_translation(), 6);
 
-       m1.concatenate_scales(3, 3);
+       m1.concatenate_scale(3, 3);
        check_equals(D(m1.get_x_scale()), 6);
        check_equals(D(m1.get_y_scale()), 12);
        check_equals(D(m1.get_rotation()), 2);
        check_equals(m1.get_x_translation(), 5);
        check_equals(m1.get_y_translation(), 6);
 
-       m1.concatenate_scales(2, 1);
+       m1.concatenate_scale(2, 1);
        check_equals(D(m1.get_x_scale()), 12);
        check_equals(D(m1.get_y_scale()), 12);
        check_equals(D(m1.get_rotation()), 2);
@@ -182,23 +180,18 @@
        m1.set_identity();
 
        // Make a distance of 64 become a distance of 20 .. 
-
        m1.set_scale(20.0/64, 20.0/64);
-    std::cout << m1 << std::endl;
 
        m1.transform(&r, p1);
        check_equals(r.x, 0);
        check_equals(r.y, 0);
 
-    std::cout << m1 << std::endl;
-    
        m1.transform(&r, p2);
        check_equals(r.x, 20);
        check_equals(r.y, 20);
 
        // Translate points to have the origin at 32,32
        // (coordinates expressed in prior-to-scaling matrix)
-    std::cout << m1 << std::endl;
        m1.concatenate_translation(-32, -32);
 
        m1.transform(&r, p1);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]