GNOME Bugzilla – Bug 760897
A few clean ups to the shm handling code
Last modified: 2016-01-20 19:31:53 UTC
Here's a few clean ups to the shm handling code I found, when skimming through the code.
Created attachment 319452 [details] [review] wayland: unlink shm file earlier in create function create_shm_pool unlinks the temporary file a little, too late. It should be unlinked before ftruncate() is called for two reasons: 1) if ftruncate fails, the file is currently not getting cleaned up at all 2) in theory, if the file is public some other process could muck with it This commit just moves the unlink call a little higher up.
Created attachment 319453 [details] [review] wayland: clean up stride calculation when creating shm surface Right now, we assume the stride for the image surface needs to be 4 byte aligned. This is, in fact, true, but it's better to ask cairo for the alignment requirement directly rather than assume we know the alignment rules. This commit changes the code to use cairo_format_stride_for_width to calculate a suitable rowstride for pixman.
Created attachment 319454 [details] [review] wayland: don't pass in width and height to create_shm_pool create_shm_pool doesn't need the width or height, it just needs the total size. By passing it in, we're requiring it to redo stride calculation unnecessarily. This commit drops the width and height parameters and makes the function just take the total size directly.
Review of attachment 319452 [details] [review]: looks right
Review of attachment 319453 [details] [review]: Feel free to push it with that change ::: gdk/wayland/gdkdisplay-wayland.c @@ +1007,3 @@ data->busy = FALSE; + stride = cairo_format_stride_for_width (format, width * scale); Benjamin preferred to just open-code the format here, without a variable.
Review of attachment 319454 [details] [review]: Looks good to me
pushed after making that change and also making the spacing around operators consistent with the rest of the code in the function. Attachment 319452 [details] pushed as c8deaea - wayland: unlink shm file earlier in create function Attachment 319453 [details] pushed as 1e001ea - wayland: clean up stride calculation when creating shm surface Attachment 319454 [details] pushed as 5150849 - wayland: don't pass in width and height to create_shm_pool