diff --git a/darwin/draw.m b/darwin/draw.m index 167d3af4..b0a1a8c4 100644 --- a/darwin/draw.m +++ b/darwin/draw.m @@ -395,6 +395,14 @@ void uiDrawMatrixTransformSize(uiDrawMatrix *m, double *x, double *y) *y = s.height; } +void uiDrawTransform(uiDrawContext *c, uiDrawMatrix *m) +{ + CGAffineTransform cm; + + m2c(m, &cm); + CGContextConcatCTM(c->c, cm); +} + // TODO figure out what besides transforms these save/restore on all platforms void uiDrawSave(uiDrawContext *c) { @@ -405,11 +413,3 @@ void uiDrawRestore(uiDrawContext *c) { CGContextRestoreGState(c->c); } - -void uiDrawTransform(uiDrawContext *c, uiDrawMatrix *m) -{ - CGAffineTransform cm; - - m2c(m, &cm); - CGContextConcatCTM(c->c, cm); -} diff --git a/ui.h b/ui.h index 29921567..2c4916e2 100644 --- a/ui.h +++ b/ui.h @@ -423,9 +423,12 @@ _UI_EXTERN int uiDrawMatrixInvert(uiDrawMatrix *m); _UI_EXTERN void uiDrawMatrixTransformPoint(uiDrawMatrix *m, double *x, double *y); _UI_EXTERN void uiDrawMatrixTransformSize(uiDrawMatrix *m, double *x, double *y); +_UI_EXTERN void uiDrawTransform(uiDrawContext *c, uiDrawMatrix *m); + +// TODO put uiDrawClip here + _UI_EXTERN void uiDrawSave(uiDrawContext *c); _UI_EXTERN void uiDrawRestore(uiDrawContext *c); -_UI_EXTERN void uiDrawTransform(uiDrawContext *c, uiDrawMatrix *m); typedef enum uiModifiers uiModifiers; diff --git a/uipriv.h b/uipriv.h index 247a317f..a8cf9273 100644 --- a/uipriv.h +++ b/uipriv.h @@ -5,6 +5,7 @@ #define uthash_malloc(sz) uiAlloc((sz), "(uthash internal)") #define uthash_free(ptr,sz) uiFree((ptr)) #include "uthash/uthash.h" +#include "uthash/utarray.h" extern uiInitOptions options; diff --git a/unix/draw.c b/unix/draw.c index 875b78bc..677b1ccd 100644 --- a/unix/draw.c +++ b/unix/draw.c @@ -414,6 +414,14 @@ void uiDrawMatrixTransformSize(uiDrawMatrix *m, double *x, double *y) cairo_matrix_transform_distance(&c, x, y); } +void uiDrawTransform(uiDrawContext *c, uiDrawMatrix *m) +{ + cairo_matrix_t cm; + + m2c(m, &cm); + cairo_transform(c->cr, &cm); +} + void uiDrawSave(uiDrawContext *c) { cairo_save(c->cr); @@ -423,11 +431,3 @@ void uiDrawRestore(uiDrawContext *c) { cairo_restore(c->cr); } - -void uiDrawTransform(uiDrawContext *c, uiDrawMatrix *m) -{ - cairo_matrix_t cm; - - m2c(m, &cm); - cairo_transform(c->cr, &cm); -} diff --git a/windows/draw.c b/windows/draw.c index 73e4ba78..b1444514 100644 --- a/windows/draw.c +++ b/windows/draw.c @@ -650,6 +650,27 @@ void uiDrawMatrixTransformSize(uiDrawMatrix *m, double *x, double *y) fallbackTransformSize(m, x, y); } +void uiDrawTransform(uiDrawContext *c, uiDrawMatrix *m) +{ + D2D1_MATRIX_3X2_F dm; + uiDrawMatrix already; + uiDrawMatrix temp; + + ID2D1RenderTarget_GetTransform(c->rt, &dm); + d2m(&dm, &already); + temp = *m; // don't modify m + // you would think we have to do already * m, right? + // WRONG! we have to do m * already + // why? a few reasons + // a) this lovely comment in cairo's source - http://cgit.freedesktop.org/cairo/tree/src/cairo-matrix.c?id=0537479bd1d4c5a3bc0f6f41dec4deb98481f34a#n330 + // Direct2D uses column vectors and I don't know if this is even documented + // b) that's what Core Graphics does + // TODO see if Microsoft says to do this + uiDrawMatrixMultiply(&temp, &already); + m2d(&temp, &dm); + ID2D1RenderTarget_SetTransform(c->rt, &dm); +} + void uiDrawSave(uiDrawContext *c) { ID2D1DrawingStateBlock *dsb; @@ -675,24 +696,3 @@ void uiDrawRestore(uiDrawContext *c) ID2D1RenderTarget_RestoreDrawingState(c->rt, dsb); ID2D1DrawingStateBlock_Release(dsb); } - -void uiDrawTransform(uiDrawContext *c, uiDrawMatrix *m) -{ - D2D1_MATRIX_3X2_F dm; - uiDrawMatrix already; - uiDrawMatrix temp; - - ID2D1RenderTarget_GetTransform(c->rt, &dm); - d2m(&dm, &already); - temp = *m; // don't modify m - // you would think we have to do already * m, right? - // WRONG! we have to do m * already - // why? a few reasons - // a) this lovely comment in cairo's source - http://cgit.freedesktop.org/cairo/tree/src/cairo-matrix.c?id=0537479bd1d4c5a3bc0f6f41dec4deb98481f34a#n330 - // Direct2D uses column vectors and I don't know if this is even documented - // b) that's what Core Graphics does - // TODO see if Microsoft says to do this - uiDrawMatrixMultiply(&temp, &already); - m2d(&temp, &dm); - ID2D1RenderTarget_SetTransform(c->rt, &dm); -}