diff options
author | Gerd Hoffmann <kraxel@redhat.com> | 2019-12-02 12:36:50 +0100 |
---|---|---|
committer | Gerd Hoffmann <kraxel@redhat.com> | 2019-12-02 12:36:50 +0100 |
commit | 7612977a7e685461db033a8509d0bce6a0a28dc6 (patch) | |
tree | 3bfd79e34b2842831d099a15c400b556dfa02029 | |
parent | 88aea3146426a0b2034de37aba46bc1fcb193dc3 (diff) | |
download | drminfo-7612977a7e685461db033a8509d0bce6a0a28dc6.tar.gz |
more vgem code restruction
-rw-r--r-- | drmtest.c | 58 |
1 files changed, 29 insertions, 29 deletions
@@ -219,7 +219,7 @@ static void drm_zap_mappings(void) /* ------------------------------------------------------------------ */ -static void drm_init_dumb_obj(int fd, bool create_dmabuf) +static void drm_init_dumb_obj(int fd, bool use_pixman, bool create_dmabuf) { struct drm_mode_map_dumb mreq; int rc; @@ -267,6 +267,33 @@ static void drm_init_dumb_obj(int fd, bool create_dmabuf) } } } + + if (use_pixman) { + pxfb = pixman_image_create_bits(fmt->pixman, + creq.width, + creq.height, + (void*)fbmem, + creq.pitch); + pxref = pixman_image_create_bits(fmt->pixman, + creq.width, + creq.height, + NULL, 0); + pxcs = pixman_image_create_bits(PIXMAN_x2r10g10b10, + creq.width, + creq.height, + NULL, 0); + cs = cairo_image_surface_create_for_data((void*)pixman_image_get_data(pxcs), + CAIRO_FORMAT_RGB30, + creq.width, + creq.height, + pixman_image_get_stride(pxcs)); + } else { + cs = cairo_image_surface_create_for_data(fbmem, + fmt->cairo, + creq.width, + creq.height, + creq.pitch); + } } static void drm_init_dumb_fb(bool use_pixman, bool create_dmabuf) @@ -274,7 +301,7 @@ static void drm_init_dumb_fb(bool use_pixman, bool create_dmabuf) uint32_t zero = 0; int rc; - drm_init_dumb_obj(drm_fd, create_dmabuf); + drm_init_dumb_obj(drm_fd, use_pixman, create_dmabuf); if (fmt->fourcc) { rc = drmModeAddFB2(drm_fd, creq.width, creq.height, fmt->fourcc, @@ -297,33 +324,6 @@ static void drm_init_dumb_fb(bool use_pixman, bool create_dmabuf) exit(1); } } - - if (use_pixman) { - pxfb = pixman_image_create_bits(fmt->pixman, - creq.width, - creq.height, - (void*)fbmem, - creq.pitch); - pxref = pixman_image_create_bits(fmt->pixman, - creq.width, - creq.height, - NULL, 0); - pxcs = pixman_image_create_bits(PIXMAN_x2r10g10b10, - creq.width, - creq.height, - NULL, 0); - cs = cairo_image_surface_create_for_data((void*)pixman_image_get_data(pxcs), - CAIRO_FORMAT_RGB30, - creq.width, - creq.height, - pixman_image_get_stride(pxcs)); - } else { - cs = cairo_image_surface_create_for_data(fbmem, - fmt->cairo, - creq.width, - creq.height, - creq.pitch); - } } static void drm_draw_dumb_fb(bool autotest, int updatetest) |