OSDN Git Service

drm_hwcomposer: Check against gem handles for popped buffer
authorAllen Martin <amartin@nvidia.com>
Sun, 22 Feb 2015 12:18:17 +0000 (04:18 -0800)
committerStéphane Marchesin <marcheu@google.com>
Sun, 22 Feb 2015 12:47:43 +0000 (12:47 +0000)
Add check before closing gem handle for most recently popped buffer in
addition to buffers in queue.

Change-Id: Icb096bd4db439b1195a123e28468142829fc61ea
Reviewed-on: https://chrome-internal-review.googlesource.com/200725
Reviewed-by: Stéphane Marchesin <marcheu@google.com>
Commit-Queue: Stéphane Marchesin <marcheu@google.com>
Tested-by: Stéphane Marchesin <marcheu@google.com>
hwcomposer.cpp

index 38616ff..77caf90 100644 (file)
@@ -318,8 +318,7 @@ static int hwc_wait_and_set(struct hwc_drm_display *hd,
                        continue;
 
                /* check for duplicate handle in buf_queue */
-               bool found = false;
-               std::list<struct hwc_drm_bo>::iterator bi;
+               bool found;
 
                ret = pthread_mutex_lock(&hd->set_worker.lock);
                if (ret) {
@@ -328,13 +327,17 @@ static int hwc_wait_and_set(struct hwc_drm_display *hd,
                }
 
                found = false;
-               for (bi = hd->buf_queue.begin();
+               for (std::list<struct hwc_drm_bo>::iterator bi = hd->buf_queue.begin();
                     bi != hd->buf_queue.end();
                     ++bi)
                        for (int j = 0; j < ARRAY_SIZE(bi->gem_handles); j++)
-                               if (hd->front.gem_handles[i] == bi->gem_handles[j])
+                               if (hd->front.gem_handles[i] == bi->gem_handles[j] )
                                        found = true;
 
+               for (int j = 0; j < ARRAY_SIZE(buf->gem_handles); j++)
+                       if (hd->front.gem_handles[i] == buf->gem_handles[j])
+                               found = true;
+
                if (!found) {
                        args.handle = hd->front.gem_handles[i];
                        drmIoctl(hd->ctx->fd, DRM_IOCTL_GEM_CLOSE, &args);