diff options
author | Thomas Hellstrom <thellstrom@vmware.com> | 2019-01-17 10:19:04 +0100 |
---|---|---|
committer | Thomas Hellstrom <thellstrom@vmware.com> | 2019-01-28 14:47:55 +0100 |
commit | 5569f16a14a1b6974051b57cd2850f00882a899c (patch) | |
tree | be1b58805be7dc0eebc9deb9eeb5b396027cb8c4 | |
parent | 0a7c3570c92d2d831fec34415b3d821af18ba858 (diff) |
vmwgfx: Unify style in scanout_update and present functions
Since the functions are pretty similar, Make them look more similar in terms
of memory allocation methods and variable names
Reported-by: Brian Paul <brianp@vmware.com>
Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
-rw-r--r-- | vmwgfx/vmwgfx_driver.c | 41 |
1 files changed, 25 insertions, 16 deletions
diff --git a/vmwgfx/vmwgfx_driver.c b/vmwgfx/vmwgfx_driver.c index 8297d53..be0404d 100644 --- a/vmwgfx/vmwgfx_driver.c +++ b/vmwgfx/vmwgfx_driver.c @@ -650,36 +650,45 @@ drv_pre_init(ScrnInfoPtr pScrn, int flags) static Bool vmwgfx_scanout_update(int drm_fd, int fb_id, RegionPtr dirty) { - unsigned int num_cliprects = REGION_NUM_RECTS(dirty); - unsigned int alloc_cliprects = min(num_cliprects, - DRM_MODE_FB_DIRTY_MAX_CLIPS); - drmModeClip *clip = alloca(alloc_cliprects * sizeof(drmModeClip)); - BoxPtr rect = REGION_RECTS(dirty); + BoxPtr clips = REGION_RECTS(dirty); + unsigned int num_clips = REGION_NUM_RECTS(dirty); + unsigned int alloc_clips = min(num_clips, DRM_MODE_FB_DIRTY_MAX_CLIPS); + drmModeClip *rects, *r; int i, ret; - while (num_cliprects > 0) { - unsigned int cur_cliprects = min(num_cliprects, - DRM_MODE_FB_DIRTY_MAX_CLIPS); + if (num_clips == 0) + return TRUE; + + rects = malloc(alloc_clips * sizeof(*rects)); + if (!rects) { + LogMessage(X_ERROR, "Failed to alloc cliprects for scanout update.\n"); + return FALSE; + } - memset(clip, 0, alloc_cliprects * sizeof(drmModeClip)); + while (num_clips > 0) { + unsigned int cur_clips = min(num_clips, DRM_MODE_FB_DIRTY_MAX_CLIPS); - for (i = 0; i < cur_cliprects; i++, rect++) { - clip[i].x1 = rect->x1; - clip[i].y1 = rect->y1; - clip[i].x2 = rect->x2; - clip[i].y2 = rect->y2; + memset(rects, 0, alloc_clips * sizeof(*rects)); + + for (i = 0, r = rects; i < cur_clips; ++i, ++r, ++clips) { + r->x1 = clips->x1; + r->y1 = clips->y1; + r->x2 = clips->x2; + r->y2 = clips->y2; } - ret = drmModeDirtyFB(drm_fd, fb_id, clip, cur_cliprects); + ret = drmModeDirtyFB(drm_fd, fb_id, rects, cur_clips); if (ret) { LogMessage(X_ERROR, "%s: failed to send dirty (%i, %s)\n", __func__, ret, strerror(-ret)); return FALSE; } - num_cliprects -= cur_cliprects; + num_clips -= cur_clips; } + free(rects); + return TRUE; } |