Vasily Khoruzhick | 71c2dd3 | 2013-01-07 20:39:49 +0300 | [diff] [blame] | 1 | /* |
| 2 | * Copyright © 2012 Intel Corporation |
| 3 | * Copyright © 2013 Vasily Khoruzhick <anarsoul@gmail.com> |
Pekka Paalanen | 6764bbe | 2015-02-11 12:29:56 +0200 | [diff] [blame] | 4 | * Copyright © 2015 Collabora, Ltd. |
Vasily Khoruzhick | 71c2dd3 | 2013-01-07 20:39:49 +0300 | [diff] [blame] | 5 | * |
Bryce Harrington | a0bbfea | 2015-06-11 15:35:43 -0700 | [diff] [blame] | 6 | * Permission is hereby granted, free of charge, to any person obtaining |
| 7 | * a copy of this software and associated documentation files (the |
| 8 | * "Software"), to deal in the Software without restriction, including |
| 9 | * without limitation the rights to use, copy, modify, merge, publish, |
| 10 | * distribute, sublicense, and/or sell copies of the Software, and to |
| 11 | * permit persons to whom the Software is furnished to do so, subject to |
| 12 | * the following conditions: |
Vasily Khoruzhick | 71c2dd3 | 2013-01-07 20:39:49 +0300 | [diff] [blame] | 13 | * |
Bryce Harrington | a0bbfea | 2015-06-11 15:35:43 -0700 | [diff] [blame] | 14 | * The above copyright notice and this permission notice (including the |
| 15 | * next paragraph) shall be included in all copies or substantial |
| 16 | * portions of the Software. |
| 17 | * |
| 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 20 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| 21 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS |
| 22 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN |
| 23 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
| 24 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 25 | * SOFTWARE. |
Vasily Khoruzhick | 71c2dd3 | 2013-01-07 20:39:49 +0300 | [diff] [blame] | 26 | */ |
| 27 | |
Daniel Stone | c228e23 | 2013-05-22 18:03:19 +0300 | [diff] [blame] | 28 | #include "config.h" |
Vasily Khoruzhick | 71c2dd3 | 2013-01-07 20:39:49 +0300 | [diff] [blame] | 29 | |
| 30 | #include <errno.h> |
Jussi Kukkonen | 649bbce | 2016-07-19 14:16:27 +0300 | [diff] [blame] | 31 | #include <stdint.h> |
Vasily Khoruzhick | 71c2dd3 | 2013-01-07 20:39:49 +0300 | [diff] [blame] | 32 | #include <stdlib.h> |
Pekka Paalanen | f75b6bb | 2015-03-04 16:12:04 +0200 | [diff] [blame] | 33 | #include <assert.h> |
Vasily Khoruzhick | 71c2dd3 | 2013-01-07 20:39:49 +0300 | [diff] [blame] | 34 | |
| 35 | #include "pixman-renderer.h" |
Jon Cruz | 867d50e | 2015-06-15 15:37:10 -0700 | [diff] [blame] | 36 | #include "shared/helpers.h" |
Vasily Khoruzhick | 71c2dd3 | 2013-01-07 20:39:49 +0300 | [diff] [blame] | 37 | |
Ander Conselvan de Oliveira | 8792ef1 | 2013-01-25 15:13:00 +0200 | [diff] [blame] | 38 | #include <linux/input.h> |
| 39 | |
Vasily Khoruzhick | 71c2dd3 | 2013-01-07 20:39:49 +0300 | [diff] [blame] | 40 | struct pixman_output_state { |
Ander Conselvan de Oliveira | 936effd | 2013-01-25 15:13:01 +0200 | [diff] [blame] | 41 | void *shadow_buffer; |
| 42 | pixman_image_t *shadow_image; |
Vasily Khoruzhick | 71c2dd3 | 2013-01-07 20:39:49 +0300 | [diff] [blame] | 43 | pixman_image_t *hw_buffer; |
Pekka Paalanen | acf50c3 | 2018-04-23 11:44:56 +0200 | [diff] [blame] | 44 | pixman_region32_t *hw_extra_damage; |
Vasily Khoruzhick | 71c2dd3 | 2013-01-07 20:39:49 +0300 | [diff] [blame] | 45 | }; |
| 46 | |
| 47 | struct pixman_surface_state { |
Ander Conselvan de Oliveira | aa398ae | 2013-10-25 16:26:33 +0300 | [diff] [blame] | 48 | struct weston_surface *surface; |
| 49 | |
Vasily Khoruzhick | 71c2dd3 | 2013-01-07 20:39:49 +0300 | [diff] [blame] | 50 | pixman_image_t *image; |
| 51 | struct weston_buffer_reference buffer_ref; |
Alexandros Frantzis | 6762967 | 2018-10-19 12:14:11 +0300 | [diff] [blame] | 52 | struct weston_buffer_release_reference buffer_release_ref; |
Ander Conselvan de Oliveira | aa398ae | 2013-10-25 16:26:33 +0300 | [diff] [blame] | 53 | |
Lubomir Rintel | ddc2b1e | 2013-12-12 12:57:56 +0100 | [diff] [blame] | 54 | struct wl_listener buffer_destroy_listener; |
Ander Conselvan de Oliveira | aa398ae | 2013-10-25 16:26:33 +0300 | [diff] [blame] | 55 | struct wl_listener surface_destroy_listener; |
Ander Conselvan de Oliveira | adda00e | 2013-10-25 16:26:34 +0300 | [diff] [blame] | 56 | struct wl_listener renderer_destroy_listener; |
Vasily Khoruzhick | 71c2dd3 | 2013-01-07 20:39:49 +0300 | [diff] [blame] | 57 | }; |
| 58 | |
| 59 | struct pixman_renderer { |
| 60 | struct weston_renderer base; |
Ander Conselvan de Oliveira | 6b16214 | 2013-10-25 16:26:32 +0300 | [diff] [blame] | 61 | |
Ander Conselvan de Oliveira | 8792ef1 | 2013-01-25 15:13:00 +0200 | [diff] [blame] | 62 | int repaint_debug; |
| 63 | pixman_image_t *debug_color; |
Ander Conselvan de Oliveira | 6b16214 | 2013-10-25 16:26:32 +0300 | [diff] [blame] | 64 | struct weston_binding *debug_binding; |
Ander Conselvan de Oliveira | adda00e | 2013-10-25 16:26:34 +0300 | [diff] [blame] | 65 | |
| 66 | struct wl_signal destroy_signal; |
Vasily Khoruzhick | 71c2dd3 | 2013-01-07 20:39:49 +0300 | [diff] [blame] | 67 | }; |
| 68 | |
| 69 | static inline struct pixman_output_state * |
| 70 | get_output_state(struct weston_output *output) |
| 71 | { |
| 72 | return (struct pixman_output_state *)output->renderer_state; |
| 73 | } |
| 74 | |
Ander Conselvan de Oliveira | aa398ae | 2013-10-25 16:26:33 +0300 | [diff] [blame] | 75 | static int |
| 76 | pixman_renderer_create_surface(struct weston_surface *surface); |
| 77 | |
Vasily Khoruzhick | 71c2dd3 | 2013-01-07 20:39:49 +0300 | [diff] [blame] | 78 | static inline struct pixman_surface_state * |
| 79 | get_surface_state(struct weston_surface *surface) |
| 80 | { |
Ander Conselvan de Oliveira | aa398ae | 2013-10-25 16:26:33 +0300 | [diff] [blame] | 81 | if (!surface->renderer_state) |
| 82 | pixman_renderer_create_surface(surface); |
| 83 | |
Vasily Khoruzhick | 71c2dd3 | 2013-01-07 20:39:49 +0300 | [diff] [blame] | 84 | return (struct pixman_surface_state *)surface->renderer_state; |
| 85 | } |
| 86 | |
| 87 | static inline struct pixman_renderer * |
| 88 | get_renderer(struct weston_compositor *ec) |
| 89 | { |
| 90 | return (struct pixman_renderer *)ec->renderer; |
| 91 | } |
| 92 | |
| 93 | static int |
| 94 | pixman_renderer_read_pixels(struct weston_output *output, |
| 95 | pixman_format_code_t format, void *pixels, |
| 96 | uint32_t x, uint32_t y, |
| 97 | uint32_t width, uint32_t height) |
| 98 | { |
| 99 | struct pixman_output_state *po = get_output_state(output); |
| 100 | pixman_image_t *out_buf; |
Vasily Khoruzhick | 71c2dd3 | 2013-01-07 20:39:49 +0300 | [diff] [blame] | 101 | |
| 102 | if (!po->hw_buffer) { |
| 103 | errno = ENODEV; |
| 104 | return -1; |
| 105 | } |
| 106 | |
| 107 | out_buf = pixman_image_create_bits(format, |
| 108 | width, |
| 109 | height, |
| 110 | pixels, |
| 111 | (PIXMAN_FORMAT_BPP(format) / 8) * width); |
| 112 | |
Alexander Larsson | 97af792 | 2013-05-29 12:01:33 +0200 | [diff] [blame] | 113 | pixman_image_composite32(PIXMAN_OP_SRC, |
| 114 | po->hw_buffer, /* src */ |
| 115 | NULL /* mask */, |
| 116 | out_buf, /* dest */ |
Stefan Agner | da2e574 | 2019-06-16 23:28:15 +0200 | [diff] [blame] | 117 | x, y, /* src_x, src_y */ |
Alexander Larsson | 97af792 | 2013-05-29 12:01:33 +0200 | [diff] [blame] | 118 | 0, 0, /* mask_x, mask_y */ |
| 119 | 0, 0, /* dest_x, dest_y */ |
| 120 | pixman_image_get_width (po->hw_buffer), /* width */ |
| 121 | pixman_image_get_height (po->hw_buffer) /* height */); |
Vasily Khoruzhick | 71c2dd3 | 2013-01-07 20:39:49 +0300 | [diff] [blame] | 122 | |
| 123 | pixman_image_unref(out_buf); |
| 124 | |
| 125 | return 0; |
| 126 | } |
| 127 | |
Vasily Khoruzhick | f4a457f | 2013-01-28 22:40:29 +0300 | [diff] [blame] | 128 | #define D2F(v) pixman_double_to_fixed((double)v) |
| 129 | |
Vasily Khoruzhick | 71c2dd3 | 2013-01-07 20:39:49 +0300 | [diff] [blame] | 130 | static void |
Jason Ekstrand | 8870a23 | 2014-05-20 15:53:19 -0500 | [diff] [blame] | 131 | weston_matrix_to_pixman_transform(pixman_transform_t *pt, |
| 132 | const struct weston_matrix *wm) |
Pekka Paalanen | 0b4c535 | 2014-03-14 14:38:17 +0200 | [diff] [blame] | 133 | { |
Jason Ekstrand | 8870a23 | 2014-05-20 15:53:19 -0500 | [diff] [blame] | 134 | /* Pixman supports only 2D transform matrix, but Weston uses 3D, * |
| 135 | * so we're omitting Z coordinate here. */ |
| 136 | pt->matrix[0][0] = pixman_double_to_fixed(wm->d[0]); |
| 137 | pt->matrix[0][1] = pixman_double_to_fixed(wm->d[4]); |
| 138 | pt->matrix[0][2] = pixman_double_to_fixed(wm->d[12]); |
| 139 | pt->matrix[1][0] = pixman_double_to_fixed(wm->d[1]); |
| 140 | pt->matrix[1][1] = pixman_double_to_fixed(wm->d[5]); |
| 141 | pt->matrix[1][2] = pixman_double_to_fixed(wm->d[13]); |
| 142 | pt->matrix[2][0] = pixman_double_to_fixed(wm->d[3]); |
| 143 | pt->matrix[2][1] = pixman_double_to_fixed(wm->d[7]); |
| 144 | pt->matrix[2][2] = pixman_double_to_fixed(wm->d[15]); |
Pekka Paalanen | 0b4c535 | 2014-03-14 14:38:17 +0200 | [diff] [blame] | 145 | } |
| 146 | |
| 147 | static void |
Pekka Paalanen | 6ea523b | 2015-03-04 14:18:39 +0200 | [diff] [blame] | 148 | pixman_renderer_compute_transform(pixman_transform_t *transform_out, |
| 149 | struct weston_view *ev, |
| 150 | struct weston_output *output) |
| 151 | { |
| 152 | struct weston_matrix matrix; |
| 153 | |
| 154 | /* Set up the source transformation based on the surface |
| 155 | position, the output position/transform/scale and the client |
| 156 | specified buffer transform/scale */ |
Derek Foreman | a5855ad | 2015-03-24 11:36:16 -0500 | [diff] [blame] | 157 | matrix = output->inverse_matrix; |
Pekka Paalanen | 6ea523b | 2015-03-04 14:18:39 +0200 | [diff] [blame] | 158 | |
| 159 | if (ev->transform.enabled) { |
| 160 | weston_matrix_multiply(&matrix, &ev->transform.inverse); |
| 161 | } else { |
| 162 | weston_matrix_translate(&matrix, |
| 163 | -ev->geometry.x, -ev->geometry.y, 0); |
| 164 | } |
| 165 | |
| 166 | weston_matrix_multiply(&matrix, &ev->surface->surface_to_buffer_matrix); |
| 167 | |
| 168 | weston_matrix_to_pixman_transform(transform_out, &matrix); |
| 169 | } |
| 170 | |
Pekka Paalanen | 23d4af5 | 2015-03-04 16:18:26 +0200 | [diff] [blame] | 171 | static bool |
| 172 | view_transformation_is_translation(struct weston_view *view) |
| 173 | { |
| 174 | if (!view->transform.enabled) |
| 175 | return true; |
| 176 | |
| 177 | if (view->transform.matrix.type <= WESTON_MATRIX_TRANSFORM_TRANSLATE) |
| 178 | return true; |
| 179 | |
| 180 | return false; |
| 181 | } |
| 182 | |
Pekka Paalanen | 6ea523b | 2015-03-04 14:18:39 +0200 | [diff] [blame] | 183 | static void |
Pekka Paalanen | f75b6bb | 2015-03-04 16:12:04 +0200 | [diff] [blame] | 184 | region_intersect_only_translation(pixman_region32_t *result_global, |
| 185 | pixman_region32_t *global, |
| 186 | pixman_region32_t *surf, |
| 187 | struct weston_view *view) |
| 188 | { |
| 189 | float view_x, view_y; |
| 190 | |
| 191 | assert(view_transformation_is_translation(view)); |
| 192 | |
| 193 | /* Convert from surface to global coordinates */ |
| 194 | pixman_region32_copy(result_global, surf); |
| 195 | weston_view_to_global_float(view, 0, 0, &view_x, &view_y); |
| 196 | pixman_region32_translate(result_global, (int)view_x, (int)view_y); |
| 197 | |
| 198 | pixman_region32_intersect(result_global, result_global, global); |
| 199 | } |
| 200 | |
Pekka Paalanen | d7ca6b0 | 2015-03-05 13:25:19 +0200 | [diff] [blame] | 201 | static void |
| 202 | composite_whole(pixman_op_t op, |
| 203 | pixman_image_t *src, |
| 204 | pixman_image_t *mask, |
| 205 | pixman_image_t *dest, |
| 206 | const pixman_transform_t *transform, |
| 207 | pixman_filter_t filter) |
| 208 | { |
| 209 | int32_t dest_width; |
| 210 | int32_t dest_height; |
| 211 | |
| 212 | dest_width = pixman_image_get_width(dest); |
| 213 | dest_height = pixman_image_get_height(dest); |
| 214 | |
| 215 | pixman_image_set_transform(src, transform); |
| 216 | pixman_image_set_filter(src, filter, NULL, 0); |
| 217 | |
Pekka Paalanen | 9f53edd | 2020-03-11 15:21:04 +0200 | [diff] [blame] | 218 | /* bilinear filtering needs the equivalent of OpenGL CLAMP_TO_EDGE */ |
| 219 | if (filter == PIXMAN_FILTER_NEAREST) |
| 220 | pixman_image_set_repeat(src, PIXMAN_REPEAT_NONE); |
| 221 | else |
| 222 | pixman_image_set_repeat(src, PIXMAN_REPEAT_PAD); |
| 223 | |
Pekka Paalanen | d7ca6b0 | 2015-03-05 13:25:19 +0200 | [diff] [blame] | 224 | pixman_image_composite32(op, src, mask, dest, |
| 225 | 0, 0, /* src_x, src_y */ |
| 226 | 0, 0, /* mask_x, mask_y */ |
| 227 | 0, 0, /* dest_x, dest_y */ |
| 228 | dest_width, dest_height); |
| 229 | } |
| 230 | |
| 231 | static void |
| 232 | composite_clipped(pixman_image_t *src, |
| 233 | pixman_image_t *mask, |
| 234 | pixman_image_t *dest, |
| 235 | const pixman_transform_t *transform, |
| 236 | pixman_filter_t filter, |
| 237 | pixman_region32_t *src_clip) |
| 238 | { |
| 239 | int n_box; |
| 240 | pixman_box32_t *boxes; |
| 241 | int32_t dest_width; |
| 242 | int32_t dest_height; |
| 243 | int src_stride; |
| 244 | int bitspp; |
| 245 | pixman_format_code_t src_format; |
| 246 | void *src_data; |
| 247 | int i; |
| 248 | |
Pekka Paalanen | 9f53edd | 2020-03-11 15:21:04 +0200 | [diff] [blame] | 249 | /* |
| 250 | * Hardcoded to use PIXMAN_OP_OVER, because sampling outside of |
Pekka Paalanen | d7ca6b0 | 2015-03-05 13:25:19 +0200 | [diff] [blame] | 251 | * a Pixman image produces (0,0,0,0) instead of discarding the |
| 252 | * fragment. |
Pekka Paalanen | 9f53edd | 2020-03-11 15:21:04 +0200 | [diff] [blame] | 253 | * |
| 254 | * Also repeat mode must be PIXMAN_REPEAT_NONE (the default) to |
| 255 | * actually sample (0,0,0,0). This may cause issues for clients that |
| 256 | * expect OpenGL CLAMP_TO_EDGE sampling behavior on their buffer. |
| 257 | * Using temporary 'boximg' it is not possible to apply CLAMP_TO_EDGE |
| 258 | * correctly with bilinear filter. Maybe trapezoid rendering could be |
| 259 | * the answer instead of source clip? |
Pekka Paalanen | d7ca6b0 | 2015-03-05 13:25:19 +0200 | [diff] [blame] | 260 | */ |
| 261 | |
| 262 | dest_width = pixman_image_get_width(dest); |
| 263 | dest_height = pixman_image_get_height(dest); |
| 264 | src_format = pixman_image_get_format(src); |
| 265 | src_stride = pixman_image_get_stride(src); |
| 266 | bitspp = PIXMAN_FORMAT_BPP(src_format); |
| 267 | src_data = pixman_image_get_data(src); |
| 268 | |
| 269 | assert(src_format); |
| 270 | |
| 271 | /* This would be massive overdraw, except when n_box is 1. */ |
| 272 | boxes = pixman_region32_rectangles(src_clip, &n_box); |
| 273 | for (i = 0; i < n_box; i++) { |
| 274 | uint8_t *ptr = src_data; |
| 275 | pixman_image_t *boximg; |
| 276 | pixman_transform_t adj = *transform; |
| 277 | |
| 278 | ptr += boxes[i].y1 * src_stride; |
| 279 | ptr += boxes[i].x1 * bitspp / 8; |
| 280 | boximg = pixman_image_create_bits_no_clear(src_format, |
| 281 | boxes[i].x2 - boxes[i].x1, |
| 282 | boxes[i].y2 - boxes[i].y1, |
| 283 | (uint32_t *)ptr, src_stride); |
| 284 | |
| 285 | pixman_transform_translate(&adj, NULL, |
| 286 | pixman_int_to_fixed(-boxes[i].x1), |
| 287 | pixman_int_to_fixed(-boxes[i].y1)); |
| 288 | pixman_image_set_transform(boximg, &adj); |
| 289 | |
| 290 | pixman_image_set_filter(boximg, filter, NULL, 0); |
| 291 | pixman_image_composite32(PIXMAN_OP_OVER, boximg, mask, dest, |
| 292 | 0, 0, /* src_x, src_y */ |
| 293 | 0, 0, /* mask_x, mask_y */ |
| 294 | 0, 0, /* dest_x, dest_y */ |
| 295 | dest_width, dest_height); |
| 296 | |
| 297 | pixman_image_unref(boximg); |
| 298 | } |
| 299 | |
| 300 | if (n_box > 1) { |
| 301 | static bool warned = false; |
| 302 | |
| 303 | if (!warned) |
| 304 | weston_log("Pixman-renderer warning: %dx overdraw\n", |
| 305 | n_box); |
| 306 | warned = true; |
| 307 | } |
| 308 | } |
| 309 | |
Pekka Paalanen | 11af0d9 | 2015-03-05 11:56:29 +0200 | [diff] [blame] | 310 | /** Paint an intersected region |
| 311 | * |
| 312 | * \param ev The view to be painted. |
| 313 | * \param output The output being painted. |
| 314 | * \param repaint_output The region to be painted in output coordinates. |
Pekka Paalanen | d7ca6b0 | 2015-03-05 13:25:19 +0200 | [diff] [blame] | 315 | * \param source_clip The region of the source image to use, in source image |
| 316 | * coordinates. If NULL, use the whole source image. |
Pekka Paalanen | 11af0d9 | 2015-03-05 11:56:29 +0200 | [diff] [blame] | 317 | * \param pixman_op Compositing operator, either SRC or OVER. |
| 318 | */ |
Pekka Paalanen | f75b6bb | 2015-03-04 16:12:04 +0200 | [diff] [blame] | 319 | static void |
Jason Ekstrand | a7af704 | 2013-10-12 22:38:11 -0500 | [diff] [blame] | 320 | repaint_region(struct weston_view *ev, struct weston_output *output, |
Pekka Paalanen | 11af0d9 | 2015-03-05 11:56:29 +0200 | [diff] [blame] | 321 | pixman_region32_t *repaint_output, |
Pekka Paalanen | d7ca6b0 | 2015-03-05 13:25:19 +0200 | [diff] [blame] | 322 | pixman_region32_t *source_clip, |
Alexander Larsson | 1f206b4 | 2013-05-22 14:41:36 +0200 | [diff] [blame] | 323 | pixman_op_t pixman_op) |
Vasily Khoruzhick | 71c2dd3 | 2013-01-07 20:39:49 +0300 | [diff] [blame] | 324 | { |
Ander Conselvan de Oliveira | 8792ef1 | 2013-01-25 15:13:00 +0200 | [diff] [blame] | 325 | struct pixman_renderer *pr = |
| 326 | (struct pixman_renderer *) output->compositor->renderer; |
Jason Ekstrand | a7af704 | 2013-10-12 22:38:11 -0500 | [diff] [blame] | 327 | struct pixman_surface_state *ps = get_surface_state(ev->surface); |
Vasily Khoruzhick | 71c2dd3 | 2013-01-07 20:39:49 +0300 | [diff] [blame] | 328 | struct pixman_output_state *po = get_output_state(output); |
Pekka Paalanen | 952b6c8 | 2014-03-14 14:38:15 +0200 | [diff] [blame] | 329 | struct weston_buffer_viewport *vp = &ev->surface->buffer_viewport; |
Pekka Paalanen | 26ded94 | 2018-04-23 11:44:57 +0200 | [diff] [blame] | 330 | pixman_image_t *target_image; |
Alexander Larsson | 1f206b4 | 2013-05-22 14:41:36 +0200 | [diff] [blame] | 331 | pixman_transform_t transform; |
Pekka Paalanen | d7ca6b0 | 2015-03-05 13:25:19 +0200 | [diff] [blame] | 332 | pixman_filter_t filter; |
Manuel Bachmann | 9c4ab66 | 2014-04-07 11:58:45 +0200 | [diff] [blame] | 333 | pixman_image_t *mask_image; |
| 334 | pixman_color_t mask = { 0, }; |
Vasily Khoruzhick | 71c2dd3 | 2013-01-07 20:39:49 +0300 | [diff] [blame] | 335 | |
Pekka Paalanen | 26ded94 | 2018-04-23 11:44:57 +0200 | [diff] [blame] | 336 | if (po->shadow_image) |
| 337 | target_image = po->shadow_image; |
| 338 | else |
| 339 | target_image = po->hw_buffer; |
| 340 | |
| 341 | /* Clip rendering to the damaged output region */ |
| 342 | pixman_image_set_clip_region32(target_image, repaint_output); |
Ander Conselvan de Oliveira | 8792ef1 | 2013-01-25 15:13:00 +0200 | [diff] [blame] | 343 | |
Pekka Paalanen | 6ea523b | 2015-03-04 14:18:39 +0200 | [diff] [blame] | 344 | pixman_renderer_compute_transform(&transform, ev, output); |
Alexander Larsson | 1f206b4 | 2013-05-22 14:41:36 +0200 | [diff] [blame] | 345 | |
Pekka Paalanen | 952b6c8 | 2014-03-14 14:38:15 +0200 | [diff] [blame] | 346 | if (ev->transform.enabled || output->current_scale != vp->buffer.scale) |
Pekka Paalanen | d7ca6b0 | 2015-03-05 13:25:19 +0200 | [diff] [blame] | 347 | filter = PIXMAN_FILTER_BILINEAR; |
Alexander Larsson | 1f206b4 | 2013-05-22 14:41:36 +0200 | [diff] [blame] | 348 | else |
Pekka Paalanen | d7ca6b0 | 2015-03-05 13:25:19 +0200 | [diff] [blame] | 349 | filter = PIXMAN_FILTER_NEAREST; |
Alexander Larsson | 1f206b4 | 2013-05-22 14:41:36 +0200 | [diff] [blame] | 350 | |
Neil Roberts | e505171 | 2013-11-13 15:44:06 +0000 | [diff] [blame] | 351 | if (ps->buffer_ref.buffer) |
| 352 | wl_shm_buffer_begin_access(ps->buffer_ref.buffer->shm_buffer); |
| 353 | |
Manuel Bachmann | b1fff41 | 2014-04-05 05:31:37 +0200 | [diff] [blame] | 354 | if (ev->alpha < 1.0) { |
Manuel Bachmann | 9c4ab66 | 2014-04-07 11:58:45 +0200 | [diff] [blame] | 355 | mask.alpha = 0xffff * ev->alpha; |
Manuel Bachmann | b1fff41 | 2014-04-05 05:31:37 +0200 | [diff] [blame] | 356 | mask_image = pixman_image_create_solid_fill(&mask); |
Manuel Bachmann | 9c4ab66 | 2014-04-07 11:58:45 +0200 | [diff] [blame] | 357 | } else { |
Manuel Bachmann | b1fff41 | 2014-04-05 05:31:37 +0200 | [diff] [blame] | 358 | mask_image = NULL; |
Manuel Bachmann | 9c4ab66 | 2014-04-07 11:58:45 +0200 | [diff] [blame] | 359 | } |
Manuel Bachmann | b1fff41 | 2014-04-05 05:31:37 +0200 | [diff] [blame] | 360 | |
Pekka Paalanen | d7ca6b0 | 2015-03-05 13:25:19 +0200 | [diff] [blame] | 361 | if (source_clip) |
Pekka Paalanen | 26ded94 | 2018-04-23 11:44:57 +0200 | [diff] [blame] | 362 | composite_clipped(ps->image, mask_image, target_image, |
Pekka Paalanen | d7ca6b0 | 2015-03-05 13:25:19 +0200 | [diff] [blame] | 363 | &transform, filter, source_clip); |
| 364 | else |
| 365 | composite_whole(pixman_op, ps->image, mask_image, |
Pekka Paalanen | 26ded94 | 2018-04-23 11:44:57 +0200 | [diff] [blame] | 366 | target_image, &transform, filter); |
Alexander Larsson | 1f206b4 | 2013-05-22 14:41:36 +0200 | [diff] [blame] | 367 | |
Manuel Bachmann | 9c4ab66 | 2014-04-07 11:58:45 +0200 | [diff] [blame] | 368 | if (mask_image) |
| 369 | pixman_image_unref(mask_image); |
| 370 | |
Neil Roberts | e505171 | 2013-11-13 15:44:06 +0000 | [diff] [blame] | 371 | if (ps->buffer_ref.buffer) |
| 372 | wl_shm_buffer_end_access(ps->buffer_ref.buffer->shm_buffer); |
| 373 | |
Alexander Larsson | 1f206b4 | 2013-05-22 14:41:36 +0200 | [diff] [blame] | 374 | if (pr->repaint_debug) |
Ander Conselvan de Oliveira | 8792ef1 | 2013-01-25 15:13:00 +0200 | [diff] [blame] | 375 | pixman_image_composite32(PIXMAN_OP_OVER, |
Alexander Larsson | 1f206b4 | 2013-05-22 14:41:36 +0200 | [diff] [blame] | 376 | pr->debug_color, /* src */ |
| 377 | NULL /* mask */, |
Pekka Paalanen | 26ded94 | 2018-04-23 11:44:57 +0200 | [diff] [blame] | 378 | target_image, /* dest */ |
Alexander Larsson | 1f206b4 | 2013-05-22 14:41:36 +0200 | [diff] [blame] | 379 | 0, 0, /* src_x, src_y */ |
| 380 | 0, 0, /* mask_x, mask_y */ |
| 381 | 0, 0, /* dest_x, dest_y */ |
Pekka Paalanen | 26ded94 | 2018-04-23 11:44:57 +0200 | [diff] [blame] | 382 | pixman_image_get_width (target_image), /* width */ |
| 383 | pixman_image_get_height (target_image) /* height */); |
Alexander Larsson | 1f206b4 | 2013-05-22 14:41:36 +0200 | [diff] [blame] | 384 | |
Pekka Paalanen | 26ded94 | 2018-04-23 11:44:57 +0200 | [diff] [blame] | 385 | pixman_image_set_clip_region32(target_image, NULL); |
Vasily Khoruzhick | 71c2dd3 | 2013-01-07 20:39:49 +0300 | [diff] [blame] | 386 | } |
| 387 | |
| 388 | static void |
Pekka Paalanen | ccf99ce | 2015-03-05 12:57:35 +0200 | [diff] [blame] | 389 | draw_view_translated(struct weston_view *view, struct weston_output *output, |
| 390 | pixman_region32_t *repaint_global) |
| 391 | { |
| 392 | struct weston_surface *surface = view->surface; |
| 393 | /* non-opaque region in surface coordinates: */ |
| 394 | pixman_region32_t surface_blend; |
| 395 | /* region to be painted in output coordinates: */ |
| 396 | pixman_region32_t repaint_output; |
| 397 | |
| 398 | pixman_region32_init(&repaint_output); |
| 399 | |
| 400 | /* Blended region is whole surface minus opaque region, |
| 401 | * unless surface alpha forces us to blend all. |
| 402 | */ |
| 403 | pixman_region32_init_rect(&surface_blend, 0, 0, |
| 404 | surface->width, surface->height); |
| 405 | |
| 406 | if (!(view->alpha < 1.0)) { |
| 407 | pixman_region32_subtract(&surface_blend, &surface_blend, |
| 408 | &surface->opaque); |
| 409 | |
| 410 | if (pixman_region32_not_empty(&surface->opaque)) { |
| 411 | region_intersect_only_translation(&repaint_output, |
| 412 | repaint_global, |
| 413 | &surface->opaque, |
| 414 | view); |
Pekka Paalanen | 0692079 | 2020-12-08 15:22:36 +0200 | [diff] [blame^] | 415 | weston_output_region_from_global(output, |
| 416 | &repaint_output); |
Pekka Paalanen | ccf99ce | 2015-03-05 12:57:35 +0200 | [diff] [blame] | 417 | |
Pekka Paalanen | d7ca6b0 | 2015-03-05 13:25:19 +0200 | [diff] [blame] | 418 | repaint_region(view, output, &repaint_output, NULL, |
Pekka Paalanen | ccf99ce | 2015-03-05 12:57:35 +0200 | [diff] [blame] | 419 | PIXMAN_OP_SRC); |
| 420 | } |
| 421 | } |
| 422 | |
| 423 | if (pixman_region32_not_empty(&surface_blend)) { |
| 424 | region_intersect_only_translation(&repaint_output, |
| 425 | repaint_global, |
| 426 | &surface_blend, view); |
Pekka Paalanen | 0692079 | 2020-12-08 15:22:36 +0200 | [diff] [blame^] | 427 | weston_output_region_from_global(output, &repaint_output); |
Pekka Paalanen | ccf99ce | 2015-03-05 12:57:35 +0200 | [diff] [blame] | 428 | |
Pekka Paalanen | d7ca6b0 | 2015-03-05 13:25:19 +0200 | [diff] [blame] | 429 | repaint_region(view, output, &repaint_output, NULL, |
Pekka Paalanen | ccf99ce | 2015-03-05 12:57:35 +0200 | [diff] [blame] | 430 | PIXMAN_OP_OVER); |
| 431 | } |
| 432 | |
| 433 | pixman_region32_fini(&surface_blend); |
| 434 | pixman_region32_fini(&repaint_output); |
| 435 | } |
| 436 | |
| 437 | static void |
Pekka Paalanen | d7ca6b0 | 2015-03-05 13:25:19 +0200 | [diff] [blame] | 438 | draw_view_source_clipped(struct weston_view *view, |
| 439 | struct weston_output *output, |
| 440 | pixman_region32_t *repaint_global) |
| 441 | { |
| 442 | struct weston_surface *surface = view->surface; |
| 443 | pixman_region32_t surf_region; |
| 444 | pixman_region32_t buffer_region; |
| 445 | pixman_region32_t repaint_output; |
| 446 | |
| 447 | /* Do not bother separating the opaque region from non-opaque. |
| 448 | * Source clipping requires PIXMAN_OP_OVER in all cases, so painting |
| 449 | * opaque separately has no benefit. |
| 450 | */ |
| 451 | |
| 452 | pixman_region32_init_rect(&surf_region, 0, 0, |
| 453 | surface->width, surface->height); |
Pekka Paalanen | c93782a | 2015-03-06 10:33:50 +0200 | [diff] [blame] | 454 | if (view->geometry.scissor_enabled) |
| 455 | pixman_region32_intersect(&surf_region, &surf_region, |
| 456 | &view->geometry.scissor); |
| 457 | |
Pekka Paalanen | d7ca6b0 | 2015-03-05 13:25:19 +0200 | [diff] [blame] | 458 | pixman_region32_init(&buffer_region); |
| 459 | weston_surface_to_buffer_region(surface, &surf_region, &buffer_region); |
| 460 | |
| 461 | pixman_region32_init(&repaint_output); |
| 462 | pixman_region32_copy(&repaint_output, repaint_global); |
Pekka Paalanen | 0692079 | 2020-12-08 15:22:36 +0200 | [diff] [blame^] | 463 | weston_output_region_from_global(output, &repaint_output); |
Pekka Paalanen | d7ca6b0 | 2015-03-05 13:25:19 +0200 | [diff] [blame] | 464 | |
| 465 | repaint_region(view, output, &repaint_output, &buffer_region, |
| 466 | PIXMAN_OP_OVER); |
| 467 | |
| 468 | pixman_region32_fini(&repaint_output); |
| 469 | pixman_region32_fini(&buffer_region); |
| 470 | pixman_region32_fini(&surf_region); |
| 471 | } |
| 472 | |
| 473 | static void |
Jason Ekstrand | a7af704 | 2013-10-12 22:38:11 -0500 | [diff] [blame] | 474 | draw_view(struct weston_view *ev, struct weston_output *output, |
| 475 | pixman_region32_t *damage) /* in global coordinates */ |
Vasily Khoruzhick | 71c2dd3 | 2013-01-07 20:39:49 +0300 | [diff] [blame] | 476 | { |
Jason Ekstrand | a7af704 | 2013-10-12 22:38:11 -0500 | [diff] [blame] | 477 | struct pixman_surface_state *ps = get_surface_state(ev->surface); |
Vasily Khoruzhick | 71c2dd3 | 2013-01-07 20:39:49 +0300 | [diff] [blame] | 478 | /* repaint bounding region in global coordinates: */ |
| 479 | pixman_region32_t repaint; |
Vasily Khoruzhick | 71c2dd3 | 2013-01-07 20:39:49 +0300 | [diff] [blame] | 480 | |
| 481 | /* No buffer attached */ |
| 482 | if (!ps->image) |
| 483 | return; |
| 484 | |
| 485 | pixman_region32_init(&repaint); |
| 486 | pixman_region32_intersect(&repaint, |
Pekka Paalanen | 25c0ca5 | 2015-02-19 11:15:33 +0200 | [diff] [blame] | 487 | &ev->transform.boundingbox, damage); |
Jason Ekstrand | a7af704 | 2013-10-12 22:38:11 -0500 | [diff] [blame] | 488 | pixman_region32_subtract(&repaint, &repaint, &ev->clip); |
Vasily Khoruzhick | 71c2dd3 | 2013-01-07 20:39:49 +0300 | [diff] [blame] | 489 | |
| 490 | if (!pixman_region32_not_empty(&repaint)) |
| 491 | goto out; |
| 492 | |
Pekka Paalanen | ccf99ce | 2015-03-05 12:57:35 +0200 | [diff] [blame] | 493 | if (view_transformation_is_translation(ev)) { |
Pekka Paalanen | d7ca6b0 | 2015-03-05 13:25:19 +0200 | [diff] [blame] | 494 | /* The simple case: The surface regions opaque, non-opaque, |
| 495 | * etc. are convertible to global coordinate space. |
| 496 | * There is no need to use a source clip region. |
| 497 | * It is possible to paint opaque region as PIXMAN_OP_SRC. |
Pekka Paalanen | c93782a | 2015-03-06 10:33:50 +0200 | [diff] [blame] | 498 | * Also the boundingbox is accurate rather than an |
| 499 | * approximation. |
Pekka Paalanen | d7ca6b0 | 2015-03-05 13:25:19 +0200 | [diff] [blame] | 500 | */ |
Pekka Paalanen | ccf99ce | 2015-03-05 12:57:35 +0200 | [diff] [blame] | 501 | draw_view_translated(ev, output, &repaint); |
| 502 | } else { |
Pekka Paalanen | d7ca6b0 | 2015-03-05 13:25:19 +0200 | [diff] [blame] | 503 | /* The complex case: the view transformation does not allow |
| 504 | * converting opaque etc. regions into global coordinate space. |
| 505 | * Therefore we need source clipping to avoid sampling from |
| 506 | * unwanted source image areas, unless the source image is |
| 507 | * to be used whole. Source clipping does not work with |
| 508 | * PIXMAN_OP_SRC. |
| 509 | */ |
| 510 | draw_view_source_clipped(ev, output, &repaint); |
Vasily Khoruzhick | 71c2dd3 | 2013-01-07 20:39:49 +0300 | [diff] [blame] | 511 | } |
| 512 | |
Vasily Khoruzhick | 71c2dd3 | 2013-01-07 20:39:49 +0300 | [diff] [blame] | 513 | out: |
| 514 | pixman_region32_fini(&repaint); |
| 515 | } |
| 516 | static void |
| 517 | repaint_surfaces(struct weston_output *output, pixman_region32_t *damage) |
| 518 | { |
| 519 | struct weston_compositor *compositor = output->compositor; |
Jason Ekstrand | a7af704 | 2013-10-12 22:38:11 -0500 | [diff] [blame] | 520 | struct weston_view *view; |
Vasily Khoruzhick | 71c2dd3 | 2013-01-07 20:39:49 +0300 | [diff] [blame] | 521 | |
Jason Ekstrand | a7af704 | 2013-10-12 22:38:11 -0500 | [diff] [blame] | 522 | wl_list_for_each_reverse(view, &compositor->view_list, link) |
| 523 | if (view->plane == &compositor->primary_plane) |
| 524 | draw_view(view, output, damage); |
Vasily Khoruzhick | 71c2dd3 | 2013-01-07 20:39:49 +0300 | [diff] [blame] | 525 | } |
| 526 | |
| 527 | static void |
Ander Conselvan de Oliveira | 936effd | 2013-01-25 15:13:01 +0200 | [diff] [blame] | 528 | copy_to_hw_buffer(struct weston_output *output, pixman_region32_t *region) |
| 529 | { |
| 530 | struct pixman_output_state *po = get_output_state(output); |
Alexander Larsson | 1f206b4 | 2013-05-22 14:41:36 +0200 | [diff] [blame] | 531 | pixman_region32_t output_region; |
Ander Conselvan de Oliveira | 936effd | 2013-01-25 15:13:01 +0200 | [diff] [blame] | 532 | |
Alexander Larsson | 1f206b4 | 2013-05-22 14:41:36 +0200 | [diff] [blame] | 533 | pixman_region32_init(&output_region); |
| 534 | pixman_region32_copy(&output_region, region); |
Ander Conselvan de Oliveira | 936effd | 2013-01-25 15:13:01 +0200 | [diff] [blame] | 535 | |
Pekka Paalanen | 0692079 | 2020-12-08 15:22:36 +0200 | [diff] [blame^] | 536 | weston_output_region_from_global(output, &output_region); |
Ander Conselvan de Oliveira | 936effd | 2013-01-25 15:13:01 +0200 | [diff] [blame] | 537 | |
Alexander Larsson | 1f206b4 | 2013-05-22 14:41:36 +0200 | [diff] [blame] | 538 | pixman_image_set_clip_region32 (po->hw_buffer, &output_region); |
Ryo Munakata | 389d205 | 2014-09-04 01:56:53 +0900 | [diff] [blame] | 539 | pixman_region32_fini(&output_region); |
Ander Conselvan de Oliveira | 936effd | 2013-01-25 15:13:01 +0200 | [diff] [blame] | 540 | |
Alexander Larsson | 1f206b4 | 2013-05-22 14:41:36 +0200 | [diff] [blame] | 541 | pixman_image_composite32(PIXMAN_OP_SRC, |
| 542 | po->shadow_image, /* src */ |
| 543 | NULL /* mask */, |
| 544 | po->hw_buffer, /* dest */ |
| 545 | 0, 0, /* src_x, src_y */ |
| 546 | 0, 0, /* mask_x, mask_y */ |
| 547 | 0, 0, /* dest_x, dest_y */ |
| 548 | pixman_image_get_width (po->hw_buffer), /* width */ |
| 549 | pixman_image_get_height (po->hw_buffer) /* height */); |
| 550 | |
| 551 | pixman_image_set_clip_region32 (po->hw_buffer, NULL); |
Ander Conselvan de Oliveira | 936effd | 2013-01-25 15:13:01 +0200 | [diff] [blame] | 552 | } |
| 553 | |
| 554 | static void |
Vasily Khoruzhick | 71c2dd3 | 2013-01-07 20:39:49 +0300 | [diff] [blame] | 555 | pixman_renderer_repaint_output(struct weston_output *output, |
Pekka Paalanen | acf50c3 | 2018-04-23 11:44:56 +0200 | [diff] [blame] | 556 | pixman_region32_t *output_damage) |
Vasily Khoruzhick | 71c2dd3 | 2013-01-07 20:39:49 +0300 | [diff] [blame] | 557 | { |
| 558 | struct pixman_output_state *po = get_output_state(output); |
Pekka Paalanen | acf50c3 | 2018-04-23 11:44:56 +0200 | [diff] [blame] | 559 | pixman_region32_t hw_damage; |
Vasily Khoruzhick | 71c2dd3 | 2013-01-07 20:39:49 +0300 | [diff] [blame] | 560 | |
Pekka Paalanen | acf50c3 | 2018-04-23 11:44:56 +0200 | [diff] [blame] | 561 | if (!po->hw_buffer) { |
| 562 | po->hw_extra_damage = NULL; |
| 563 | return; |
| 564 | } |
| 565 | |
| 566 | pixman_region32_init(&hw_damage); |
| 567 | if (po->hw_extra_damage) { |
| 568 | pixman_region32_union(&hw_damage, |
| 569 | po->hw_extra_damage, output_damage); |
| 570 | po->hw_extra_damage = NULL; |
| 571 | } else { |
| 572 | pixman_region32_copy(&hw_damage, output_damage); |
| 573 | } |
Vasily Khoruzhick | 71c2dd3 | 2013-01-07 20:39:49 +0300 | [diff] [blame] | 574 | |
Pekka Paalanen | 26ded94 | 2018-04-23 11:44:57 +0200 | [diff] [blame] | 575 | if (po->shadow_image) { |
| 576 | repaint_surfaces(output, output_damage); |
| 577 | copy_to_hw_buffer(output, &hw_damage); |
| 578 | } else { |
| 579 | repaint_surfaces(output, &hw_damage); |
| 580 | } |
Pekka Paalanen | acf50c3 | 2018-04-23 11:44:56 +0200 | [diff] [blame] | 581 | pixman_region32_fini(&hw_damage); |
Vasily Khoruzhick | 71c2dd3 | 2013-01-07 20:39:49 +0300 | [diff] [blame] | 582 | |
Stefan Agner | 0bb9447 | 2019-12-09 13:26:57 +0100 | [diff] [blame] | 583 | wl_signal_emit(&output->frame_signal, output_damage); |
Vasily Khoruzhick | 71c2dd3 | 2013-01-07 20:39:49 +0300 | [diff] [blame] | 584 | |
| 585 | /* Actual flip should be done by caller */ |
| 586 | } |
| 587 | |
| 588 | static void |
| 589 | pixman_renderer_flush_damage(struct weston_surface *surface) |
| 590 | { |
| 591 | /* No-op for pixman renderer */ |
| 592 | } |
| 593 | |
| 594 | static void |
Lubomir Rintel | ddc2b1e | 2013-12-12 12:57:56 +0100 | [diff] [blame] | 595 | buffer_state_handle_buffer_destroy(struct wl_listener *listener, void *data) |
| 596 | { |
| 597 | struct pixman_surface_state *ps; |
| 598 | |
| 599 | ps = container_of(listener, struct pixman_surface_state, |
| 600 | buffer_destroy_listener); |
| 601 | |
| 602 | if (ps->image) { |
| 603 | pixman_image_unref(ps->image); |
| 604 | ps->image = NULL; |
| 605 | } |
| 606 | |
| 607 | ps->buffer_destroy_listener.notify = NULL; |
| 608 | } |
| 609 | |
| 610 | static void |
Jason Ekstrand | 6bd6294 | 2013-06-20 20:38:23 -0500 | [diff] [blame] | 611 | pixman_renderer_attach(struct weston_surface *es, struct weston_buffer *buffer) |
Vasily Khoruzhick | 71c2dd3 | 2013-01-07 20:39:49 +0300 | [diff] [blame] | 612 | { |
| 613 | struct pixman_surface_state *ps = get_surface_state(es); |
Jason Ekstrand | 6bd6294 | 2013-06-20 20:38:23 -0500 | [diff] [blame] | 614 | struct wl_shm_buffer *shm_buffer; |
Vasily Khoruzhick | 71c2dd3 | 2013-01-07 20:39:49 +0300 | [diff] [blame] | 615 | pixman_format_code_t pixman_format; |
| 616 | |
| 617 | weston_buffer_reference(&ps->buffer_ref, buffer); |
Alexandros Frantzis | 6762967 | 2018-10-19 12:14:11 +0300 | [diff] [blame] | 618 | weston_buffer_release_reference(&ps->buffer_release_ref, |
| 619 | es->buffer_release_ref.buffer_release); |
Vasily Khoruzhick | 71c2dd3 | 2013-01-07 20:39:49 +0300 | [diff] [blame] | 620 | |
Lubomir Rintel | ddc2b1e | 2013-12-12 12:57:56 +0100 | [diff] [blame] | 621 | if (ps->buffer_destroy_listener.notify) { |
| 622 | wl_list_remove(&ps->buffer_destroy_listener.link); |
| 623 | ps->buffer_destroy_listener.notify = NULL; |
| 624 | } |
| 625 | |
Vasily Khoruzhick | 71c2dd3 | 2013-01-07 20:39:49 +0300 | [diff] [blame] | 626 | if (ps->image) { |
| 627 | pixman_image_unref(ps->image); |
| 628 | ps->image = NULL; |
| 629 | } |
| 630 | |
| 631 | if (!buffer) |
| 632 | return; |
Jason Ekstrand | 52c476a | 2015-11-18 16:32:29 -0600 | [diff] [blame] | 633 | |
Jason Ekstrand | 6bd6294 | 2013-06-20 20:38:23 -0500 | [diff] [blame] | 634 | shm_buffer = wl_shm_buffer_get(buffer->resource); |
Vasily Khoruzhick | 71c2dd3 | 2013-01-07 20:39:49 +0300 | [diff] [blame] | 635 | |
Jason Ekstrand | 6bd6294 | 2013-06-20 20:38:23 -0500 | [diff] [blame] | 636 | if (! shm_buffer) { |
Vasily Khoruzhick | 71c2dd3 | 2013-01-07 20:39:49 +0300 | [diff] [blame] | 637 | weston_log("Pixman renderer supports only SHM buffers\n"); |
| 638 | weston_buffer_reference(&ps->buffer_ref, NULL); |
Alexandros Frantzis | 6762967 | 2018-10-19 12:14:11 +0300 | [diff] [blame] | 639 | weston_buffer_release_reference(&ps->buffer_release_ref, NULL); |
Vasily Khoruzhick | 71c2dd3 | 2013-01-07 20:39:49 +0300 | [diff] [blame] | 640 | return; |
| 641 | } |
| 642 | |
Jason Ekstrand | 6bd6294 | 2013-06-20 20:38:23 -0500 | [diff] [blame] | 643 | switch (wl_shm_buffer_get_format(shm_buffer)) { |
Vasily Khoruzhick | 71c2dd3 | 2013-01-07 20:39:49 +0300 | [diff] [blame] | 644 | case WL_SHM_FORMAT_XRGB8888: |
| 645 | pixman_format = PIXMAN_x8r8g8b8; |
Philipp Zabel | 195dade | 2018-09-03 19:44:59 +0200 | [diff] [blame] | 646 | es->is_opaque = true; |
Vasily Khoruzhick | 71c2dd3 | 2013-01-07 20:39:49 +0300 | [diff] [blame] | 647 | break; |
| 648 | case WL_SHM_FORMAT_ARGB8888: |
| 649 | pixman_format = PIXMAN_a8r8g8b8; |
Philipp Zabel | 195dade | 2018-09-03 19:44:59 +0200 | [diff] [blame] | 650 | es->is_opaque = false; |
Vasily Khoruzhick | 71c2dd3 | 2013-01-07 20:39:49 +0300 | [diff] [blame] | 651 | break; |
Tomeu Vizoso | 1c1fc29 | 2013-08-06 20:05:56 +0200 | [diff] [blame] | 652 | case WL_SHM_FORMAT_RGB565: |
| 653 | pixman_format = PIXMAN_r5g6b5; |
Philipp Zabel | 195dade | 2018-09-03 19:44:59 +0200 | [diff] [blame] | 654 | es->is_opaque = true; |
Tomeu Vizoso | 1c1fc29 | 2013-08-06 20:05:56 +0200 | [diff] [blame] | 655 | break; |
Vasily Khoruzhick | 71c2dd3 | 2013-01-07 20:39:49 +0300 | [diff] [blame] | 656 | default: |
Vasilis Liaskovitis | 486b463 | 2018-10-10 16:14:55 +0200 | [diff] [blame] | 657 | weston_log("Unsupported SHM buffer format 0x%x\n", |
| 658 | wl_shm_buffer_get_format(shm_buffer)); |
Vasily Khoruzhick | 71c2dd3 | 2013-01-07 20:39:49 +0300 | [diff] [blame] | 659 | weston_buffer_reference(&ps->buffer_ref, NULL); |
Alexandros Frantzis | 6762967 | 2018-10-19 12:14:11 +0300 | [diff] [blame] | 660 | weston_buffer_release_reference(&ps->buffer_release_ref, NULL); |
Vasilis Liaskovitis | 486b463 | 2018-10-10 16:14:55 +0200 | [diff] [blame] | 661 | weston_buffer_send_server_error(buffer, |
| 662 | "disconnecting due to unhandled buffer type"); |
Vasily Khoruzhick | 71c2dd3 | 2013-01-07 20:39:49 +0300 | [diff] [blame] | 663 | return; |
| 664 | break; |
| 665 | } |
Jason Ekstrand | 6bd6294 | 2013-06-20 20:38:23 -0500 | [diff] [blame] | 666 | |
| 667 | buffer->shm_buffer = shm_buffer; |
| 668 | buffer->width = wl_shm_buffer_get_width(shm_buffer); |
| 669 | buffer->height = wl_shm_buffer_get_height(shm_buffer); |
| 670 | |
Vasily Khoruzhick | 71c2dd3 | 2013-01-07 20:39:49 +0300 | [diff] [blame] | 671 | ps->image = pixman_image_create_bits(pixman_format, |
Jason Ekstrand | 6bd6294 | 2013-06-20 20:38:23 -0500 | [diff] [blame] | 672 | buffer->width, buffer->height, |
| 673 | wl_shm_buffer_get_data(shm_buffer), |
| 674 | wl_shm_buffer_get_stride(shm_buffer)); |
Lubomir Rintel | ddc2b1e | 2013-12-12 12:57:56 +0100 | [diff] [blame] | 675 | |
| 676 | ps->buffer_destroy_listener.notify = |
| 677 | buffer_state_handle_buffer_destroy; |
| 678 | wl_signal_add(&buffer->destroy_signal, |
| 679 | &ps->buffer_destroy_listener); |
Vasily Khoruzhick | 71c2dd3 | 2013-01-07 20:39:49 +0300 | [diff] [blame] | 680 | } |
| 681 | |
Ander Conselvan de Oliveira | aa398ae | 2013-10-25 16:26:33 +0300 | [diff] [blame] | 682 | static void |
Ander Conselvan de Oliveira | adda00e | 2013-10-25 16:26:34 +0300 | [diff] [blame] | 683 | pixman_renderer_surface_state_destroy(struct pixman_surface_state *ps) |
Ander Conselvan de Oliveira | aa398ae | 2013-10-25 16:26:33 +0300 | [diff] [blame] | 684 | { |
Ander Conselvan de Oliveira | adda00e | 2013-10-25 16:26:34 +0300 | [diff] [blame] | 685 | wl_list_remove(&ps->surface_destroy_listener.link); |
| 686 | wl_list_remove(&ps->renderer_destroy_listener.link); |
Lubomir Rintel | ddc2b1e | 2013-12-12 12:57:56 +0100 | [diff] [blame] | 687 | if (ps->buffer_destroy_listener.notify) { |
| 688 | wl_list_remove(&ps->buffer_destroy_listener.link); |
| 689 | ps->buffer_destroy_listener.notify = NULL; |
| 690 | } |
Ander Conselvan de Oliveira | aa398ae | 2013-10-25 16:26:33 +0300 | [diff] [blame] | 691 | |
| 692 | ps->surface->renderer_state = NULL; |
| 693 | |
| 694 | if (ps->image) { |
| 695 | pixman_image_unref(ps->image); |
| 696 | ps->image = NULL; |
| 697 | } |
| 698 | weston_buffer_reference(&ps->buffer_ref, NULL); |
Alexandros Frantzis | 6762967 | 2018-10-19 12:14:11 +0300 | [diff] [blame] | 699 | weston_buffer_release_reference(&ps->buffer_release_ref, NULL); |
Ander Conselvan de Oliveira | aa398ae | 2013-10-25 16:26:33 +0300 | [diff] [blame] | 700 | free(ps); |
| 701 | } |
| 702 | |
Ander Conselvan de Oliveira | adda00e | 2013-10-25 16:26:34 +0300 | [diff] [blame] | 703 | static void |
| 704 | surface_state_handle_surface_destroy(struct wl_listener *listener, void *data) |
| 705 | { |
| 706 | struct pixman_surface_state *ps; |
| 707 | |
| 708 | ps = container_of(listener, struct pixman_surface_state, |
| 709 | surface_destroy_listener); |
| 710 | |
| 711 | pixman_renderer_surface_state_destroy(ps); |
| 712 | } |
| 713 | |
| 714 | static void |
| 715 | surface_state_handle_renderer_destroy(struct wl_listener *listener, void *data) |
| 716 | { |
| 717 | struct pixman_surface_state *ps; |
| 718 | |
| 719 | ps = container_of(listener, struct pixman_surface_state, |
| 720 | renderer_destroy_listener); |
| 721 | |
| 722 | pixman_renderer_surface_state_destroy(ps); |
| 723 | } |
| 724 | |
Vasily Khoruzhick | 71c2dd3 | 2013-01-07 20:39:49 +0300 | [diff] [blame] | 725 | static int |
| 726 | pixman_renderer_create_surface(struct weston_surface *surface) |
| 727 | { |
| 728 | struct pixman_surface_state *ps; |
Ander Conselvan de Oliveira | adda00e | 2013-10-25 16:26:34 +0300 | [diff] [blame] | 729 | struct pixman_renderer *pr = get_renderer(surface->compositor); |
Vasily Khoruzhick | 71c2dd3 | 2013-01-07 20:39:49 +0300 | [diff] [blame] | 730 | |
Bryce Harrington | de16d89 | 2014-11-20 22:21:57 -0800 | [diff] [blame] | 731 | ps = zalloc(sizeof *ps); |
| 732 | if (ps == NULL) |
Vasily Khoruzhick | 71c2dd3 | 2013-01-07 20:39:49 +0300 | [diff] [blame] | 733 | return -1; |
| 734 | |
| 735 | surface->renderer_state = ps; |
| 736 | |
Ander Conselvan de Oliveira | aa398ae | 2013-10-25 16:26:33 +0300 | [diff] [blame] | 737 | ps->surface = surface; |
| 738 | |
| 739 | ps->surface_destroy_listener.notify = |
| 740 | surface_state_handle_surface_destroy; |
| 741 | wl_signal_add(&surface->destroy_signal, |
| 742 | &ps->surface_destroy_listener); |
| 743 | |
Ander Conselvan de Oliveira | adda00e | 2013-10-25 16:26:34 +0300 | [diff] [blame] | 744 | ps->renderer_destroy_listener.notify = |
| 745 | surface_state_handle_renderer_destroy; |
| 746 | wl_signal_add(&pr->destroy_signal, |
| 747 | &ps->renderer_destroy_listener); |
| 748 | |
Vasily Khoruzhick | 71c2dd3 | 2013-01-07 20:39:49 +0300 | [diff] [blame] | 749 | return 0; |
| 750 | } |
| 751 | |
| 752 | static void |
| 753 | pixman_renderer_surface_set_color(struct weston_surface *es, |
| 754 | float red, float green, float blue, float alpha) |
| 755 | { |
| 756 | struct pixman_surface_state *ps = get_surface_state(es); |
| 757 | pixman_color_t color; |
| 758 | |
| 759 | color.red = red * 0xffff; |
| 760 | color.green = green * 0xffff; |
| 761 | color.blue = blue * 0xffff; |
| 762 | color.alpha = alpha * 0xffff; |
Jason Ekstrand | 52c476a | 2015-11-18 16:32:29 -0600 | [diff] [blame] | 763 | |
Vasily Khoruzhick | 71c2dd3 | 2013-01-07 20:39:49 +0300 | [diff] [blame] | 764 | if (ps->image) { |
| 765 | pixman_image_unref(ps->image); |
| 766 | ps->image = NULL; |
| 767 | } |
| 768 | |
| 769 | ps->image = pixman_image_create_solid_fill(&color); |
| 770 | } |
| 771 | |
| 772 | static void |
Vasily Khoruzhick | 71c2dd3 | 2013-01-07 20:39:49 +0300 | [diff] [blame] | 773 | pixman_renderer_destroy(struct weston_compositor *ec) |
| 774 | { |
Ander Conselvan de Oliveira | 6b16214 | 2013-10-25 16:26:32 +0300 | [diff] [blame] | 775 | struct pixman_renderer *pr = get_renderer(ec); |
| 776 | |
Ander Conselvan de Oliveira | adda00e | 2013-10-25 16:26:34 +0300 | [diff] [blame] | 777 | wl_signal_emit(&pr->destroy_signal, pr); |
Ander Conselvan de Oliveira | 6b16214 | 2013-10-25 16:26:32 +0300 | [diff] [blame] | 778 | weston_binding_destroy(pr->debug_binding); |
| 779 | free(pr); |
| 780 | |
Vasily Khoruzhick | 71c2dd3 | 2013-01-07 20:39:49 +0300 | [diff] [blame] | 781 | ec->renderer = NULL; |
| 782 | } |
| 783 | |
Ander Conselvan de Oliveira | 8792ef1 | 2013-01-25 15:13:00 +0200 | [diff] [blame] | 784 | static void |
Pekka Paalanen | 6764bbe | 2015-02-11 12:29:56 +0200 | [diff] [blame] | 785 | pixman_renderer_surface_get_content_size(struct weston_surface *surface, |
| 786 | int *width, int *height) |
| 787 | { |
| 788 | struct pixman_surface_state *ps = get_surface_state(surface); |
| 789 | |
| 790 | if (ps->image) { |
| 791 | *width = pixman_image_get_width(ps->image); |
| 792 | *height = pixman_image_get_height(ps->image); |
| 793 | } else { |
| 794 | *width = 0; |
| 795 | *height = 0; |
| 796 | } |
| 797 | } |
| 798 | |
| 799 | static int |
| 800 | pixman_renderer_surface_copy_content(struct weston_surface *surface, |
| 801 | void *target, size_t size, |
| 802 | int src_x, int src_y, |
| 803 | int width, int height) |
| 804 | { |
| 805 | const pixman_format_code_t format = PIXMAN_a8b8g8r8; |
| 806 | const size_t bytespp = 4; /* PIXMAN_a8b8g8r8 */ |
| 807 | struct pixman_surface_state *ps = get_surface_state(surface); |
| 808 | pixman_image_t *out_buf; |
| 809 | |
| 810 | if (!ps->image) |
| 811 | return -1; |
| 812 | |
| 813 | out_buf = pixman_image_create_bits(format, width, height, |
| 814 | target, width * bytespp); |
| 815 | |
| 816 | pixman_image_set_transform(ps->image, NULL); |
| 817 | pixman_image_composite32(PIXMAN_OP_SRC, |
| 818 | ps->image, /* src */ |
| 819 | NULL, /* mask */ |
| 820 | out_buf, /* dest */ |
| 821 | src_x, src_y, /* src_x, src_y */ |
| 822 | 0, 0, /* mask_x, mask_y */ |
| 823 | 0, 0, /* dest_x, dest_y */ |
| 824 | width, height); |
| 825 | |
| 826 | pixman_image_unref(out_buf); |
| 827 | |
| 828 | return 0; |
| 829 | } |
| 830 | |
| 831 | static void |
Alexandros Frantzis | 47e79c8 | 2017-11-16 18:20:57 +0200 | [diff] [blame] | 832 | debug_binding(struct weston_keyboard *keyboard, const struct timespec *time, |
| 833 | uint32_t key, void *data) |
Ander Conselvan de Oliveira | 8792ef1 | 2013-01-25 15:13:00 +0200 | [diff] [blame] | 834 | { |
| 835 | struct weston_compositor *ec = data; |
| 836 | struct pixman_renderer *pr = (struct pixman_renderer *) ec->renderer; |
| 837 | |
| 838 | pr->repaint_debug ^= 1; |
| 839 | |
| 840 | if (pr->repaint_debug) { |
| 841 | pixman_color_t red = { |
| 842 | 0x3fff, 0x0000, 0x0000, 0x3fff |
| 843 | }; |
| 844 | |
| 845 | pr->debug_color = pixman_image_create_solid_fill(&red); |
| 846 | } else { |
| 847 | pixman_image_unref(pr->debug_color); |
| 848 | weston_compositor_damage_all(ec); |
| 849 | } |
| 850 | } |
| 851 | |
Vasily Khoruzhick | 71c2dd3 | 2013-01-07 20:39:49 +0300 | [diff] [blame] | 852 | WL_EXPORT int |
| 853 | pixman_renderer_init(struct weston_compositor *ec) |
| 854 | { |
Ander Conselvan de Oliveira | 8792ef1 | 2013-01-25 15:13:00 +0200 | [diff] [blame] | 855 | struct pixman_renderer *renderer; |
Vasily Khoruzhick | 71c2dd3 | 2013-01-07 20:39:49 +0300 | [diff] [blame] | 856 | |
Bryce Harrington | de16d89 | 2014-11-20 22:21:57 -0800 | [diff] [blame] | 857 | renderer = zalloc(sizeof *renderer); |
Vasily Khoruzhick | 71c2dd3 | 2013-01-07 20:39:49 +0300 | [diff] [blame] | 858 | if (renderer == NULL) |
| 859 | return -1; |
| 860 | |
Philipp Brüschweiler | f3e39f9 | 2013-03-08 20:35:39 +0100 | [diff] [blame] | 861 | renderer->repaint_debug = 0; |
| 862 | renderer->debug_color = NULL; |
Ander Conselvan de Oliveira | 8792ef1 | 2013-01-25 15:13:00 +0200 | [diff] [blame] | 863 | renderer->base.read_pixels = pixman_renderer_read_pixels; |
| 864 | renderer->base.repaint_output = pixman_renderer_repaint_output; |
| 865 | renderer->base.flush_damage = pixman_renderer_flush_damage; |
| 866 | renderer->base.attach = pixman_renderer_attach; |
Ander Conselvan de Oliveira | 8792ef1 | 2013-01-25 15:13:00 +0200 | [diff] [blame] | 867 | renderer->base.surface_set_color = pixman_renderer_surface_set_color; |
Ander Conselvan de Oliveira | 8792ef1 | 2013-01-25 15:13:00 +0200 | [diff] [blame] | 868 | renderer->base.destroy = pixman_renderer_destroy; |
Pekka Paalanen | 6764bbe | 2015-02-11 12:29:56 +0200 | [diff] [blame] | 869 | renderer->base.surface_get_content_size = |
| 870 | pixman_renderer_surface_get_content_size; |
| 871 | renderer->base.surface_copy_content = |
| 872 | pixman_renderer_surface_copy_content; |
Ander Conselvan de Oliveira | 8792ef1 | 2013-01-25 15:13:00 +0200 | [diff] [blame] | 873 | ec->renderer = &renderer->base; |
Pekka Paalanen | 7bb6510 | 2013-05-22 18:03:04 +0300 | [diff] [blame] | 874 | ec->capabilities |= WESTON_CAP_ROTATION_ANY; |
Pekka Paalanen | c93782a | 2015-03-06 10:33:50 +0200 | [diff] [blame] | 875 | ec->capabilities |= WESTON_CAP_VIEW_CLIP_MASK; |
Vasily Khoruzhick | 71c2dd3 | 2013-01-07 20:39:49 +0300 | [diff] [blame] | 876 | |
Ander Conselvan de Oliveira | 6b16214 | 2013-10-25 16:26:32 +0300 | [diff] [blame] | 877 | renderer->debug_binding = |
| 878 | weston_compositor_add_debug_binding(ec, KEY_R, |
| 879 | debug_binding, ec); |
Tomeu Vizoso | 1c1fc29 | 2013-08-06 20:05:56 +0200 | [diff] [blame] | 880 | |
| 881 | wl_display_add_shm_format(ec->wl_display, WL_SHM_FORMAT_RGB565); |
| 882 | |
Ander Conselvan de Oliveira | adda00e | 2013-10-25 16:26:34 +0300 | [diff] [blame] | 883 | wl_signal_init(&renderer->destroy_signal); |
| 884 | |
Vasily Khoruzhick | 71c2dd3 | 2013-01-07 20:39:49 +0300 | [diff] [blame] | 885 | return 0; |
| 886 | } |
| 887 | |
| 888 | WL_EXPORT void |
Pekka Paalanen | acf50c3 | 2018-04-23 11:44:56 +0200 | [diff] [blame] | 889 | pixman_renderer_output_set_buffer(struct weston_output *output, |
| 890 | pixman_image_t *buffer) |
Vasily Khoruzhick | 71c2dd3 | 2013-01-07 20:39:49 +0300 | [diff] [blame] | 891 | { |
| 892 | struct pixman_output_state *po = get_output_state(output); |
| 893 | |
| 894 | if (po->hw_buffer) |
| 895 | pixman_image_unref(po->hw_buffer); |
| 896 | po->hw_buffer = buffer; |
| 897 | |
| 898 | if (po->hw_buffer) { |
| 899 | output->compositor->read_format = pixman_image_get_format(po->hw_buffer); |
| 900 | pixman_image_ref(po->hw_buffer); |
| 901 | } |
| 902 | } |
| 903 | |
Pekka Paalanen | acf50c3 | 2018-04-23 11:44:56 +0200 | [diff] [blame] | 904 | WL_EXPORT void |
| 905 | pixman_renderer_output_set_hw_extra_damage(struct weston_output *output, |
| 906 | pixman_region32_t *extra_damage) |
| 907 | { |
| 908 | struct pixman_output_state *po = get_output_state(output); |
| 909 | |
| 910 | po->hw_extra_damage = extra_damage; |
| 911 | } |
| 912 | |
Vasily Khoruzhick | 71c2dd3 | 2013-01-07 20:39:49 +0300 | [diff] [blame] | 913 | WL_EXPORT int |
Daniel Stone | 61abf35 | 2020-03-06 12:46:30 +0000 | [diff] [blame] | 914 | pixman_renderer_output_create(struct weston_output *output, |
| 915 | const struct pixman_renderer_output_options *options) |
Vasily Khoruzhick | 71c2dd3 | 2013-01-07 20:39:49 +0300 | [diff] [blame] | 916 | { |
Bryce Harrington | de16d89 | 2014-11-20 22:21:57 -0800 | [diff] [blame] | 917 | struct pixman_output_state *po; |
Ander Conselvan de Oliveira | 936effd | 2013-01-25 15:13:01 +0200 | [diff] [blame] | 918 | int w, h; |
Vasily Khoruzhick | 71c2dd3 | 2013-01-07 20:39:49 +0300 | [diff] [blame] | 919 | |
Bryce Harrington | de16d89 | 2014-11-20 22:21:57 -0800 | [diff] [blame] | 920 | po = zalloc(sizeof *po); |
| 921 | if (po == NULL) |
Vasily Khoruzhick | 71c2dd3 | 2013-01-07 20:39:49 +0300 | [diff] [blame] | 922 | return -1; |
Ander Conselvan de Oliveira | 936effd | 2013-01-25 15:13:01 +0200 | [diff] [blame] | 923 | |
Daniel Stone | 61abf35 | 2020-03-06 12:46:30 +0000 | [diff] [blame] | 924 | if (options->use_shadow) { |
Pekka Paalanen | 26ded94 | 2018-04-23 11:44:57 +0200 | [diff] [blame] | 925 | /* set shadow image transformation */ |
| 926 | w = output->current_mode->width; |
| 927 | h = output->current_mode->height; |
Ander Conselvan de Oliveira | 936effd | 2013-01-25 15:13:01 +0200 | [diff] [blame] | 928 | |
Pekka Paalanen | 26ded94 | 2018-04-23 11:44:57 +0200 | [diff] [blame] | 929 | po->shadow_buffer = malloc(w * h * 4); |
Ander Conselvan de Oliveira | 936effd | 2013-01-25 15:13:01 +0200 | [diff] [blame] | 930 | |
Pekka Paalanen | 26ded94 | 2018-04-23 11:44:57 +0200 | [diff] [blame] | 931 | if (!po->shadow_buffer) { |
| 932 | free(po); |
| 933 | return -1; |
| 934 | } |
Ander Conselvan de Oliveira | 936effd | 2013-01-25 15:13:01 +0200 | [diff] [blame] | 935 | |
Pekka Paalanen | 26ded94 | 2018-04-23 11:44:57 +0200 | [diff] [blame] | 936 | po->shadow_image = |
| 937 | pixman_image_create_bits(PIXMAN_x8r8g8b8, w, h, |
| 938 | po->shadow_buffer, w * 4); |
Ander Conselvan de Oliveira | 936effd | 2013-01-25 15:13:01 +0200 | [diff] [blame] | 939 | |
Pekka Paalanen | 26ded94 | 2018-04-23 11:44:57 +0200 | [diff] [blame] | 940 | if (!po->shadow_image) { |
| 941 | free(po->shadow_buffer); |
| 942 | free(po); |
| 943 | return -1; |
| 944 | } |
Ander Conselvan de Oliveira | 936effd | 2013-01-25 15:13:01 +0200 | [diff] [blame] | 945 | } |
| 946 | |
Vasily Khoruzhick | 71c2dd3 | 2013-01-07 20:39:49 +0300 | [diff] [blame] | 947 | output->renderer_state = po; |
| 948 | |
| 949 | return 0; |
| 950 | } |
| 951 | |
| 952 | WL_EXPORT void |
| 953 | pixman_renderer_output_destroy(struct weston_output *output) |
| 954 | { |
| 955 | struct pixman_output_state *po = get_output_state(output); |
| 956 | |
Pekka Paalanen | 26ded94 | 2018-04-23 11:44:57 +0200 | [diff] [blame] | 957 | if (po->shadow_image) |
| 958 | pixman_image_unref(po->shadow_image); |
Ander Conselvan de Oliveira | 23e72b8 | 2013-01-25 15:13:06 +0200 | [diff] [blame] | 959 | |
| 960 | if (po->hw_buffer) |
| 961 | pixman_image_unref(po->hw_buffer); |
Ander Conselvan de Oliveira | 936effd | 2013-01-25 15:13:01 +0200 | [diff] [blame] | 962 | |
Arnaud Vrac | 8e3fe08 | 2014-08-25 20:56:52 +0200 | [diff] [blame] | 963 | free(po->shadow_buffer); |
| 964 | |
| 965 | po->shadow_buffer = NULL; |
Ander Conselvan de Oliveira | 936effd | 2013-01-25 15:13:01 +0200 | [diff] [blame] | 966 | po->shadow_image = NULL; |
Vasily Khoruzhick | 71c2dd3 | 2013-01-07 20:39:49 +0300 | [diff] [blame] | 967 | po->hw_buffer = NULL; |
| 968 | |
| 969 | free(po); |
| 970 | } |