diff options
author | Jason Ekstrand <jason@jlekstrand.net> | 2014-05-21 13:23:04 -0500 |
---|---|---|
committer | Jason Ekstrand <jason.ekstrand@intel.com> | 2014-06-20 17:08:44 -0700 |
commit | 450c872f4ec3362d977b897a5c98f96aca613a80 (patch) | |
tree | b9a173e507190b3bf02361d0eae66ab9568c4ce7 | |
parent | e0981160b28b02991f3b216dbb66938c24b843e2 (diff) |
pixman-renderer: Use output->matrix for region transformations and enablewip/transforms
output zoom
-rw-r--r-- | src/pixman-renderer.c | 69 |
1 files changed, 60 insertions, 9 deletions
diff --git a/src/pixman-renderer.c b/src/pixman-renderer.c index 10c80fe3..93a9a804 100644 --- a/src/pixman-renderer.c +++ b/src/pixman-renderer.c @@ -128,12 +128,68 @@ pixman_renderer_read_pixels(struct weston_output *output, } static void +weston_matrix_transform_region(pixman_region32_t *dest, + struct weston_matrix *matrix, + pixman_region32_t *src) +{ + pixman_box32_t *src_rects, *dest_rects; + int nrects, i; + + src_rects = pixman_region32_rectangles(src, &nrects); + dest_rects = malloc(nrects * sizeof(*dest_rects)); + if (!dest_rects) + return; + + for (i = 0; i < nrects; i++) { + struct weston_vector vec1 = {{ + src_rects[i].x1, src_rects[i].y1, 0, 1 + }}; + weston_matrix_transform(matrix, &vec1); + vec1.f[0] /= vec1.f[3]; + vec1.f[1] /= vec1.f[3]; + + struct weston_vector vec2 = {{ + src_rects[i].x2, src_rects[i].y2, 0, 1 + }}; + weston_matrix_transform(matrix, &vec2); + vec2.f[0] /= vec2.f[3]; + vec2.f[1] /= vec2.f[3]; + + if (vec1.f[0] < vec2.f[0]) { + dest_rects[i].x1 = floor(vec1.f[0]); + dest_rects[i].x2 = ceil(vec2.f[0]); + } else { + dest_rects[i].x1 = floor(vec2.f[0]); + dest_rects[i].x2 = ceil(vec1.f[0]); + } + + + if (vec1.f[1] < vec2.f[1]) { + dest_rects[i].y1 = floor(vec1.f[1]); + dest_rects[i].y2 = ceil(vec2.f[1]); + } else { + dest_rects[i].y1 = floor(vec2.f[1]); + dest_rects[i].y2 = ceil(vec1.f[1]); + } + } + + pixman_region32_clear(dest); + pixman_region32_init_rects(dest, dest_rects, nrects); + free(dest_rects); +} + +static void region_global_to_output(struct weston_output *output, pixman_region32_t *region) { - pixman_region32_translate(region, -output->x, -output->y); - weston_transformed_region(output->width, output->height, - output->transform, output->current_scale, - region, region); + if (output->zoom.active) { + weston_matrix_transform_region(region, &output->matrix, region); + } else { + pixman_region32_translate(region, -output->x, -output->y); + weston_transformed_region(output->width, output->height, + output->transform, + output->current_scale, + region, region); + } } #define D2F(v) pixman_double_to_fixed((double)v) @@ -288,11 +344,6 @@ draw_view(struct weston_view *ev, struct weston_output *output, if (!pixman_region32_not_empty(&repaint)) goto out; - if (output->zoom.active) { - weston_log("pixman renderer does not support zoom\n"); - goto out; - } - /* TODO: Implement repaint_region_complex() using pixman_composite_trapezoids() */ if (ev->alpha != 1.0 || (ev->transform.enabled && |