Browse Source

Minor optimizations to love.graphics.draw(texture).

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

+ 2 - 0
platform/xcode/macosx/love-macosx.plist

@@ -69,6 +69,8 @@
 	<string>public.app-category.games</string>
 	<string>public.app-category.games</string>
 	<key>NSHighResolutionCapable</key>
 	<key>NSHighResolutionCapable</key>
 	<true/>
 	<true/>
+	<key>NSSupportsAutomaticGraphicsSwitching</key>
+	<false/>
 	<key>NSHumanReadableCopyright</key>
 	<key>NSHumanReadableCopyright</key>
 	<string>© 2006-2016 LÖVE Development Team</string>
 	<string>© 2006-2016 LÖVE Development Team</string>
 	<key>NSPrincipalClass</key>
 	<key>NSPrincipalClass</key>

+ 7 - 6
src/common/Matrix.cpp

@@ -85,20 +85,21 @@ Matrix4::Matrix4(float t00, float t10, float t01, float t11, float x, float y)
 	setRawTransformation(t00, t10, t01, t11, x, y);
 	setRawTransformation(t00, t10, t01, t11, x, y);
 }
 }
 
 
-Matrix4::Matrix4(float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky)
+Matrix4::Matrix4(const Matrix4 &a, const Matrix4 &b)
 {
 {
-	setTransformation(x, y, angle, sx, sy, ox, oy, kx, ky);
+	multiply(a, b, e);
 }
 }
 
 
-Matrix4::~Matrix4()
+Matrix4::Matrix4(float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky)
 {
 {
+	setTransformation(x, y, angle, sx, sy, ox, oy, kx, ky);
 }
 }
 
 
 Matrix4 Matrix4::operator * (const Matrix4 &m) const
 Matrix4 Matrix4::operator * (const Matrix4 &m) const
 {
 {
-	Matrix4 t;
-	multiply(*this, m, t.e);
-	return t;
+	float t[16];
+	multiply(*this, m, t);
+	return Matrix4(t);
 }
 }
 
 
 void Matrix4::operator *= (const Matrix4 &m)
 void Matrix4::operator *= (const Matrix4 &m)

+ 5 - 4
src/common/Matrix.h

@@ -59,14 +59,15 @@ public:
 	Matrix4(const float elements[16]);
 	Matrix4(const float elements[16]);
 
 
 	/**
 	/**
-	 * Creates a new matrix set to a transformation.
+	 * Creates a new matrix from the result of multiplying the two specified
+	 * matrices.
 	 **/
 	 **/
-	Matrix4(float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky);
+	Matrix4(const Matrix4 &a, const Matrix4 &b);
 
 
 	/**
 	/**
-	 * Destructor.
+	 * Creates a new matrix set to a transformation.
 	 **/
 	 **/
-	~Matrix4();
+	Matrix4(float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky);
 
 
 	/**
 	/**
 	 * Multiplies this Matrix with another Matrix, changing neither.
 	 * Multiplies this Matrix with another Matrix, changing neither.

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

@@ -60,7 +60,7 @@ void Texture::drawq(Graphics *gfx, Quad *quad, const Matrix4 &m)
 
 
 void Texture::drawv(Graphics *gfx, const Matrix4 &localTransform, const Vertex *v)
 void Texture::drawv(Graphics *gfx, const Matrix4 &localTransform, const Vertex *v)
 {
 {
-	Matrix4 t = gfx->getTransform() * localTransform;
+	Matrix4 t(gfx->getTransform(), localTransform);
 
 
 	Vertex verts[4] = {v[0], v[1], v[2], v[3]};
 	Vertex verts[4] = {v[0], v[1], v[2], v[3]};
 	t.transform(verts, v, 4);
 	t.transform(verts, v, 4);