refactor: break out stride calculation to new function

This commit is contained in:
Daniel Eklöf 2019-08-18 17:59:43 +02:00
parent 8aa53d1508
commit 33b5210a6a
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
3 changed files with 13 additions and 6 deletions

6
shm.c
View file

@ -11,6 +11,7 @@
#define LOG_MODULE "shm"
#include "log.h"
#include "stride.h"
#include "tllist.h"
static tll(struct buffer) buffers;
@ -69,10 +70,7 @@ shm_get_buffer(struct wl_shm *shm, int width, int height, size_t copies)
goto err;
}
/* TODO: copied from font.c */
/* Calculate stride. Copied from cairoint.h:CAIRO_STRIDE_FOR_WIDTH_BPP */
int bpp = 32;
const int stride = (((bpp * width + 7) / 8 + 4 - 1) & -4);
const int stride = stride_for_format_and_width(PIXMAN_a8r8g8b8, width);
/* Total size */
size = stride * height;