Commits

illume committed b31db66

releasing GIL around cpu expensive C parts.

Comments (0)

Files changed (2)

 # BUG	= fixed a bug that was (or could have been) crashing
 
 Nov 27, 2006
-    Fixes for scrap, image, and overlay.  Fixes for compiling on windows.
-    Thanks John Popplewell!
+    Fixes scrap, image, overlay, compiling on windows. Thanks John Popplewell!
+    Allowed threads within the transform module. Releasing GIL around C stuff.
 
 Nov 5, 2006
     Fix for SysFont infinite loop bug.  Thanks Regis Desgroppes!
 		SDL_LockSurface(newsurf);
 		PySurface_Lock(surfobj);
 	
+                Py_BEGIN_ALLOW_THREADS
 		stretch(surf, newsurf);
-	
+                Py_END_ALLOW_THREADS
+
 		PySurface_Unlock(surfobj);
 		SDL_UnlockSurface(newsurf);
 	}
         SDL_LockSurface(newsurf);
         SDL_LockSurface(surf);
 
+        Py_BEGIN_ALLOW_THREADS
 	scale2x(surf, newsurf);
+        Py_END_ALLOW_THREADS
 
         SDL_UnlockSurface(surf);
         SDL_UnlockSurface(newsurf);
 
         if(!(((int)angle)%90))
         {
-			PySurface_Lock(surfobj);
+            PySurface_Lock(surfobj);
+
+            Py_BEGIN_ALLOW_THREADS
             newsurf = rotate90(surf, (int)angle);
-			PySurface_Unlock(surfobj);
+            Py_END_ALLOW_THREADS
+
+            PySurface_Unlock(surfobj);
             if(!newsurf) return NULL;
             return PySurface_New(newsurf);
         }
 	SDL_LockSurface(newsurf);
 	PySurface_Lock(surfobj);
 
+        Py_BEGIN_ALLOW_THREADS
 	rotate(surf, newsurf, bgcolor, sangle, cangle);
+        Py_END_ALLOW_THREADS
 
 	PySurface_Unlock(surfobj);
 	SDL_UnlockSurface(newsurf);
 	srcpix = (Uint8*)surf->pixels;
 	dstpix = (Uint8*)newsurf->pixels;
 
+
+        Py_BEGIN_ALLOW_THREADS
+
 	if(!xaxis)
 	{
 		if(!yaxis)
 			}
 		}
 	}
+        Py_END_ALLOW_THREADS
+
+
 
 	PySurface_Unlock(surfobj);
 	SDL_UnlockSurface(newsurf);
 	}
 	else
 	{
+            Py_BEGIN_ALLOW_THREADS
 	    surf32 = SDL_CreateRGBSurface(SDL_SWSURFACE, surf->w, surf->h, 32,
 					0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000);
 		SDL_BlitSurface(surf, NULL, surf32, NULL);
+            Py_END_ALLOW_THREADS
 	}
 
+        Py_BEGIN_ALLOW_THREADS
 	newsurf = rotozoomSurface(surf32, angle, scale, 1);
+        Py_END_ALLOW_THREADS
 
 	if(surf32 == surf)
 		PySurface_Unlock(surfobj);
     return RAISE(PyExc_TypeError, "Rect argument is invalid");
 
   surf=PySurface_AsSurface(surfobj);
+  Py_BEGIN_ALLOW_THREADS
   newsurf=chop(surf, rect->x, rect->y, rect->w, rect->h);
+  Py_END_ALLOW_THREADS
 
   return PySurface_New(newsurf);
 }