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: Bastiaan Jacques
Subject: [Gnash-commit] gnash ChangeLog backend/render_handler_ogl.cpp
Date: Fri, 13 Jun 2008 12:20:41 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Bastiaan Jacques <bjacques>     08/06/13 12:20:41

Modified files:
        .              : ChangeLog 
        backend        : render_handler_ogl.cpp 

Log message:
        Stick the push-pop matrix sequence in a scoped class.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.6918&r2=1.6919
http://cvs.savannah.gnu.org/viewcvs/gnash/backend/render_handler_ogl.cpp?cvsroot=gnash&r1=1.116&r2=1.117

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.6918
retrieving revision 1.6919
diff -u -b -r1.6918 -r1.6919
--- ChangeLog   13 Jun 2008 10:33:36 -0000      1.6918
+++ ChangeLog   13 Jun 2008 12:20:38 -0000      1.6919
@@ -1,3 +1,8 @@
+2008-06-13 Bastiaan Jacques <address@hidden>
+
+       * backend/render_handler_ogl.cpp: Stick the push-pop matrix sequence
+       in a scoped class.
+
 2008-06-13 Benjamin Wolsey <address@hidden>
 
        * server/vm/ActionExec.cpp: return an exception if there is no

Index: backend/render_handler_ogl.cpp
===================================================================
RCS file: /sources/gnash/gnash/backend/render_handler_ogl.cpp,v
retrieving revision 1.116
retrieving revision 1.117
diff -u -b -r1.116 -r1.117
--- backend/render_handler_ogl.cpp      10 Jun 2008 08:17:45 -0000      1.116
+++ backend/render_handler_ogl.cpp      13 Jun 2008 12:20:40 -0000      1.117
@@ -189,6 +189,34 @@
   GLenum _cap;
 };
 
+
+class oglScopeMatrix : public boost::noncopyable
+{
+public:
+  oglScopeMatrix(const matrix& m)
+  {
+    glPushMatrix();
+
+    // Multiply (AKA "append") the new matrix with the current OpenGL one.
+    float mat[16];
+    memset(&mat[0], 0, sizeof(mat));
+    mat[0] = m.sx / 65536.0f;
+    mat[1] = m.shx / 65536.0f;
+    mat[4] = m.shy / 65536.0f;
+    mat[5] = m.sy / 65536.0f;
+    mat[10] = 1;
+    mat[12] = m.tx;
+    mat[13] = m.ty;
+    mat[15] = 1;
+    glMultMatrixf(mat);
+  }
+  
+  ~oglScopeMatrix()
+  {
+    glPopMatrix();
+  }
+};
+
 static void
 check_error()
 {
@@ -769,25 +797,6 @@
     
   }
   
-  static void
-  apply_matrix(const gnash::matrix& m)
-  // multiply current matrix with opengl matrix
-  {
-    // FIXME: applying matrix transformations is faster than using 
glMultMatrix!
-  
-    float mat[16];
-    memset(&mat[0], 0, sizeof(mat));
-    mat[0] = m.sx / 65536.0f;
-    mat[1] = m.shx / 65536.0f;
-    mat[4] = m.shy / 65536.0f;
-    mat[5] = m.sy / 65536.0f;
-    mat[10] = 1;
-    mat[12] = m.tx;
-    mat[13] = m.ty;
-    mat[15] = 1;
-    glMultMatrixf(mat);
-  }
-
   virtual void
   end_display()
   {
@@ -871,8 +880,7 @@
   draw_line_strip(const boost::int16_t* coords, int vertex_count, const rgba& 
color,
                   const matrix& mat)
   {
-    glPushMatrix();
-    apply_matrix(mat);
+    oglScopeMatrix scope_mat(mat);
 
     glColor3ub(color.m_r, color.m_g, color.m_b);
 
@@ -890,7 +898,6 @@
     glPointSize(1); // return to default
 
     glDisableClientState(GL_VERTEX_ARRAY);
-    glPopMatrix();
   }
 
   // NOTE: this implementation can't handle complex polygons (such as concave
@@ -902,8 +909,7 @@
       return;
     }
 
-    glPushMatrix();
-    apply_matrix(mat);
+    oglScopeMatrix scope_mat(mat);
 
     glColor4ub(fill.m_r, fill.m_g, fill.m_b, fill.m_a);
 
@@ -1614,8 +1620,7 @@
       return; // invisible character
     }    
     
-    glPushMatrix();
-    apply_matrix(mat);
+    oglScopeMatrix scope_mat(mat);
 
     std::vector<PathVec::const_iterator> subshapes = find_subshapes(path_vec);
     
@@ -1631,8 +1636,6 @@
       draw_subshape(subshape_paths, mat, cx, pixel_scale, fill_styles,
                     line_styles);
     }
-    
-    glPopMatrix();    
   }
 
   virtual void draw_glyph(shape_character_def *def, const matrix& mat,
@@ -1649,12 +1652,9 @@
     
     std::vector<line_style> dummy_ls;
     
-    glPushMatrix();
-    apply_matrix(mat);
+    oglScopeMatrix scope_mat(mat);
     
     draw_subshape(def->get_paths(), mat, dummy_cx, pixel_scale, glyph_fs, 
dummy_ls);
-    
-    glPopMatrix();
   }
 
   virtual void set_scale(float xscale, float yscale) {




reply via email to

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