summaryrefslogtreecommitdiff
path: root/src/gallium/state_trackers/vega/shader.c
diff options
context:
space:
mode:
authorChia-I Wu <olv@lunarg.com>2010-12-01 02:30:59 +0800
committerChia-I Wu <olv@lunarg.com>2010-12-01 11:31:00 +0800
commitb06de80843e7d096bed4ae03ddc5e2842f1876af (patch)
tree37fd7f50f92ed6822282a64a9b47c32648120667 /src/gallium/state_trackers/vega/shader.c
parentca8bc9c05b2126e949425dc967923c27f62ef378 (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/shader.c')
-rw-r--r--src/gallium/state_trackers/vega/shader.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/gallium/state_trackers/vega/shader.c b/src/gallium/state_trackers/vega/shader.c
index 39c4bb0dfd..a77587c6bf 100644
--- a/src/gallium/state_trackers/vega/shader.c
+++ b/src/gallium/state_trackers/vega/shader.c
@@ -50,6 +50,8 @@ struct shader {
struct vg_paint *paint;
struct vg_image *image;
+ struct matrix paint_matrix;
+
VGboolean drawing_image;
VGImageMode image_mode;
@@ -119,7 +121,8 @@ static VGint setup_constant_buffer(struct shader *shader)
memset(shader->constants, 0, sizeof(VGfloat) * 8);
}
- paint_fill_constant_buffer(shader->paint, shader->constants + 8);
+ paint_fill_constant_buffer(shader->paint,
+ &shader->paint_matrix, shader->constants + 8);
return param_bytes;
}
@@ -324,3 +327,19 @@ void shader_set_image(struct shader *shader, struct vg_image *img)
{
shader->image = img;
}
+
+/**
+ * Set the transformation to map a pixel to the paint coordinates.
+ */
+void shader_set_paint_matrix(struct shader *shader, const struct matrix *mat)
+{
+ const struct st_framebuffer *stfb = shader->context->draw_buffer;
+ const VGfloat px_center_offset = 0.5f;
+
+ memcpy(&shader->paint_matrix, mat, sizeof(*mat));
+
+ /* make it window-to-paint for the shaders */
+ matrix_translate(&shader->paint_matrix, px_center_offset,
+ stfb->height - 1.0f + px_center_offset);
+ matrix_scale(&shader->paint_matrix, 1.0f, -1.0f);
+}