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