Browse Source

Move love.graphics Image wrapper code out of the opengl subfolder

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

+ 20 - 10
platform/xcode/liblove.xcodeproj/project.pbxproj

@@ -459,9 +459,6 @@
 		FA0B7D5E1A95902C000E1D17 /* wrap_Graphics.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA0B7BAA1A95902C000E1D17 /* wrap_Graphics.cpp */; };
 		FA0B7D5F1A95902C000E1D17 /* wrap_Graphics.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA0B7BAA1A95902C000E1D17 /* wrap_Graphics.cpp */; };
 		FA0B7D601A95902C000E1D17 /* wrap_Graphics.h in Headers */ = {isa = PBXBuildFile; fileRef = FA0B7BAB1A95902C000E1D17 /* wrap_Graphics.h */; };
-		FA0B7D611A95902C000E1D17 /* wrap_Image.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA0B7BAC1A95902C000E1D17 /* wrap_Image.cpp */; };
-		FA0B7D621A95902C000E1D17 /* wrap_Image.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA0B7BAC1A95902C000E1D17 /* wrap_Image.cpp */; };
-		FA0B7D631A95902C000E1D17 /* wrap_Image.h in Headers */ = {isa = PBXBuildFile; fileRef = FA0B7BAD1A95902C000E1D17 /* wrap_Image.h */; };
 		FA0B7D641A95902C000E1D17 /* wrap_Mesh.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA0B7BAE1A95902C000E1D17 /* wrap_Mesh.cpp */; };
 		FA0B7D651A95902C000E1D17 /* wrap_Mesh.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA0B7BAE1A95902C000E1D17 /* wrap_Mesh.cpp */; };
 		FA0B7D661A95902C000E1D17 /* wrap_Mesh.h in Headers */ = {isa = PBXBuildFile; fileRef = FA0B7BAF1A95902C000E1D17 /* wrap_Mesh.h */; };
@@ -1021,6 +1018,12 @@
 		FADF540E1E3D7CDD00012CC0 /* wrap_Video.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FADF540A1E3D7CDD00012CC0 /* wrap_Video.cpp */; };
 		FADF540F1E3D7CDD00012CC0 /* wrap_Video.h in Headers */ = {isa = PBXBuildFile; fileRef = FADF540B1E3D7CDD00012CC0 /* wrap_Video.h */; };
 		FADF54101E3D7CDD00012CC0 /* wrap_Video.lua in Resources */ = {isa = PBXBuildFile; fileRef = FADF540C1E3D7CDD00012CC0 /* wrap_Video.lua */; };
+		FADF54161E3DA08E00012CC0 /* Image.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FADF54141E3DA08E00012CC0 /* Image.cpp */; };
+		FADF54171E3DA08E00012CC0 /* Image.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FADF54141E3DA08E00012CC0 /* Image.cpp */; };
+		FADF54181E3DA08E00012CC0 /* Image.h in Headers */ = {isa = PBXBuildFile; fileRef = FADF54151E3DA08E00012CC0 /* Image.h */; };
+		FADF541B1E3DA46C00012CC0 /* wrap_Image.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FADF54191E3DA46C00012CC0 /* wrap_Image.cpp */; };
+		FADF541C1E3DA46C00012CC0 /* wrap_Image.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FADF54191E3DA46C00012CC0 /* wrap_Image.cpp */; };
+		FADF541D1E3DA46C00012CC0 /* wrap_Image.h in Headers */ = {isa = PBXBuildFile; fileRef = FADF541A1E3DA46C00012CC0 /* wrap_Image.h */; };
 		FAE272521C05A15B00A67640 /* ParticleSystem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FAE272501C05A15B00A67640 /* ParticleSystem.cpp */; };
 		FAE272531C05A15B00A67640 /* ParticleSystem.h in Headers */ = {isa = PBXBuildFile; fileRef = FAE272511C05A15B00A67640 /* ParticleSystem.h */; };
 		FAF140531E20934C00F898D2 /* CodeGen.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FAF13FC21E20934C00F898D2 /* CodeGen.cpp */; };
@@ -1464,8 +1467,6 @@
 		FA0B7BA51A95902C000E1D17 /* Buffer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Buffer.h; sourceTree = "<group>"; };
 		FA0B7BAA1A95902C000E1D17 /* wrap_Graphics.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = wrap_Graphics.cpp; sourceTree = "<group>"; };
 		FA0B7BAB1A95902C000E1D17 /* wrap_Graphics.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = wrap_Graphics.h; sourceTree = "<group>"; };
-		FA0B7BAC1A95902C000E1D17 /* wrap_Image.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = wrap_Image.cpp; sourceTree = "<group>"; };
-		FA0B7BAD1A95902C000E1D17 /* wrap_Image.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = wrap_Image.h; sourceTree = "<group>"; };
 		FA0B7BAE1A95902C000E1D17 /* wrap_Mesh.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = wrap_Mesh.cpp; sourceTree = "<group>"; };
 		FA0B7BAF1A95902C000E1D17 /* wrap_Mesh.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = wrap_Mesh.h; sourceTree = "<group>"; };
 		FA0B7BB01A95902C000E1D17 /* wrap_ParticleSystem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = wrap_ParticleSystem.cpp; sourceTree = "<group>"; };
@@ -1849,6 +1850,10 @@
 		FADF540A1E3D7CDD00012CC0 /* wrap_Video.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = wrap_Video.cpp; sourceTree = "<group>"; };
 		FADF540B1E3D7CDD00012CC0 /* wrap_Video.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = wrap_Video.h; sourceTree = "<group>"; };
 		FADF540C1E3D7CDD00012CC0 /* wrap_Video.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = wrap_Video.lua; sourceTree = "<group>"; };
+		FADF54141E3DA08E00012CC0 /* Image.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Image.cpp; sourceTree = "<group>"; };
+		FADF54151E3DA08E00012CC0 /* Image.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Image.h; sourceTree = "<group>"; };
+		FADF54191E3DA46C00012CC0 /* wrap_Image.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = wrap_Image.cpp; sourceTree = "<group>"; };
+		FADF541A1E3DA46C00012CC0 /* wrap_Image.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = wrap_Image.h; sourceTree = "<group>"; };
 		FAE272501C05A15B00A67640 /* ParticleSystem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ParticleSystem.cpp; sourceTree = "<group>"; };
 		FAE272511C05A15B00A67640 /* ParticleSystem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ParticleSystem.h; sourceTree = "<group>"; };
 		FAF13FC21E20934C00F898D2 /* CodeGen.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CodeGen.cpp; sourceTree = "<group>"; };
@@ -2642,6 +2647,8 @@
 				FA1BA09C1E16CFCE00AA2803 /* Font.h */,
 				FA0B7B8A1A95902C000E1D17 /* Graphics.cpp */,
 				FA0B7B8B1A95902C000E1D17 /* Graphics.h */,
+				FADF54141E3DA08E00012CC0 /* Image.cpp */,
+				FADF54151E3DA08E00012CC0 /* Image.h */,
 				FA0B7B8C1A95902C000E1D17 /* opengl */,
 				FAE272501C05A15B00A67640 /* ParticleSystem.cpp */,
 				FAE272511C05A15B00A67640 /* ParticleSystem.h */,
@@ -2667,6 +2674,8 @@
 				FA1BA0AB1E16F9EE00AA2803 /* wrap_Canvas.h */,
 				FA1BA0A01E16D97500AA2803 /* wrap_Font.cpp */,
 				FA1BA0A11E16D97500AA2803 /* wrap_Font.h */,
+				FADF54191E3DA46C00012CC0 /* wrap_Image.cpp */,
+				FADF541A1E3DA46C00012CC0 /* wrap_Image.h */,
 				FA620A2E1AA2F8DB005DB4C2 /* wrap_Quad.cpp */,
 				FA620A2F1AA2F8DB005DB4C2 /* wrap_Quad.h */,
 				FA1BA0B51E17043400AA2803 /* wrap_Shader.cpp */,
@@ -2716,8 +2725,6 @@
 				FA0B7BAA1A95902C000E1D17 /* wrap_Graphics.cpp */,
 				FA0B7BAB1A95902C000E1D17 /* wrap_Graphics.h */,
 				FA6AE6041B3335EC00583D5C /* wrap_Graphics.lua */,
-				FA0B7BAC1A95902C000E1D17 /* wrap_Image.cpp */,
-				FA0B7BAD1A95902C000E1D17 /* wrap_Image.h */,
 				FA0B7BAE1A95902C000E1D17 /* wrap_Mesh.cpp */,
 				FA0B7BAF1A95902C000E1D17 /* wrap_Mesh.h */,
 				FA0B7BB01A95902C000E1D17 /* wrap_ParticleSystem.cpp */,
@@ -3643,6 +3650,7 @@
 				FAB17BE81ABFAA9000F9BA27 /* lz4.h in Headers */,
 				FA0B7E6B1A95902C000E1D17 /* wrap_PulleyJoint.h in Headers */,
 				FA0B7E051A95902C000E1D17 /* Contact.h in Headers */,
+				FADF541D1E3DA46C00012CC0 /* wrap_Image.h in Headers */,
 				FA1BA0A91E16F20600AA2803 /* Canvas.h in Headers */,
 				FA0B7A691A958EA3000E1D17 /* b2Island.h in Headers */,
 				FA4F2BE41DE6650600CA37D7 /* Transform.h in Headers */,
@@ -3671,7 +3679,6 @@
 				FA0B7E7A1A95902C000E1D17 /* wrap_WheelJoint.h in Headers */,
 				FA0B7A791A958EA3000E1D17 /* b2CircleContact.h in Headers */,
 				FA0B7DD81A95902C000E1D17 /* MathModule.h in Headers */,
-				FA0B7D631A95902C000E1D17 /* wrap_Image.h in Headers */,
 				FA0B7A341A958EA3000E1D17 /* b2Collision.h in Headers */,
 				217DFBDA1D9F6D490055D849 /* auxiliar.h in Headers */,
 				FA0B7EC71A95902C000E1D17 /* ThreadModule.h in Headers */,
@@ -3720,6 +3727,7 @@
 				FA0B7A601A958EA3000E1D17 /* b2Body.h in Headers */,
 				FA0B7EAB1A95902C000E1D17 /* wrap_Sound.h in Headers */,
 				FA0B7B2C1A958EA3000E1D17 /* checked.h in Headers */,
+				FADF54181E3DA08E00012CC0 /* Image.h in Headers */,
 				FA0B7D2A1A95902C000E1D17 /* wrap_GlyphData.h in Headers */,
 				FA0B7E741A95902C000E1D17 /* wrap_Shape.h in Headers */,
 				FA0B7A5D1A958EA3000E1D17 /* b2Timer.h in Headers */,
@@ -3994,6 +4002,7 @@
 				FA0B7ECC1A95902C000E1D17 /* wrap_Channel.cpp in Sources */,
 				FA0B7E6D1A95902C000E1D17 /* wrap_RevoluteJoint.cpp in Sources */,
 				FA0B7A5F1A958EA3000E1D17 /* b2Body.cpp in Sources */,
+				FADF541C1E3DA46C00012CC0 /* wrap_Image.cpp in Sources */,
 				FA0B7E641A95902C000E1D17 /* wrap_PolygonShape.cpp in Sources */,
 				FA4F2C031DE936C200CA37D7 /* auxiliar.c in Sources */,
 				FA0B7E731A95902C000E1D17 /* wrap_Shape.cpp in Sources */,
@@ -4188,7 +4197,6 @@
 				FA0B7D8E1A95902C000E1D17 /* ddsHandler.cpp in Sources */,
 				FA0B7DFE1A95902C000E1D17 /* ChainShape.cpp in Sources */,
 				FA0B7A451A958EA3000E1D17 /* b2EdgeShape.cpp in Sources */,
-				FA0B7D621A95902C000E1D17 /* wrap_Image.cpp in Sources */,
 				FAF1406D1E20934C00F898D2 /* InfoSink.cpp in Sources */,
 				FAF1407B1E20934C00F898D2 /* limits.cpp in Sources */,
 				FA0B7ABB1A958EA3000E1D17 /* callbacks.c in Sources */,
@@ -4282,6 +4290,7 @@
 				FA0B7EAD1A95902C000E1D17 /* wrap_SoundData.cpp in Sources */,
 				FA0B7E2E1A95902C000E1D17 /* RopeJoint.cpp in Sources */,
 				FA0B7CE01A95902C000E1D17 /* Source.cpp in Sources */,
+				FADF54171E3DA08E00012CC0 /* Image.cpp in Sources */,
 				FA0B7ECF1A95902C000E1D17 /* wrap_LuaThread.cpp in Sources */,
 				FA1BA0A81E16F20600AA2803 /* Canvas.cpp in Sources */,
 				FA0B7AA51A958EA3000E1D17 /* b2RevoluteJoint.cpp in Sources */,
@@ -4350,6 +4359,7 @@
 				FA0B7E6C1A95902C000E1D17 /* wrap_RevoluteJoint.cpp in Sources */,
 				FA0B7A5E1A958EA3000E1D17 /* b2Body.cpp in Sources */,
 				FA0B7E631A95902C000E1D17 /* wrap_PolygonShape.cpp in Sources */,
+				FADF541B1E3DA46C00012CC0 /* wrap_Image.cpp in Sources */,
 				FA0B7E721A95902C000E1D17 /* wrap_Shape.cpp in Sources */,
 				FA0B7CFD1A95902C000E1D17 /* File.cpp in Sources */,
 				FA4F2BB01DE1E37B00CA37D7 /* RecordingDevice.cpp in Sources */,
@@ -4537,7 +4547,6 @@
 				FA0B7D8D1A95902C000E1D17 /* ddsHandler.cpp in Sources */,
 				FA0B7DFD1A95902C000E1D17 /* ChainShape.cpp in Sources */,
 				FA0B79201A958E3B000E1D17 /* delay.cpp in Sources */,
-				FA0B7D611A95902C000E1D17 /* wrap_Image.cpp in Sources */,
 				FA0B7A4B1A958EA3000E1D17 /* b2BlockAllocator.cpp in Sources */,
 				FA0B7A551A958EA3000E1D17 /* b2Settings.cpp in Sources */,
 				FA0B7EA91A95902C000E1D17 /* wrap_Sound.cpp in Sources */,
@@ -4638,6 +4647,7 @@
 				FA4F2BE31DE6650600CA37D7 /* Transform.cpp in Sources */,
 				FA0B7EA01A95902C000E1D17 /* Sound.cpp in Sources */,
 				FA0B7DE51A95902C000E1D17 /* Cursor.cpp in Sources */,
+				FADF54161E3DA08E00012CC0 /* Image.cpp in Sources */,
 				FA0B7EDB1A95902D000E1D17 /* Touch.cpp in Sources */,
 				FA1BA0A71E16F20600AA2803 /* Canvas.cpp in Sources */,
 				FA0B7CE81A95902C000E1D17 /* Event.cpp in Sources */,

+ 68 - 0
src/modules/graphics/Image.cpp

@@ -0,0 +1,68 @@
+/**
+ * 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.
+ **/
+
+#include "Image.h"
+
+namespace love
+{
+namespace graphics
+{
+
+love::Type Image::type("Image", &Texture::type);
+
+int Image::imageCount = 0;
+
+Image::Image(const Settings &settings)
+	: settings(settings)
+{
+	++imageCount;
+}
+
+Image::~Image()
+{
+	--imageCount;
+}
+
+const Image::Settings &Image::getFlags() const
+{
+	return settings;
+}
+
+bool Image::getConstant(const char *in, SettingType &out)
+{
+	return settingTypes.find(in, out);
+}
+
+bool Image::getConstant(SettingType in, const char *&out)
+{
+	return settingTypes.find(in, out);
+}
+
+StringMap<Image::SettingType, Image::SETTING_MAX_ENUM>::Entry Image::settingTypeEntries[] =
+{
+	{ "mipmaps",      SETTING_MIPMAPS      },
+	{ "linear",       SETTING_LINEAR       },
+	{ "pixeldensity", SETTING_PIXELDENSITY },
+};
+
+StringMap<Image::SettingType, Image::SETTING_MAX_ENUM> Image::settingTypes(Image::settingTypeEntries, sizeof(Image::settingTypeEntries));
+
+} // graphics
+} // love

+ 88 - 0
src/modules/graphics/Image.h

@@ -0,0 +1,88 @@
+/**
+ * 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/config.h"
+#include "common/StringMap.h"
+#include "common/math.h"
+#include "image/ImageData.h"
+#include "image/CompressedImageData.h"
+#include "Texture.h"
+
+namespace love
+{
+namespace graphics
+{
+
+class Image : public Texture
+{
+public:
+
+	static love::Type type;
+
+	enum SettingType
+	{
+		SETTING_MIPMAPS,
+		SETTING_LINEAR,
+		SETTING_PIXELDENSITY,
+		SETTING_MAX_ENUM
+	};
+
+	struct Settings
+	{
+		bool mipmaps = false;
+		bool linear = false;
+		float pixeldensity = 1.0f;
+	};
+
+	Image(const Settings &settings);
+	virtual ~Image();
+
+	virtual const std::vector<StrongRef<love::image::ImageData>> &getImageData() const = 0;
+	virtual const std::vector<StrongRef<love::image::CompressedImageData>> &getCompressedData() const = 0;
+
+	virtual void setMipmapSharpness(float sharpness) = 0;
+	virtual float getMipmapSharpness() const = 0;
+
+	virtual bool isCompressed() const = 0;
+
+	virtual bool refresh(int xoffset, int yoffset, int w, int h) = 0;
+
+	const Settings &getFlags() const;
+
+	static bool getConstant(const char *in, SettingType &out);
+	static bool getConstant(SettingType in, const char *&out);
+
+	static int imageCount;
+
+protected:
+
+	// The settings used to initialize this Image.
+	Settings settings;
+	
+	static StringMap<SettingType, SETTING_MAX_ENUM>::Entry settingTypeEntries[];
+	static StringMap<SettingType, SETTING_MAX_ENUM> settingTypes;
+	
+}; // Image
+
+} // graphics
+} // love

+ 4 - 37
src/modules/graphics/opengl/Image.cpp

@@ -43,10 +43,6 @@ namespace graphics
 namespace opengl
 {
 
-love::Type Image::type("Image", &Texture::type);
-
-int Image::imageCount = 0;
-
 float Image::maxMipmapSharpness = 0.0f;
 
 static int getMipmapCount(int basewidth, int baseheight)
@@ -92,10 +88,10 @@ static bool verifyMipmapLevels(const std::vector<T> &miplevels)
 }
 
 Image::Image(const std::vector<love::image::ImageData *> &imagedata, const Settings &settings)
-	: texture(0)
+	: love::graphics::Image(settings)
+	, texture(0)
 	, mipmapSharpness(defaultMipmapSharpness)
 	, compressed(false)
-	, settings(settings)
 	, sRGB(false)
 	, usingDefaultTexture(false)
 	, textureMemorySize(0)
@@ -119,15 +115,13 @@ Image::Image(const std::vector<love::image::ImageData *> &imagedata, const Setti
 
 	preload();
 	loadVolatile();
-
-	++imageCount;
 }
 
 Image::Image(const std::vector<love::image::CompressedImageData *> &compresseddata, const Settings &settings)
-	: texture(0)
+	: love::graphics::Image(settings)
+	, texture(0)
 	, mipmapSharpness(defaultMipmapSharpness)
 	, compressed(true)
-	, settings(settings)
 	, sRGB(false)
 	, usingDefaultTexture(false)
 	, textureMemorySize(0)
@@ -159,14 +153,11 @@ Image::Image(const std::vector<love::image::CompressedImageData *> &compressedda
 
 	preload();
 	loadVolatile();
-
-	++imageCount;
 }
 
 Image::~Image()
 {
 	unloadVolatile();
-	--imageCount;
 }
 
 void Image::preload()
@@ -545,11 +536,6 @@ float Image::getMipmapSharpness() const
 	return mipmapSharpness;
 }
 
-const Image::Settings &Image::getFlags() const
-{
-	return settings;
-}
-
 bool Image::isCompressed() const
 {
 	return compressed;
@@ -565,25 +551,6 @@ bool Image::hasSRGBSupport()
 	return GLAD_ES_VERSION_3_0 || GLAD_EXT_sRGB || GLAD_VERSION_2_1 || GLAD_EXT_texture_sRGB;
 }
 
-bool Image::getConstant(const char *in, SettingType &out)
-{
-	return settingTypes.find(in, out);
-}
-
-bool Image::getConstant(SettingType in, const char *&out)
-{
-	return settingTypes.find(in, out);
-}
-
-StringMap<Image::SettingType, Image::SETTING_MAX_ENUM>::Entry Image::settingTypeEntries[] =
-{
-	{ "mipmaps",      SETTING_MIPMAPS      },
-	{ "linear",       SETTING_LINEAR       },
-	{ "pixeldensity", SETTING_PIXELDENSITY },
-};
-
-StringMap<Image::SettingType, Image::SETTING_MAX_ENUM> Image::settingTypes(Image::settingTypeEntries, sizeof(Image::settingTypeEntries));
-
 } // opengl
 } // graphics
 } // love

+ 9 - 75
src/modules/graphics/opengl/Image.h

@@ -18,18 +18,10 @@
  * 3. This notice may not be removed or altered from any source distribution.
  **/
 
-#ifndef LOVE_GRAPHICS_OPENGL_IMAGE_H
-#define LOVE_GRAPHICS_OPENGL_IMAGE_H
+#pragma once
 
 // LOVE
-#include "common/config.h"
-#include "common/Matrix.h"
-#include "common/Vector.h"
-#include "common/StringMap.h"
-#include "common/math.h"
-#include "image/ImageData.h"
-#include "image/CompressedImageData.h"
-#include "graphics/Texture.h"
+#include "graphics/Image.h"
 #include "graphics/Volatile.h"
 
 // OpenGL
@@ -42,48 +34,11 @@ namespace graphics
 namespace opengl
 {
 
-/**
- * A drawable image based on OpenGL-textures. This class takes ImageData
- * objects and create textures on the GPU for fast drawing.
- *
- * @author Anders Ruud
- **/
-class Image : public Texture, public Volatile
+class Image : public love::graphics::Image, public Volatile
 {
 public:
 
-	static love::Type type;
-
-	enum SettingType
-	{
-		SETTING_MIPMAPS,
-		SETTING_LINEAR,
-		SETTING_PIXELDENSITY,
-		SETTING_MAX_ENUM
-	};
-
-	struct Settings
-	{
-		bool mipmaps = false;
-		bool linear = false;
-		float pixeldensity = 1.0f;
-	};
-
-	/**
-	 * Creates a new Image. Not that anything is ready to use
-	 * before load is called.
-	 *
-	 * @param data The data from which to load the image. Each element in the
-	 * array is a mipmap level. If more than the base level is present, all
-	 * mip levels must be present.
-	 **/
 	Image(const std::vector<love::image::ImageData *> &data, const Settings &settings);
-
-	/**
-	 * Creates a new Image with compressed image data.
-	 *
-	 * @param cdata The compressed data from which to load the image.
-	 **/
 	Image(const std::vector<love::image::CompressedImageData *> &cdata, const Settings &settings);
 
 	virtual ~Image();
@@ -94,27 +49,16 @@ public:
 
 	ptrdiff_t getHandle() const override;
 
-	const std::vector<StrongRef<love::image::ImageData>> &getImageData() const;
-	const std::vector<StrongRef<love::image::CompressedImageData>> &getCompressedData() const;
+	const std::vector<StrongRef<love::image::ImageData>> &getImageData() const override;
+	const std::vector<StrongRef<love::image::CompressedImageData>> &getCompressedData() const override;
 
 	void setFilter(const Texture::Filter &f) override;
 	bool setWrap(const Texture::Wrap &w) override;
 
-	void setMipmapSharpness(float sharpness);
-	float getMipmapSharpness() const;
-
-	/**
-	 * Whether this Image is using a compressed texture (via CompressedImageData).
-	 **/
-	bool isCompressed() const;
-
-	/**
-	 * Re-uploads the ImageData or CompressedImageData associated with this Image to
-	 * the GPU.
-	 **/
-	bool refresh(int xoffset, int yoffset, int w, int h);
-
-	const Settings &getFlags() const;
+	void setMipmapSharpness(float sharpness) override;
+	float getMipmapSharpness() const override;
+	bool isCompressed() const override;
+	bool refresh(int xoffset, int yoffset, int w, int h) override;
 
 	static bool isFormatSupported(PixelFormat pixelformat);
 	static bool hasSRGBSupport();
@@ -122,8 +66,6 @@ public:
 	static bool getConstant(const char *in, SettingType &out);
 	static bool getConstant(SettingType in, const char *&out);
 
-	static int imageCount;
-
 private:
 
 	void preload();
@@ -151,9 +93,6 @@ private:
 	// Whether this Image is using a compressed texture.
 	bool compressed;
 
-	// The settings used to initialize this Image.
-	Settings settings;
-
 	bool sRGB;
 
 	// True if the image wasn't able to be properly created and it had to fall
@@ -164,13 +103,8 @@ private:
 
 	static float maxMipmapSharpness;
 
-	static StringMap<SettingType, SETTING_MAX_ENUM>::Entry settingTypeEntries[];
-	static StringMap<SettingType, SETTING_MAX_ENUM> settingTypes;
-
 }; // Image
 
 } // opengl
 } // graphics
 } // love
-
-#endif // LOVE_GRAPHICS_OPENGL_IMAGE_H

+ 1 - 1
src/modules/graphics/opengl/wrap_Graphics.h

@@ -24,7 +24,7 @@
 // LOVE
 #include "common/config.h"
 #include "graphics/wrap_Font.h"
-#include "wrap_Image.h"
+#include "graphics/wrap_Image.h"
 #include "graphics/wrap_Quad.h"
 #include "wrap_SpriteBatch.h"
 #include "wrap_ParticleSystem.h"

+ 2 - 2
src/modules/graphics/opengl/wrap_Mesh.cpp

@@ -474,9 +474,9 @@ int w_Mesh_getTexture(lua_State *L)
 		return 0;
 
 	// FIXME: big hack right here.
-	if (typeid(*tex) == typeid(Image))
+	if (dynamic_cast<Image *>(tex) != nullptr)
 		luax_pushtype(L, Image::type, tex);
-	else if (typeid(*tex) == typeid(Canvas))
+	else if (dynamic_cast<Canvas *>(tex) != nullptr)
 		luax_pushtype(L, Canvas::type, tex);
 	else
 		return luaL_error(L, "Unable to determine texture type.");

+ 2 - 5
src/modules/graphics/opengl/wrap_ParticleSystem.cpp

@@ -29,9 +29,6 @@
 // C
 #include <cstring>
 
-// C++
-#include <typeinfo>
-
 namespace love
 {
 namespace graphics
@@ -70,9 +67,9 @@ int w_ParticleSystem_getTexture(lua_State *L)
 	Texture *tex = t->getTexture();
 
 	// FIXME: big hack right here.
-	if (typeid(*tex) == typeid(Image))
+	if (dynamic_cast<Image *>(tex) != nullptr)
 		luax_pushtype(L, Image::type, tex);
-	else if (typeid(*tex) == typeid(Canvas))
+	else if (dynamic_cast<Canvas *>(tex) != nullptr)
 		luax_pushtype(L, Canvas::type, tex);
 	else
 		return luaL_error(L, "Unable to determine texture type.");

+ 2 - 2
src/modules/graphics/opengl/wrap_SpriteBatch.cpp

@@ -135,9 +135,9 @@ int w_SpriteBatch_getTexture(lua_State *L)
 	Texture *tex = t->getTexture();
 
 	// FIXME: big hack right here.
-	if (typeid(*tex) == typeid(Image))
+	if (dynamic_cast<Image *>(tex) != nullptr)
 		luax_pushtype(L, Image::type, tex);
-	else if (typeid(*tex) == typeid(Canvas))
+	else if (dynamic_cast<Canvas *>(tex) != nullptr)
 		luax_pushtype(L, Canvas::type, tex);
 	else
 		return luaL_error(L, "Unable to determine texture type.");

+ 0 - 3
src/modules/graphics/opengl/wrap_Image.cpp → src/modules/graphics/wrap_Image.cpp

@@ -25,8 +25,6 @@ namespace love
 {
 namespace graphics
 {
-namespace opengl
-{
 
 Image *luax_checkimage(lua_State *L, int idx)
 {
@@ -156,6 +154,5 @@ extern "C" int luaopen_image(lua_State *L)
 	return luax_register_type(L, &Image::type, w_Texture_functions, w_Image_functions, nullptr);
 }
 
-} // opengl
 } // graphics
 } // love

+ 2 - 8
src/modules/graphics/opengl/wrap_Image.h → src/modules/graphics/wrap_Image.h

@@ -18,27 +18,21 @@
  * 3. This notice may not be removed or altered from any source distribution.
  **/
 
-#ifndef LOVE_GRAPHICS_OPENGL_WRAP_IMAGE_H
-#define LOVE_GRAPHICS_OPENGL_WRAP_IMAGE_H
+#pragma once
 
 // LOVE
 #include "common/runtime.h"
 #include "Image.h"
-#include "graphics/wrap_Texture.h"
+#include "wrap_Texture.h"
 
 namespace love
 {
 namespace graphics
 {
-namespace opengl
-{
 
 const char *luax_imageSettingName(Image::SettingType settingtype);
 Image *luax_checkimage(lua_State *L, int idx);
 extern "C" int luaopen_image(lua_State *L);
 
-} // opengl
 } // graphics
 } // love
-
-#endif // LOVE_GRAPHICS_OPENGL_WRAP_IMAGE_H