Browse Source

Simplified some compressed image parsing code.

--HG--
branch : minor
Alex Szpakowski 8 years ago
parent
commit
a41f78dfe4

+ 0 - 1
CMakeLists.txt

@@ -579,7 +579,6 @@ source_group("modules\\graphics\\opengl" FILES ${LOVE_SRC_MODULE_GRAPHICS_OPENGL
 #
 
 set(LOVE_SRC_MODULE_IMAGE_ROOT
-	src/modules/image/CompressedFormatHandler.h
 	src/modules/image/CompressedImageData.cpp
 	src/modules/image/CompressedImageData.h
 	src/modules/image/CompressedSlice.cpp

+ 0 - 4
platform/xcode/liblove.xcodeproj/project.pbxproj

@@ -938,7 +938,6 @@
 		FA91DA8B1F377C3900C80E33 /* deprecation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA91DA891F377C3900C80E33 /* deprecation.cpp */; };
 		FA91DA8C1F377C3900C80E33 /* deprecation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA91DA891F377C3900C80E33 /* deprecation.cpp */; };
 		FA91DA8D1F377C3900C80E33 /* deprecation.h in Headers */ = {isa = PBXBuildFile; fileRef = FA91DA8A1F377C3900C80E33 /* deprecation.h */; };
-		FA93C4521F315B960087CCD4 /* CompressedFormatHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = FA93C44F1F315B960087CCD4 /* CompressedFormatHandler.h */; };
 		FA93C4531F315B960087CCD4 /* FormatHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = FA93C4501F315B960087CCD4 /* FormatHandler.h */; };
 		FA93C4541F315B960087CCD4 /* FormatHandler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA93C4511F315B960087CCD4 /* FormatHandler.cpp */; };
 		FA9B4A0816E1578300074F42 /* SDL2.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA9B4A0716E1578300074F42 /* SDL2.framework */; };
@@ -1801,7 +1800,6 @@
 		FA91591D1CF1ED7500A7053F /* halffloat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = halffloat.h; sourceTree = "<group>"; };
 		FA91DA891F377C3900C80E33 /* deprecation.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = deprecation.cpp; sourceTree = "<group>"; };
 		FA91DA8A1F377C3900C80E33 /* deprecation.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = deprecation.h; sourceTree = "<group>"; };
-		FA93C44F1F315B960087CCD4 /* CompressedFormatHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CompressedFormatHandler.h; sourceTree = "<group>"; };
 		FA93C4501F315B960087CCD4 /* FormatHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FormatHandler.h; sourceTree = "<group>"; };
 		FA93C4511F315B960087CCD4 /* FormatHandler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FormatHandler.cpp; sourceTree = "<group>"; };
 		FA9B4A0716E1578300074F42 /* SDL2.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SDL2.framework; path = /Library/Frameworks/SDL2.framework; sourceTree = "<absolute>"; };
@@ -2764,7 +2762,6 @@
 		FA0B7BC21A95902C000E1D17 /* image */ = {
 			isa = PBXGroup;
 			children = (
-				FA93C44F1F315B960087CCD4 /* CompressedFormatHandler.h */,
 				FA0B7BC31A95902C000E1D17 /* CompressedImageData.cpp */,
 				FA0B7BC41A95902C000E1D17 /* CompressedImageData.h */,
 				FAECA1B01F3164700095D008 /* CompressedSlice.cpp */,
@@ -3661,7 +3658,6 @@
 				FA0B7E351A95902C000E1D17 /* WeldJoint.h in Headers */,
 				FA0B7E2F1A95902C000E1D17 /* RopeJoint.h in Headers */,
 				FA0B7D141A95902C000E1D17 /* Font.h in Headers */,
-				FA93C4521F315B960087CCD4 /* CompressedFormatHandler.h in Headers */,
 				FA0B7D411A95902C000E1D17 /* Mesh.h in Headers */,
 				FA0B7E591A95902C000E1D17 /* wrap_Joint.h in Headers */,
 				FA0B79351A958E3B000E1D17 /* macosx.h in Headers */,

+ 0 - 70
src/modules/image/CompressedFormatHandler.h

@@ -1,70 +0,0 @@
-/**
- * Copyright (c) 2006-2017 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.
- **/
-
-#pragma once
-
-// LOVE
-#include "common/Object.h"
-#include "common/Data.h"
-#include "CompressedSlice.h"
-
-namespace love
-{
-namespace image
-{
-
-/**
- * Base class for all CompressedImageData parser library interfaces.
- * We inherit from love::Object to take advantage of reference counting...
- **/
-class CompressedFormatHandler : public love::Object
-{
-public:
-
-	CompressedFormatHandler() {}
-	virtual ~CompressedFormatHandler() {}
-
-	/**
-	 * Determines whether a particular FileData can be parsed as
-	 * CompressedImageData by this handler.
-	 * @param data The data to parse.
-	 **/
-	virtual bool canParse(const Data *data) = 0;
-
-	/**
-	 * Parses compressed image filedata into a list of sub-images and returns
-	 * a single block of memory containing all the images.
-	 *
-	 * @param[in] filedata The data to parse.
-	 * @param[out] images The list of sub-images generated. Byte data is a
-	 *             pointer to the returned data.
-	 * @param[out] format The format of the Compressed Data.
-	 * @param[out] sRGB Whether the texture is sRGB-encoded.
-	 *
-	 * @return The single block of memory containing the parsed images.
-	 **/
-	virtual StrongRef<CompressedMemory> parse(Data *filedata,
-	               std::vector<StrongRef<CompressedSlice>> &images,
-	               PixelFormat &format, bool &sRGB) = 0;
-
-}; // CompressedFormatHandler
-
-} // image
-} // love

+ 5 - 5
src/modules/image/CompressedImageData.cpp

@@ -27,15 +27,15 @@ namespace image
 
 love::Type CompressedImageData::type("CompressedImageData", &Data::type);
 
-CompressedImageData::CompressedImageData(const std::list<CompressedFormatHandler *> &formats, Data *filedata)
+CompressedImageData::CompressedImageData(const std::list<FormatHandler *> &formats, Data *filedata)
 	: format(PIXELFORMAT_UNKNOWN)
 	, sRGB(false)
 {
-	CompressedFormatHandler *parser = nullptr;
+	FormatHandler *parser = nullptr;
 
-	for (CompressedFormatHandler *handler : formats)
+	for (FormatHandler *handler : formats)
 	{
-		if (handler->canParse(filedata))
+		if (handler->canParseCompressed(filedata))
 		{
 			parser = handler;
 			break;
@@ -45,7 +45,7 @@ CompressedImageData::CompressedImageData(const std::list<CompressedFormatHandler
 	if (parser == nullptr)
 		throw love::Exception("Could not parse compressed data: Unknown format.");
 
-	memory = parser->parse(filedata, dataImages, format, sRGB);
+	memory = parser->parseCompressed(filedata, dataImages, format, sRGB);
 
 	if (memory == nullptr)
 		throw love::Exception("Could not parse compressed data.");

+ 2 - 2
src/modules/image/CompressedImageData.h

@@ -26,7 +26,7 @@
 #include "common/int.h"
 #include "common/pixelformat.h"
 #include "CompressedSlice.h"
-#include "CompressedFormatHandler.h"
+#include "FormatHandler.h"
 
 // STL
 #include <vector>
@@ -48,7 +48,7 @@ public:
 
 	static love::Type type;
 
-	CompressedImageData(const std::list<CompressedFormatHandler *> &formats, Data *filedata);
+	CompressedImageData(const std::list<FormatHandler *> &formats, Data *filedata);
 	CompressedImageData(const CompressedImageData &c);
 	virtual ~CompressedImageData();
 

+ 11 - 1
src/modules/image/FormatHandler.cpp

@@ -55,7 +55,17 @@ FormatHandler::EncodedImage FormatHandler::encode(const DecodedImage& /*img*/, E
 	throw love::Exception("Image encoding is not implemented for this format backend.");
 }
 
-void FormatHandler::free(unsigned char *mem)
+bool FormatHandler::canParseCompressed(Data* /*data*/)
+{
+	return false;
+}
+
+StrongRef<CompressedMemory> FormatHandler::parseCompressed(Data* /*filedata*/, std::vector<StrongRef<CompressedSlice>>& /*images*/, PixelFormat& /*format*/, bool& /*sRGB*/)
+{
+	throw love::Exception("Compressed image parsing is not implemented for this format backend.");
+}
+
+void FormatHandler::freeRawPixels(unsigned char *mem)
 {
 	delete[] mem;
 }

+ 30 - 16
src/modules/image/FormatHandler.h

@@ -22,8 +22,9 @@
 
 // LOVE
 #include "common/Object.h"
-#include "common/pixelformat.h"
 #include "common/Data.h"
+#include "common/pixelformat.h"
+#include "CompressedSlice.h"
 
 namespace love
 {
@@ -31,8 +32,8 @@ namespace image
 {
 
 /**
- * Base class for all ImageData encoder/decoder library interfaces.
- * We inherit from love::Object to take advantage of reference counting...
+ * Base class for all ImageData and CompressedImageData encoder/decoder library
+ * interfaces. We inherit from love::Object to take advantage of ref coounting.
  **/
 class FormatHandler : public love::Object
 {
@@ -66,41 +67,54 @@ public:
 	 * The default constructor is called when the Image module is initialized.
 	 **/
 	FormatHandler();
-
-	/**
-	 * The destructor is called when the Image module is uninitialized.
-	 **/
 	virtual ~FormatHandler();
 
 	/**
-	 * Whether this format handler can decode a particular FileData.
+	 * Whether this format handler can decode the given Data into raw pixels.
 	 **/
 	virtual bool canDecode(Data *data);
 
 	/**
-	 * Whether this format handler can encode to a particular format.
+	 * Whether this format handler can encode raw pixels to a particular format.
 	 **/
 	virtual bool canEncode(PixelFormat rawFormat, EncodedFormat encodedFormat);
 
 	/**
 	 * Decodes an image from its encoded form into raw pixel data.
-	 * @param data The encoded data to decode.
-	 * @return The decoded pixel data.
 	 **/
 	virtual DecodedImage decode(Data *data);
 
 	/**
 	 * Encodes an image from raw pixel data into a particular format.
-	 * @param img The raw image data to encode.
-	 * @param format The format to encode to.
-	 * @return The encoded image data.
 	 **/
 	virtual EncodedImage encode(const DecodedImage &img, EncodedFormat format);
 
 	/**
-	 * Frees memory allocated by the format handler.
+	 * Whether this format handler can parse the given Data into a
+	 * CompressedImageData object.
+	 **/
+	virtual bool canParseCompressed(Data *data);
+
+	/**
+	 * Parses compressed image data into a list of sub-images and returns a
+	 * single block of memory containing all the images.
+	 *
+	 * @param[in] filedata The data to parse.
+	 * @param[out] images The list of sub-images generated. Byte data is a
+	 *             pointer to the returned data.
+	 * @param[out] format The format of the Compressed Data.
+	 * @param[out] sRGB Whether the texture is sRGB-encoded.
+	 *
+	 * @return The single block of memory containing the parsed images.
+	 **/
+	virtual StrongRef<CompressedMemory> parseCompressed(Data *filedata,
+	        std::vector<StrongRef<CompressedSlice>> &images,
+	        PixelFormat &format, bool &sRGB);
+
+	/**
+	 * Frees raw pixel memory allocated by the format handler.
 	 **/
-	virtual void free(unsigned char *mem);
+	virtual void freeRawPixels(unsigned char *mem);
 
 }; // FormatHandler
 

+ 3 - 9
src/modules/image/Image.cpp

@@ -49,9 +49,6 @@ Image::Image()
 		new PNGHandler,
 		new STBHandler,
 		new EXRHandler,
-	};
-
-	compressedFormatHandlers = {
 		new DDSHandler,
 		new PVRHandler,
 		new KTXHandler,
@@ -66,9 +63,6 @@ Image::~Image()
 	// release them instead of deleting them completely here.
 	for (FormatHandler *handler : formatHandlers)
 		handler->release();
-
-	for (CompressedFormatHandler *handler : compressedFormatHandlers)
-		handler->release();
 }
 
 const char *Image::getName() const
@@ -93,14 +87,14 @@ love::image::ImageData *Image::newImageData(int width, int height, PixelFormat f
 
 love::image::CompressedImageData *Image::newCompressedData(Data *data)
 {
-	return new CompressedImageData(compressedFormatHandlers, data);
+	return new CompressedImageData(formatHandlers, data);
 }
 
 bool Image::isCompressed(Data *data)
 {
-	for (CompressedFormatHandler *handler : compressedFormatHandlers)
+	for (FormatHandler *handler : formatHandlers)
 	{
-		if (handler->canParse(data))
+		if (handler->canParseCompressed(data))
 			return true;
 	}
 

+ 0 - 3
src/modules/image/Image.h

@@ -107,9 +107,6 @@ 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 CompressedImageData.
-	std::list<CompressedFormatHandler *> compressedFormatHandlers;
-
 }; // Image
 
 } // image

+ 5 - 5
src/modules/image/ImageData.cpp

@@ -78,7 +78,7 @@ ImageData::ImageData(const ImageData &c)
 ImageData::~ImageData()
 {
 	if (decodeHandler.get())
-		decodeHandler->free(data);
+		decodeHandler->freeRawPixels(data);
 	else
 		delete[] data;
 }
@@ -145,13 +145,13 @@ void ImageData::decode(Data *data)
 
 	if (decodedimage.size != decodedimage.width * decodedimage.height * getPixelFormatSize(decodedimage.format))
 	{
-		decoder->free(decodedimage.data);
+		decoder->freeRawPixels(decodedimage.data);
 		throw love::Exception("Could not convert image!");
 	}
 
 	// Clean up any old data.
 	if (decodeHandler)
-		decodeHandler->free(this->data);
+		decodeHandler->freeRawPixels(this->data);
 	else
 		delete[] this->data;
 
@@ -210,12 +210,12 @@ love::filesystem::FileData *ImageData::encode(FormatHandler::EncodedFormat encod
 	}
 	catch (love::Exception &)
 	{
-		encoder->free(encodedimage.data);
+		encoder->freeRawPixels(encodedimage.data);
 		throw;
 	}
 
 	memcpy(filedata->getData(), encodedimage.data, encodedimage.size);
-	encoder->free(encodedimage.data);
+	encoder->freeRawPixels(encodedimage.data);
 
 	if (writefile)
 	{

+ 3 - 3
src/modules/image/magpie/ASTCHandler.cpp

@@ -87,7 +87,7 @@ static PixelFormat convertFormat(uint32 blockX, uint32 blockY, uint32 blockZ)
 
 } // Anonymous namespace.
 
-bool ASTCHandler::canParse(const Data *data)
+bool ASTCHandler::canParseCompressed(Data *data)
 {
 	if (data->getSize() <= sizeof(ASTCHeader))
 		return false;
@@ -105,9 +105,9 @@ bool ASTCHandler::canParse(const Data *data)
 	return true;
 }
 
-StrongRef<CompressedMemory> ASTCHandler::parse(Data *filedata, std::vector<StrongRef<CompressedSlice>> &images, PixelFormat &format, bool &sRGB)
+StrongRef<CompressedMemory> ASTCHandler::parseCompressed(Data *filedata, std::vector<StrongRef<CompressedSlice>> &images, PixelFormat &format, bool &sRGB)
 {
-	if (!canParse(filedata))
+	if (!canParseCompressed(filedata))
 		throw love::Exception("Could not decode compressed data (not an .astc file?)");
 
 	ASTCHeader header = *(const ASTCHeader *) filedata->getData();

+ 5 - 5
src/modules/image/magpie/ASTCHandler.h

@@ -21,7 +21,7 @@
 #pragma once
 
 #include "common/config.h"
-#include "image/CompressedFormatHandler.h"
+#include "image/FormatHandler.h"
 
 namespace love
 {
@@ -34,16 +34,16 @@ namespace magpie
  * Handles simple .astc files (generated by ARM's astcenc tool) with compressed
  * ASTC data inside.
  **/
-class ASTCHandler : public CompressedFormatHandler
+class ASTCHandler : public FormatHandler
 {
 public:
 
 	virtual ~ASTCHandler() {}
 
-	// Implements CompressedFormatHandler.
-	bool canParse(const Data *data) override;
+	// Implements FormatHandler.
+	bool canParseCompressed(Data *data) override;
 
-	StrongRef<CompressedMemory> parse(Data *filedata,
+	StrongRef<CompressedMemory> parseCompressed(Data *filedata,
 	        std::vector<StrongRef<CompressedSlice>> &images,
 	        PixelFormat &format, bool &sRGB) override;
 

+ 1 - 1
src/modules/image/magpie/EXRHandler.cpp

@@ -193,7 +193,7 @@ FormatHandler::EncodedImage EXRHandler::encode(const DecodedImage & /*img*/, Enc
 	throw love::Exception("Invalid format.");
 }
 
-void EXRHandler::free(unsigned char *mem)
+void EXRHandler::freeRawPixels(unsigned char *mem)
 {
 	delete[] mem;
 }

+ 1 - 1
src/modules/image/magpie/EXRHandler.h

@@ -44,7 +44,7 @@ public:
 	virtual DecodedImage decode(Data *data);
 	virtual EncodedImage encode(const DecodedImage &img, EncodedFormat format);
 
-	virtual void free(unsigned char *mem);
+	virtual void freeRawPixels(unsigned char *mem);
 
 }; // EXRHandler
 

+ 3 - 3
src/modules/image/magpie/KTXHandler.cpp

@@ -281,7 +281,7 @@ PixelFormat convertFormat(uint32 glformat, bool &sRGB)
 
 } // Anonymous namespace.
 
-bool KTXHandler::canParse(const Data *data)
+bool KTXHandler::canParseCompressed(Data *data)
 {
 	if (data->getSize() < sizeof(KTXHeader))
 		return false;
@@ -298,9 +298,9 @@ bool KTXHandler::canParse(const Data *data)
 	return true;
 }
 
-StrongRef<CompressedMemory> KTXHandler::parse(Data *filedata, std::vector<StrongRef<CompressedSlice>> &images, PixelFormat &format, bool &sRGB)
+StrongRef<CompressedMemory> KTXHandler::parseCompressed(Data *filedata, std::vector<StrongRef<CompressedSlice>> &images, PixelFormat &format, bool &sRGB)
 {
-	if (!canParse(filedata))
+	if (!canParseCompressed(filedata))
 		throw love::Exception("Could not decode compressed data (not a KTX file?)");
 
 	KTXHeader header = *(KTXHeader *) filedata->getData();

+ 5 - 5
src/modules/image/magpie/KTXHandler.h

@@ -21,7 +21,7 @@
 #pragma once
 
 #include "common/config.h"
-#include "image/CompressedFormatHandler.h"
+#include "image/FormatHandler.h"
 
 namespace love
 {
@@ -33,16 +33,16 @@ namespace magpie
 /**
  * Handles KTX files with compressed image data inside.
  **/
-class KTXHandler : public CompressedFormatHandler
+class KTXHandler : public FormatHandler
 {
 public:
 
 	virtual ~KTXHandler() {}
 
-	// Implements CompressedFormatHandler.
-	bool canParse(const Data *data) override;
+	// Implements FormatHandler.
+	bool canParseCompressed(Data *data) override;
 
-	StrongRef<CompressedMemory> parse(Data *filedata,
+	StrongRef<CompressedMemory> parseCompressed(Data *filedata,
 	        std::vector<StrongRef<CompressedSlice>> &images,
 	        PixelFormat &format, bool &sRGB) override;
 

+ 3 - 3
src/modules/image/magpie/PKMHandler.cpp

@@ -97,7 +97,7 @@ static PixelFormat convertFormat(uint16 texformat)
 
 } // Anonymous namespace.
 
-bool PKMHandler::canParse(const Data *data)
+bool PKMHandler::canParseCompressed(Data *data)
 {
 	if (data->getSize() <= sizeof(PKMHeader))
 		return false;
@@ -114,9 +114,9 @@ bool PKMHandler::canParse(const Data *data)
 	return true;
 }
 
-StrongRef<CompressedMemory> PKMHandler::parse(Data *filedata, std::vector<StrongRef<CompressedSlice>> &images, PixelFormat &format, bool &sRGB)
+StrongRef<CompressedMemory> PKMHandler::parseCompressed(Data *filedata, std::vector<StrongRef<CompressedSlice>> &images, PixelFormat &format, bool &sRGB)
 {
-	if (!canParse(filedata))
+	if (!canParseCompressed(filedata))
 		throw love::Exception("Could not decode compressed data (not a PKM file?)");
 
 	PKMHeader header = *(const PKMHeader *) filedata->getData();

+ 5 - 5
src/modules/image/magpie/PKMHandler.h

@@ -21,7 +21,7 @@
 #pragma once
 
 #include "common/config.h"
-#include "image/CompressedFormatHandler.h"
+#include "image/FormatHandler.h"
 
 namespace love
 {
@@ -33,16 +33,16 @@ namespace magpie
 /**
  * Handles PKM files with compressed ETC data inside.
  **/
-class PKMHandler : public CompressedFormatHandler
+class PKMHandler : public FormatHandler
 {
 public:
 
 	virtual ~PKMHandler() {}
 
-	// Implements CompressedFormatHandler.
-	bool canParse(const Data *data) override;
+	// Implements FormatHandler.
+	bool canParseCompressed(Data *data) override;
 
-	StrongRef<CompressedMemory> parse(Data *filedata,
+	StrongRef<CompressedMemory> parseCompressed(Data *filedata,
 	        std::vector<StrongRef<CompressedSlice>> &images,
 	        PixelFormat &format, bool &sRGB) override;
 

+ 1 - 1
src/modules/image/magpie/PNGHandler.cpp

@@ -257,7 +257,7 @@ FormatHandler::EncodedImage PNGHandler::encode(const DecodedImage &img, EncodedF
 	return encimg;
 }
 
-void PNGHandler::free(unsigned char *mem)
+void PNGHandler::freeRawPixels(unsigned char *mem)
 {
 	// LodePNG uses malloc, realloc, and free.
 	if (mem)

+ 1 - 1
src/modules/image/magpie/PNGHandler.h

@@ -45,7 +45,7 @@ public:
 	virtual DecodedImage decode(Data *data);
 	virtual EncodedImage encode(const DecodedImage &img, EncodedFormat format);
 
-	virtual void free(unsigned char *mem);
+	virtual void freeRawPixels(unsigned char *mem);
 
 }; // PNGHandler
 

+ 3 - 3
src/modules/image/magpie/PVRHandler.cpp

@@ -454,7 +454,7 @@ size_t getMipLevelSize(const PVRTexHeaderV3 &header, int miplevel)
 } // Anonymous namespace.
 
 
-bool PVRHandler::canParse(const Data *data)
+bool PVRHandler::canParseCompressed(Data *data)
 {
 	if (data->getSize() < sizeof(PVRTexHeaderV2) || data->getSize() < sizeof(PVRTexHeaderV3))
 		return false;
@@ -475,9 +475,9 @@ bool PVRHandler::canParse(const Data *data)
 	return false;
 }
 
-StrongRef<CompressedMemory> PVRHandler::parse(Data *filedata, std::vector<StrongRef<CompressedSlice>> &images, PixelFormat &format, bool &sRGB)
+StrongRef<CompressedMemory> PVRHandler::parseCompressed(Data *filedata, std::vector<StrongRef<CompressedSlice>> &images, PixelFormat &format, bool &sRGB)
 {
-	if (!canParse(filedata))
+	if (!canParseCompressed(filedata))
 		throw love::Exception("Could not decode compressed data (not a PVR file?)");
 
 	PVRTexHeaderV3 header3 = *(PVRTexHeaderV3 *) filedata->getData();

+ 5 - 5
src/modules/image/magpie/PVRHandler.h

@@ -22,7 +22,7 @@
 
 // LOVE
 #include "common/config.h"
-#include "image/CompressedFormatHandler.h"
+#include "image/FormatHandler.h"
 
 namespace love
 {
@@ -31,16 +31,16 @@ namespace image
 namespace magpie
 {
 
-class PVRHandler : public CompressedFormatHandler
+class PVRHandler : public FormatHandler
 {
 public:
 
 	virtual ~PVRHandler() {}
 
-	// Implements CompressedFormatHandler.
-	bool canParse(const Data *data) override;
+	// Implements FormatHandler.
+	bool canParseCompressed(Data *data) override;
 
-	StrongRef<CompressedMemory> parse(Data *filedata,
+	StrongRef<CompressedMemory> parseCompressed(Data *filedata,
 	        std::vector<StrongRef<CompressedSlice>> &images,
 	        PixelFormat &format, bool &sRGB) override;
 

+ 1 - 1
src/modules/image/magpie/STBHandler.cpp

@@ -162,7 +162,7 @@ FormatHandler::EncodedImage STBHandler::encode(const DecodedImage &img, EncodedF
 	return encimg;
 }
 
-void STBHandler::free(unsigned char *mem)
+void STBHandler::freeRawPixels(unsigned char *mem)
 {
 	// The STB decoder gave memory allocated directly by stb_image to the
 	// ImageData, so we use stb_image_free to delete it.

+ 1 - 1
src/modules/image/magpie/STBHandler.h

@@ -48,7 +48,7 @@ public:
 	DecodedImage decode(Data *data) override;
 	EncodedImage encode(const DecodedImage &img, EncodedFormat format) override;
 
-	void free(unsigned char *mem) override;
+	void freeRawPixels(unsigned char *mem) override;
 
 }; // STBHandler
 

+ 2 - 2
src/modules/image/magpie/ddsHandler.cpp

@@ -28,12 +28,12 @@ namespace image
 namespace magpie
 {
 
-bool DDSHandler::canParse(const Data *data)
+bool DDSHandler::canParseCompressed(Data *data)
 {
 	return dds::isCompressedDDS(data->getData(), data->getSize());
 }
 
-StrongRef<CompressedMemory> DDSHandler::parse(Data *filedata, std::vector<StrongRef<CompressedSlice>> &images, PixelFormat &format, bool &sRGB)
+StrongRef<CompressedMemory> DDSHandler::parseCompressed(Data *filedata, std::vector<StrongRef<CompressedSlice>> &images, PixelFormat &format, bool &sRGB)
 {
 	if (!dds::isDDS(filedata->getData(), filedata->getSize()))
 		throw love::Exception("Could not decode compressed data (not a DDS file?)");

+ 5 - 5
src/modules/image/magpie/ddsHandler.h

@@ -21,7 +21,7 @@
 #pragma once
 
 // LOVE
-#include "image/CompressedFormatHandler.h"
+#include "image/FormatHandler.h"
 
 // dds parser
 #include "ddsparse/ddsparse.h"
@@ -39,16 +39,16 @@ namespace magpie
 /**
  * Interface between CompressedImageData and the ddsparse library.
  **/
-class DDSHandler : public CompressedFormatHandler
+class DDSHandler : public FormatHandler
 {
 public:
 
 	virtual ~DDSHandler() {}
 
-	// Implements CompressedFormatHandler.
-	bool canParse(const Data *data) override;
+	// Implements FormatHandler.
+	bool canParseCompressed(Data *data) override;
 
-	StrongRef<CompressedMemory> parse(Data *filedata,
+	StrongRef<CompressedMemory> parseCompressed(Data *filedata,
 	        std::vector<StrongRef<CompressedSlice>> &images,
 	        PixelFormat &format, bool &sRGB) override;