Browse Source

Rename all cases of 'pixel density' to 'DPI scale' in love's APIs.

--HG--
branch : minor
Alex Szpakowski 8 years ago
parent
commit
844900db39
37 changed files with 129 additions and 129 deletions
  1. 2 2
      src/modules/font/BMFontRasterizer.cpp
  2. 1 1
      src/modules/font/BMFontRasterizer.h
  3. 8 8
      src/modules/font/Font.cpp
  4. 5 5
      src/modules/font/Font.h
  5. 2 2
      src/modules/font/ImageRasterizer.cpp
  6. 1 1
      src/modules/font/ImageRasterizer.h
  7. 2 2
      src/modules/font/Rasterizer.cpp
  8. 2 2
      src/modules/font/Rasterizer.h
  9. 5 5
      src/modules/font/freetype/Font.cpp
  10. 1 1
      src/modules/font/freetype/Font.h
  11. 3 3
      src/modules/font/freetype/TrueTypeRasterizer.cpp
  12. 1 1
      src/modules/font/freetype/TrueTypeRasterizer.h
  13. 8 8
      src/modules/font/wrap_Font.cpp
  14. 2 2
      src/modules/graphics/Canvas.cpp
  15. 1 1
      src/modules/graphics/Canvas.h
  16. 1 1
      src/modules/graphics/Deprecations.cpp
  17. 14 14
      src/modules/graphics/Font.cpp
  18. 2 2
      src/modules/graphics/Font.h
  19. 5 5
      src/modules/graphics/Graphics.cpp
  20. 3 3
      src/modules/graphics/Graphics.h
  21. 2 2
      src/modules/graphics/Image.cpp
  22. 1 1
      src/modules/graphics/Image.h
  23. 1 1
      src/modules/graphics/Texture.cpp
  24. 1 1
      src/modules/graphics/Texture.h
  25. 3 3
      src/modules/graphics/Video.cpp
  26. 1 1
      src/modules/graphics/Video.h
  27. 6 6
      src/modules/graphics/opengl/Graphics.cpp
  28. 3 3
      src/modules/graphics/wrap_Font.cpp
  29. 25 25
      src/modules/graphics/wrap_Graphics.cpp
  30. 1 1
      src/modules/graphics/wrap_Graphics.lua
  31. 3 3
      src/modules/graphics/wrap_Texture.cpp
  32. 1 1
      src/modules/window/Window.h
  33. 5 5
      src/modules/window/sdl/Window.cpp
  34. 1 1
      src/modules/window/sdl/Window.h
  35. 3 3
      src/modules/window/wrap_Window.cpp
  36. 1 1
      src/scripts/nogame.lua
  37. 2 2
      src/scripts/nogame.lua.h

+ 2 - 2
src/modules/font/BMFontRasterizer.cpp

@@ -131,12 +131,12 @@ std::string BMFontLine::getAttributeString(const char *name) const
 } // anonymous namespace
 
 
-BMFontRasterizer::BMFontRasterizer(love::filesystem::FileData *fontdef, const std::vector<image::ImageData *> &imagelist, float pixeldensity)
+BMFontRasterizer::BMFontRasterizer(love::filesystem::FileData *fontdef, const std::vector<image::ImageData *> &imagelist, float dpiscale)
 	: fontSize(0)
 	, unicode(false)
 	, lineHeight(0)
 {
-	this->pixelDensity = pixeldensity;
+	this->dpiScale = dpiscale;
 
 	const std::string &filename = fontdef->getFilename();
 

+ 1 - 1
src/modules/font/BMFontRasterizer.h

@@ -42,7 +42,7 @@ class BMFontRasterizer : public Rasterizer
 {
 public:
 
-	BMFontRasterizer(love::filesystem::FileData *fontdef, const std::vector<image::ImageData *> &imagelist, float pixeldensity);
+	BMFontRasterizer(love::filesystem::FileData *fontdef, const std::vector<image::ImageData *> &imagelist, float dpiscale);
 	virtual ~BMFontRasterizer();
 
 	// Implements Rasterizer.

+ 8 - 8
src/modules/font/Font.cpp

@@ -48,18 +48,18 @@ Rasterizer *Font::newTrueTypeRasterizer(int size, TrueTypeRasterizer::Hinting hi
 	return newTrueTypeRasterizer(data.get(), size, hinting);
 }
 
-Rasterizer *Font::newTrueTypeRasterizer(int size, float pixeldensity, TrueTypeRasterizer::Hinting hinting)
+Rasterizer *Font::newTrueTypeRasterizer(int size, float dpiscale, TrueTypeRasterizer::Hinting hinting)
 {
 	StrongRef<DefaultFontData> data(new DefaultFontData, Acquire::NORETAIN);
-	return newTrueTypeRasterizer(data.get(), size, pixeldensity, hinting);
+	return newTrueTypeRasterizer(data.get(), size, dpiscale, hinting);
 }
 
-Rasterizer *Font::newBMFontRasterizer(love::filesystem::FileData *fontdef, const std::vector<image::ImageData *> &images, float pixeldensity)
+Rasterizer *Font::newBMFontRasterizer(love::filesystem::FileData *fontdef, const std::vector<image::ImageData *> &images, float dpiscale)
 {
-	return new BMFontRasterizer(fontdef, images, pixeldensity);
+	return new BMFontRasterizer(fontdef, images, dpiscale);
 }
 
-Rasterizer *Font::newImageRasterizer(love::image::ImageData *data, const std::string &text, int extraspacing, float pixeldensity)
+Rasterizer *Font::newImageRasterizer(love::image::ImageData *data, const std::string &text, int extraspacing, float dpiscale)
 {
 	std::vector<uint32> glyphs;
 	glyphs.reserve(text.size());
@@ -77,12 +77,12 @@ Rasterizer *Font::newImageRasterizer(love::image::ImageData *data, const std::st
 		throw love::Exception("UTF-8 decoding error: %s", e.what());
 	}
 
-	return newImageRasterizer(data, &glyphs[0], (int) glyphs.size(), extraspacing, pixeldensity);
+	return newImageRasterizer(data, &glyphs[0], (int) glyphs.size(), extraspacing, dpiscale);
 }
 
-Rasterizer *Font::newImageRasterizer(love::image::ImageData *data, uint32 *glyphs, int numglyphs, int extraspacing, float pixeldensity)
+Rasterizer *Font::newImageRasterizer(love::image::ImageData *data, uint32 *glyphs, int numglyphs, int extraspacing, float dpiscale)
 {
-	return new ImageRasterizer(data, glyphs, numglyphs, extraspacing, pixeldensity);
+	return new ImageRasterizer(data, glyphs, numglyphs, extraspacing, dpiscale);
 }
 
 GlyphData *Font::newGlyphData(Rasterizer *r, const std::string &text)

+ 5 - 5
src/modules/font/Font.h

@@ -48,14 +48,14 @@ public:
 	virtual Rasterizer *newRasterizer(love::filesystem::FileData *data) = 0;
 
 	virtual Rasterizer *newTrueTypeRasterizer(int size, TrueTypeRasterizer::Hinting hinting);
-	virtual Rasterizer *newTrueTypeRasterizer(int size, float pixeldensity, TrueTypeRasterizer::Hinting hinting);
+	virtual Rasterizer *newTrueTypeRasterizer(int size, float dpiscale, TrueTypeRasterizer::Hinting hinting);
 	virtual Rasterizer *newTrueTypeRasterizer(love::Data *data, int size, TrueTypeRasterizer::Hinting hinting) = 0;
-	virtual Rasterizer *newTrueTypeRasterizer(love::Data *data, int size, float pixeldensity, TrueTypeRasterizer::Hinting hinting) = 0;
+	virtual Rasterizer *newTrueTypeRasterizer(love::Data *data, int size, float dpiscale, TrueTypeRasterizer::Hinting hinting) = 0;
 
-	virtual Rasterizer *newBMFontRasterizer(love::filesystem::FileData *fontdef, const std::vector<image::ImageData *> &images, float pixeldensity);
+	virtual Rasterizer *newBMFontRasterizer(love::filesystem::FileData *fontdef, const std::vector<image::ImageData *> &images, float dpiscale);
 
-	virtual Rasterizer *newImageRasterizer(love::image::ImageData *data, const std::string &glyphs, int extraspacing, float pixeldensity);
-	virtual Rasterizer *newImageRasterizer(love::image::ImageData *data, uint32 *glyphs, int length, int extraspacing, float pixeldensity);
+	virtual Rasterizer *newImageRasterizer(love::image::ImageData *data, const std::string &glyphs, int extraspacing, float dpiscale);
+	virtual Rasterizer *newImageRasterizer(love::image::ImageData *data, uint32 *glyphs, int length, int extraspacing, float dpiscale);
 
 	virtual GlyphData *newGlyphData(Rasterizer *r, const std::string &glyph);
 	virtual GlyphData *newGlyphData(Rasterizer *r, uint32 glyph);

+ 2 - 2
src/modules/font/ImageRasterizer.cpp

@@ -31,13 +31,13 @@ namespace font
 
 static_assert(sizeof(Color) == 4, "sizeof(Color) must equal 4 bytes!");
 
-ImageRasterizer::ImageRasterizer(love::image::ImageData *data, uint32 *glyphs, int numglyphs, int extraspacing, float pixeldensity)
+ImageRasterizer::ImageRasterizer(love::image::ImageData *data, uint32 *glyphs, int numglyphs, int extraspacing, float dpiscale)
 	: imageData(data)
 	, glyphs(glyphs)
 	, numglyphs(numglyphs)
 	, extraSpacing(extraspacing)
 {
-	this->pixelDensity = pixeldensity;
+	this->dpiScale = dpiscale;
 
 	if (data->getFormat() != PIXELFORMAT_RGBA8)
 		throw love::Exception("Only 32-bit RGBA images are supported in Image Fonts!");

+ 1 - 1
src/modules/font/ImageRasterizer.h

@@ -39,7 +39,7 @@ namespace font
 class ImageRasterizer : public Rasterizer
 {
 public:
-	ImageRasterizer(love::image::ImageData *imageData, uint32 *glyphs, int numglyphs, int extraspacing, float pixeldensity);
+	ImageRasterizer(love::image::ImageData *imageData, uint32 *glyphs, int numglyphs, int extraspacing, float dpiscale);
 	virtual ~ImageRasterizer();
 
 	// Implement Rasterizer

+ 2 - 2
src/modules/font/Rasterizer.cpp

@@ -102,9 +102,9 @@ float Rasterizer::getKerning(uint32 /*leftglyph*/, uint32 /*rightglyph*/) const
 	return 0.0f;
 }
 
-float Rasterizer::getPixelDensity() const
+float Rasterizer::getDPIScale() const
 {
-	return pixelDensity;
+	return dpiScale;
 }
 
 } // font

+ 2 - 2
src/modules/font/Rasterizer.h

@@ -120,12 +120,12 @@ public:
 
 	virtual DataType getDataType() const = 0;
 
-	float getPixelDensity() const;
+	float getDPIScale() const;
 
 protected:
 
 	FontMetrics metrics;
-	float pixelDensity;
+	float dpiScale;
 
 }; // Rasterizer
 

+ 5 - 5
src/modules/font/freetype/Font.cpp

@@ -58,17 +58,17 @@ Rasterizer *Font::newRasterizer(love::filesystem::FileData *data)
 
 Rasterizer *Font::newTrueTypeRasterizer(love::Data *data, int size, TrueTypeRasterizer::Hinting hinting)
 {
-	float pixeldensity = 1.0f;
+	float dpiscale = 1.0f;
 	auto window = Module::getInstance<window::Window>(Module::M_WINDOW);
 	if (window != nullptr)
-		pixeldensity = window->getPixelDensity();
+		dpiscale = window->getDPIScale();
 
-	return newTrueTypeRasterizer(data, size, pixeldensity, hinting);
+	return newTrueTypeRasterizer(data, size, dpiscale, hinting);
 }
 
-Rasterizer *Font::newTrueTypeRasterizer(love::Data *data, int size, float pixeldensity, TrueTypeRasterizer::Hinting hinting)
+Rasterizer *Font::newTrueTypeRasterizer(love::Data *data, int size, float dpiscale, TrueTypeRasterizer::Hinting hinting)
 {
-	return new TrueTypeRasterizer(library, data, size, pixeldensity, hinting);
+	return new TrueTypeRasterizer(library, data, size, dpiscale, hinting);
 }
 
 const char *Font::getName() const

+ 1 - 1
src/modules/font/freetype/Font.h

@@ -46,7 +46,7 @@ public:
 	// Implements Font
 	Rasterizer *newRasterizer(love::filesystem::FileData *data) override;
 	Rasterizer *newTrueTypeRasterizer(love::Data *data, int size, TrueTypeRasterizer::Hinting hinting) override;
-	Rasterizer *newTrueTypeRasterizer(love::Data *data, int size, float pixeldensity, TrueTypeRasterizer::Hinting hinting) override;
+	Rasterizer *newTrueTypeRasterizer(love::Data *data, int size, float dpiscale, TrueTypeRasterizer::Hinting hinting) override;
 
 	// Implement Module
 	const char *getName() const override;

+ 3 - 3
src/modules/font/freetype/TrueTypeRasterizer.cpp

@@ -32,12 +32,12 @@ namespace font
 namespace freetype
 {
 
-TrueTypeRasterizer::TrueTypeRasterizer(FT_Library library, love::Data *data, int size, float pixeldensity, Hinting hinting)
+TrueTypeRasterizer::TrueTypeRasterizer(FT_Library library, love::Data *data, int size, float dpiscale, Hinting hinting)
 	: data(data)
 	, hinting(hinting)
 {
-	this->pixelDensity = pixeldensity;
-	size = floorf(size * pixeldensity + 0.5f);
+	this->dpiScale = dpiscale;
+	size = floorf(size * dpiscale + 0.5f);
 
 	if (size <= 0)
 		throw love::Exception("Invalid TrueType font size: %d", size);

+ 1 - 1
src/modules/font/freetype/TrueTypeRasterizer.h

@@ -44,7 +44,7 @@ class TrueTypeRasterizer : public love::font::TrueTypeRasterizer
 {
 public:
 
-	TrueTypeRasterizer(FT_Library library, love::Data *data, int size, float pixeldensity, Hinting hinting);
+	TrueTypeRasterizer(FT_Library library, love::Data *data, int size, float dpiscale, Hinting hinting);
 	virtual ~TrueTypeRasterizer();
 
 	// Implement Rasterizer

+ 8 - 8
src/modules/font/wrap_Font.cpp

@@ -82,8 +82,8 @@ int w_newTrueTypeRasterizer(lua_State *L)
 			luax_catchexcept(L, [&](){ t = instance()->newTrueTypeRasterizer(size, hinting); });
 		else
 		{
-			float pixeldensity = (float) luaL_checknumber(L, 3);
-			luax_catchexcept(L, [&](){ t = instance()->newTrueTypeRasterizer(size, pixeldensity, hinting); });
+			float dpiscale = (float) luaL_checknumber(L, 3);
+			luax_catchexcept(L, [&](){ t = instance()->newTrueTypeRasterizer(size, dpiscale, hinting); });
 		}
 	}
 	else
@@ -113,9 +113,9 @@ int w_newTrueTypeRasterizer(lua_State *L)
 		}
 		else
 		{
-			float pixeldensity = (float) luaL_checknumber(L, 4);
+			float dpiscale = (float) luaL_checknumber(L, 4);
 			luax_catchexcept(L,
-				[&]() { t = instance()->newTrueTypeRasterizer(d, size, pixeldensity, hinting); },
+				[&]() { t = instance()->newTrueTypeRasterizer(d, size, dpiscale, hinting); },
 				[&](bool) { d->release(); }
 			);
 		}
@@ -138,7 +138,7 @@ int w_newBMFontRasterizer(lua_State *L)
 
 	filesystem::FileData *d = filesystem::luax_getfiledata(L, 1);
 	std::vector<image::ImageData *> images;
-	float pixeldensity = (float) luaL_optnumber(L, 3, 1.0);
+	float dpiscale = (float) luaL_optnumber(L, 3, 1.0);
 
 	if (lua_istable(L, 2))
 	{
@@ -163,7 +163,7 @@ int w_newBMFontRasterizer(lua_State *L)
 	}
 
 	luax_catchexcept(L,
-		[&]() { t = instance()->newBMFontRasterizer(d, images, pixeldensity); },
+		[&]() { t = instance()->newBMFontRasterizer(d, images, dpiscale); },
 		[&](bool) { d->release(); for (auto id : images) id->release(); }
 	);
 
@@ -181,9 +181,9 @@ int w_newImageRasterizer(lua_State *L)
 	image::ImageData *d = luax_checktype<image::ImageData>(L, 1);
 	std::string glyphs = luax_checkstring(L, 2);
 	int extraspacing = (int) luaL_optinteger(L, 3, 0);
-	float pixeldensity = (float) luaL_optnumber(L, 4, 1.0);
+	float dpiscale = (float) luaL_optnumber(L, 4, 1.0);
 
-	luax_catchexcept(L, [&](){ t = instance()->newImageRasterizer(d, glyphs, extraspacing, pixeldensity); });
+	luax_catchexcept(L, [&](){ t = instance()->newImageRasterizer(d, glyphs, extraspacing, dpiscale); });
 
 	luax_pushtype(L, t);
 	t->release();

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

@@ -36,8 +36,8 @@ Canvas::Canvas(const Settings &settings)
 
 	width = settings.width;
 	height = settings.height;
-	pixelWidth = (int) ((width * settings.pixeldensity) + 0.5);
-	pixelHeight = (int) ((height * settings.pixeldensity) + 0.5);
+	pixelWidth = (int) ((width * settings.dpiScale) + 0.5);
+	pixelHeight = (int) ((height * settings.dpiScale) + 0.5);
 
 	format = settings.format;
 

+ 1 - 1
src/modules/graphics/Canvas.h

@@ -55,7 +55,7 @@ public:
 		MipmapMode mipmaps = MIPMAPS_NONE;
 		PixelFormat format = PIXELFORMAT_NORMAL;
 		TextureType type = TEXTURE_2D;
-		float pixeldensity = 1.0f;
+		float dpiScale = 1.0f;
 		int msaa = 0;
 		OptionalBool readable;
 	};

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

@@ -76,7 +76,7 @@ void Deprecations::draw(Graphics *gfx)
 	{
 		auto hinting = font::TrueTypeRasterizer::HINTING_NORMAL;
 
-		if (!isGammaCorrect() && gfx->getScreenPixelDensity() <= 1.0)
+		if (!isGammaCorrect() && gfx->getScreenDPIScale() <= 1.0)
 			hinting = font::TrueTypeRasterizer::HINTING_LIGHT;
 
 		font.set(gfx->newDefaultFont(9, hinting), Acquire::NORETAIN);

+ 14 - 14
src/modules/graphics/Font.cpp

@@ -54,7 +54,7 @@ Font::Font(love::font::Rasterizer *r, const Texture::Filter &f)
 	, textureWidth(128)
 	, textureHeight(128)
 	, filter(f)
-	, pixelDensity(r->getPixelDensity())
+	, dpiScale(r->getDPIScale())
 	, useSpacesAsTab(false)
 	, textureCacheID(0)
 {
@@ -247,7 +247,7 @@ const Font::Glyph &Font::addGlyph(uint32 glyph)
 	Glyph g;
 
 	g.texture = 0;
-	g.spacing = floorf(gd->getAdvance() / pixelDensity + 0.5f);
+	g.spacing = floorf(gd->getAdvance() / dpiScale + 0.5f);
 
 	memset(g.vertices, 0, sizeof(GlyphVertex) * 4);
 
@@ -275,18 +275,18 @@ const Font::Glyph &Font::addGlyph(uint32 glyph)
 		// 1---3
 		const GlyphVertex verts[4] =
 		{
-			{float(-o),          float(-o),          normToUint16((tX-o)/tWidth),   normToUint16((tY-o)/tHeight),   c},
-			{float(-o),          (h+o)/pixelDensity, normToUint16((tX-o)/tWidth),   normToUint16((tY+h+o)/tHeight), c},
-			{(w+o)/pixelDensity, float(-o),          normToUint16((tX+w+o)/tWidth), normToUint16((tY-o)/tHeight),   c},
-			{(w+o)/pixelDensity, (h+o)/pixelDensity, normToUint16((tX+w+o)/tWidth), normToUint16((tY+h+o)/tHeight), c}
+			{float(-o),      float(-o),      normToUint16((tX-o)/tWidth),   normToUint16((tY-o)/tHeight),   c},
+			{float(-o),      (h+o)/dpiScale, normToUint16((tX-o)/tWidth),   normToUint16((tY+h+o)/tHeight), c},
+			{(w+o)/dpiScale, float(-o),      normToUint16((tX+w+o)/tWidth), normToUint16((tY-o)/tHeight),   c},
+			{(w+o)/dpiScale, (h+o)/dpiScale, normToUint16((tX+w+o)/tWidth), normToUint16((tY+h+o)/tHeight), c}
 		};
 
 		// Copy vertex data to the glyph and set proper bearing.
 		for (int i = 0; i < 4; i++)
 		{
 			g.vertices[i] = verts[i];
-			g.vertices[i].x += gd->getBearingX() / pixelDensity;
-			g.vertices[i].y -= gd->getBearingY() / pixelDensity;
+			g.vertices[i].x += gd->getBearingX() / dpiScale;
+			g.vertices[i].y -= gd->getBearingY() / dpiScale;
 		}
 
 		textureX += w + TEXTURE_PADDING;
@@ -321,7 +321,7 @@ float Font::getKerning(uint32 leftglyph, uint32 rightglyph)
 	{
 		if (r->hasGlyph(leftglyph) && r->hasGlyph(rightglyph))
 		{
-			k = floorf(r->getKerning(leftglyph, rightglyph) / pixelDensity + 0.5f);
+			k = floorf(r->getKerning(leftglyph, rightglyph) / dpiScale + 0.5f);
 			break;
 		}
 	}
@@ -382,7 +382,7 @@ void Font::getCodepointsFromString(const std::vector<ColoredString> &strs, Color
 
 float Font::getHeight() const
 {
-	return (float) floorf(height / pixelDensity + 0.5f);
+	return (float) floorf(height / dpiScale + 0.5f);
 }
 
 std::vector<Font::DrawCommand> Font::generateVertices(const ColoredCodepoints &codepoints, const Colorf &constantcolor, std::vector<GlyphVertex> &vertices, float extra_spacing, Vector2 offset, TextInfo *info)
@@ -921,12 +921,12 @@ const Texture::Filter &Font::getFilter() const
 
 int Font::getAscent() const
 {
-	return floorf(rasterizers[0]->getAscent() / pixelDensity + 0.5f);
+	return floorf(rasterizers[0]->getAscent() / dpiScale + 0.5f);
 }
 
 int Font::getDescent() const
 {
-	return floorf(rasterizers[0]->getDescent() / pixelDensity + 0.5f);
+	return floorf(rasterizers[0]->getDescent() / dpiScale + 0.5f);
 }
 
 float Font::getBaseline() const
@@ -992,9 +992,9 @@ void Font::setFallbacks(const std::vector<Font *> &fallbacks)
 		rasterizers.push_back(f->rasterizers[0]);
 }
 
-float Font::getPixelDensity() const
+float Font::getDPIScale() const
 {
-	return pixelDensity;
+	return dpiScale;
 }
 
 uint32 Font::getTextureCacheID() const

+ 2 - 2
src/modules/graphics/Font.h

@@ -171,7 +171,7 @@ public:
 
 	void setFallbacks(const std::vector<Font *> &fallbacks);
 
-	float getPixelDensity() const;
+	float getDPIScale() const;
 
 	uint32 getTextureCacheID() const;
 
@@ -228,7 +228,7 @@ private:
 
 	Texture::Filter filter;
 
-	float pixelDensity;
+	float dpiScale;
 
 	int textureX, textureY;
 	int rowHeight;

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

@@ -172,9 +172,9 @@ Font *Graphics::newDefaultFont(int size, font::TrueTypeRasterizer::Hinting hinti
 	return newFont(r.get(), filter);
 }
 
-Video *Graphics::newVideo(love::video::VideoStream *stream, float pixeldensity)
+Video *Graphics::newVideo(love::video::VideoStream *stream, float dpiscale)
 {
-	return new Video(this, stream, pixeldensity);
+	return new Video(this, stream, dpiscale);
 }
 
 bool Graphics::validateShader(bool gles, const Shader::ShaderSource &source, std::string &err)
@@ -202,7 +202,7 @@ int Graphics::getPixelHeight() const
 	return pixelHeight;
 }
 
-double Graphics::getCurrentPixelDensity() const
+double Graphics::getCurrentDPIScale() const
 {
 	if (states.back().renderTargets.colors.size() > 0)
 	{
@@ -210,10 +210,10 @@ double Graphics::getCurrentPixelDensity() const
 		return (double) c->getPixelHeight() / (double) c->getHeight();
 	}
 
-	return getScreenPixelDensity();
+	return getScreenDPIScale();
 }
 
-double Graphics::getScreenPixelDensity() const
+double Graphics::getScreenDPIScale() const
 {
 	return (double) getPixelHeight() / (double) getHeight();
 }

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

@@ -372,7 +372,7 @@ public:
 	Quad *newQuad(Quad::Viewport v, double sw, double sh);
 	Font *newFont(love::font::Rasterizer *data, const Texture::Filter &filter = Texture::defaultFilter);
 	Font *newDefaultFont(int size, font::TrueTypeRasterizer::Hinting hinting, const Texture::Filter &filter = Texture::defaultFilter);
-	Video *newVideo(love::video::VideoStream *stream, float pixeldensity);
+	Video *newVideo(love::video::VideoStream *stream, float dpiscale);
 
 	virtual SpriteBatch *newSpriteBatch(Texture *texture, int size, vertex::Usage usage) = 0;
 
@@ -450,8 +450,8 @@ public:
 	int getPixelWidth() const;
 	int getPixelHeight() const;
 
-	double getCurrentPixelDensity() const;
-	double getScreenPixelDensity() const;
+	double getCurrentDPIScale() const;
+	double getScreenDPIScale() const;
 
 	/**
 	 * Sets the current constant color.

+ 2 - 2
src/modules/graphics/Image.cpp

@@ -83,8 +83,8 @@ void Image::init(PixelFormat fmt, int w, int h, const Settings &settings)
 	pixelWidth = w;
 	pixelHeight = h;
 
-	width  = (int) (pixelWidth / settings.pixeldensity + 0.5);
-	height = (int) (pixelHeight / settings.pixeldensity + 0.5);
+	width  = (int) (pixelWidth / settings.dpiScale + 0.5);
+	height = (int) (pixelHeight / settings.dpiScale + 0.5);
 
 	mipmapCount = mipmapsType == MIPMAPS_NONE ? 1 : getMipmapCount(w, h);
 	format = fmt;

+ 1 - 1
src/modules/graphics/Image.h

@@ -50,7 +50,7 @@ public:
 	{
 		bool mipmaps = false;
 		bool linear = false;
-		float pixeldensity = 1.0f;
+		float dpiScale = 1.0f;
 	};
 
 	struct Slices

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

@@ -239,7 +239,7 @@ int Texture::getPixelHeight(int mip) const
 	return std::max(pixelHeight >> mip, 1);
 }
 
-float Texture::getPixelDensity() const
+float Texture::getDPIScale() const
 {
 	return (float) pixelHeight / (float) height;
 }

+ 1 - 1
src/modules/graphics/Texture.h

@@ -136,7 +136,7 @@ public:
 	int getPixelWidth(int mip = 0) const;
 	int getPixelHeight(int mip = 0) const;
 
-	float getPixelDensity() const;
+	float getDPIScale() const;
 
 	virtual void setFilter(const Filter &f);
 	virtual const Filter &getFilter() const;

+ 3 - 3
src/modules/graphics/Video.cpp

@@ -31,10 +31,10 @@ namespace graphics
 
 love::Type Video::type("Video", &Drawable::type);
 
-Video::Video(Graphics *gfx, love::video::VideoStream *stream, float pixeldensity)
+Video::Video(Graphics *gfx, love::video::VideoStream *stream, float dpiscale)
 	: stream(stream)
-	, width(stream->getWidth() / pixeldensity)
-	, height(stream->getHeight() / pixeldensity)
+	, width(stream->getWidth() / dpiscale)
+	, height(stream->getHeight() / dpiscale)
 	, filter(Texture::defaultFilter)
 {
 	filter.mipmap = Texture::FILTER_NONE;

+ 1 - 1
src/modules/graphics/Video.h

@@ -41,7 +41,7 @@ public:
 
 	static love::Type type;
 
-	Video(Graphics *gfx, love::video::VideoStream *stream, float pixeldensity = 1.0f);
+	Video(Graphics *gfx, love::video::VideoStream *stream, float dpiscale = 1.0f);
 	virtual ~Video();
 
 	// Drawable

+ 6 - 6
src/modules/graphics/opengl/Graphics.cpp

@@ -1027,13 +1027,13 @@ void Graphics::setScissor(const Rect &rect)
 
 	glEnable(GL_SCISSOR_TEST);
 
-	double density = getCurrentPixelDensity();
+	double dpiscale = getCurrentDPIScale();
 
 	Rect glrect;
-	glrect.x = (int) (rect.x * density);
-	glrect.y = (int) (rect.y * density);
-	glrect.w = (int) (rect.w * density);
-	glrect.h = (int) (rect.h * density);
+	glrect.x = (int) (rect.x * dpiscale);
+	glrect.y = (int) (rect.y * dpiscale);
+	glrect.w = (int) (rect.w * dpiscale);
+	glrect.h = (int) (rect.h * dpiscale);
 
 	// OpenGL's reversed y-coordinate is compensated for in OpenGL::setScissor.
 	gl.setScissor(glrect, isCanvasActive());
@@ -1260,7 +1260,7 @@ void Graphics::setPointSize(float size)
 	if (streamBufferState.primitiveMode == vertex::PrimitiveMode::POINTS)
 		flushStreamDraws();
 
-	gl.setPointSize(size * getCurrentPixelDensity());
+	gl.setPointSize(size * getCurrentDPIScale());
 	states.back().pointSize = size;
 }
 

+ 3 - 3
src/modules/graphics/wrap_Font.cpp

@@ -226,10 +226,10 @@ int w_Font_setFallbacks(lua_State *L)
 	return 0;
 }
 
-int w_Font_getPixelDensity(lua_State *L)
+int w_Font_getDPIScale(lua_State *L)
 {
 	Font *t = luax_checkfont(L, 1);
-	lua_pushnumber(L, t->getPixelDensity());
+	lua_pushnumber(L, t->getDPIScale());
 	return 1;
 }
 
@@ -247,7 +247,7 @@ static const luaL_Reg w_Font_functions[] =
 	{ "getBaseline", w_Font_getBaseline },
 	{ "hasGlyphs", w_Font_hasGlyphs },
 	{ "setFallbacks", w_Font_setFallbacks },
-	{ "getPixelDensity", w_Font_getPixelDensity },
+	{ "getDPIScale", w_Font_getDPIScale },
 	{ 0, 0 }
 };
 

+ 25 - 25
src/modules/graphics/wrap_Graphics.cpp

@@ -234,9 +234,9 @@ int w_getPixelDimensions(lua_State *L)
 	return 2;
 }
 
-int w_getPixelDensity(lua_State *L)
+int w_getDPIScale(lua_State *L)
 {
-	lua_pushnumber(L, instance()->getScreenPixelDensity());
+	lua_pushnumber(L, instance()->getScreenDPIScale());
 	return 1;
 }
 
@@ -631,7 +631,7 @@ int w_getStencilTest(lua_State *L)
 	return 2;
 }
 
-static void parsePixelDensity(Data *d, float *pixeldensity)
+static void parseDPIScale(Data *d, float *dpiscale)
 {
 	auto fd = dynamic_cast<love::filesystem::FileData *>(d);
 	if (fd == nullptr)
@@ -648,8 +648,8 @@ static void parsePixelDensity(Data *d, float *pixeldensity)
 	{
 		char *end = nullptr;
 		long density = strtol(fname.c_str() + atpos + 1, &end, 10);
-		if (end != nullptr && density > 0 && pixeldensity != nullptr)
-			*pixeldensity = (float) density;
+		if (end != nullptr && density > 0 && dpiscale != nullptr)
+			*dpiscale = (float) density;
 	}
 }
 
@@ -662,14 +662,14 @@ static Image::Settings w__optImageSettings(lua_State *L, int idx, const Image::S
 		luaL_checktype(L, idx, LUA_TTABLE);
 		settings.mipmaps = luax_boolflag(L, idx, "mipmaps", s.mipmaps);
 		settings.linear = luax_boolflag(L, idx, "linear", s.linear);
-		settings.pixeldensity = (float) luax_numberflag(L, idx, "pixeldensity", s.pixeldensity);
+		settings.dpiScale = (float) luax_numberflag(L, idx, "dpiscale", s.dpiScale);
 	}
 
 	return settings;
 }
 
 static std::pair<StrongRef<image::ImageData>, StrongRef<image::CompressedImageData>>
-getImageData(lua_State *L, int idx, bool allowcompressed, float *density)
+getImageData(lua_State *L, int idx, bool allowcompressed, float *dpiscale)
 {
 	StrongRef<image::ImageData> idata;
 	StrongRef<image::CompressedImageData> cdata;
@@ -687,8 +687,8 @@ getImageData(lua_State *L, int idx, bool allowcompressed, float *density)
 
 		StrongRef<Data> fdata(filesystem::luax_getdata(L, idx), Acquire::NORETAIN);
 
-		if (density != nullptr)
-			parsePixelDensity(fdata, density);
+		if (dpiscale != nullptr)
+			parseDPIScale(fdata, dpiscale);
 
 		if (allowcompressed && imagemodule->isCompressed(fdata))
 			luax_catchexcept(L, [&]() { cdata.set(imagemodule->newCompressedData(fdata), Acquire::NORETAIN); });
@@ -724,7 +724,7 @@ int w_newCubeImage(lua_State *L)
 
 	if (!lua_istable(L, 1))
 	{
-		auto data = getImageData(L, 1, true, &settings.pixeldensity);
+		auto data = getImageData(L, 1, true, &settings.dpiScale);
 
 		std::vector<StrongRef<love::image::ImageData>> faces;
 
@@ -758,7 +758,7 @@ int w_newCubeImage(lua_State *L)
 				{
 					lua_rawgeti(L, -1, mip + 1);
 
-					auto data = getImageData(L, -1, true, face == 0 && mip == 0 ? &settings.pixeldensity : nullptr);
+					auto data = getImageData(L, -1, true, face == 0 && mip == 0 ? &settings.dpiScale : nullptr);
 					if (data.first.get())
 						slices.set(face, mip, data.first);
 					else
@@ -776,7 +776,7 @@ int w_newCubeImage(lua_State *L)
 			{
 				lua_rawgeti(L, 1, i + 1);
 
-				auto data = getImageData(L, -1, true, i == 0 ? &settings.pixeldensity : nullptr);
+				auto data = getImageData(L, -1, true, i == 0 ? &settings.dpiScale : nullptr);
 
 				if (data.first.get())
 				{
@@ -829,7 +829,7 @@ int w_newArrayImage(lua_State *L)
 				{
 					lua_rawgeti(L, -1, mip + 1);
 
-					auto data = getImageData(L, -1, true, slice == 0 && mip == 0 ? &settings.pixeldensity : nullptr);
+					auto data = getImageData(L, -1, true, slice == 0 && mip == 0 ? &settings.dpiScale : nullptr);
 					if (data.first.get())
 						slices.set(slice, mip, data.first);
 					else
@@ -844,7 +844,7 @@ int w_newArrayImage(lua_State *L)
 			for (int slice = 0; slice < tlen; slice++)
 			{
 				lua_rawgeti(L, 1, slice + 1);
-				auto data = getImageData(L, -1, true, slice == 0 ? &settings.pixeldensity : nullptr);
+				auto data = getImageData(L, -1, true, slice == 0 ? &settings.dpiScale : nullptr);
 				if (data.first.get())
 					slices.set(slice, 0, data.first);
 				else
@@ -856,7 +856,7 @@ int w_newArrayImage(lua_State *L)
 	}
 	else
 	{
-		auto data = getImageData(L, 1, true, &settings.pixeldensity);
+		auto data = getImageData(L, 1, true, &settings.dpiScale);
 		if (data.first.get())
 			slices.set(0, 0, data.first);
 		else
@@ -893,7 +893,7 @@ int w_newVolumeImage(lua_State *L)
 				{
 					lua_rawgeti(L, -1, mip + 1);
 
-					auto data = getImageData(L, -1, true, slice == 0 && mip == 0 ? &settings.pixeldensity : nullptr);
+					auto data = getImageData(L, -1, true, slice == 0 && mip == 0 ? &settings.dpiScale : nullptr);
 					if (data.first.get())
 						slices.set(slice, mip, data.first);
 					else
@@ -908,7 +908,7 @@ int w_newVolumeImage(lua_State *L)
 			for (int layer = 0; layer < tlen; layer++)
 			{
 				lua_rawgeti(L, 1, layer + 1);
-				auto data = getImageData(L, -1, true, layer == 0 ? &settings.pixeldensity : nullptr);
+				auto data = getImageData(L, -1, true, layer == 0 ? &settings.dpiScale : nullptr);
 				if (data.first.get())
 					slices.set(layer, 0, data.first);
 				else
@@ -920,7 +920,7 @@ int w_newVolumeImage(lua_State *L)
 	}
 	else
 	{
-		auto data = getImageData(L, 1, true, &settings.pixeldensity);
+		auto data = getImageData(L, 1, true, &settings.dpiScale);
 
 		if (data.first.get())
 		{
@@ -951,7 +951,7 @@ int w_newImage(lua_State *L)
 		for (int i = 0; i < n; i++)
 		{
 			lua_rawgeti(L, 1, i + 1);
-			auto data = getImageData(L, -1, true, i == 0 ? &settings.pixeldensity : nullptr);
+			auto data = getImageData(L, -1, true, i == 0 ? &settings.dpiScale : nullptr);
 			if (data.first.get())
 				slices.set(0, i, data.first);
 			else
@@ -961,7 +961,7 @@ int w_newImage(lua_State *L)
 	}
 	else
 	{
-		auto data = getImageData(L, 1, true, &settings.pixeldensity);
+		auto data = getImageData(L, 1, true, &settings.dpiScale);
 		if (data.first.get())
 			slices.set(0, 0, data.first);
 		else
@@ -1131,7 +1131,7 @@ int w_newCanvas(lua_State *L)
 	settings.height = (int) luaL_optinteger(L, 2, instance()->getHeight());
 
 	// Default to the screen's current pixel density scale.
-	settings.pixeldensity = instance()->getScreenPixelDensity();
+	settings.dpiScale = instance()->getScreenDPIScale();
 
 	int startidx = 3;
 
@@ -1146,7 +1146,7 @@ int w_newCanvas(lua_State *L)
 	{
 		luaL_checktype(L, startidx, LUA_TTABLE);
 
-		settings.pixeldensity = (float) luax_numberflag(L, startidx, "pixeldensity", settings.pixeldensity);
+		settings.dpiScale = (float) luax_numberflag(L, startidx, "dpiscale", settings.dpiScale);
 		settings.msaa = luax_intflag(L, startidx, "msaa", settings.msaa);
 
 		lua_getfield(L, startidx, "format");
@@ -1596,10 +1596,10 @@ int w_newVideo(lua_State *L)
 		luax_convobj(L, 1, "video", "newVideoStream");
 
 	auto stream = luax_checktype<love::video::VideoStream>(L, 1);
-	float pixeldensity = (float) luaL_optnumber(L, 2, 1.0);
+	float dpiscale = (float) luaL_optnumber(L, 2, 1.0);
 	Video *video = nullptr;
 
-	luax_catchexcept(L, [&]() { video = instance()->newVideo(stream, pixeldensity); });
+	luax_catchexcept(L, [&]() { video = instance()->newVideo(stream, dpiscale); });
 
 	luax_pushtype(L, video);
 	video->release();
@@ -2838,7 +2838,7 @@ static const luaL_Reg functions[] =
 	{ "getPixelWidth", w_getPixelWidth },
 	{ "getPixelHeight", w_getPixelHeight },
 	{ "getPixelDimensions", w_getPixelDimensions },
-	{ "getPixelDensity", w_getPixelDensity },
+	{ "getDPIScale", w_getDPIScale },
 
 	{ "setScissor", w_setScissor },
 	{ "intersectScissor", w_intersectScissor },

+ 1 - 1
src/modules/graphics/wrap_Graphics.lua

@@ -488,7 +488,7 @@ function love.graphics.newVideo(file, settings)
 	settings = settings == nil and {} or settings
 	if type(settings) ~= "table" then error("bad argument #2 to newVideo (expected table)", 2) end
 
-	local video = love.graphics._newVideo(file, settings.pixeldensity)
+	local video = love.graphics._newVideo(file, settings.dpiscale)
 	local source, success
 
 	if settings.audio ~= false and love.audio then

+ 3 - 3
src/modules/graphics/wrap_Texture.cpp

@@ -122,10 +122,10 @@ int w_Texture_getPixelDimensions(lua_State *L)
 	return 2;
 }
 
-int w_Texture_getPixelDensity(lua_State *L)
+int w_Texture_getDPIScale(lua_State *L)
 {
 	Texture *t = luax_checktexture(L, 1);
-	lua_pushnumber(L, t->getPixelDensity());
+	lua_pushnumber(L, t->getDPIScale());
 	return 1;
 }
 
@@ -312,7 +312,7 @@ const luaL_Reg w_Texture_functions[] =
 	{ "getPixelWidth", w_Texture_getPixelWidth },
 	{ "getPixelHeight", w_Texture_getPixelHeight },
 	{ "getPixelDimensions", w_Texture_getPixelDimensions },
-	{ "getPixelDensity", w_Texture_getPixelDensity },
+	{ "getDPIScale", w_Texture_getDPIScale },
 	{ "setFilter", w_Texture_setFilter },
 	{ "getFilter", w_Texture_getFilter },
 	{ "setMipmapFilter", w_Texture_setMipmapFilter },

+ 1 - 1
src/modules/window/Window.h

@@ -179,7 +179,7 @@ public:
 	virtual void windowToDPICoords(double *x, double *y) const = 0;
 	virtual void DPIToWindowCoords(double *x, double *y) const = 0;
 
-	virtual double getPixelDensity() const = 0;
+	virtual double getDPIScale() const = 0;
 
 	virtual double toPixels(double x) const = 0;
 	virtual void toPixels(double wx, double wy, double &px, double &py) const = 0;

+ 5 - 5
src/modules/window/sdl/Window.cpp

@@ -1026,7 +1026,7 @@ void Window::DPIToWindowCoords(double *x, double *y) const
 		*y = py;
 }
 
-double Window::getPixelDensity() const
+double Window::getDPIScale() const
 {
 #ifdef LOVE_ANDROID
 	return love::android::getScreenScale();
@@ -1037,24 +1037,24 @@ double Window::getPixelDensity() const
 
 double Window::toPixels(double x) const
 {
-	return x * getPixelDensity();
+	return x * getDPIScale();
 }
 
 void Window::toPixels(double wx, double wy, double &px, double &py) const
 {
-	double scale = getPixelDensity();
+	double scale = getDPIScale();
 	px = wx * scale;
 	py = wy * scale;
 }
 
 double Window::fromPixels(double x) const
 {
-	return x / getPixelDensity();
+	return x / getDPIScale();
 }
 
 void Window::fromPixels(double px, double py, double &wx, double &wy) const
 {
-	double scale = getPixelDensity();
+	double scale = getDPIScale();
 	wx = px / scale;
 	wy = py / scale;
 }

+ 1 - 1
src/modules/window/sdl/Window.h

@@ -101,7 +101,7 @@ public:
 	void windowToDPICoords(double *x, double *y) const;
 	void DPIToWindowCoords(double *x, double *y) const;
 
-	double getPixelDensity() const;
+	double getDPIScale() const;
 
 	double toPixels(double x) const;
 	void toPixels(double wx, double wy, double &px, double &py) const;

+ 3 - 3
src/modules/window/wrap_Window.cpp

@@ -419,9 +419,9 @@ int w_isVisible(lua_State *L)
 	return 1;
 }
 
-int w_getPixelDensity(lua_State *L)
+int w_getDPIScale(lua_State *L)
 {
-	lua_pushnumber(L, instance()->getPixelDensity());
+	lua_pushnumber(L, instance()->getDPIScale());
 	return 1;
 }
 
@@ -581,7 +581,7 @@ static const luaL_Reg functions[] =
 	{ "hasFocus", w_hasFocus },
 	{ "hasMouseFocus", w_hasMouseFocus },
 	{ "isVisible", w_isVisible },
-	{ "getPixelDensity", w_getPixelDensity },
+	{ "getDPIScale", w_getDPIScale },
 	{ "toPixels", w_toPixels },
 	{ "fromPixels", w_fromPixels },
 	{ "minimize", w_minimize },

+ 1 - 1
src/scripts/nogame.lua

@@ -729,7 +729,7 @@ function love.nogame()
 
 		local ww, wh = love.graphics.getDimensions()
 
-		if love.window.getPixelDensity() > 1 then
+		if love.window.getDPIScale() > 1 then
 			mosaic_image = g_images.mosaic[2]
 		end
 

+ 2 - 2
src/scripts/nogame.lua.h

@@ -3130,8 +3130,8 @@ const unsigned char nogame_lua[] =
 	0x6f, 0x76, 0x65, 0x2e, 0x67, 0x72, 0x61, 0x70, 0x68, 0x69, 0x63, 0x73, 0x2e, 0x67, 0x65, 0x74, 0x44, 0x69, 
 	0x6d, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x28, 0x29, 0x0a,
 	0x09, 0x09, 0x69, 0x66, 0x20, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x77, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x2e, 0x67, 
-	0x65, 0x74, 0x50, 0x69, 0x78, 0x65, 0x6c, 0x44, 0x65, 0x6e, 0x73, 0x69, 0x74, 0x79, 0x28, 0x29, 0x20, 0x3e, 
-	0x20, 0x31, 0x20, 0x74, 0x68, 0x65, 0x6e, 0x0a,
+	0x65, 0x74, 0x44, 0x50, 0x49, 0x53, 0x63, 0x61, 0x6c, 0x65, 0x28, 0x29, 0x20, 0x3e, 0x20, 0x31, 0x20, 0x74, 
+	0x68, 0x65, 0x6e, 0x0a,
 	0x09, 0x09, 0x09, 0x6d, 0x6f, 0x73, 0x61, 0x69, 0x63, 0x5f, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x20, 0x3d, 0x20, 
 	0x67, 0x5f, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x73, 0x2e, 0x6d, 0x6f, 0x73, 0x61, 0x69, 0x63, 0x5b, 0x32, 0x5d, 0x0a,
 	0x09, 0x09, 0x65, 0x6e, 0x64, 0x0a,