diff options
author | Gwan-gyeong Mun <[email protected]> | 2017-07-19 15:05:31 +0100 |
---|---|---|
committer | Eric Engestrom <[email protected]> | 2017-08-01 18:37:58 +0100 |
commit | fe2a6281b3b299998fe7399e7dbcc2077d773824 (patch) | |
tree | 747932f813cd8092024602ec6d2e6d4548be33cc /src/egl/drivers | |
parent | 3a5e3aa5a53cff55a5e31766d713a41ffa5a93d7 (diff) |
egl/drm: Fix misused x and y offsets in swrast_get_image()
It fixes misused x and y variables on the calculation of the memory copy regions.
Cc: Giovanni Campagna <[email protected]>
Fixes: 8430af5ebe1ee8119e14 "Add support for swrast to the DRM EGL platform"
Signed-off-by: Mun Gwan-gyeong <[email protected]>
Reviewed-by: Eric Engestrom <[email protected]>
Reviewed-by: Emil Velikov <[email protected]>
[Eric: use gbm_bo_get_bpp() instead of local function, split clamp patch]
Signed-off-by: Eric Engestrom <[email protected]>
Diffstat (limited to 'src/egl/drivers')
-rw-r--r-- | src/egl/drivers/dri2/platform_drm.c | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/src/egl/drivers/dri2/platform_drm.c b/src/egl/drivers/dri2/platform_drm.c index b1cb3e13e6a..a952aa54560 100644 --- a/src/egl/drivers/dri2/platform_drm.c +++ b/src/egl/drivers/dri2/platform_drm.c @@ -575,20 +575,35 @@ swrast_get_image(__DRIdrawable *driDrawable, struct dri2_egl_surface *dri2_surf = loaderPrivate; int internal_stride, stride; struct gbm_dri_bo *bo; + uint32_t bpp; + int x_bytes, width_bytes; + char *src, *dst; if (get_swrast_front_bo(dri2_surf) < 0) return; bo = gbm_dri_bo(dri2_surf->current->bo); - if (gbm_dri_bo_map_dumb(bo) == NULL) + + bpp = gbm_bo_get_bpp(&bo->base); + if (bpp == 0) return; + x_bytes = x * (bpp >> 3); + width_bytes = width * (bpp >> 3); + internal_stride = bo->base.stride; - stride = width * 4; + stride = width_bytes; + + if (gbm_dri_bo_map_dumb(bo) == NULL) + return; + + dst = data; + src = bo->map + x_bytes + (y * internal_stride); for (int i = 0; i < height; i++) { - memcpy(data + i * stride, - bo->map + (x + i) * internal_stride + y, stride); + memcpy(dst, src, width_bytes); + dst += stride; + src += internal_stride; } gbm_dri_bo_unmap_dumb(bo); |