Author: ArcRiley
Date: 2008-01-09 20:36:58 +0000 (Wed, 09 Jan 2008)
New Revision: 759

Modified:
   trunk/pysoy/src/textures/Print.pxi
   trunk/pysoy/src/textures/Texture.pxi
   trunk/pysoy/src/textures/soy.textures.pxd
Log:
adding texture update mutex


Modified: trunk/pysoy/src/textures/Print.pxi
===================================================================
--- trunk/pysoy/src/textures/Print.pxi  2008-01-06 02:50:08 UTC (rev 758)
+++ trunk/pysoy/src/textures/Print.pxi  2008-01-09 20:36:58 UTC (rev 759)
@@ -74,7 +74,7 @@
       return self._text
     def __set__(self, value) :
       if type(value) == str :
-        self._text = value      
+        self._text = value
       else :
         raise TypeError('Text must be a string')
       self._draw()
@@ -102,6 +102,7 @@
     if not (self._font and self._text) :
       return
     # Clear the background
+    py.PyThread_acquire_lock(self._mutex,1)
     self._clear()
     cairo.cairo_select_font_face(self._context,
                                  self._font,
@@ -113,4 +114,4 @@
     cairo.cairo_move_to(self._context, 10.0, 50.0)
     cairo.cairo_show_text(self._context, self._text)
     self._update = 1
-
+    py.PyThread_release_lock(self._mutex)

Modified: trunk/pysoy/src/textures/Texture.pxi
===================================================================
--- trunk/pysoy/src/textures/Texture.pxi        2008-01-06 02:50:08 UTC (rev 
758)
+++ trunk/pysoy/src/textures/Texture.pxi        2008-01-09 20:36:58 UTC (rev 
759)
@@ -23,6 +23,7 @@
      The base texture class which all others inherit
   '''
   def __cinit__(self, *args, **keywords) :
+    self._mutex = py.PyThread_allocate_lock()
     self._iFormats[1] = gl.GL_LUMINANCE8
     self._iFormats[2] = gl.GL_LUMINANCE8_ALPHA8
     self._iFormats[3] = gl.GL_RGB8
@@ -96,6 +97,7 @@
 
 
   cdef void _bind(self) :
+    py.PyThread_acquire_lock(self._mutex,1)
     if self._textureTarget == gl.GL_TEXTURE_1D :
       gl.glEnable(gl.GL_TEXTURE_1D)
     elif self._textureTarget == gl.GL_TEXTURE_2D :
@@ -139,6 +141,7 @@
     if self._scaleX :
       gl.glMatrixMode(gl.GL_TEXTURE)
       gl.glScalef(self._scaleX, self._scaleY, self._scaleZ)
+    py.PyThread_release_lock(self._mutex)
 
     #cdef int max_size
     #gl.glGetIntegerv(gl.GL_MAX_TEXTURE_SIZE, &max_size)
@@ -153,7 +156,9 @@
       gl.glDisable(gl.GL_TEXTURE_2D)
     elif self._textureTarget == gl.GL_TEXTURE_3D :
       gl.glDisable(gl.GL_TEXTURE_3D)
-    gl.glLoadIdentity()
+    if self._scaleX :
+      gl.glMatrixMode(gl.GL_TEXTURE)
+      gl.glLoadIdentity()
 
 
   cdef void _resize(self, int c, int x, int y, int z) :
@@ -198,3 +203,4 @@
     if self._textureID != 0 :
       gl.glDeleteTextures(1, &self._textureID)
     self._resize(0,0,0,0)
+    py.PyThread_free_lock(self._mutex)

Modified: trunk/pysoy/src/textures/soy.textures.pxd
===================================================================
--- trunk/pysoy/src/textures/soy.textures.pxd   2008-01-06 02:50:08 UTC (rev 
758)
+++ trunk/pysoy/src/textures/soy.textures.pxd   2008-01-09 20:36:58 UTC (rev 
759)
@@ -28,6 +28,7 @@
 cdef class Texture (soy._internals.Loadable) :
   cdef gl.GLuint    _textureID
   cdef gl.GLenum    _textureTarget
+  cdef void*        _mutex
   cdef int          _chans
   cdef gl.GLsizei   _width
   cdef gl.GLsizei   _height

_______________________________________________
PySoy-SVN mailing list
[email protected]
http://www.pysoy.org/mailman/listinfo/pysoy-svn

Reply via email to