summaryrefslogtreecommitdiff
path: root/cppcanvas/source/inc/implrenderer.hxx
diff options
context:
space:
mode:
Diffstat (limited to 'cppcanvas/source/inc/implrenderer.hxx')
-rw-r--r--cppcanvas/source/inc/implrenderer.hxx33
1 files changed, 23 insertions, 10 deletions
diff --git a/cppcanvas/source/inc/implrenderer.hxx b/cppcanvas/source/inc/implrenderer.hxx
index 0b584fad9a85..033882d15620 100644
--- a/cppcanvas/source/inc/implrenderer.hxx
+++ b/cppcanvas/source/inc/implrenderer.hxx
@@ -76,19 +76,26 @@ namespace cppcanvas
};
// EMF+
- // TODO: replace?
+ // Transformation matrix (used for Affine Transformation)
+ // [ eM11, eM12, eDx ]
+ // [ eM21, eM22, eDy ]
+ // [ 0, 0, 1 ]
+ // that consists of a linear map (eM11, eM12, eM21, eM22)
+ // More info: https://en.wikipedia.org/wiki/Linear_map
+ // followed by a translation (eDx, eDy)
+
struct XForm
{
- float eM11;
- float eM12;
- float eM21;
- float eM22;
- float eDx;
- float eDy;
+ float eM11; // M1,1 value in the matrix. Increases or decreases the size of the pixels horizontally.
+ float eM12; // M1,2 value in the matrix. This effectively angles the X axis up or down.
+ float eM21; // M2,1 value in the matrix. This effectively angles the Y axis left or right.
+ float eM22; // M2,2 value in the matrix. Increases or decreases the size of the pixels vertically.
+ float eDx; // Delta x (Dx) value in the matrix. Moves the whole coordinate system horizontally.
+ float eDy; // Delta y (Dy) value in the matrix. Moves the whole coordinate system vertically.
XForm()
{
SetIdentity ();
- };
+ }
void SetIdentity ()
{
@@ -106,14 +113,20 @@ namespace cppcanvas
eDy = f.eDy;
}
+ // Multiple two square matrices
+ // [ eM11, eM12, eDx ] [ f.eM11, f.eM12, f.eDx ]
+ // [ eM21, eM22, eDy ] x [ f.eM21, f.eM22, f.eDy ]
+ // [ 0, 0, 1 ] [ 0, 0, 1 ]
+ // More information: https://en.wikipedia.org/wiki/Matrix_multiplication#Square_matrices
+ // FIXME We shouldn't modify source matrix during computation
void Multiply (const XForm& f)
{
eM11 = eM11*f.eM11 + eM12*f.eM21;
eM12 = eM11*f.eM12 + eM12*f.eM22;
eM21 = eM21*f.eM11 + eM22*f.eM21;
eM22 = eM21*f.eM12 + eM22*f.eM22;
- eDx *= eDx*f.eM11 + eDy*f.eM21 + f.eDx;
- eDy *= eDx*f.eM12 + eDy*f.eM22 + f.eDy;
+ eDx = eDx*f.eM11 + eDy*f.eM21 + f.eDx;
+ eDy = eDx*f.eM12 + eDy*f.eM22 + f.eDy;
}
#ifdef OSL_BIGENDIAN