mirror of
https://github.com/love2d/love.git
synced 2026-08-18 03:34:23 +02:00
Improved performance and reduced temporary memory usage of love.graphics.newScreenshot and Canvas:getImageData
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user