mirror of
https://github.com/love2d/love.git
synced 2026-08-16 00:02:12 +02:00
Merged default into minor
--HG-- branch : minor
This commit is contained in:
@@ -44,11 +44,11 @@ class Image : public Module
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
**/
|
||||
virtual ~Image() {}
|
||||
|
||||
// Implements Module.
|
||||
virtual ModuleType getModuleType() const { return M_IMAGE; }
|
||||
|
||||
/**
|
||||
* Creates new ImageData from FileData.
|
||||
* @param data The FileData containing the encoded image data.
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace love
|
||||
namespace image
|
||||
{
|
||||
|
||||
static Image *instance = nullptr;
|
||||
#define instance() (Module::getInstance<Image>(Module::M_IMAGE))
|
||||
|
||||
int w_newImageData(lua_State *L)
|
||||
{
|
||||
@@ -45,7 +45,7 @@ int w_newImageData(lua_State *L)
|
||||
return luaL_error(L, "Invalid image size.");
|
||||
|
||||
ImageData *t = nullptr;
|
||||
luax_catchexcept(L, [&](){ t = instance->newImageData(w, h); });
|
||||
luax_catchexcept(L, [&](){ t = instance()->newImageData(w, h); });
|
||||
|
||||
luax_pushtype(L, "ImageData", IMAGE_IMAGE_DATA_T, t);
|
||||
return 1;
|
||||
@@ -56,7 +56,7 @@ int w_newImageData(lua_State *L)
|
||||
|
||||
ImageData *t = nullptr;
|
||||
luax_catchexcept(L,
|
||||
[&]() { t = instance->newImageData(data); },
|
||||
[&]() { t = instance()->newImageData(data); },
|
||||
[&]() { data->release(); }
|
||||
);
|
||||
|
||||
@@ -70,7 +70,7 @@ int w_newCompressedData(lua_State *L)
|
||||
|
||||
CompressedData *t = nullptr;
|
||||
luax_catchexcept(L,
|
||||
[&]() { t = instance->newCompressedData(data); },
|
||||
[&]() { t = instance()->newCompressedData(data); },
|
||||
[&]() { data->release(); }
|
||||
);
|
||||
|
||||
@@ -81,7 +81,7 @@ int w_newCompressedData(lua_State *L)
|
||||
int w_isCompressed(lua_State *L)
|
||||
{
|
||||
love::filesystem::FileData *data = love::filesystem::luax_getfiledata(L, 1);
|
||||
bool compressed = instance->isCompressed(data);
|
||||
bool compressed = instance()->isCompressed(data);
|
||||
data->release();
|
||||
|
||||
luax_pushboolean(L, compressed);
|
||||
@@ -106,6 +106,7 @@ static const lua_CFunction types[] =
|
||||
|
||||
extern "C" int luaopen_love_image(lua_State *L)
|
||||
{
|
||||
Image *instance = instance();
|
||||
if (instance == nullptr)
|
||||
{
|
||||
luax_catchexcept(L, [&](){ instance = new love::image::magpie::Image(); });
|
||||
|
||||
Reference in New Issue
Block a user