Move decoder-agnostic love.image code out of the magpie backend folder.

--HG--
branch : minor
This commit is contained in:
Alex Szpakowski
2017-08-01 23:22:24 -03:00
parent 217552b5ff
commit 84d5d8b636
37 changed files with 631 additions and 921 deletions
+20 -7
View File
@@ -28,6 +28,9 @@
#include "ImageData.h"
#include "CompressedImageData.h"
// C++
#include <list>
namespace love
{
namespace image
@@ -46,17 +49,19 @@ public:
static love::Type type;
virtual ~Image() {}
Image();
virtual ~Image();
// Implements Module.
virtual ModuleType getModuleType() const { return M_IMAGE; }
ModuleType getModuleType() const override { return M_IMAGE; }
const char *getName() const override;
/**
* Creates new ImageData from FileData.
* @param data The FileData containing the encoded image data.
* @return The new ImageData.
**/
virtual ImageData *newImageData(love::filesystem::FileData *data) = 0;
ImageData *newImageData(love::filesystem::FileData *data);
/**
* Creates empty ImageData with the given size.
@@ -64,7 +69,7 @@ public:
* @param height The height of the ImageData.
* @return The new ImageData.
**/
virtual ImageData *newImageData(int width, int height, PixelFormat format = PIXELFORMAT_RGBA8) = 0;
ImageData *newImageData(int width, int height, PixelFormat format = PIXELFORMAT_RGBA8);
/**
* Creates empty ImageData with the given size.
@@ -75,28 +80,36 @@ public:
* copy it.
* @return The new ImageData.
**/
virtual ImageData *newImageData(int width, int height, PixelFormat format, void *data, bool own = false) = 0;
ImageData *newImageData(int width, int height, PixelFormat format, void *data, bool own = false);
/**
* Creates new CompressedImageData from FileData.
* @param data The FileData containing the compressed image data.
* @return The new CompressedImageData.
**/
virtual CompressedImageData *newCompressedData(love::filesystem::FileData *data) = 0;
CompressedImageData *newCompressedData(love::filesystem::FileData *data);
/**
* Determines whether a FileData is Compressed image data or not.
* @param data The FileData to test.
**/
virtual bool isCompressed(love::filesystem::FileData *data) = 0;
bool isCompressed(love::filesystem::FileData *data);
std::vector<StrongRef<ImageData>> newCubeFaces(ImageData *src);
std::vector<StrongRef<ImageData>> newVolumeLayers(ImageData *src);
const std::list<FormatHandler *> &getFormatHandlers() const;
private:
ImageData *newPastedImageData(ImageData *src, int sx, int sy, int w, int h);
// Image format handlers we can use for decoding and encoding ImageData.
std::list<FormatHandler *> formatHandlers;
// Compressed image format handers we can use for parsing CompressedImageData.
std::list<CompressedFormatHandler *> compressedFormatHandlers;
}; // Image
} // image