[4/8] gdiplus: added GdipMultiplyMatrix

Evan Stade estade at gmail.com
Tue Jul 17 21:31:15 CDT 2007


Hi,

Changelog:
*added GdipMultiplyMatrix
*added MatrixOrder enum type

 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 deletions(-)

-- 
Evan Stade
-------------- next part --------------
diff --git a/dlls/gdiplus/gdiplus.spec b/dlls/gdiplus/gdiplus.spec
index a50d866..bd71115 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 909bfee..c8eb689 100644
--- a/dlls/gdiplus/matrix.c
+++ b/dlls/gdiplus/matrix.c
@@ -25,6 +25,28 @@ #include "wingdi.h"
 #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(GpM
     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 4f5b193..eb807ce 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 Interpola
 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 df6ca7c..2567afe 100644
--- a/include/gdiplusflat.h
+++ b/include/gdiplusflat.h
@@ -87,6 +87,7 @@ GpStatus WINGDIPAPI GdipTransformPath(Gp
 
 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 ea24033..0e431c5 100644
--- a/include/gdiplusgpstubs.h
+++ b/include/gdiplusgpstubs.h
@@ -54,5 +54,6 @@ typedef RectF GpRectF;
 typedef LineJoin GpLineJoin;
 typedef DashCap GpDashCap;
 typedef DashStyle GpDashStyle;
+typedef MatrixOrder GpMatrixOrder;
 
 #endif
-- 
1.4.1


More information about the wine-patches mailing list