Browse Source

Remove graphics::Canvas and graphics::Image

Alex Szpakowski 5 years ago
parent
commit
258129738f

+ 0 - 4
CMakeLists.txt

@@ -518,8 +518,6 @@ source_group("modules\\font\\freetype" FILES ${LOVE_SRC_MODULE_FONT_FREETYPE})
 set(LOVE_SRC_MODULE_GRAPHICS_ROOT
 set(LOVE_SRC_MODULE_GRAPHICS_ROOT
 	src/modules/graphics/Buffer.cpp
 	src/modules/graphics/Buffer.cpp
 	src/modules/graphics/Buffer.h
 	src/modules/graphics/Buffer.h
-	src/modules/graphics/Canvas.cpp
-	src/modules/graphics/Canvas.h
 	src/modules/graphics/Deprecations.cpp
 	src/modules/graphics/Deprecations.cpp
 	src/modules/graphics/Deprecations.h
 	src/modules/graphics/Deprecations.h
 	src/modules/graphics/Drawable.cpp
 	src/modules/graphics/Drawable.cpp
@@ -528,8 +526,6 @@ set(LOVE_SRC_MODULE_GRAPHICS_ROOT
 	src/modules/graphics/Font.h
 	src/modules/graphics/Font.h
 	src/modules/graphics/Graphics.cpp
 	src/modules/graphics/Graphics.cpp
 	src/modules/graphics/Graphics.h
 	src/modules/graphics/Graphics.h
-	src/modules/graphics/Image.cpp
-	src/modules/graphics/Image.h
 	src/modules/graphics/Mesh.cpp
 	src/modules/graphics/Mesh.cpp
 	src/modules/graphics/Mesh.h
 	src/modules/graphics/Mesh.h
 	src/modules/graphics/ParticleSystem.cpp
 	src/modules/graphics/ParticleSystem.cpp

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

@@ -787,9 +787,6 @@
 		FA1BA0A21E16D97500AA2803 /* wrap_Font.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA1BA0A01E16D97500AA2803 /* wrap_Font.cpp */; };
 		FA1BA0A21E16D97500AA2803 /* wrap_Font.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA1BA0A01E16D97500AA2803 /* wrap_Font.cpp */; };
 		FA1BA0A31E16D97500AA2803 /* wrap_Font.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA1BA0A01E16D97500AA2803 /* wrap_Font.cpp */; };
 		FA1BA0A31E16D97500AA2803 /* wrap_Font.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA1BA0A01E16D97500AA2803 /* wrap_Font.cpp */; };
 		FA1BA0A41E16D97500AA2803 /* wrap_Font.h in Headers */ = {isa = PBXBuildFile; fileRef = FA1BA0A11E16D97500AA2803 /* wrap_Font.h */; };
 		FA1BA0A41E16D97500AA2803 /* wrap_Font.h in Headers */ = {isa = PBXBuildFile; fileRef = FA1BA0A11E16D97500AA2803 /* wrap_Font.h */; };
-		FA1BA0A71E16F20600AA2803 /* Canvas.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA1BA0A51E16F20600AA2803 /* Canvas.cpp */; };
-		FA1BA0A81E16F20600AA2803 /* Canvas.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA1BA0A51E16F20600AA2803 /* Canvas.cpp */; };
-		FA1BA0A91E16F20600AA2803 /* Canvas.h in Headers */ = {isa = PBXBuildFile; fileRef = FA1BA0A61E16F20600AA2803 /* Canvas.h */; };
 		FA1BA0B11E16FD0800AA2803 /* Shader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA1BA0AF1E16FD0800AA2803 /* Shader.cpp */; };
 		FA1BA0B11E16FD0800AA2803 /* Shader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA1BA0AF1E16FD0800AA2803 /* Shader.cpp */; };
 		FA1BA0B21E16FD0800AA2803 /* Shader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA1BA0AF1E16FD0800AA2803 /* Shader.cpp */; };
 		FA1BA0B21E16FD0800AA2803 /* Shader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA1BA0AF1E16FD0800AA2803 /* Shader.cpp */; };
 		FA1BA0B31E16FD0800AA2803 /* Shader.h in Headers */ = {isa = PBXBuildFile; fileRef = FA1BA0B01E16FD0800AA2803 /* Shader.h */; };
 		FA1BA0B31E16FD0800AA2803 /* Shader.h in Headers */ = {isa = PBXBuildFile; fileRef = FA1BA0B01E16FD0800AA2803 /* Shader.h */; };
@@ -1057,9 +1054,6 @@
 		FADF540E1E3D7CDD00012CC0 /* wrap_Video.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FADF540A1E3D7CDD00012CC0 /* wrap_Video.cpp */; };
 		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 */; };
 		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 */; };
 		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 */; };
 		FADF54201E3DA52C00012CC0 /* wrap_ParticleSystem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FADF541E1E3DA52C00012CC0 /* wrap_ParticleSystem.cpp */; };
 		FADF54201E3DA52C00012CC0 /* wrap_ParticleSystem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FADF541E1E3DA52C00012CC0 /* wrap_ParticleSystem.cpp */; };
 		FADF54211E3DA52C00012CC0 /* wrap_ParticleSystem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FADF541E1E3DA52C00012CC0 /* wrap_ParticleSystem.cpp */; };
 		FADF54211E3DA52C00012CC0 /* wrap_ParticleSystem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FADF541E1E3DA52C00012CC0 /* wrap_ParticleSystem.cpp */; };
 		FADF54221E3DA52C00012CC0 /* wrap_ParticleSystem.h in Headers */ = {isa = PBXBuildFile; fileRef = FADF541F1E3DA52C00012CC0 /* wrap_ParticleSystem.h */; };
 		FADF54221E3DA52C00012CC0 /* wrap_ParticleSystem.h in Headers */ = {isa = PBXBuildFile; fileRef = FADF541F1E3DA52C00012CC0 /* wrap_ParticleSystem.h */; };
@@ -1799,8 +1793,6 @@
 		FA1BA09C1E16CFCE00AA2803 /* Font.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Font.h; sourceTree = "<group>"; };
 		FA1BA09C1E16CFCE00AA2803 /* Font.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Font.h; sourceTree = "<group>"; };
 		FA1BA0A01E16D97500AA2803 /* wrap_Font.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = wrap_Font.cpp; sourceTree = "<group>"; };
 		FA1BA0A01E16D97500AA2803 /* wrap_Font.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = wrap_Font.cpp; sourceTree = "<group>"; };
 		FA1BA0A11E16D97500AA2803 /* wrap_Font.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = wrap_Font.h; sourceTree = "<group>"; };
 		FA1BA0A11E16D97500AA2803 /* wrap_Font.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = wrap_Font.h; sourceTree = "<group>"; };
-		FA1BA0A51E16F20600AA2803 /* Canvas.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = Canvas.cpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
-		FA1BA0A61E16F20600AA2803 /* Canvas.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = Canvas.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
 		FA1BA0AF1E16FD0800AA2803 /* Shader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Shader.cpp; sourceTree = "<group>"; };
 		FA1BA0AF1E16FD0800AA2803 /* Shader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Shader.cpp; sourceTree = "<group>"; };
 		FA1BA0B01E16FD0800AA2803 /* Shader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Shader.h; sourceTree = "<group>"; };
 		FA1BA0B01E16FD0800AA2803 /* Shader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Shader.h; sourceTree = "<group>"; };
 		FA1BA0B51E17043400AA2803 /* wrap_Shader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = wrap_Shader.cpp; sourceTree = "<group>"; };
 		FA1BA0B51E17043400AA2803 /* wrap_Shader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = wrap_Shader.cpp; sourceTree = "<group>"; };
@@ -2001,8 +1993,6 @@
 		FADF540A1E3D7CDD00012CC0 /* wrap_Video.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = wrap_Video.cpp; sourceTree = "<group>"; };
 		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>"; };
 		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>"; };
 		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>"; };
 		FADF541E1E3DA52C00012CC0 /* wrap_ParticleSystem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = wrap_ParticleSystem.cpp; sourceTree = "<group>"; };
 		FADF541E1E3DA52C00012CC0 /* wrap_ParticleSystem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = wrap_ParticleSystem.cpp; sourceTree = "<group>"; };
 		FADF541F1E3DA52C00012CC0 /* wrap_ParticleSystem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = wrap_ParticleSystem.h; sourceTree = "<group>"; };
 		FADF541F1E3DA52C00012CC0 /* wrap_ParticleSystem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = wrap_ParticleSystem.h; sourceTree = "<group>"; };
 		FADF54231E3DA5BA00012CC0 /* Mesh.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Mesh.cpp; sourceTree = "<group>"; };
 		FADF54231E3DA5BA00012CC0 /* Mesh.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Mesh.cpp; sourceTree = "<group>"; };
@@ -2827,8 +2817,6 @@
 			children = (
 			children = (
 				FADF53F61E3C7ACD00012CC0 /* Buffer.cpp */,
 				FADF53F61E3C7ACD00012CC0 /* Buffer.cpp */,
 				FADF53F71E3C7ACD00012CC0 /* Buffer.h */,
 				FADF53F71E3C7ACD00012CC0 /* Buffer.h */,
-				FA1BA0A51E16F20600AA2803 /* Canvas.cpp */,
-				FA1BA0A61E16F20600AA2803 /* Canvas.h */,
 				FA9D53AA1F5307E900125C6B /* Deprecations.cpp */,
 				FA9D53AA1F5307E900125C6B /* Deprecations.cpp */,
 				FA9D53AB1F5307E900125C6B /* Deprecations.h */,
 				FA9D53AB1F5307E900125C6B /* Deprecations.h */,
 				FA9D8DDC1DEF842A002CD881 /* Drawable.cpp */,
 				FA9D8DDC1DEF842A002CD881 /* Drawable.cpp */,
@@ -2837,8 +2825,6 @@
 				FA1BA09C1E16CFCE00AA2803 /* Font.h */,
 				FA1BA09C1E16CFCE00AA2803 /* Font.h */,
 				FA0B7B8A1A95902C000E1D17 /* Graphics.cpp */,
 				FA0B7B8A1A95902C000E1D17 /* Graphics.cpp */,
 				FA0B7B8B1A95902C000E1D17 /* Graphics.h */,
 				FA0B7B8B1A95902C000E1D17 /* Graphics.h */,
-				FADF54141E3DA08E00012CC0 /* Image.cpp */,
-				FADF54151E3DA08E00012CC0 /* Image.h */,
 				FADF54231E3DA5BA00012CC0 /* Mesh.cpp */,
 				FADF54231E3DA5BA00012CC0 /* Mesh.cpp */,
 				FADF54241E3DA5BA00012CC0 /* Mesh.h */,
 				FADF54241E3DA5BA00012CC0 /* Mesh.h */,
 				FA0B7B8C1A95902C000E1D17 /* opengl */,
 				FA0B7B8C1A95902C000E1D17 /* opengl */,
@@ -3959,7 +3945,6 @@
 				FAB17BE81ABFAA9000F9BA27 /* lz4.h in Headers */,
 				FAB17BE81ABFAA9000F9BA27 /* lz4.h in Headers */,
 				FA0B7E6B1A95902C000E1D17 /* wrap_PulleyJoint.h in Headers */,
 				FA0B7E6B1A95902C000E1D17 /* wrap_PulleyJoint.h in Headers */,
 				FA0B7E051A95902C000E1D17 /* Contact.h in Headers */,
 				FA0B7E051A95902C000E1D17 /* Contact.h in Headers */,
-				FA1BA0A91E16F20600AA2803 /* Canvas.h in Headers */,
 				FA0B7A691A958EA3000E1D17 /* b2Island.h in Headers */,
 				FA0B7A691A958EA3000E1D17 /* b2Island.h in Headers */,
 				FA4F2BE41DE6650600CA37D7 /* Transform.h in Headers */,
 				FA4F2BE41DE6650600CA37D7 /* Transform.h in Headers */,
 				FA0B7E0E1A95902C000E1D17 /* Fixture.h in Headers */,
 				FA0B7E0E1A95902C000E1D17 /* Fixture.h in Headers */,
@@ -4037,7 +4022,6 @@
 				FA0B7A601A958EA3000E1D17 /* b2Body.h in Headers */,
 				FA0B7A601A958EA3000E1D17 /* b2Body.h in Headers */,
 				FA0B7EAB1A95902C000E1D17 /* wrap_Sound.h in Headers */,
 				FA0B7EAB1A95902C000E1D17 /* wrap_Sound.h in Headers */,
 				FA0B7B2C1A958EA3000E1D17 /* checked.h in Headers */,
 				FA0B7B2C1A958EA3000E1D17 /* checked.h in Headers */,
-				FADF54181E3DA08E00012CC0 /* Image.h in Headers */,
 				FA0B7D2A1A95902C000E1D17 /* wrap_GlyphData.h in Headers */,
 				FA0B7D2A1A95902C000E1D17 /* wrap_GlyphData.h in Headers */,
 				FACA02F11F5E396B0084B28F /* DataModule.h in Headers */,
 				FACA02F11F5E396B0084B28F /* DataModule.h in Headers */,
 				FA0B7E741A95902C000E1D17 /* wrap_Shape.h in Headers */,
 				FA0B7E741A95902C000E1D17 /* wrap_Shape.h in Headers */,
@@ -4645,9 +4629,7 @@
 				FA0B7EAD1A95902C000E1D17 /* wrap_SoundData.cpp in Sources */,
 				FA0B7EAD1A95902C000E1D17 /* wrap_SoundData.cpp in Sources */,
 				FA0B7E2E1A95902C000E1D17 /* RopeJoint.cpp in Sources */,
 				FA0B7E2E1A95902C000E1D17 /* RopeJoint.cpp in Sources */,
 				FA0B7CE01A95902C000E1D17 /* Source.cpp in Sources */,
 				FA0B7CE01A95902C000E1D17 /* Source.cpp in Sources */,
-				FADF54171E3DA08E00012CC0 /* Image.cpp in Sources */,
 				FA0B7ECF1A95902C000E1D17 /* wrap_LuaThread.cpp in Sources */,
 				FA0B7ECF1A95902C000E1D17 /* wrap_LuaThread.cpp in Sources */,
-				FA1BA0A81E16F20600AA2803 /* Canvas.cpp in Sources */,
 				FA0B7AA51A958EA3000E1D17 /* b2RevoluteJoint.cpp in Sources */,
 				FA0B7AA51A958EA3000E1D17 /* b2RevoluteJoint.cpp in Sources */,
 				FA0B7EA11A95902C000E1D17 /* Sound.cpp in Sources */,
 				FA0B7EA11A95902C000E1D17 /* Sound.cpp in Sources */,
 				FA0B7DE61A95902C000E1D17 /* Cursor.cpp in Sources */,
 				FA0B7DE61A95902C000E1D17 /* Cursor.cpp in Sources */,
@@ -5044,9 +5026,7 @@
 				FA4F2BE31DE6650600CA37D7 /* Transform.cpp in Sources */,
 				FA4F2BE31DE6650600CA37D7 /* Transform.cpp in Sources */,
 				FA0B7EA01A95902C000E1D17 /* Sound.cpp in Sources */,
 				FA0B7EA01A95902C000E1D17 /* Sound.cpp in Sources */,
 				FA0B7DE51A95902C000E1D17 /* Cursor.cpp in Sources */,
 				FA0B7DE51A95902C000E1D17 /* Cursor.cpp in Sources */,
-				FADF54161E3DA08E00012CC0 /* Image.cpp in Sources */,
 				FA0B7EDB1A95902D000E1D17 /* Touch.cpp in Sources */,
 				FA0B7EDB1A95902D000E1D17 /* Touch.cpp in Sources */,
-				FA1BA0A71E16F20600AA2803 /* Canvas.cpp in Sources */,
 				FA0B7CE81A95902C000E1D17 /* Event.cpp in Sources */,
 				FA0B7CE81A95902C000E1D17 /* Event.cpp in Sources */,
 				FA0B7ACF1A958EA3000E1D17 /* peer.c in Sources */,
 				FA0B7ACF1A958EA3000E1D17 /* peer.c in Sources */,
 				FA0B7ADE1A958EA3000E1D17 /* lodepng.cpp in Sources */,
 				FA0B7ADE1A958EA3000E1D17 /* lodepng.cpp in Sources */,

+ 0 - 144
src/modules/graphics/Canvas.cpp

@@ -1,144 +0,0 @@
-/**
- * Copyright (c) 2006-2020 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 "Canvas.h"
-#include "Graphics.h"
-
-namespace love
-{
-namespace graphics
-{
-
-love::Type Canvas::type("Canvas", &Texture::type);
-
-Canvas::Canvas(const Settings &settings)
-	: Texture(settings.type)
-{
-	this->settings = settings;
-
-	renderTarget = true;
-	sRGB = false;
-	requestedMSAA = settings.msaa;
-
-	mipmapsMode = settings.mipmaps;
-	width = settings.width;
-	height = settings.height;
-	pixelWidth = (int) ((width * settings.dpiScale) + 0.5);
-	pixelHeight = (int) ((height * settings.dpiScale) + 0.5);
-
-	format = settings.format;
-
-	if (texType == TEXTURE_VOLUME)
-		depth = settings.layers;
-	else if (texType == TEXTURE_2D_ARRAY)
-		layers = settings.layers;
-
-	if (width <= 0 || height <= 0 || layers <= 0)
-		throw love::Exception("Canvas dimensions must be greater than 0.");
-
-	if (texType != TEXTURE_2D && settings.msaa > 1)
-		throw love::Exception("MSAA is only supported for Canvases with the 2D texture type.");
-
-	if (settings.readable.hasValue)
-		readable = settings.readable.value;
-	else
-		readable = !isPixelFormatDepthStencil(format);
-
-	if (readable && isPixelFormatDepthStencil(format) && settings.msaa > 1)
-		throw love::Exception("Readable depth/stencil Canvases with MSAA are not currently supported.");
-
-	if ((!readable || settings.msaa > 1) && mipmapsMode != MIPMAPS_NONE)
-		throw love::Exception("Non-readable and MSAA textures cannot have mipmaps.");
-
-	if (mipmapsMode != MIPMAPS_NONE)
-		mipmapCount = getTotalMipmapCount(pixelWidth, pixelHeight, depth);
-
-	auto gfx = Module::getInstance<Graphics>(Module::M_GRAPHICS);
-	const Graphics::Capabilities &caps = gfx->getCapabilities();
-
-	if (!gfx->isPixelFormatSupported(format, renderTarget, readable, sRGB))
-	{
-		const char *fstr = "rgba8";
-		const char *readablestr = "";
-		if (readable != !isPixelFormatDepthStencil(format))
-			readablestr = readable ? " readable" : " non-readable";
-		love::getConstant(format, fstr);
-		throw love::Exception("The %s%s canvas format is not supported by your graphics drivers.", fstr, readablestr);
-	}
-
-	if (getRequestedMSAA() > 1 && texType != TEXTURE_2D)
-		throw love::Exception("MSAA is only supported for 2D texture types.");
-
-	if (!readable && texType != TEXTURE_2D)
-		throw love::Exception("Non-readable pixel formats are only supported for 2D texture types.");
-
-	if (!caps.textureTypes[texType])
-	{
-		const char *textypestr = "unknown";
-		Texture::getConstant(texType, textypestr);
-		throw love::Exception("%s textures are not supported on this system!", textypestr);
-	}
-
-	validateDimensions(true);
-}
-
-Canvas::~Canvas()
-{
-}
-
-bool Canvas::getConstant(const char *in, SettingType &out)
-{
-	return settingTypes.find(in, out);
-}
-
-bool Canvas::getConstant(SettingType in, const char *&out)
-{
-	return settingTypes.find(in, out);
-}
-
-const char *Canvas::getConstant(SettingType in)
-{
-	const char *name = nullptr;
-	getConstant(in, name);
-	return name;
-}
-
-std::vector<std::string> Canvas::getConstants(SettingType)
-{
-	return settingTypes.getNames();
-}
-
-StringMap<Canvas::SettingType, Canvas::SETTING_MAX_ENUM>::Entry Canvas::settingTypeEntries[] =
-{
-	// Width / height / layers are currently omittted because they're separate
-	// arguments to newCanvas in the wrapper code.
-	{ "mipmaps",  SETTING_MIPMAPS   },
-	{ "format",   SETTING_FORMAT    },
-	{ "type",     SETTING_TYPE      },
-	{ "dpiscale", SETTING_DPI_SCALE },
-	{ "msaa",     SETTING_MSAA      },
-	{ "readable", SETTING_READABLE  },
-};
-
-StringMap<Canvas::SettingType, Canvas::SETTING_MAX_ENUM> Canvas::settingTypes(Canvas::settingTypeEntries, sizeof(Canvas::settingTypeEntries));
-
-} // graphics
-} // love
-

+ 0 - 89
src/modules/graphics/Canvas.h

@@ -1,89 +0,0 @@
-/**
-* Copyright (c) 2006-2020 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
-
-#include "image/Image.h"
-#include "image/ImageData.h"
-#include "Texture.h"
-#include "common/Optional.h"
-#include "common/StringMap.h"
-
-namespace love
-{
-namespace graphics
-{
-
-class Graphics;
-
-class Canvas : public Texture
-{
-public:
-
-	static love::Type type;
-
-	enum SettingType
-	{
-		SETTING_WIDTH,
-		SETTING_HEIGHT,
-		SETTING_LAYERS,
-		SETTING_MIPMAPS,
-		SETTING_FORMAT,
-		SETTING_TYPE,
-		SETTING_DPI_SCALE,
-		SETTING_MSAA,
-		SETTING_READABLE,
-		SETTING_MAX_ENUM
-	};
-
-	struct Settings
-	{
-		int width  = 1;
-		int height = 1;
-		int layers = 1; // depth for 3D textures
-		MipmapsMode mipmaps = MIPMAPS_NONE;
-		PixelFormat format = PIXELFORMAT_NORMAL;
-		TextureType type = TEXTURE_2D;
-		float dpiScale = 1.0f;
-		int msaa = 0;
-		OptionalBool readable;
-	};
-
-	Canvas(const Settings &settings);
-	virtual ~Canvas();
-
-	static bool getConstant(const char *in, SettingType &out);
-	static bool getConstant(SettingType in, const char *&out);
-	static const char *getConstant(SettingType in);
-	static std::vector<std::string> getConstants(SettingType);
-
-protected:
-
-	Settings settings;
-
-private:
-
-	static StringMap<SettingType, SETTING_MAX_ENUM>::Entry settingTypeEntries[];
-	static StringMap<SettingType, SETTING_MAX_ENUM> settingTypes;
-	
-}; // Canvas
-
-} // graphics
-} // love

+ 5 - 2
src/modules/graphics/Font.cpp

@@ -150,8 +150,11 @@ void Font::createTexture()
 		textures.pop_back();
 		textures.pop_back();
 	}
 	}
 
 
-	Image::Settings settings;
-	texture = gfx->newImage(TEXTURE_2D, pixelFormat, size.width, size.height, 1, settings);
+	Texture::Settings settings;
+	settings.format = pixelFormat;
+	settings.width = size.width;
+	settings.height = size.height;
+	texture = gfx->newImage(settings, nullptr);
 	texture->setSamplerState(samplerState);
 	texture->setSamplerState(samplerState);
 
 
 	{
 	{

+ 1 - 1
src/modules/graphics/Graphics.cpp

@@ -820,7 +820,7 @@ Texture *Graphics::getTemporaryTexture(PixelFormat format, int w, int h, int sam
 
 
 	if (texture == nullptr)
 	if (texture == nullptr)
 	{
 	{
-		Canvas::Settings settings;
+		Texture::Settings settings;
 		settings.format = format;
 		settings.format = format;
 		settings.width = w;
 		settings.width = w;
 		settings.height = h;
 		settings.height = h;

+ 2 - 5
src/modules/graphics/Graphics.h

@@ -32,13 +32,11 @@
 #include "StreamBuffer.h"
 #include "StreamBuffer.h"
 #include "vertex.h"
 #include "vertex.h"
 #include "Texture.h"
 #include "Texture.h"
-#include "Canvas.h"
 #include "Font.h"
 #include "Font.h"
 #include "ShaderStage.h"
 #include "ShaderStage.h"
 #include "Shader.h"
 #include "Shader.h"
 #include "Quad.h"
 #include "Quad.h"
 #include "Mesh.h"
 #include "Mesh.h"
-#include "Image.h"
 #include "Deprecations.h"
 #include "Deprecations.h"
 #include "renderstate.h"
 #include "renderstate.h"
 #include "math/Transform.h"
 #include "math/Transform.h"
@@ -428,8 +426,7 @@ public:
 	// Implements Module.
 	// Implements Module.
 	virtual ModuleType getModuleType() const { return M_GRAPHICS; }
 	virtual ModuleType getModuleType() const { return M_GRAPHICS; }
 
 
-	virtual Texture *newImage(const Texture::Slices &data, const Image::Settings &settings) = 0;
-	virtual Texture *newImage(TextureType textype, PixelFormat format, int width, int height, int slices, const Image::Settings &settings) = 0;
+	virtual Texture *newImage(const Texture::Settings &settings, const Texture::Slices *data) = 0;
 
 
 	Quad *newQuad(Quad::Viewport v, double sw, double sh);
 	Quad *newQuad(Quad::Viewport v, double sw, double sh);
 	Font *newFont(love::font::Rasterizer *data);
 	Font *newFont(love::font::Rasterizer *data);
@@ -439,7 +436,7 @@ public:
 	SpriteBatch *newSpriteBatch(Texture *texture, int size, vertex::Usage usage);
 	SpriteBatch *newSpriteBatch(Texture *texture, int size, vertex::Usage usage);
 	ParticleSystem *newParticleSystem(Texture *texture, int size);
 	ParticleSystem *newParticleSystem(Texture *texture, int size);
 
 
-	virtual Texture *newCanvas(const Canvas::Settings &settings) = 0;
+	virtual Texture *newCanvas(const Texture::Settings &settings) = 0;
 
 
 	ShaderStage *newShaderStage(ShaderStage::StageType stage, const std::string &source);
 	ShaderStage *newShaderStage(ShaderStage::StageType stage, const std::string &source);
 	Shader *newShader(const std::string &vertex, const std::string &pixel);
 	Shader *newShader(const std::string &vertex, const std::string &pixel);

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

@@ -1,140 +0,0 @@
-/**
- * Copyright (c) 2006-2020 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"
-#include "Graphics.h"
-
-// C++
-#include <algorithm>
-
-namespace love
-{
-namespace graphics
-{
-
-love::Type Image::type("Image", &Texture::type);
-
-Image::Image(TextureType textype, const Settings &settings)
-	: Texture(textype)
-	, settings(settings)
-{
-	renderTarget = false;
-	sRGB = isGammaCorrect() && !settings.linear;
-}
-
-Image::Image(TextureType textype, PixelFormat format, int width, int height, int slices, const Settings &settings)
-	: Image(textype, settings)
-{
-	if (isPixelFormatCompressed(format))
-		throw love::Exception("This constructor is only supported for non-compressed pixel formats.");
-
-	if (textype == TEXTURE_2D_ARRAY)
-		layers = slices;
-	else if (textype == TEXTURE_VOLUME)
-		depth = slices;
-
-	init(format, width, height, 1, settings);
-}
-
-Image::Image(const Slices &slices, const Settings &settings)
-	: Image(slices.getTextureType(), settings)
-{
-	int dataMipmaps = 1;
-	if (slices.validate() && slices.getMipmapCount() > 1)
-		dataMipmaps = slices.getMipmapCount();
-
-	if (texType == TEXTURE_2D_ARRAY)
-		this->layers = slices.getSliceCount();
-	else if (texType == TEXTURE_VOLUME)
-		this->depth = slices.getSliceCount();
-
-	love::image::ImageDataBase *slice = slices.get(0, 0);
-	init(slice->getFormat(), slice->getWidth(), slice->getHeight(), dataMipmaps, settings);
-}
-
-Image::~Image()
-{
-}
-
-void Image::init(PixelFormat fmt, int w, int h, int dataMipmaps, const Settings &settings)
-{
-	Graphics *gfx = Module::getInstance<Graphics>(Module::M_GRAPHICS);
-	if (gfx != nullptr && !gfx->isPixelFormatSupported(fmt, renderTarget, readable, sRGB))
-	{
-		const char *str;
-		if (love::getConstant(fmt, str))
-		{
-			throw love::Exception("Cannot create image: "
-								  "%s%s images are not supported on this system.", sRGB ? "sRGB " : "", str);
-		}
-		else
-			throw love::Exception("cannot create image: format is not supported on this system.");
-	}
-
-	pixelWidth = w;
-	pixelHeight = h;
-	mipmapsMode = settings.mipmaps ? MIPMAPS_MANUAL : MIPMAPS_NONE;
-
-	width  = (int) (pixelWidth / settings.dpiScale + 0.5);
-	height = (int) (pixelHeight / settings.dpiScale + 0.5);
-
-	format = fmt;
-
-	if (mipmapsMode == MIPMAPS_NONE || (isCompressed() && dataMipmaps <= 1))
-		mipmapCount = 1;
-	else
-		mipmapCount = getTotalMipmapCount(w, h, depth);
-
-	initQuad();
-}
-
-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);
-}
-
-const char *Image::getConstant(SettingType in)
-{
-	const char *name = nullptr;
-	getConstant(in, name);
-	return name;
-}
-
-std::vector<std::string> Image::getConstants(SettingType)
-{
-	return settingTypes.getNames();
-}
-
-StringMap<Image::SettingType, Image::SETTING_MAX_ENUM>::Entry Image::settingTypeEntries[] =
-{
-	{ "mipmaps",  SETTING_MIPMAPS   },
-	{ "linear",   SETTING_LINEAR    },
-	{ "dpiscale", SETTING_DPI_SCALE },
-};
-
-StringMap<Image::SettingType, Image::SETTING_MAX_ENUM> Image::settingTypes(Image::settingTypeEntries, sizeof(Image::settingTypeEntries));
-
-} // graphics
-} // love

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

@@ -1,82 +0,0 @@
-/**
- * Copyright (c) 2006-2020 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 "Texture.h"
-
-namespace love
-{
-namespace graphics
-{
-
-class Image : public Texture
-{
-public:
-
-	static love::Type type;
-
-	enum SettingType
-	{
-		SETTING_MIPMAPS,
-		SETTING_LINEAR,
-		SETTING_DPI_SCALE,
-		SETTING_MAX_ENUM
-	};
-
-	struct Settings
-	{
-		bool mipmaps = false;
-		bool linear = false;
-		float dpiScale = 1.0f;
-	};
-
-	virtual ~Image();
-
-	static bool getConstant(const char *in, SettingType &out);
-	static bool getConstant(SettingType in, const char *&out);
-	static const char *getConstant(SettingType in);
-	static std::vector<std::string> getConstants(SettingType);
-
-protected:
-
-	Image(const Slices &data, const Settings &settings);
-	Image(TextureType textype, PixelFormat format, int width, int height, int slices, const Settings &settings);
-
-	// The settings used to initialize this Image.
-	Settings settings;
-
-private:
-
-	Image(TextureType textype, const Settings &settings);
-
-	void init(PixelFormat fmt, int w, int h, int dataMipmaps, const Settings &settings);
-
-	static StringMap<SettingType, SETTING_MAX_ENUM>::Entry settingTypeEntries[];
-	static StringMap<SettingType, SETTING_MAX_ENUM> settingTypes;
-
-}; // Image
-
-} // graphics
-} // love

+ 165 - 32
src/modules/graphics/Texture.cpp

@@ -159,28 +159,122 @@ love::Type Texture::type("Texture", &Drawable::type);
 int Texture::textureCount = 0;
 int Texture::textureCount = 0;
 int64 Texture::totalGraphicsMemory = 0;
 int64 Texture::totalGraphicsMemory = 0;
 
 
-Texture::Texture(TextureType texType)
-	: texType(texType)
-	, format(PIXELFORMAT_UNKNOWN)
-	, renderTarget(false)
+Texture::Texture(const Settings &settings, const Slices *slices)
+	: texType(settings.type)
+	, format(settings.format)
+	, renderTarget(settings.renderTarget)
 	, readable(true)
 	, readable(true)
-	, mipmapsMode(MIPMAPS_NONE)
-	, sRGB(false)
-	, width(0)
-	, height(0)
-	, depth(1)
-	, layers(1)
+	, mipmapsMode(settings.mipmaps)
+	, sRGB(isGammaCorrect() && !settings.linear)
+	, width(settings.width)
+	, height(settings.height)
+	, depth(settings.type == TEXTURE_VOLUME ? settings.layers : 1)
+	, layers(settings.type == TEXTURE_2D_ARRAY ? settings.layers : 1)
 	, mipmapCount(1)
 	, mipmapCount(1)
 	, pixelWidth(0)
 	, pixelWidth(0)
 	, pixelHeight(0)
 	, pixelHeight(0)
-	, requestedMSAA(1)
+	, requestedMSAA(settings.msaa)
 	, samplerState()
 	, samplerState()
 	, graphicsMemorySize(0)
 	, graphicsMemorySize(0)
 	, usingDefaultTexture(false)
 	, usingDefaultTexture(false)
 {
 {
 	auto gfx = Module::getInstance<Graphics>(Module::M_GRAPHICS);
 	auto gfx = Module::getInstance<Graphics>(Module::M_GRAPHICS);
-	if (gfx != nullptr)
-		samplerState = gfx->getDefaultSamplerState();
+
+	if (slices != nullptr && slices->getMipmapCount() > 0 && slices->getSliceCount() > 0)
+	{
+		texType = slices->getTextureType();
+
+		int dataMipmaps = 1;
+		if (slices->validate() && slices->getMipmapCount() > 1)
+			dataMipmaps = slices->getMipmapCount();
+
+		love::image::ImageDataBase *slice = slices->get(0, 0);
+
+		format = slice->getFormat();
+
+		pixelWidth = slice->getWidth();
+		pixelHeight = slice->getHeight();
+
+		if (texType == TEXTURE_2D_ARRAY)
+			layers = slices->getSliceCount();
+		else if (texType == TEXTURE_VOLUME)
+			depth = slices->getSliceCount();
+
+		width  = (int) (pixelWidth / settings.dpiScale + 0.5);
+		height = (int) (pixelHeight / settings.dpiScale + 0.5);
+
+		if (isCompressed() && dataMipmaps <= 1)
+			mipmapsMode = MIPMAPS_NONE;
+	}
+	else
+	{
+		if (isCompressed())
+			throw love::Exception("Compressed textures must be created with initial data.");
+
+		pixelWidth = (int) ((width * settings.dpiScale) + 0.5);
+		pixelHeight = (int) ((height * settings.dpiScale) + 0.5);
+	}
+
+	if (settings.readable.hasValue)
+		readable = settings.readable.value;
+	else
+		readable = !isPixelFormatDepthStencil(format);
+
+	format = gfx->getSizedFormat(format, renderTarget, readable, sRGB);
+
+	if (mipmapsMode == MIPMAPS_AUTO && isCompressed())
+		mipmapsMode = MIPMAPS_MANUAL;
+
+	if (mipmapsMode != MIPMAPS_NONE)
+		mipmapCount = getTotalMipmapCount(pixelWidth, pixelHeight, depth);
+
+	if (pixelWidth <= 0 || pixelHeight <= 0 || layers <= 0 || depth <= 0)
+		throw love::Exception("Texture dimensions must be greater than 0.");
+
+	if (texType != TEXTURE_2D && requestedMSAA > 1)
+		throw love::Exception("MSAA is only supported for textures with the 2D texture type.");
+
+	if (readable && isPixelFormatDepthStencil(format) && settings.msaa > 1)
+		throw love::Exception("Readable depth/stencil textures with MSAA are not currently supported.");
+
+	if ((!readable || settings.msaa > 1) && mipmapsMode != MIPMAPS_NONE)
+		throw love::Exception("Non-readable and MSAA textures cannot have mipmaps.");
+
+	if (!readable && texType != TEXTURE_2D)
+		throw love::Exception("Non-readable pixel formats are only supported for 2D texture types.");
+
+	if (isCompressed() && renderTarget)
+		throw love::Exception("Compressed textures cannot be render targets.");
+
+	if (!gfx->isPixelFormatSupported(format, renderTarget, readable, sRGB))
+	{
+		const char *fstr = "unknown";
+		love::getConstant(format, fstr);
+
+		const char *readablestr = "";
+		if (readable != !isPixelFormatDepthStencil(format))
+			readablestr = readable ? " readable" : " non-readable";
+
+		const char *rtstr = "";
+		if (renderTarget)
+			rtstr = " as a render target";
+
+		throw love::Exception("The %s%s pixel format is not supported%s on this system.", fstr, readablestr, rtstr);
+	}
+
+	if (!gfx->getCapabilities().textureTypes[texType])
+	{
+		const char *textypestr = "unknown";
+		Texture::getConstant(texType, textypestr);
+		throw love::Exception("%s textures are not supported on this system.", textypestr);
+	}
+
+	validateDimensions(!renderTarget);
+
+	samplerState = gfx->getDefaultSamplerState();
+
+	initQuad();
+
 	++textureCount;
 	++textureCount;
 }
 }
 
 
@@ -780,6 +874,42 @@ bool Texture::Slices::validate() const
 	return true;
 	return true;
 }
 }
 
 
+static StringMap<TextureType, TEXTURE_MAX_ENUM>::Entry texTypeEntries[] =
+{
+	{ "2d",     TEXTURE_2D       },
+	{ "volume", TEXTURE_VOLUME   },
+	{ "array",  TEXTURE_2D_ARRAY },
+	{ "cube",   TEXTURE_CUBE     },
+};
+
+static StringMap<TextureType, TEXTURE_MAX_ENUM> texTypes(texTypeEntries, sizeof(texTypeEntries));
+
+static StringMap<Texture::MipmapsMode, Texture::MIPMAPS_MAX_ENUM>::Entry mipmapEntries[] =
+{
+	{ "none",   Texture::MIPMAPS_NONE   },
+	{ "manual", Texture::MIPMAPS_MANUAL },
+	{ "auto",   Texture::MIPMAPS_AUTO   },
+};
+
+static StringMap<Texture::MipmapsMode, Texture::MIPMAPS_MAX_ENUM> mipmapModes(mipmapEntries, sizeof(mipmapEntries));
+
+static StringMap<Texture::SettingType, Texture::SETTING_MAX_ENUM>::Entry settingTypeEntries[] =
+{
+	{ "width",        Texture::SETTING_WIDTH         },
+	{ "height",       Texture::SETTING_HEIGHT        },
+	{ "layers",       Texture::SETTING_LAYERS        },
+	{ "mipmaps",      Texture::SETTING_MIPMAPS       },
+	{ "format",       Texture::SETTING_FORMAT        },
+	{ "linear",       Texture::SETTING_LINEAR        },
+	{ "type",         Texture::SETTING_TYPE          },
+	{ "dpiscale",     Texture::SETTING_DPI_SCALE     },
+	{ "msaa",         Texture::SETTING_MSAA          },
+	{ "rendertarget", Texture::SETTING_RENDER_TARGET },
+	{ "readable",     Texture::SETTING_READABLE      },
+};
+
+static StringMap<Texture::SettingType, Texture::SETTING_MAX_ENUM> settingTypes(settingTypeEntries, sizeof(settingTypeEntries));
+
 bool Texture::getConstant(const char *in, TextureType &out)
 bool Texture::getConstant(const char *in, TextureType &out)
 {
 {
 	return texTypes.find(in, out);
 	return texTypes.find(in, out);
@@ -795,25 +925,6 @@ std::vector<std::string> Texture::getConstants(TextureType)
 	return texTypes.getNames();
 	return texTypes.getNames();
 }
 }
 
 
-StringMap<TextureType, TEXTURE_MAX_ENUM>::Entry Texture::texTypeEntries[] =
-{
-	{ "2d", TEXTURE_2D },
-	{ "volume", TEXTURE_VOLUME },
-	{ "array", TEXTURE_2D_ARRAY },
-	{ "cube", TEXTURE_CUBE },
-};
-
-StringMap<TextureType, TEXTURE_MAX_ENUM> Texture::texTypes(Texture::texTypeEntries, sizeof(Texture::texTypeEntries));
-
-static StringMap<Texture::MipmapsMode, Texture::MIPMAPS_MAX_ENUM>::Entry mipmapEntries[] =
-{
-	{ "none",   Texture::MIPMAPS_NONE   },
-	{ "manual", Texture::MIPMAPS_MANUAL },
-	{ "auto",   Texture::MIPMAPS_AUTO   },
-};
-
-static StringMap<Texture::MipmapsMode, Texture::MIPMAPS_MAX_ENUM> mipmapModes(mipmapEntries, sizeof(mipmapEntries));
-
 bool Texture::getConstant(const char *in, MipmapsMode &out)
 bool Texture::getConstant(const char *in, MipmapsMode &out)
 {
 {
 	return mipmapModes.find(in, out);
 	return mipmapModes.find(in, out);
@@ -829,5 +940,27 @@ std::vector<std::string> Texture::getConstants(MipmapsMode)
 	return mipmapModes.getNames();
 	return mipmapModes.getNames();
 }
 }
 
 
+bool Texture::getConstant(const char *in, SettingType &out)
+{
+	return settingTypes.find(in, out);
+}
+
+bool Texture::getConstant(SettingType in, const char *&out)
+{
+	return settingTypes.find(in, out);
+}
+
+const char *Texture::getConstant(SettingType in)
+{
+	const char *name = nullptr;
+	getConstant(in, name);
+	return name;
+}
+
+std::vector<std::string> Texture::getConstants(SettingType)
+{
+	return settingTypes.getNames();
+}
+
 } // graphics
 } // graphics
 } // love
 } // love

+ 38 - 6
src/modules/graphics/Texture.h

@@ -137,6 +137,38 @@ public:
 		MIPMAPS_MAX_ENUM
 		MIPMAPS_MAX_ENUM
 	};
 	};
 
 
+	enum SettingType
+	{
+		SETTING_WIDTH,
+		SETTING_HEIGHT,
+		SETTING_LAYERS,
+		SETTING_MIPMAPS,
+		SETTING_FORMAT,
+		SETTING_LINEAR,
+		SETTING_TYPE,
+		SETTING_DPI_SCALE,
+		SETTING_MSAA,
+		SETTING_RENDER_TARGET,
+		SETTING_READABLE,
+		SETTING_MAX_ENUM
+	};
+
+	// Size and format will be overridden by ImageData when supplied.
+	struct Settings
+	{
+		int width  = 1;
+		int height = 1;
+		int layers = 1; // depth for 3D textures
+		TextureType type = TEXTURE_2D;
+		MipmapsMode mipmaps = MIPMAPS_NONE;
+		PixelFormat format = PIXELFORMAT_NORMAL;
+		bool linear = false;
+		float dpiScale = 1.0f;
+		int msaa = 0;
+		bool renderTarget = false;
+		OptionalBool readable;
+	};
+
 	struct Slices
 	struct Slices
 	{
 	{
 	public:
 	public:
@@ -169,7 +201,7 @@ public:
 
 
 	static int64 totalGraphicsMemory;
 	static int64 totalGraphicsMemory;
 
 
-	Texture(TextureType texType);
+	Texture(const Settings &settings, const Slices *slices);
 	virtual ~Texture();
 	virtual ~Texture();
 
 
 	// Drawable.
 	// Drawable.
@@ -234,6 +266,11 @@ public:
 	static bool getConstant(MipmapsMode in, const char *&out);
 	static bool getConstant(MipmapsMode in, const char *&out);
 	static std::vector<std::string> getConstants(MipmapsMode);
 	static std::vector<std::string> getConstants(MipmapsMode);
 
 
+	static bool getConstant(const char *in, SettingType &out);
+	static bool getConstant(SettingType in, const char *&out);
+	static const char *getConstant(SettingType in);
+	static std::vector<std::string> getConstants(SettingType);
+
 protected:
 protected:
 
 
 	void initQuad();
 	void initQuad();
@@ -276,11 +313,6 @@ protected:
 	// back to a default texture.
 	// back to a default texture.
 	bool usingDefaultTexture;
 	bool usingDefaultTexture;
 
 
-private:
-
-	static StringMap<TextureType, TEXTURE_MAX_ENUM>::Entry texTypeEntries[];
-	static StringMap<TextureType, TEXTURE_MAX_ENUM> texTypes;
-
 }; // Texture
 }; // Texture
 
 
 } // graphics
 } // graphics

+ 5 - 2
src/modules/graphics/Video.cpp

@@ -79,11 +79,14 @@ Video::Video(Graphics *gfx, love::video::VideoStream *stream, float dpiscale)
 
 
 	const unsigned char *data[3] = {frame->yplane, frame->cbplane, frame->crplane};
 	const unsigned char *data[3] = {frame->yplane, frame->cbplane, frame->crplane};
 
 
-	Image::Settings settings;
+	Texture::Settings settings;
 
 
 	for (int i = 0; i < 3; i++)
 	for (int i = 0; i < 3; i++)
 	{
 	{
-		Texture *tex = gfx->newImage(TEXTURE_2D, PIXELFORMAT_R8_UNORM, widths[i], heights[i], 1, settings);
+		settings.width = widths[i];
+		settings.height = heights[i];
+		settings.format = PIXELFORMAT_R8_UNORM;
+		Texture *tex = gfx->newImage(settings, nullptr);
 
 
 		tex->setSamplerState(samplerState);
 		tex->setSamplerState(samplerState);
 
 

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

@@ -183,7 +183,7 @@ static bool createRenderbuffer(int width, int height, int &samples, PixelFormat
 }
 }
 
 
 Canvas::Canvas(const Settings &settings)
 Canvas::Canvas(const Settings &settings)
-	: love::graphics::Canvas(settings)
+	: love::graphics::Texture(settings, nullptr)
 	, fbo(0)
 	, fbo(0)
 	, texture(0)
 	, texture(0)
     , renderbuffer(0)
     , renderbuffer(0)
@@ -346,7 +346,7 @@ ptrdiff_t Canvas::getHandle() const
 
 
 love::image::ImageData *Canvas::newImageData(love::image::Image *module, int slice, int mipmap, const Rect &r)
 love::image::ImageData *Canvas::newImageData(love::image::Image *module, int slice, int mipmap, const Rect &r)
 {
 {
-	love::image::ImageData *data = love::graphics::Canvas::newImageData(module, slice, mipmap, r);
+	love::image::ImageData *data = love::graphics::Texture::newImageData(module, slice, mipmap, r);
 
 
 	bool isSRGB = false;
 	bool isSRGB = false;
 	OpenGL::TextureFormat fmt = gl.convertPixelFormat(data->getFormat(), false, isSRGB);
 	OpenGL::TextureFormat fmt = gl.convertPixelFormat(data->getFormat(), false, isSRGB);

+ 2 - 2
src/modules/graphics/opengl/Canvas.h

@@ -24,7 +24,7 @@
 #include "common/config.h"
 #include "common/config.h"
 #include "common/Color.h"
 #include "common/Color.h"
 #include "common/int.h"
 #include "common/int.h"
-#include "graphics/Canvas.h"
+#include "graphics/Texture.h"
 #include "graphics/Volatile.h"
 #include "graphics/Volatile.h"
 #include "OpenGL.h"
 #include "OpenGL.h"
 
 
@@ -35,7 +35,7 @@ namespace graphics
 namespace opengl
 namespace opengl
 {
 {
 
 
-class Canvas final : public love::graphics::Canvas, public Volatile
+class Canvas final : public love::graphics::Texture, public Volatile
 {
 {
 public:
 public:
 
 

+ 3 - 8
src/modules/graphics/opengl/Graphics.cpp

@@ -130,17 +130,12 @@ love::graphics::StreamBuffer *Graphics::newStreamBuffer(BufferType type, size_t
 	return CreateStreamBuffer(type, size);
 	return CreateStreamBuffer(type, size);
 }
 }
 
 
-love::graphics::Texture *Graphics::newImage(const Texture::Slices &data, const Image::Settings &settings)
+love::graphics::Texture *Graphics::newImage(const Texture::Settings &settings, const Texture::Slices *data)
 {
 {
-	return new Image(data, settings);
+	return new Image(settings, data);
 }
 }
 
 
-love::graphics::Texture *Graphics::newImage(TextureType textype, PixelFormat format, int width, int height, int slices, const Image::Settings &settings)
-{
-	return new Image(textype, format, width, height, slices, settings);
-}
-
-love::graphics::Texture *Graphics::newCanvas(const Canvas::Settings &settings)
+love::graphics::Texture *Graphics::newCanvas(const Texture::Settings &settings)
 {
 {
 	return new Canvas(settings);
 	return new Canvas(settings);
 }
 }

+ 2 - 3
src/modules/graphics/opengl/Graphics.h

@@ -60,9 +60,8 @@ public:
 	// Implements Module.
 	// Implements Module.
 	const char *getName() const override;
 	const char *getName() const override;
 
 
-	love::graphics::Texture *newImage(const Texture::Slices &data, const Image::Settings &settings) override;
-	love::graphics::Texture *newImage(TextureType textype, PixelFormat format, int width, int height, int slices, const Image::Settings &settings) override;
-	love::graphics::Texture *newCanvas(const Canvas::Settings &settings) override;
+	love::graphics::Texture *newImage(const Texture::Settings &settings, const Texture::Slices *data) override;
+	love::graphics::Texture *newCanvas(const Texture::Settings &settings) override;
 	love::graphics::Buffer *newBuffer(size_t size, const void *data, BufferType type, vertex::Usage usage, uint32 mapflags) override;
 	love::graphics::Buffer *newBuffer(size_t size, const void *data, BufferType type, vertex::Usage usage, uint32 mapflags) override;
 
 
 	void setViewportSize(int width, int height, int pixelwidth, int pixelheight) override;
 	void setViewportSize(int width, int height, int pixelwidth, int pixelheight) override;

+ 5 - 11
src/modules/graphics/opengl/Image.cpp

@@ -33,19 +33,13 @@ namespace graphics
 namespace opengl
 namespace opengl
 {
 {
 
 
-Image::Image(TextureType textype, PixelFormat format, int width, int height, int slices, const Settings &settings)
-	: love::graphics::Image(textype, format, width, height, slices, settings)
-	, slices(textype)
-	, texture(0)
-{
-	loadVolatile();
-}
-
-Image::Image(const Slices &slices, const Settings &settings)
-	: love::graphics::Image(slices, settings)
-	, slices(slices)
+Image::Image(const Settings &settings, const Slices *data)
+	: love::graphics::Texture(settings, data)
+	, slices(settings.type)
 	, texture(0)
 	, texture(0)
 {
 {
+	if (data != nullptr)
+		slices = *data;
 	loadVolatile();
 	loadVolatile();
 }
 }
 
 

+ 3 - 4
src/modules/graphics/opengl/Image.h

@@ -21,7 +21,7 @@
 #pragma once
 #pragma once
 
 
 // LOVE
 // LOVE
-#include "graphics/Image.h"
+#include "graphics/Texture.h"
 #include "graphics/Volatile.h"
 #include "graphics/Volatile.h"
 
 
 // OpenGL
 // OpenGL
@@ -34,12 +34,11 @@ namespace graphics
 namespace opengl
 namespace opengl
 {
 {
 
 
-class Image final : public love::graphics::Image, public Volatile
+class Image final : public love::graphics::Texture, public Volatile
 {
 {
 public:
 public:
 
 
-	Image(const Slices &data, const Settings &settings);
-	Image(TextureType textype, PixelFormat format, int width, int height, int slices, const Settings &settings);
+	Image(const Settings &settings, const Slices *data);
 
 
 	virtual ~Image();
 	virtual ~Image();
 
 

+ 21 - 20
src/modules/graphics/wrap_Graphics.cpp

@@ -700,19 +700,19 @@ static void parseDPIScale(Data *d, float *dpiscale)
 	}
 	}
 }
 }
 
 
-static Image::Settings w__optImageSettings(lua_State *L, int idx, bool &setdpiscale)
+static Texture::Settings w__optImageSettings(lua_State *L, int idx, bool &setdpiscale)
 {
 {
-	Image::Settings s;
+	Texture::Settings s;
 
 
 	setdpiscale = false;
 	setdpiscale = false;
 	if (!lua_isnoneornil(L, idx))
 	if (!lua_isnoneornil(L, idx))
 	{
 	{
-		luax_checktablefields<Image::SettingType>(L, idx, "image setting name", Image::getConstant);
+		luax_checktablefields<Texture::SettingType>(L, idx, "image setting name", Texture::getConstant);
 
 
-		s.mipmaps = luax_boolflag(L, idx, Image::getConstant(Image::SETTING_MIPMAPS), s.mipmaps);
-		s.linear = luax_boolflag(L, idx, Image::getConstant(Image::SETTING_LINEAR), s.linear);
+		s.mipmaps = luax_boolflag(L, idx, "mipmaps", false) ? Texture::MIPMAPS_MANUAL : Texture::MIPMAPS_NONE;
+		s.linear = luax_boolflag(L, idx, Texture::getConstant(Texture::SETTING_LINEAR), s.linear);
 
 
-		lua_getfield(L, idx, Image::getConstant(Image::SETTING_DPI_SCALE));
+		lua_getfield(L, idx, Texture::getConstant(Texture::SETTING_DPI_SCALE));
 		if (lua_isnumber(L, -1))
 		if (lua_isnumber(L, -1))
 		{
 		{
 			s.dpiScale = (float) lua_tonumber(L, -1);
 			s.dpiScale = (float) lua_tonumber(L, -1);
@@ -757,11 +757,11 @@ getImageData(lua_State *L, int idx, bool allowcompressed, float *dpiscale)
 	return std::make_pair(idata, cdata);
 	return std::make_pair(idata, cdata);
 }
 }
 
 
-static int w__pushNewImage(lua_State *L, Texture::Slices &slices, const Image::Settings &settings)
+static int w__pushNewImage(lua_State *L, Texture::Slices &slices, const Texture::Settings &settings)
 {
 {
 	StrongRef<Texture> i;
 	StrongRef<Texture> i;
 	luax_catchexcept(L,
 	luax_catchexcept(L,
-		[&]() { i.set(instance()->newImage(slices, settings), Acquire::NORETAIN); },
+		[&]() { i.set(instance()->newImage(settings, &slices), Acquire::NORETAIN); },
 		[&](bool) { slices.clear(); }
 		[&](bool) { slices.clear(); }
 	);
 	);
 
 
@@ -776,7 +776,7 @@ int w_newCubeImage(lua_State *L)
 	Texture::Slices slices(TEXTURE_CUBE);
 	Texture::Slices slices(TEXTURE_CUBE);
 
 
 	bool dpiscaleset = false;
 	bool dpiscaleset = false;
-	Image::Settings settings = w__optImageSettings(L, 2, dpiscaleset);
+	Texture::Settings settings = w__optImageSettings(L, 2, dpiscaleset);
 	float *autodpiscale = dpiscaleset ? nullptr : &settings.dpiScale;
 	float *autodpiscale = dpiscaleset ? nullptr : &settings.dpiScale;
 
 
 	auto imagemodule = Module::getInstance<love::image::Image>(Module::M_IMAGE);
 	auto imagemodule = Module::getInstance<love::image::Image>(Module::M_IMAGE);
@@ -870,7 +870,7 @@ int w_newArrayImage(lua_State *L)
 	Texture::Slices slices(TEXTURE_2D_ARRAY);
 	Texture::Slices slices(TEXTURE_2D_ARRAY);
 
 
 	bool dpiscaleset = false;
 	bool dpiscaleset = false;
-	Image::Settings settings = w__optImageSettings(L, 2, dpiscaleset);
+	Texture::Settings settings = w__optImageSettings(L, 2, dpiscaleset);
 	float *autodpiscale = dpiscaleset ? nullptr : &settings.dpiScale;
 	float *autodpiscale = dpiscaleset ? nullptr : &settings.dpiScale;
 
 
 	if (lua_istable(L, 1))
 	if (lua_istable(L, 1))
@@ -936,7 +936,7 @@ int w_newVolumeImage(lua_State *L)
 	Texture::Slices slices(TEXTURE_VOLUME);
 	Texture::Slices slices(TEXTURE_VOLUME);
 
 
 	bool dpiscaleset = false;
 	bool dpiscaleset = false;
-	Image::Settings settings = w__optImageSettings(L, 2, dpiscaleset);
+	Texture::Settings settings = w__optImageSettings(L, 2, dpiscaleset);
 	float *autodpiscale = dpiscaleset ? nullptr : &settings.dpiScale;
 	float *autodpiscale = dpiscaleset ? nullptr : &settings.dpiScale;
 
 
 	if (lua_istable(L, 1))
 	if (lua_istable(L, 1))
@@ -1007,7 +1007,7 @@ int w_newImage(lua_State *L)
 	Texture::Slices slices(TEXTURE_2D);
 	Texture::Slices slices(TEXTURE_2D);
 
 
 	bool dpiscaleset = false;
 	bool dpiscaleset = false;
-	Image::Settings settings = w__optImageSettings(L, 2, dpiscaleset);
+	Texture::Settings settings = w__optImageSettings(L, 2, dpiscaleset);
 	float *autodpiscale = dpiscaleset ? nullptr : &settings.dpiScale;
 	float *autodpiscale = dpiscaleset ? nullptr : &settings.dpiScale;
 
 
 	if (lua_istable(L, 1))
 	if (lua_istable(L, 1))
@@ -1185,7 +1185,8 @@ int w_newCanvas(lua_State *L)
 {
 {
 	luax_checkgraphicscreated(L);
 	luax_checkgraphicscreated(L);
 
 
-	Canvas::Settings settings;
+	Texture::Settings settings;
+	settings.renderTarget = true;
 
 
 	// check if width and height are given. else default to screen dimensions.
 	// check if width and height are given. else default to screen dimensions.
 	settings.width  = (int) luaL_optinteger(L, 1, instance()->getWidth());
 	settings.width  = (int) luaL_optinteger(L, 1, instance()->getWidth());
@@ -1205,12 +1206,12 @@ int w_newCanvas(lua_State *L)
 
 
 	if (!lua_isnoneornil(L, startidx))
 	if (!lua_isnoneornil(L, startidx))
 	{
 	{
-		luax_checktablefields<Canvas::SettingType>(L, startidx, "canvas setting name", Canvas::getConstant);
+		luax_checktablefields<Texture::SettingType>(L, startidx, "texture setting name", Texture::getConstant);
 
 
-		settings.dpiScale = (float) luax_numberflag(L, startidx, Canvas::getConstant(Canvas::SETTING_DPI_SCALE), settings.dpiScale);
-		settings.msaa = luax_intflag(L, startidx, Canvas::getConstant(Canvas::SETTING_MSAA), settings.msaa);
+		settings.dpiScale = (float) luax_numberflag(L, startidx, Texture::getConstant(Texture::SETTING_DPI_SCALE), settings.dpiScale);
+		settings.msaa = luax_intflag(L, startidx, Texture::getConstant(Texture::SETTING_MSAA), settings.msaa);
 
 
-		lua_getfield(L, startidx, Canvas::getConstant(Canvas::SETTING_FORMAT));
+		lua_getfield(L, startidx, Texture::getConstant(Texture::SETTING_FORMAT));
 		if (!lua_isnoneornil(L, -1))
 		if (!lua_isnoneornil(L, -1))
 		{
 		{
 			const char *str = luaL_checkstring(L, -1);
 			const char *str = luaL_checkstring(L, -1);
@@ -1219,7 +1220,7 @@ int w_newCanvas(lua_State *L)
 		}
 		}
 		lua_pop(L, 1);
 		lua_pop(L, 1);
 
 
-		lua_getfield(L, startidx, Canvas::getConstant(Canvas::SETTING_TYPE));
+		lua_getfield(L, startidx, Texture::getConstant(Texture::SETTING_TYPE));
 		if (!lua_isnoneornil(L, -1))
 		if (!lua_isnoneornil(L, -1))
 		{
 		{
 			const char *str = luaL_checkstring(L, -1);
 			const char *str = luaL_checkstring(L, -1);
@@ -1228,7 +1229,7 @@ int w_newCanvas(lua_State *L)
 		}
 		}
 		lua_pop(L, 1);
 		lua_pop(L, 1);
 
 
-		lua_getfield(L, startidx, Canvas::getConstant(Canvas::SETTING_READABLE));
+		lua_getfield(L, startidx, Texture::getConstant(Texture::SETTING_READABLE));
 		if (!lua_isnoneornil(L, -1))
 		if (!lua_isnoneornil(L, -1))
 		{
 		{
 			settings.readable.hasValue = true;
 			settings.readable.hasValue = true;
@@ -1236,7 +1237,7 @@ int w_newCanvas(lua_State *L)
 		}
 		}
 		lua_pop(L, 1);
 		lua_pop(L, 1);
 
 
-		lua_getfield(L, startidx, Canvas::getConstant(Canvas::SETTING_MIPMAPS));
+		lua_getfield(L, startidx, Texture::getConstant(Texture::SETTING_MIPMAPS));
 		if (!lua_isnoneornil(L, -1))
 		if (!lua_isnoneornil(L, -1))
 		{
 		{
 			const char *str = luaL_checkstring(L, -1);
 			const char *str = luaL_checkstring(L, -1);