From 19aee7e75c3107f143c61203eab659918b8e8a60 Mon Sep 17 00:00:00 2001 From: Alex Szpakowski Date: Wed, 28 Dec 2016 01:24:21 -0400 Subject: [PATCH] Minor optimizations to love.graphics.draw(texture). --HG-- branch : minor --- platform/xcode/macosx/love-macosx.plist | 2 ++ src/common/Matrix.cpp | 15 ++++++++------- src/common/Matrix.h | 11 ++++++----- src/modules/graphics/Texture.cpp | 2 +- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/platform/xcode/macosx/love-macosx.plist b/platform/xcode/macosx/love-macosx.plist index acf845a37..386742df1 100644 --- a/platform/xcode/macosx/love-macosx.plist +++ b/platform/xcode/macosx/love-macosx.plist @@ -69,6 +69,8 @@ public.app-category.games NSHighResolutionCapable + NSSupportsAutomaticGraphicsSwitching + NSHumanReadableCopyright © 2006-2016 LÖVE Development Team NSPrincipalClass diff --git a/src/common/Matrix.cpp b/src/common/Matrix.cpp index 2e6167ad0..9aef6a1bf 100644 --- a/src/common/Matrix.cpp +++ b/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); } +Matrix4::Matrix4(const Matrix4 &a, const Matrix4 &b) +{ + multiply(a, b, e); +} + 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() -{ -} - 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) diff --git a/src/common/Matrix.h b/src/common/Matrix.h index 2e62b12b8..a9e10ec2c 100644 --- a/src/common/Matrix.h +++ b/src/common/Matrix.h @@ -58,16 +58,17 @@ public: **/ Matrix4(const float elements[16]); + /** + * Creates a new matrix from the result of multiplying the two specified + * matrices. + **/ + Matrix4(const Matrix4 &a, const Matrix4 &b); + /** * Creates a new matrix set to a transformation. **/ Matrix4(float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky); - /** - * Destructor. - **/ - ~Matrix4(); - /** * Multiplies this Matrix with another Matrix, changing neither. * @param m The Matrix to multiply with this Matrix. diff --git a/src/modules/graphics/Texture.cpp b/src/modules/graphics/Texture.cpp index 8cbdbf5f6..4cfc6cf0b 100644 --- a/src/modules/graphics/Texture.cpp +++ b/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) { - Matrix4 t = gfx->getTransform() * localTransform; + Matrix4 t(gfx->getTransform(), localTransform); Vertex verts[4] = {v[0], v[1], v[2], v[3]}; t.transform(verts, v, 4);