mirror of
https://github.com/love2d/love.git
synced 2026-08-16 16:20:42 +02:00
Data:clone ported to minor
minor tweaks --HG-- branch : minor
This commit is contained in:
@@ -61,6 +61,32 @@ CompressedImageData::CompressedImageData(std::list<CompressedFormatHandler *> fo
|
||||
}
|
||||
}
|
||||
|
||||
CompressedImageData::CompressedImageData(const CompressedImageData &c)
|
||||
{
|
||||
format = c.format;
|
||||
sRGB = c.sRGB;
|
||||
dataSize = c.dataSize;
|
||||
|
||||
data = new uint8[dataSize];
|
||||
memcpy(data, c.data, dataSize);
|
||||
|
||||
for (auto i : c.dataImages )
|
||||
{
|
||||
struct SubImage s;
|
||||
s.width = i.width;
|
||||
s.height = i.height;
|
||||
s.size = i.size;
|
||||
s.data = (uint8*)((intptr_t)data + (intptr_t)i.data - (intptr_t)c.data);
|
||||
|
||||
dataImages.push_back(s);
|
||||
}
|
||||
}
|
||||
|
||||
Data *CompressedImageData::clone() const
|
||||
{
|
||||
return new CompressedImageData(*this);
|
||||
}
|
||||
|
||||
CompressedImageData::~CompressedImageData()
|
||||
{
|
||||
delete[] data;
|
||||
|
||||
@@ -41,8 +41,10 @@ class CompressedImageData : public love::image::CompressedImageData
|
||||
public:
|
||||
|
||||
CompressedImageData(std::list<CompressedFormatHandler *> formats, love::filesystem::FileData *filedata);
|
||||
CompressedImageData(const CompressedImageData &c);
|
||||
virtual ~CompressedImageData();
|
||||
|
||||
virtual Data *clone() const;
|
||||
}; // CompressedImageData
|
||||
|
||||
} // magpie
|
||||
|
||||
@@ -78,6 +78,20 @@ ImageData::ImageData(std::list<FormatHandler *> formatHandlers, int width, int h
|
||||
handler->retain();
|
||||
}
|
||||
|
||||
ImageData::ImageData(const ImageData &c)
|
||||
: formatHandlers(c.formatHandlers)
|
||||
, decodeHandler(nullptr)
|
||||
{
|
||||
width = c.width;
|
||||
height = c.height;
|
||||
format = c.format;
|
||||
|
||||
for (FormatHandler *handler : formatHandlers)
|
||||
handler->retain();
|
||||
|
||||
create(width, height, format, c.getData());
|
||||
}
|
||||
|
||||
ImageData::~ImageData()
|
||||
{
|
||||
if (decodeHandler)
|
||||
@@ -89,6 +103,11 @@ ImageData::~ImageData()
|
||||
handler->release();
|
||||
}
|
||||
|
||||
Data *ImageData::clone() const
|
||||
{
|
||||
return new ImageData(*this);
|
||||
}
|
||||
|
||||
void ImageData::create(int width, int height, PixelFormat format, void *data)
|
||||
{
|
||||
size_t datasize = width * height * getPixelFormatSize(format);
|
||||
|
||||
@@ -42,8 +42,10 @@ public:
|
||||
ImageData(std::list<FormatHandler *> formatHandlers, love::filesystem::FileData *data);
|
||||
ImageData(std::list<FormatHandler *> formatHandlers, int width, int height, PixelFormat format = PIXELFORMAT_RGBA8);
|
||||
ImageData(std::list<FormatHandler *> formatHandlers, int width, int height, PixelFormat format, void *data, bool own);
|
||||
ImageData(const ImageData &c);
|
||||
virtual ~ImageData();
|
||||
|
||||
virtual Data *clone() const;
|
||||
// Implements image::ImageData.
|
||||
virtual love::filesystem::FileData *encode(EncodedFormat encodedFormat, const char *filename);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user