mirror of
https://github.com/love2d/love.git
synced 2026-08-16 00:02:12 +02:00
Added love.math.compress(data, format [, level]) and love.math.decompress(compresseddata) / love.math.decompress(compressedstring, format).
Renamed the love.image CompressedData type to CompressedImageData. love.math.compress returns a love.math CompressedData object which holds the newly compressed data. Currently supported formats are "lz4" and "zlib". Note that the formats are not file formats and don't compress filesystem hierarchies.
This commit is contained in:
@@ -1,139 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2015 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
* appreciated but is not required.
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
**/
|
||||
|
||||
#include "CompressedData.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace image
|
||||
{
|
||||
|
||||
CompressedData::CompressedData()
|
||||
: format(FORMAT_UNKNOWN)
|
||||
, sRGB(false)
|
||||
, data(nullptr)
|
||||
, dataSize(0)
|
||||
{
|
||||
}
|
||||
|
||||
CompressedData::~CompressedData()
|
||||
{
|
||||
}
|
||||
|
||||
size_t CompressedData::getSize() const
|
||||
{
|
||||
return dataSize;
|
||||
}
|
||||
|
||||
void *CompressedData::getData() const
|
||||
{
|
||||
return data;
|
||||
}
|
||||
|
||||
int CompressedData::getMipmapCount() const
|
||||
{
|
||||
return (int) dataImages.size();
|
||||
}
|
||||
|
||||
size_t CompressedData::getSize(int miplevel) const
|
||||
{
|
||||
checkMipmapLevelExists(miplevel);
|
||||
|
||||
return dataImages[miplevel].size;
|
||||
}
|
||||
|
||||
void *CompressedData::getData(int miplevel) const
|
||||
{
|
||||
checkMipmapLevelExists(miplevel);
|
||||
|
||||
return &dataImages[miplevel].data[0];
|
||||
}
|
||||
|
||||
int CompressedData::getWidth(int miplevel) const
|
||||
{
|
||||
checkMipmapLevelExists(miplevel);
|
||||
|
||||
return dataImages[miplevel].width;
|
||||
}
|
||||
|
||||
int CompressedData::getHeight(int miplevel) const
|
||||
{
|
||||
checkMipmapLevelExists(miplevel);
|
||||
|
||||
return dataImages[miplevel].height;
|
||||
}
|
||||
|
||||
CompressedData::Format CompressedData::getFormat() const
|
||||
{
|
||||
return format;
|
||||
}
|
||||
|
||||
bool CompressedData::isSRGB() const
|
||||
{
|
||||
return sRGB;
|
||||
}
|
||||
|
||||
void CompressedData::checkMipmapLevelExists(int miplevel) const
|
||||
{
|
||||
if (miplevel < 0 || miplevel >= (int) dataImages.size())
|
||||
throw love::Exception("Mipmap level %d does not exist", miplevel + 1);
|
||||
}
|
||||
|
||||
bool CompressedData::getConstant(const char *in, CompressedData::Format &out)
|
||||
{
|
||||
return formats.find(in, out);
|
||||
}
|
||||
|
||||
bool CompressedData::getConstant(CompressedData::Format in, const char *&out)
|
||||
{
|
||||
return formats.find(in, out);
|
||||
}
|
||||
|
||||
StringMap<CompressedData::Format, CompressedData::FORMAT_MAX_ENUM>::Entry CompressedData::formatEntries[] =
|
||||
{
|
||||
{"unknown", CompressedData::FORMAT_UNKNOWN},
|
||||
{"DXT1", CompressedData::FORMAT_DXT1},
|
||||
{"DXT3", CompressedData::FORMAT_DXT3},
|
||||
{"DXT5", CompressedData::FORMAT_DXT5},
|
||||
{"BC4", CompressedData::FORMAT_BC4},
|
||||
{"BC4s", CompressedData::FORMAT_BC4s},
|
||||
{"BC5", CompressedData::FORMAT_BC5},
|
||||
{"BC5s", CompressedData::FORMAT_BC5s},
|
||||
{"BC6h", CompressedData::FORMAT_BC6H},
|
||||
{"BC6hs", CompressedData::FORMAT_BC6Hs},
|
||||
{"BC7", CompressedData::FORMAT_BC7},
|
||||
{"ETC1", CompressedData::FORMAT_ETC1},
|
||||
{"ETC2rgb", CompressedData::FORMAT_ETC2_RGB},
|
||||
{"ETC2rgba", CompressedData::FORMAT_ETC2_RGBA},
|
||||
{"ETC2rgba1", CompressedData::FORMAT_ETC2_RGBA1},
|
||||
{"EACr", CompressedData::FORMAT_EAC_R},
|
||||
{"EACrs", CompressedData::FORMAT_EAC_Rs},
|
||||
{"EACrg", CompressedData::FORMAT_EAC_RG},
|
||||
{"EACrgs", CompressedData::FORMAT_EAC_RGs},
|
||||
{"PVR1rgb2", CompressedData::FORMAT_PVR1_RGB2},
|
||||
{"PVR1rgb4", CompressedData::FORMAT_PVR1_RGB4},
|
||||
{"PVR1rgba2", CompressedData::FORMAT_PVR1_RGBA2},
|
||||
{"PVR1rgba4", CompressedData::FORMAT_PVR1_RGBA4},
|
||||
};
|
||||
|
||||
StringMap<CompressedData::Format, CompressedData::FORMAT_MAX_ENUM> CompressedData::formats(CompressedData::formatEntries, sizeof(CompressedData::formatEntries));
|
||||
|
||||
} // image
|
||||
} // love
|
||||
@@ -0,0 +1,139 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2015 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
* appreciated but is not required.
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
**/
|
||||
|
||||
#include "CompressedImageData.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace image
|
||||
{
|
||||
|
||||
CompressedImageData::CompressedImageData()
|
||||
: format(FORMAT_UNKNOWN)
|
||||
, sRGB(false)
|
||||
, data(nullptr)
|
||||
, dataSize(0)
|
||||
{
|
||||
}
|
||||
|
||||
CompressedImageData::~CompressedImageData()
|
||||
{
|
||||
}
|
||||
|
||||
size_t CompressedImageData::getSize() const
|
||||
{
|
||||
return dataSize;
|
||||
}
|
||||
|
||||
void *CompressedImageData::getData() const
|
||||
{
|
||||
return data;
|
||||
}
|
||||
|
||||
int CompressedImageData::getMipmapCount() const
|
||||
{
|
||||
return (int) dataImages.size();
|
||||
}
|
||||
|
||||
size_t CompressedImageData::getSize(int miplevel) const
|
||||
{
|
||||
checkMipmapLevelExists(miplevel);
|
||||
|
||||
return dataImages[miplevel].size;
|
||||
}
|
||||
|
||||
void *CompressedImageData::getData(int miplevel) const
|
||||
{
|
||||
checkMipmapLevelExists(miplevel);
|
||||
|
||||
return &dataImages[miplevel].data[0];
|
||||
}
|
||||
|
||||
int CompressedImageData::getWidth(int miplevel) const
|
||||
{
|
||||
checkMipmapLevelExists(miplevel);
|
||||
|
||||
return dataImages[miplevel].width;
|
||||
}
|
||||
|
||||
int CompressedImageData::getHeight(int miplevel) const
|
||||
{
|
||||
checkMipmapLevelExists(miplevel);
|
||||
|
||||
return dataImages[miplevel].height;
|
||||
}
|
||||
|
||||
CompressedImageData::Format CompressedImageData::getFormat() const
|
||||
{
|
||||
return format;
|
||||
}
|
||||
|
||||
bool CompressedImageData::isSRGB() const
|
||||
{
|
||||
return sRGB;
|
||||
}
|
||||
|
||||
void CompressedImageData::checkMipmapLevelExists(int miplevel) const
|
||||
{
|
||||
if (miplevel < 0 || miplevel >= (int) dataImages.size())
|
||||
throw love::Exception("Mipmap level %d does not exist", miplevel + 1);
|
||||
}
|
||||
|
||||
bool CompressedImageData::getConstant(const char *in, CompressedImageData::Format &out)
|
||||
{
|
||||
return formats.find(in, out);
|
||||
}
|
||||
|
||||
bool CompressedImageData::getConstant(CompressedImageData::Format in, const char *&out)
|
||||
{
|
||||
return formats.find(in, out);
|
||||
}
|
||||
|
||||
StringMap<CompressedImageData::Format, CompressedImageData::FORMAT_MAX_ENUM>::Entry CompressedImageData::formatEntries[] =
|
||||
{
|
||||
{"unknown", FORMAT_UNKNOWN},
|
||||
{"DXT1", FORMAT_DXT1},
|
||||
{"DXT3", FORMAT_DXT3},
|
||||
{"DXT5", FORMAT_DXT5},
|
||||
{"BC4", FORMAT_BC4},
|
||||
{"BC4s", FORMAT_BC4s},
|
||||
{"BC5", FORMAT_BC5},
|
||||
{"BC5s", FORMAT_BC5s},
|
||||
{"BC6h", FORMAT_BC6H},
|
||||
{"BC6hs", FORMAT_BC6Hs},
|
||||
{"BC7", FORMAT_BC7},
|
||||
{"ETC1", FORMAT_ETC1},
|
||||
{"ETC2rgb", FORMAT_ETC2_RGB},
|
||||
{"ETC2rgba", FORMAT_ETC2_RGBA},
|
||||
{"ETC2rgba1", FORMAT_ETC2_RGBA1},
|
||||
{"EACr", FORMAT_EAC_R},
|
||||
{"EACrs", FORMAT_EAC_Rs},
|
||||
{"EACrg", FORMAT_EAC_RG},
|
||||
{"EACrgs", FORMAT_EAC_RGs},
|
||||
{"PVR1rgb2", FORMAT_PVR1_RGB2},
|
||||
{"PVR1rgb4", FORMAT_PVR1_RGB4},
|
||||
{"PVR1rgba2", FORMAT_PVR1_RGBA2},
|
||||
{"PVR1rgba4", FORMAT_PVR1_RGBA4},
|
||||
};
|
||||
|
||||
StringMap<CompressedImageData::Format, CompressedImageData::FORMAT_MAX_ENUM> CompressedImageData::formats(CompressedImageData::formatEntries, sizeof(CompressedImageData::formatEntries));
|
||||
|
||||
} // image
|
||||
} // love
|
||||
@@ -18,8 +18,8 @@
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
**/
|
||||
|
||||
#ifndef LOVE_IMAGE_COMPRESSED_DATA_H
|
||||
#define LOVE_IMAGE_COMPRESSED_DATA_H
|
||||
#ifndef LOVE_IMAGE_COMPRESSED_IMAGE_DATA_H
|
||||
#define LOVE_IMAGE_COMPRESSED_IMAGE_DATA_H
|
||||
|
||||
// LOVE
|
||||
#include "common/Data.h"
|
||||
@@ -35,11 +35,11 @@ namespace image
|
||||
{
|
||||
|
||||
/**
|
||||
* CompressedData represents image data which is designed to be uploaded to the
|
||||
* GPU and rendered in its compressed form, without being un-compressed.
|
||||
* CompressedImageData represents image data which is designed to be uploaded to
|
||||
* the GPU and rendered in its compressed form, without being decompressed.
|
||||
* http://renderingpipeline.com/2012/07/texture-compression/
|
||||
**/
|
||||
class CompressedData : public Data
|
||||
class CompressedImageData : public Data
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -81,8 +81,8 @@ public:
|
||||
uint8 *data; // Should not have ownership of the data.
|
||||
};
|
||||
|
||||
CompressedData();
|
||||
virtual ~CompressedData();
|
||||
CompressedImageData();
|
||||
virtual ~CompressedImageData();
|
||||
|
||||
// Implements Data.
|
||||
virtual void *getData() const;
|
||||
@@ -144,9 +144,9 @@ private:
|
||||
static StringMap<Format, FORMAT_MAX_ENUM>::Entry formatEntries[];
|
||||
static StringMap<Format, FORMAT_MAX_ENUM> formats;
|
||||
|
||||
}; // CompressedData
|
||||
}; // CompressedImageData
|
||||
|
||||
} // image
|
||||
} // love
|
||||
|
||||
#endif // LOVE_IMAGE_COMPRESSED_DATA_H
|
||||
#endif // LOVE_IMAGE_COMPRESSED_IMAGE_DATA_H
|
||||
@@ -26,7 +26,7 @@
|
||||
#include "common/Module.h"
|
||||
#include "filesystem/File.h"
|
||||
#include "ImageData.h"
|
||||
#include "CompressedData.h"
|
||||
#include "CompressedImageData.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
@@ -76,11 +76,11 @@ public:
|
||||
virtual ImageData *newImageData(int width, int height, void *data, bool own = false) = 0;
|
||||
|
||||
/**
|
||||
* Creates new CompressedData from FileData.
|
||||
* Creates new CompressedImageData from FileData.
|
||||
* @param data The FileData containing the compressed image data.
|
||||
* @return The new CompressedData.
|
||||
* @return The new CompressedImageData.
|
||||
**/
|
||||
virtual CompressedData *newCompressedData(love::filesystem::FileData *data) = 0;
|
||||
virtual CompressedImageData *newCompressedData(love::filesystem::FileData *data) = 0;
|
||||
|
||||
/**
|
||||
* Determines whether a FileData is Compressed image data or not.
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
// LOVE
|
||||
#include "filesystem/FileData.h"
|
||||
#include "image/CompressedData.h"
|
||||
#include "image/CompressedImageData.h"
|
||||
#include "common/Object.h"
|
||||
|
||||
namespace love
|
||||
@@ -34,7 +34,7 @@ namespace magpie
|
||||
{
|
||||
|
||||
/**
|
||||
* Base class for all CompressedData parser library interfaces.
|
||||
* Base class for all CompressedImageData parser library interfaces.
|
||||
* We inherit from love::Object to take advantage of reference counting...
|
||||
**/
|
||||
class CompressedFormatHandler : public love::Object
|
||||
@@ -45,7 +45,7 @@ public:
|
||||
virtual ~CompressedFormatHandler() {}
|
||||
|
||||
/**
|
||||
* Determines whether a particular FileData can be parsed as CompressedData
|
||||
* Determines whether a particular FileData can be parsed as CompressedImageData
|
||||
* by this handler.
|
||||
* @param data The data to parse.
|
||||
**/
|
||||
@@ -64,8 +64,8 @@ public:
|
||||
*
|
||||
* @return The single block of memory containing the parsed images.
|
||||
**/
|
||||
virtual uint8 *parse(filesystem::FileData *filedata, std::vector<CompressedData::SubImage> &images,
|
||||
size_t &dataSize, CompressedData::Format &format, bool &sRGB) = 0;
|
||||
virtual uint8 *parse(filesystem::FileData *filedata, std::vector<CompressedImageData::SubImage> &images,
|
||||
size_t &dataSize, CompressedImageData::Format &format, bool &sRGB) = 0;
|
||||
|
||||
}; // CompressedFormatHandler
|
||||
|
||||
|
||||
+3
-3
@@ -18,7 +18,7 @@
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
**/
|
||||
|
||||
#include "CompressedData.h"
|
||||
#include "CompressedImageData.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
@@ -27,7 +27,7 @@ namespace image
|
||||
namespace magpie
|
||||
{
|
||||
|
||||
CompressedData::CompressedData(std::list<CompressedFormatHandler *> formats, love::filesystem::FileData *filedata)
|
||||
CompressedImageData::CompressedImageData(std::list<CompressedFormatHandler *> formats, love::filesystem::FileData *filedata)
|
||||
{
|
||||
CompressedFormatHandler *parser = nullptr;
|
||||
|
||||
@@ -61,7 +61,7 @@ CompressedData::CompressedData(std::list<CompressedFormatHandler *> formats, lov
|
||||
}
|
||||
}
|
||||
|
||||
CompressedData::~CompressedData()
|
||||
CompressedImageData::~CompressedImageData()
|
||||
{
|
||||
delete[] data;
|
||||
}
|
||||
+8
-8
@@ -18,13 +18,13 @@
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
**/
|
||||
|
||||
#ifndef LOVE_IMAGE_MAGPIE_COMPRESSED_DATA_H
|
||||
#define LOVE_IMAGE_MAGPIE_COMPRESSED_DATA_H
|
||||
#ifndef LOVE_IMAGE_MAGPIE_COMPRESSED_IMAGE_DATA_H
|
||||
#define LOVE_IMAGE_MAGPIE_COMPRESSED_IMAGE_DATA_H
|
||||
|
||||
// LOVE
|
||||
#include "CompressedFormatHandler.h"
|
||||
#include "filesystem/FileData.h"
|
||||
#include "image/CompressedData.h"
|
||||
#include "image/CompressedImageData.h"
|
||||
|
||||
// C++
|
||||
#include <list>
|
||||
@@ -36,17 +36,17 @@ namespace image
|
||||
namespace magpie
|
||||
{
|
||||
|
||||
class CompressedData : public love::image::CompressedData
|
||||
class CompressedImageData : public love::image::CompressedImageData
|
||||
{
|
||||
public:
|
||||
|
||||
CompressedData(std::list<CompressedFormatHandler *> formats, love::filesystem::FileData *filedata);
|
||||
virtual ~CompressedData();
|
||||
CompressedImageData(std::list<CompressedFormatHandler *> formats, love::filesystem::FileData *filedata);
|
||||
virtual ~CompressedImageData();
|
||||
|
||||
}; // CompressedData
|
||||
}; // CompressedImageData
|
||||
|
||||
} // magpie
|
||||
} // image
|
||||
} // love
|
||||
|
||||
#endif // LOVE_IMAGE_MAGPIE_COMPRESSED_DATA_H
|
||||
#endif // LOVE_IMAGE_MAGPIE_COMPRESSED_IMAGE_DATA_H
|
||||
@@ -21,7 +21,7 @@
|
||||
#include "Image.h"
|
||||
|
||||
#include "ImageData.h"
|
||||
#include "CompressedData.h"
|
||||
#include "CompressedImageData.h"
|
||||
|
||||
#include "JPEGHandler.h"
|
||||
#include "PNGHandler.h"
|
||||
@@ -91,9 +91,9 @@ love::image::ImageData *Image::newImageData(int width, int height, void *data, b
|
||||
return new ImageData(formatHandlers, width, height, data, own);
|
||||
}
|
||||
|
||||
love::image::CompressedData *Image::newCompressedData(love::filesystem::FileData *data)
|
||||
love::image::CompressedImageData *Image::newCompressedData(love::filesystem::FileData *data)
|
||||
{
|
||||
return new CompressedData(compressedFormatHandlers, data);
|
||||
return new CompressedImageData(compressedFormatHandlers, data);
|
||||
}
|
||||
|
||||
bool Image::isCompressed(love::filesystem::FileData *data)
|
||||
|
||||
@@ -55,7 +55,7 @@ public:
|
||||
love::image::ImageData *newImageData(int width, int height);
|
||||
love::image::ImageData *newImageData(int width, int height, void *data, bool own = false);
|
||||
|
||||
love::image::CompressedData *newCompressedData(love::filesystem::FileData *data);
|
||||
love::image::CompressedImageData *newCompressedData(love::filesystem::FileData *data);
|
||||
|
||||
bool isCompressed(love::filesystem::FileData *data);
|
||||
|
||||
@@ -64,7 +64,7 @@ private:
|
||||
// Image format handlers we can use for decoding and encoding ImageData.
|
||||
std::list<FormatHandler *> formatHandlers;
|
||||
|
||||
// Compressed image format handers we can use for parsing CompressedData.
|
||||
// Compressed image format handers we can use for parsing CompressedImageData.
|
||||
std::list<CompressedFormatHandler *> compressedFormatHandlers;
|
||||
|
||||
}; // Image
|
||||
|
||||
@@ -90,53 +90,53 @@ enum KTXGLInternalFormat
|
||||
KTX_GL_COMPRESSED_RGBA_S3TC_DXT5_EXT = 0x83F3
|
||||
};
|
||||
|
||||
CompressedData::Format convertFormat(uint32 glformat, bool &sRGB)
|
||||
CompressedImageData::Format convertFormat(uint32 glformat, bool &sRGB)
|
||||
{
|
||||
sRGB = false;
|
||||
|
||||
switch (glformat)
|
||||
{
|
||||
case KTX_GL_ETC1_RGB8_OES:
|
||||
return CompressedData::FORMAT_ETC1;
|
||||
return CompressedImageData::FORMAT_ETC1;
|
||||
case KTX_GL_COMPRESSED_R11_EAC:
|
||||
return CompressedData::FORMAT_EAC_R;
|
||||
return CompressedImageData::FORMAT_EAC_R;
|
||||
case KTX_GL_COMPRESSED_SIGNED_R11_EAC:
|
||||
return CompressedData::FORMAT_EAC_Rs;
|
||||
return CompressedImageData::FORMAT_EAC_Rs;
|
||||
case KTX_GL_COMPRESSED_RG11_EAC:
|
||||
return CompressedData::FORMAT_EAC_RG;
|
||||
return CompressedImageData::FORMAT_EAC_RG;
|
||||
case KTX_GL_COMPRESSED_SIGNED_RG11_EAC:
|
||||
return CompressedData::FORMAT_EAC_RGs;
|
||||
return CompressedImageData::FORMAT_EAC_RGs;
|
||||
case KTX_GL_COMPRESSED_RGB8_ETC2:
|
||||
return CompressedData::FORMAT_ETC2_RGB;
|
||||
return CompressedImageData::FORMAT_ETC2_RGB;
|
||||
case KTX_GL_COMPRESSED_SRGB8_ETC2:
|
||||
sRGB = true;
|
||||
return CompressedData::FORMAT_ETC2_RGB;
|
||||
return CompressedImageData::FORMAT_ETC2_RGB;
|
||||
case KTX_GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2:
|
||||
return CompressedData::FORMAT_ETC2_RGBA1;
|
||||
return CompressedImageData::FORMAT_ETC2_RGBA1;
|
||||
case KTX_GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2:
|
||||
sRGB = true;
|
||||
return CompressedData::FORMAT_ETC2_RGBA1;
|
||||
return CompressedImageData::FORMAT_ETC2_RGBA1;
|
||||
case KTX_GL_COMPRESSED_RGBA8_ETC2_EAC:
|
||||
return CompressedData::FORMAT_ETC2_RGBA;
|
||||
return CompressedImageData::FORMAT_ETC2_RGBA;
|
||||
case KTX_GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:
|
||||
sRGB = true;
|
||||
return CompressedData::FORMAT_ETC2_RGBA;
|
||||
return CompressedImageData::FORMAT_ETC2_RGBA;
|
||||
case KTX_GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG:
|
||||
return CompressedData::FORMAT_PVR1_RGB4;
|
||||
return CompressedImageData::FORMAT_PVR1_RGB4;
|
||||
case KTX_GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG:
|
||||
return CompressedData::FORMAT_PVR1_RGB2;
|
||||
return CompressedImageData::FORMAT_PVR1_RGB2;
|
||||
case KTX_GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG:
|
||||
return CompressedData::FORMAT_PVR1_RGBA4;
|
||||
return CompressedImageData::FORMAT_PVR1_RGBA4;
|
||||
case KTX_GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG:
|
||||
return CompressedData::FORMAT_PVR1_RGBA2;
|
||||
return CompressedImageData::FORMAT_PVR1_RGBA2;
|
||||
case KTX_GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
|
||||
return CompressedData::FORMAT_DXT1;
|
||||
return CompressedImageData::FORMAT_DXT1;
|
||||
case KTX_GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
|
||||
return CompressedData::FORMAT_DXT3;
|
||||
return CompressedImageData::FORMAT_DXT3;
|
||||
case KTX_GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
|
||||
return CompressedData::FORMAT_DXT5;
|
||||
return CompressedImageData::FORMAT_DXT5;
|
||||
default:
|
||||
return CompressedData::FORMAT_UNKNOWN;
|
||||
return CompressedImageData::FORMAT_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,7 +159,7 @@ bool KTXHandler::canParse(const filesystem::FileData *data)
|
||||
return true;
|
||||
}
|
||||
|
||||
uint8 *KTXHandler::parse(filesystem::FileData *filedata, std::vector<CompressedData::SubImage> &images, size_t &dataSize, CompressedData::Format &format, bool &sRGB)
|
||||
uint8 *KTXHandler::parse(filesystem::FileData *filedata, std::vector<CompressedImageData::SubImage> &images, size_t &dataSize, CompressedImageData::Format &format, bool &sRGB)
|
||||
{
|
||||
if (!canParse(filedata))
|
||||
throw love::Exception("Could not decode compressed data (not a KTX file?)");
|
||||
@@ -176,9 +176,9 @@ uint8 *KTXHandler::parse(filesystem::FileData *filedata, std::vector<CompressedD
|
||||
header.numberOfMipmapLevels = std::max(header.numberOfMipmapLevels, 1u);
|
||||
|
||||
bool isSRGB = false;
|
||||
CompressedData::Format cformat = convertFormat(header.glInternalFormat, isSRGB);
|
||||
CompressedImageData::Format cformat = convertFormat(header.glInternalFormat, isSRGB);
|
||||
|
||||
if (cformat == CompressedData::FORMAT_UNKNOWN)
|
||||
if (cformat == CompressedImageData::FORMAT_UNKNOWN)
|
||||
throw love::Exception("Unsupported image format in KTX file.");
|
||||
|
||||
if (header.numberOfArrayElements > 0)
|
||||
@@ -241,7 +241,7 @@ uint8 *KTXHandler::parse(filesystem::FileData *filedata, std::vector<CompressedD
|
||||
|
||||
uint32 mipsizepadded = (mipsize + 3) & ~uint32(3);
|
||||
|
||||
CompressedData::SubImage mip;
|
||||
CompressedImageData::SubImage mip;
|
||||
mip.width = (int) std::max(header.pixelWidth >> i, 1u);
|
||||
mip.height = (int) std::max(header.pixelHeight >> i, 1u);
|
||||
mip.size = mipsize;
|
||||
|
||||
@@ -42,7 +42,7 @@ public:
|
||||
|
||||
// Implements CompressedFormatHandler.
|
||||
virtual bool canParse(const filesystem::FileData *data);
|
||||
virtual uint8 *parse(filesystem::FileData *filedata, std::vector<CompressedData::SubImage> &images, size_t &dataSize, CompressedData::Format &format, bool &sRGB);
|
||||
virtual uint8 *parse(filesystem::FileData *filedata, std::vector<CompressedImageData::SubImage> &images, size_t &dataSize, CompressedImageData::Format &format, bool &sRGB);
|
||||
|
||||
}; // KTXHandler
|
||||
|
||||
|
||||
@@ -68,29 +68,29 @@ enum PKMTextureFormat
|
||||
ETC2PACKAGE_RG_SIGNED_NO_MIPMAPS
|
||||
};
|
||||
|
||||
CompressedData::Format convertFormat(uint16 texformat)
|
||||
static CompressedImageData::Format convertFormat(uint16 texformat)
|
||||
{
|
||||
switch (texformat)
|
||||
{
|
||||
case ETC1_RGB_NO_MIPMAPS:
|
||||
return CompressedData::FORMAT_ETC1;
|
||||
return CompressedImageData::FORMAT_ETC1;
|
||||
case ETC2PACKAGE_RGB_NO_MIPMAPS:
|
||||
return CompressedData::FORMAT_ETC2_RGB;
|
||||
return CompressedImageData::FORMAT_ETC2_RGB;
|
||||
case ETC2PACKAGE_RGBA_NO_MIPMAPS_OLD:
|
||||
case ETC2PACKAGE_RGBA_NO_MIPMAPS:
|
||||
return CompressedData::FORMAT_ETC2_RGBA;
|
||||
return CompressedImageData::FORMAT_ETC2_RGBA;
|
||||
case ETC2PACKAGE_RGBA1_NO_MIPMAPS:
|
||||
return CompressedData::FORMAT_ETC2_RGBA1;
|
||||
return CompressedImageData::FORMAT_ETC2_RGBA1;
|
||||
case ETC2PACKAGE_R_NO_MIPMAPS:
|
||||
return CompressedData::FORMAT_EAC_R;
|
||||
return CompressedImageData::FORMAT_EAC_R;
|
||||
case ETC2PACKAGE_RG_NO_MIPMAPS:
|
||||
return CompressedData::FORMAT_EAC_RG;
|
||||
return CompressedImageData::FORMAT_EAC_RG;
|
||||
case ETC2PACKAGE_R_SIGNED_NO_MIPMAPS:
|
||||
return CompressedData::FORMAT_EAC_Rs;
|
||||
return CompressedImageData::FORMAT_EAC_Rs;
|
||||
case ETC2PACKAGE_RG_SIGNED_NO_MIPMAPS:
|
||||
return CompressedData::FORMAT_EAC_RGs;
|
||||
return CompressedImageData::FORMAT_EAC_RGs;
|
||||
default:
|
||||
return CompressedData::FORMAT_UNKNOWN;
|
||||
return CompressedImageData::FORMAT_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ bool PKMHandler::canParse(const filesystem::FileData *data)
|
||||
return true;
|
||||
}
|
||||
|
||||
uint8 *PKMHandler::parse(filesystem::FileData *filedata, std::vector<CompressedData::SubImage> &images, size_t &dataSize, CompressedData::Format &format, bool &sRGB)
|
||||
uint8 *PKMHandler::parse(filesystem::FileData *filedata, std::vector<CompressedImageData::SubImage> &images, size_t &dataSize, CompressedImageData::Format &format, bool &sRGB)
|
||||
{
|
||||
if (!canParse(filedata))
|
||||
throw love::Exception("Could not decode compressed data (not a PKM file?)");
|
||||
@@ -126,9 +126,9 @@ uint8 *PKMHandler::parse(filesystem::FileData *filedata, std::vector<CompressedD
|
||||
header.widthBig = swap16big(header.widthBig);
|
||||
header.heightBig = swap16big(header.heightBig);
|
||||
|
||||
CompressedData::Format cformat = convertFormat(header.textureFormatBig);
|
||||
CompressedImageData::Format cformat = convertFormat(header.textureFormatBig);
|
||||
|
||||
if (cformat == CompressedData::FORMAT_UNKNOWN)
|
||||
if (cformat == CompressedImageData::FORMAT_UNKNOWN)
|
||||
throw love::Exception("Could not parse PKM file: unsupported texture format.");
|
||||
|
||||
// The rest of the file after the header is all texture data.
|
||||
@@ -147,7 +147,7 @@ uint8 *PKMHandler::parse(filesystem::FileData *filedata, std::vector<CompressedD
|
||||
// PKM files only store a single mipmap level.
|
||||
memcpy(data, (uint8 *) filedata->getData() + sizeof(PKMHeader), totalsize);
|
||||
|
||||
CompressedData::SubImage mip;
|
||||
CompressedImageData::SubImage mip;
|
||||
|
||||
// TODO: verify whether glCompressedTexImage works properly with the unpadded
|
||||
// width and height values (extended == padded.)
|
||||
|
||||
@@ -42,7 +42,7 @@ public:
|
||||
|
||||
// Implements CompressedFormatHandler.
|
||||
virtual bool canParse(const filesystem::FileData *data);
|
||||
virtual uint8 *parse(filesystem::FileData *filedata, std::vector<CompressedData::SubImage> &images, size_t &dataSize, CompressedData::Format &format, bool &sRGB);
|
||||
virtual uint8 *parse(filesystem::FileData *filedata, std::vector<CompressedImageData::SubImage> &images, size_t &dataSize, CompressedImageData::Format &format, bool &sRGB);
|
||||
|
||||
}; // PKMHandler
|
||||
|
||||
|
||||
@@ -163,28 +163,28 @@ void ConvertPVRHeader(PVRTexHeaderV2 header2, PVRTexHeaderV3 *header3)
|
||||
}
|
||||
}
|
||||
|
||||
CompressedData::Format convertFormat(PVRV3PixelFormat format)
|
||||
static CompressedImageData::Format convertFormat(PVRV3PixelFormat format)
|
||||
{
|
||||
switch (format)
|
||||
{
|
||||
case ePVRTPF_PVRTCI_2bpp_RGB:
|
||||
return CompressedData::FORMAT_PVR1_RGB2;
|
||||
return CompressedImageData::FORMAT_PVR1_RGB2;
|
||||
case ePVRTPF_PVRTCI_2bpp_RGBA:
|
||||
return CompressedData::FORMAT_PVR1_RGBA2;
|
||||
return CompressedImageData::FORMAT_PVR1_RGBA2;
|
||||
case ePVRTPF_PVRTCI_4bpp_RGB:
|
||||
return CompressedData::FORMAT_PVR1_RGB4;
|
||||
return CompressedImageData::FORMAT_PVR1_RGB4;
|
||||
case ePVRTPF_PVRTCI_4bpp_RGBA:
|
||||
return CompressedData::FORMAT_PVR1_RGBA4;
|
||||
return CompressedImageData::FORMAT_PVR1_RGBA4;
|
||||
case ePVRTPF_ETC1:
|
||||
return CompressedData::FORMAT_ETC1;
|
||||
return CompressedImageData::FORMAT_ETC1;
|
||||
case ePVRTPF_DXT1:
|
||||
return CompressedData::FORMAT_DXT1;
|
||||
return CompressedImageData::FORMAT_DXT1;
|
||||
case ePVRTPF_DXT3:
|
||||
return CompressedData::FORMAT_DXT3;
|
||||
return CompressedImageData::FORMAT_DXT3;
|
||||
case ePVRTPF_DXT5:
|
||||
return CompressedData::FORMAT_DXT5;
|
||||
return CompressedImageData::FORMAT_DXT5;
|
||||
default:
|
||||
return CompressedData::FORMAT_UNKNOWN;
|
||||
return CompressedImageData::FORMAT_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -294,7 +294,7 @@ bool PVRHandler::canParse(const filesystem::FileData *data)
|
||||
return false;
|
||||
}
|
||||
|
||||
uint8 *PVRHandler::parse(filesystem::FileData *filedata, std::vector<CompressedData::SubImage> &images, size_t &dataSize, CompressedData::Format &format, bool &sRGB)
|
||||
uint8 *PVRHandler::parse(filesystem::FileData *filedata, std::vector<CompressedImageData::SubImage> &images, size_t &dataSize, CompressedImageData::Format &format, bool &sRGB)
|
||||
{
|
||||
if (!canParse(filedata))
|
||||
throw love::Exception("Could not decode compressed data (not a PVR file?)");
|
||||
@@ -324,9 +324,9 @@ uint8 *PVRHandler::parse(filesystem::FileData *filedata, std::vector<CompressedD
|
||||
if (header3.depth > 1)
|
||||
throw love::Exception("Image depths greater than 1 in PVR files are unsupported.");
|
||||
|
||||
CompressedData::Format cformat = convertFormat((PVRV3PixelFormat) header3.pixelFormat);
|
||||
CompressedImageData::Format cformat = convertFormat((PVRV3PixelFormat) header3.pixelFormat);
|
||||
|
||||
if (cformat == CompressedData::FORMAT_UNKNOWN)
|
||||
if (cformat == CompressedImageData::FORMAT_UNKNOWN)
|
||||
throw love::Exception("Could not parse PVR file: unsupported image format.");
|
||||
|
||||
size_t totalsize = 0;
|
||||
@@ -361,7 +361,7 @@ uint8 *PVRHandler::parse(filesystem::FileData *filedata, std::vector<CompressedD
|
||||
if (curoffset + mipsize > totalsize)
|
||||
break; // Just in case.
|
||||
|
||||
CompressedData::SubImage mip;
|
||||
CompressedImageData::SubImage mip;
|
||||
mip.width = std::max((int) header3.width >> i, 1);
|
||||
mip.height = std::max((int) header3.height >> i, 1);
|
||||
mip.size = mipsize;
|
||||
|
||||
@@ -40,7 +40,7 @@ public:
|
||||
|
||||
// Implements CompressedFormatHandler.
|
||||
virtual bool canParse(const filesystem::FileData *data);
|
||||
virtual uint8 *parse(filesystem::FileData *filedata, std::vector<CompressedData::SubImage> &images, size_t &dataSize, CompressedData::Format &format, bool &sRGB);
|
||||
virtual uint8 *parse(filesystem::FileData *filedata, std::vector<CompressedImageData::SubImage> &images, size_t &dataSize, CompressedImageData::Format &format, bool &sRGB);
|
||||
|
||||
}; // PVRHandler
|
||||
|
||||
|
||||
@@ -32,12 +32,12 @@ bool DDSHandler::canParse(const filesystem::FileData *data)
|
||||
return dds::isCompressedDDS(data->getData(), data->getSize());
|
||||
}
|
||||
|
||||
uint8 *DDSHandler::parse(filesystem::FileData *filedata, std::vector<CompressedData::SubImage> &images, size_t &dataSize, CompressedData::Format &format, bool &sRGB)
|
||||
uint8 *DDSHandler::parse(filesystem::FileData *filedata, std::vector<CompressedImageData::SubImage> &images, size_t &dataSize, CompressedImageData::Format &format, bool &sRGB)
|
||||
{
|
||||
if (!dds::isDDS(filedata->getData(), filedata->getSize()))
|
||||
throw love::Exception("Could not decode compressed data (not a DDS file?)");
|
||||
|
||||
CompressedData::Format texformat = CompressedData::FORMAT_UNKNOWN;
|
||||
CompressedImageData::Format texformat = CompressedImageData::FORMAT_UNKNOWN;
|
||||
bool isSRGB = false;
|
||||
|
||||
uint8 *data = nullptr;
|
||||
@@ -51,7 +51,7 @@ uint8 *DDSHandler::parse(filesystem::FileData *filedata, std::vector<CompressedD
|
||||
|
||||
texformat = convertFormat(parser.getFormat(), isSRGB);
|
||||
|
||||
if (texformat == CompressedData::FORMAT_UNKNOWN)
|
||||
if (texformat == CompressedImageData::FORMAT_UNKNOWN)
|
||||
throw love::Exception("Could not parse compressed data: Unsupported format.");
|
||||
|
||||
if (parser.getMipmapCount() == 0)
|
||||
@@ -68,13 +68,13 @@ uint8 *DDSHandler::parse(filesystem::FileData *filedata, std::vector<CompressedD
|
||||
|
||||
size_t dataOffset = 0;
|
||||
|
||||
// Copy the parsed mipmap levels from the FileData to our CompressedData.
|
||||
// Copy the parsed mipmap levels from the FileData to our CompressedImageData.
|
||||
for (size_t i = 0; i < parser.getMipmapCount(); i++)
|
||||
{
|
||||
// Fetch the data for this mipmap level.
|
||||
const dds::Image *img = parser.getImageData(i);
|
||||
|
||||
CompressedData::SubImage mip;
|
||||
CompressedImageData::SubImage mip;
|
||||
|
||||
mip.width = img->width;
|
||||
mip.height = img->height;
|
||||
@@ -101,37 +101,37 @@ uint8 *DDSHandler::parse(filesystem::FileData *filedata, std::vector<CompressedD
|
||||
return data;
|
||||
}
|
||||
|
||||
CompressedData::Format DDSHandler::convertFormat(dds::Format ddsformat, bool &sRGB)
|
||||
CompressedImageData::Format DDSHandler::convertFormat(dds::Format ddsformat, bool &sRGB)
|
||||
{
|
||||
sRGB = false;
|
||||
|
||||
switch (ddsformat)
|
||||
{
|
||||
case dds::FORMAT_DXT1:
|
||||
return CompressedData::FORMAT_DXT1;
|
||||
return CompressedImageData::FORMAT_DXT1;
|
||||
case dds::FORMAT_DXT3:
|
||||
return CompressedData::FORMAT_DXT3;
|
||||
return CompressedImageData::FORMAT_DXT3;
|
||||
case dds::FORMAT_DXT5:
|
||||
return CompressedData::FORMAT_DXT5;
|
||||
return CompressedImageData::FORMAT_DXT5;
|
||||
case dds::FORMAT_BC4:
|
||||
return CompressedData::FORMAT_BC4;
|
||||
return CompressedImageData::FORMAT_BC4;
|
||||
case dds::FORMAT_BC4s:
|
||||
return CompressedData::FORMAT_BC4s;
|
||||
return CompressedImageData::FORMAT_BC4s;
|
||||
case dds::FORMAT_BC5:
|
||||
return CompressedData::FORMAT_BC5;
|
||||
return CompressedImageData::FORMAT_BC5;
|
||||
case dds::FORMAT_BC5s:
|
||||
return CompressedData::FORMAT_BC5s;
|
||||
return CompressedImageData::FORMAT_BC5s;
|
||||
case dds::FORMAT_BC6H:
|
||||
return CompressedData::FORMAT_BC6H;
|
||||
return CompressedImageData::FORMAT_BC6H;
|
||||
case dds::FORMAT_BC6Hs:
|
||||
return CompressedData::FORMAT_BC6Hs;
|
||||
return CompressedImageData::FORMAT_BC6Hs;
|
||||
case dds::FORMAT_BC7:
|
||||
return CompressedData::FORMAT_BC7;
|
||||
return CompressedImageData::FORMAT_BC7;
|
||||
case dds::FORMAT_BC7srgb:
|
||||
sRGB = true;
|
||||
return CompressedData::FORMAT_BC7;
|
||||
return CompressedImageData::FORMAT_BC7;
|
||||
default:
|
||||
return CompressedData::FORMAT_UNKNOWN;
|
||||
return CompressedImageData::FORMAT_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace magpie
|
||||
{
|
||||
|
||||
/**
|
||||
* Interface between CompressedData and the ddsparse library.
|
||||
* Interface between CompressedImageData and the ddsparse library.
|
||||
**/
|
||||
class DDSHandler : public CompressedFormatHandler
|
||||
{
|
||||
@@ -48,11 +48,11 @@ public:
|
||||
|
||||
// Implements CompressedFormatHandler.
|
||||
virtual bool canParse(const filesystem::FileData *data);
|
||||
virtual uint8 *parse(filesystem::FileData *filedata, std::vector<CompressedData::SubImage> &images, size_t &dataSize, CompressedData::Format &format, bool &sRGB);
|
||||
virtual uint8 *parse(filesystem::FileData *filedata, std::vector<CompressedImageData::SubImage> &images, size_t &dataSize, CompressedImageData::Format &format, bool &sRGB);
|
||||
|
||||
private:
|
||||
|
||||
static CompressedData::Format convertFormat(dds::Format ddsformat, bool &sRGB);
|
||||
static CompressedImageData::Format convertFormat(dds::Format ddsformat, bool &sRGB);
|
||||
|
||||
}; // DDSHandler
|
||||
|
||||
|
||||
+22
-22
@@ -18,7 +18,7 @@
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
**/
|
||||
|
||||
#include "wrap_CompressedData.h"
|
||||
#include "wrap_CompressedImageData.h"
|
||||
#include "common/wrap_Data.h"
|
||||
|
||||
namespace love
|
||||
@@ -26,14 +26,14 @@ namespace love
|
||||
namespace image
|
||||
{
|
||||
|
||||
CompressedData *luax_checkcompresseddata(lua_State *L, int idx)
|
||||
CompressedImageData *luax_checkcompressedimagedata(lua_State *L, int idx)
|
||||
{
|
||||
return luax_checktype<CompressedData>(L, idx, IMAGE_COMPRESSED_DATA_ID);
|
||||
return luax_checktype<CompressedImageData>(L, idx, IMAGE_COMPRESSED_IMAGE_DATA_ID);
|
||||
}
|
||||
|
||||
int w_CompressedData_getWidth(lua_State *L)
|
||||
int w_CompressedImageData_getWidth(lua_State *L)
|
||||
{
|
||||
CompressedData *t = luax_checkcompresseddata(L, 1);
|
||||
CompressedImageData *t = luax_checkcompressedimagedata(L, 1);
|
||||
int miplevel = luaL_optint(L, 2, 1);
|
||||
int width = 0;
|
||||
|
||||
@@ -43,9 +43,9 @@ int w_CompressedData_getWidth(lua_State *L)
|
||||
return 1;
|
||||
}
|
||||
|
||||
int w_CompressedData_getHeight(lua_State *L)
|
||||
int w_CompressedImageData_getHeight(lua_State *L)
|
||||
{
|
||||
CompressedData *t = luax_checkcompresseddata(L, 1);
|
||||
CompressedImageData *t = luax_checkcompressedimagedata(L, 1);
|
||||
int miplevel = luaL_optint(L, 2, 1);
|
||||
int height = 0;
|
||||
|
||||
@@ -55,9 +55,9 @@ int w_CompressedData_getHeight(lua_State *L)
|
||||
return 1;
|
||||
}
|
||||
|
||||
int w_CompressedData_getDimensions(lua_State *L)
|
||||
int w_CompressedImageData_getDimensions(lua_State *L)
|
||||
{
|
||||
CompressedData *t = luax_checkcompresseddata(L, 1);
|
||||
CompressedImageData *t = luax_checkcompressedimagedata(L, 1);
|
||||
int miplevel = luaL_optint(L, 2, 1);
|
||||
int width = 0, height = 0;
|
||||
|
||||
@@ -72,21 +72,21 @@ int w_CompressedData_getDimensions(lua_State *L)
|
||||
return 2;
|
||||
}
|
||||
|
||||
int w_CompressedData_getMipmapCount(lua_State *L)
|
||||
int w_CompressedImageData_getMipmapCount(lua_State *L)
|
||||
{
|
||||
CompressedData *t = luax_checkcompresseddata(L, 1);
|
||||
CompressedImageData *t = luax_checkcompressedimagedata(L, 1);
|
||||
lua_pushinteger(L, t->getMipmapCount());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int w_CompressedData_getFormat(lua_State *L)
|
||||
int w_CompressedImageData_getFormat(lua_State *L)
|
||||
{
|
||||
CompressedData *t = luax_checkcompresseddata(L, 1);
|
||||
CompressedImageData *t = luax_checkcompressedimagedata(L, 1);
|
||||
|
||||
image::CompressedData::Format format = t->getFormat();
|
||||
image::CompressedImageData::Format format = t->getFormat();
|
||||
const char *str;
|
||||
|
||||
if (image::CompressedData::getConstant(format, str))
|
||||
if (image::CompressedImageData::getConstant(format, str))
|
||||
lua_pushstring(L, str);
|
||||
else
|
||||
lua_pushstring(L, "unknown");
|
||||
@@ -101,17 +101,17 @@ static const luaL_Reg functions[] =
|
||||
{ "getPointer", w_Data_getPointer },
|
||||
{ "getSize", w_Data_getSize },
|
||||
|
||||
{ "getWidth", w_CompressedData_getWidth },
|
||||
{ "getHeight", w_CompressedData_getHeight },
|
||||
{ "getDimensions", w_CompressedData_getDimensions },
|
||||
{ "getMipmapCount", w_CompressedData_getMipmapCount },
|
||||
{ "getFormat", w_CompressedData_getFormat },
|
||||
{ "getWidth", w_CompressedImageData_getWidth },
|
||||
{ "getHeight", w_CompressedImageData_getHeight },
|
||||
{ "getDimensions", w_CompressedImageData_getDimensions },
|
||||
{ "getMipmapCount", w_CompressedImageData_getMipmapCount },
|
||||
{ "getFormat", w_CompressedImageData_getFormat },
|
||||
{ 0, 0 },
|
||||
};
|
||||
|
||||
extern "C" int luaopen_compresseddata(lua_State *L)
|
||||
extern "C" int luaopen_compressedimagedata(lua_State *L)
|
||||
{
|
||||
return luax_register_type(L, IMAGE_COMPRESSED_DATA_ID, functions);
|
||||
return luax_register_type(L, IMAGE_COMPRESSED_IMAGE_DATA_ID, functions);
|
||||
}
|
||||
|
||||
} // image
|
||||
+11
-11
@@ -18,27 +18,27 @@
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
**/
|
||||
|
||||
#ifndef LOVE_IMAGE_WRAP_COMRESSED_DATA_H
|
||||
#define LOVE_IMAGE_WRAP_COMRESSED_DATA_H
|
||||
#ifndef LOVE_IMAGE_WRAP_COMRESSED_IMAGE_DATA_H
|
||||
#define LOVE_IMAGE_WRAP_COMRESSED_IMAGE_DATA_H
|
||||
|
||||
// LOVE
|
||||
#include "common/runtime.h"
|
||||
#include "CompressedData.h"
|
||||
#include "CompressedImageData.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace image
|
||||
{
|
||||
|
||||
CompressedData *luax_checkcompresseddata(lua_State *L, int idx);
|
||||
int w_CompressedData_getWidth(lua_State *L);
|
||||
int w_CompressedData_getHeight(lua_State *L);
|
||||
int w_CompressedData_getDimensions(lua_State *L);
|
||||
int w_CompressedData_getMipmapCount(lua_State *L);
|
||||
int w_CompressedData_getFormat(lua_State *L);
|
||||
extern "C" int luaopen_compresseddata(lua_State *L);
|
||||
CompressedImageData *luax_checkcompressedimagedata(lua_State *L, int idx);
|
||||
int w_CompressedImageData_getWidth(lua_State *L);
|
||||
int w_CompressedImageData_getHeight(lua_State *L);
|
||||
int w_CompressedImageData_getDimensions(lua_State *L);
|
||||
int w_CompressedImageData_getMipmapCount(lua_State *L);
|
||||
int w_CompressedImageData_getFormat(lua_State *L);
|
||||
extern "C" int luaopen_compressedimagedata(lua_State *L);
|
||||
|
||||
} // image
|
||||
} // love
|
||||
|
||||
#endif // LOVE_IMAGE_WRAP_COMRESSED_DATA_H
|
||||
#endif // LOVE_IMAGE_WRAP_COMRESSED_IMAGE_DATA_H
|
||||
@@ -70,13 +70,13 @@ int w_newCompressedData(lua_State *L)
|
||||
{
|
||||
love::filesystem::FileData *data = love::filesystem::luax_getfiledata(L, 1);
|
||||
|
||||
CompressedData *t = nullptr;
|
||||
CompressedImageData *t = nullptr;
|
||||
luax_catchexcept(L,
|
||||
[&]() { t = instance()->newCompressedData(data); },
|
||||
[&]() { data->release(); }
|
||||
);
|
||||
|
||||
luax_pushtype(L, IMAGE_COMPRESSED_DATA_ID, t);
|
||||
luax_pushtype(L, IMAGE_COMPRESSED_IMAGE_DATA_ID, t);
|
||||
t->release();
|
||||
return 1;
|
||||
}
|
||||
@@ -103,7 +103,7 @@ static const luaL_Reg functions[] =
|
||||
static const lua_CFunction types[] =
|
||||
{
|
||||
luaopen_imagedata,
|
||||
luaopen_compresseddata,
|
||||
luaopen_compressedimagedata,
|
||||
0
|
||||
};
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// LOVE
|
||||
#include "Image.h"
|
||||
#include "wrap_ImageData.h"
|
||||
#include "wrap_CompressedData.h"
|
||||
#include "wrap_CompressedImageData.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user