From 12e3eadd415a13c070673234fc97817ca53a704d Mon Sep 17 00:00:00 2001 From: Evan Stade Date: Tue, 17 Jul 2007 19:31:15 -0700 Subject: [PATCH] gdiplus: Added GdipMultiplyMatrix. --- dlls/gdiplus/gdiplus.spec | 2 +- dlls/gdiplus/matrix.c | 36 ++++++++++++++++++++++++++++++++++++ include/gdiplusenums.h | 7 +++++++ include/gdiplusflat.h | 1 + include/gdiplusgpstubs.h | 1 + 5 files changed, 46 insertions(+), 1 deletion(-) diff --git a/dlls/gdiplus/gdiplus.spec b/dlls/gdiplus/gdiplus.spec index 9bc512288a0..21e38283802 100644 --- a/dlls/gdiplus/gdiplus.spec +++ b/dlls/gdiplus/gdiplus.spec @@ -424,7 +424,7 @@ @ stub GdipMeasureDriverString @ stub GdipMeasureString @ stub GdipMultiplyLineTransform -@ stub GdipMultiplyMatrix +@ stdcall GdipMultiplyMatrix(ptr ptr long) @ stub GdipMultiplyPathGradientTransform @ stub GdipMultiplyPenTransform @ stub GdipMultiplyTextureTransform diff --git a/dlls/gdiplus/matrix.c b/dlls/gdiplus/matrix.c index 909bfee910e..c8eb6892d31 100644 --- a/dlls/gdiplus/matrix.c +++ b/dlls/gdiplus/matrix.c @@ -25,6 +25,28 @@ #include "gdiplus.h" #include "gdiplus_private.h" +/* Multiplies two matrices of the form + * + * idx:0 idx:1 0 + * idx:2 idx:3 0 + * idx:4 idx:5 1 + * + * and puts the output in out. + * */ +static void matrix_multiply(GDIPCONST REAL * left, GDIPCONST REAL * right, REAL * out) +{ + REAL temp[6]; + int i, odd; + + for(i = 0; i < 6; i++){ + odd = i % 2; + temp[i] = left[i - odd] * right[odd] + left[i - odd + 1] * right[odd + 2] + + (i >= 4 ? right[odd + 4] : 0.0); + } + + memcpy(out, temp, 6 * sizeof(REAL)); +} + GpStatus WINGDIPAPI GdipCreateMatrix2(REAL m11, REAL m12, REAL m21, REAL m22, REAL dx, REAL dy, GpMatrix **matrix) { @@ -57,6 +79,20 @@ GpStatus WINGDIPAPI GdipDeleteMatrix(GpMatrix *matrix) return Ok; } +GpStatus WINGDIPAPI GdipMultiplyMatrix(GpMatrix *matrix, GpMatrix* matrix2, + GpMatrixOrder order) +{ + if(!matrix || !matrix2) + return InvalidParameter; + + if(order == MatrixOrderAppend) + matrix_multiply(matrix->matrix, matrix2->matrix, matrix->matrix); + else + matrix_multiply(matrix2->matrix, matrix->matrix, matrix->matrix); + + return Ok; +} + GpStatus WINGDIPAPI GdipTransformMatrixPoints(GpMatrix *matrix, GpPointF *pts, INT count) { diff --git a/include/gdiplusenums.h b/include/gdiplusenums.h index 4f5b193fcc4..eb807ce705d 100644 --- a/include/gdiplusenums.h +++ b/include/gdiplusenums.h @@ -151,6 +151,12 @@ enum DashStyle DashStyleCustom }; +enum MatrixOrder +{ + MatrixOrderPrepend = 0, + MatrixOrderAppend = 1 +}; + #ifndef __cplusplus typedef enum Unit Unit; @@ -166,6 +172,7 @@ typedef enum InterpolationMode InterpolationMode; typedef enum PixelOffsetMode PixelOffsetMode; typedef enum DashCap DashCap; typedef enum DashStyle DashStyle; +typedef enum MatrixOrder MatrixOrder; #endif /* end of c typedefs */ diff --git a/include/gdiplusflat.h b/include/gdiplusflat.h index a358a1e938d..e3ab4e012ca 100644 --- a/include/gdiplusflat.h +++ b/include/gdiplusflat.h @@ -87,6 +87,7 @@ GpStatus WINGDIPAPI GdipTransformPath(GpPath*,GpMatrix*); GpStatus WINGDIPAPI GdipCreateMatrix2(REAL,REAL,REAL,REAL,REAL,REAL,GpMatrix**); GpStatus WINGDIPAPI GdipDeleteMatrix(GpMatrix*); +GpStatus WINGDIPAPI GdipMultiplyMatrix(GpMatrix*,GpMatrix*,GpMatrixOrder); GpStatus WINGDIPAPI GdipTransformMatrixPoints(GpMatrix*,GpPointF*,INT); GpStatus WINGDIPAPI GdipCreatePathIter(GpPathIterator**,GpPath*); diff --git a/include/gdiplusgpstubs.h b/include/gdiplusgpstubs.h index 7cb18880b03..8bb5bb68343 100644 --- a/include/gdiplusgpstubs.h +++ b/include/gdiplusgpstubs.h @@ -52,5 +52,6 @@ typedef RectF GpRectF; typedef LineJoin GpLineJoin; typedef DashCap GpDashCap; typedef DashStyle GpDashStyle; +typedef MatrixOrder GpMatrixOrder; #endif