diff options
author | Chia-I Wu <olv@lunarg.com> | 2010-12-01 02:30:59 +0800 |
---|---|---|
committer | Chia-I Wu <olv@lunarg.com> | 2010-12-01 11:31:00 +0800 |
commit | b06de80843e7d096bed4ae03ddc5e2842f1876af (patch) | |
tree | 37fd7f50f92ed6822282a64a9b47c32648120667 /src/gallium/state_trackers/vega/vg_context.c | |
parent | ca8bc9c05b2126e949425dc967923c27f62ef378 (diff) |
st/vega: Fix paint coordinates transformations.
Depending on whether vgDrawPath(mode), vgDrawImage, or vgDrawGlyph[s] is
called, different paint-to-user and user-to-surface matrices should be
used to derive the sample points for the paint.
This fixes "paint" demo.
Diffstat (limited to 'src/gallium/state_trackers/vega/vg_context.c')
-rw-r--r-- | src/gallium/state_trackers/vega/vg_context.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/gallium/state_trackers/vega/vg_context.c b/src/gallium/state_trackers/vega/vg_context.c index 4d088b965d..65adadd1fe 100644 --- a/src/gallium/state_trackers/vega/vg_context.c +++ b/src/gallium/state_trackers/vega/vg_context.c @@ -509,3 +509,28 @@ void vg_prepare_blend_surface_from_mask(struct vg_context *ctx) if (dest_surface) pipe_surface_reference(&dest_surface, NULL); } + +/** + * A transformation from window coordinates to paint coordinates. + */ +VGboolean vg_get_paint_matrix(struct vg_context *ctx, + const struct matrix *paint_to_user, + const struct matrix *user_to_surface, + struct matrix *mat) +{ + struct matrix tmp; + + /* get user-to-paint matrix */ + memcpy(mat, paint_to_user, sizeof(*paint_to_user)); + if (!matrix_invert(mat)) + return VG_FALSE; + + /* get surface-to-user matrix */ + memcpy(&tmp, user_to_surface, sizeof(*user_to_surface)); + if (!matrix_invert(&tmp)) + return VG_FALSE; + + matrix_mult(mat, &tmp); + + return VG_TRUE; +} |