Improved performance and reduced temporary memory usage of love.graphics.newScreenshot and Canvas:getImageData

This commit is contained in:
Alex Szpakowski
2013-06-15 22:07:16 -03:00
parent 15535517d6
commit f25efcc8af
7 changed files with 18 additions and 12 deletions
+2 -2
View File
@@ -57,9 +57,9 @@ love::image::ImageData *Image::newImageData(int width, int height)
return new ImageData(width, height);
}
love::image::ImageData *Image::newImageData(int width, int height, void *data)
love::image::ImageData *Image::newImageData(int width, int height, void *data, bool own)
{
return new ImageData(width, height, data);
return new ImageData(width, height, data, own);
}
love::image::CompressedData *Image::newCompressedData(love::filesystem::FileData *data)
+1 -1
View File
@@ -48,7 +48,7 @@ public:
love::image::ImageData *newImageData(love::filesystem::FileData *data);
love::image::ImageData *newImageData(int width, int height);
love::image::ImageData *newImageData(int width, int height, void *data);
love::image::ImageData *newImageData(int width, int height, void *data, bool own = false);
love::image::CompressedData *newCompressedData(love::filesystem::FileData *data);
+6 -2
View File
@@ -45,11 +45,15 @@ ImageData::ImageData(int width, int height)
memset(data, 0, width*height*sizeof(pixel));
}
ImageData::ImageData(int width, int height, void *data)
ImageData::ImageData(int width, int height, void *data, bool own)
{
this->width = width;
this->height = height;
create(width, height, data);
if (own)
this->data = (unsigned char *) data;
else
create(width, height, data);
}
ImageData::~ImageData()
+1 -1
View File
@@ -38,7 +38,7 @@ public:
ImageData(love::filesystem::FileData *data);
ImageData(int width, int height);
ImageData(int width, int height, void *data);
ImageData(int width, int height, void *data, bool own);
virtual ~ImageData();
// Implements image::ImageData.