Improved performance of ImageData:mapPixel (now up to 2x as fast as in 0.8.0!); love.graphics.newImage, Image:refresh, love.window.setIcon, and ImageRasterizers now prevent other threads from modifying the ImageData used in those functions until they're done accessing it

This commit is contained in:
Alex Szpakowski
2013-06-25 05:28:20 -03:00
parent 8d7e0b5629
commit 6e3a7288dd
8 changed files with 191 additions and 28 deletions
+17 -4
View File
@@ -268,6 +268,9 @@ std::string Window::getWindowTitle() const
bool Window::setIcon(love::image::ImageData *imgd)
{
if (!imgd)
return false;
Uint32 rmask, gmask, bmask, amask;
#ifdef LOVE_BIG_ENDIAN
rmask = 0xFF000000;
@@ -281,11 +284,21 @@ bool Window::setIcon(love::image::ImageData *imgd)
amask = 0xFF000000;
#endif
int w = static_cast<int>(imgd->getWidth());
int h = static_cast<int>(imgd->getHeight());
int pitch = static_cast<int>(imgd->getWidth() * 4);
int w = imgd->getWidth();
int h = imgd->getHeight();
int pitch = imgd->getWidth() * 4;
SDL_Surface *icon = 0;
{
// We don't want another thread modifying the ImageData mid-copy.
love::thread::Lock lock(imgd->getMutex());
icon = SDL_CreateRGBSurfaceFrom(imgd->getData(), w, h, 32, pitch, rmask, gmask, bmask, amask);
}
if (!icon)
return false;
SDL_Surface *icon = SDL_CreateRGBSurfaceFrom(imgd->getData(), w, h, 32, pitch, rmask, gmask, bmask, amask);
SDL_WM_SetIcon(icon, NULL);
SDL_FreeSurface(icon);