hwc: fix set() with zero layers
authorGreg Hackmann <ghackmann@google.com>
Wed, 22 Aug 2012 18:27:38 +0000 (11:27 -0700)
committerGreg Hackmann <ghackmann@google.com>
Wed, 22 Aug 2012 18:35:13 +0000 (11:35 -0700)
Initialization for the post callback should not be skipped, since set()
requires eglSwapBuffers() to be called even when there are zero layers

Change-Id: I624ef55e73b389aadf3516a6d2c541d67d398333
Signed-off-by: Greg Hackmann <ghackmann@google.com>
libhwc/hwc.cpp

index 885c6575b16ecc68605801774a4947e224fc0044..d5b5851b9fa894968e4b767e9fc7ebd44056244e 100644 (file)
@@ -971,51 +971,49 @@ static int exynos5_set(struct hwc_composer_device_1 *dev,
     pthread_mutex_t *lock = NULL;
     exynos5_hwc_post_data_t *data = NULL;
 
-    if (displays[0]->numHwLayers) {
-        for (size_t i = 0; i < NUM_HW_WINDOWS; i++) {
-            if (pdev->bufs.overlay_map[i] != -1) {
-                pdev->bufs.overlays[i] =
-                    displays[0]->hwLayers[pdev->bufs.overlay_map[i]];
-            }
+    for (size_t i = 0; i < NUM_HW_WINDOWS; i++) {
+        if (pdev->bufs.overlay_map[i] != -1) {
+            pdev->bufs.overlays[i] =
+                displays[0]->hwLayers[pdev->bufs.overlay_map[i]];
         }
+    }
 
-        data = (exynos5_hwc_post_data_t *)
-                malloc(sizeof(exynos5_hwc_post_data_t));
-        memcpy(data, &pdev->bufs, sizeof(pdev->bufs));
-
-        data->fence = -1;
-        pthread_mutex_init(&data->completion_lock, NULL);
-        pthread_cond_init(&data->completion, NULL);
-
-        if (pdev->bufs.fb_window == NO_FB_NEEDED) {
-            exynos5_post_callback(data, NULL);
-        } else {
-
-            struct hwc_callback_entry entry;
-            entry.callback = exynos5_post_callback;
-            entry.data = data;
-
-            queue = reinterpret_cast<hwc_callback_queue_t *>(
-                pdev->gralloc_module->queue);
-            lock = const_cast<pthread_mutex_t *>(
-                &pdev->gralloc_module->queue_lock);
-
-            pthread_mutex_lock(lock);
-            queue->push_front(entry);
-            pthread_mutex_unlock(lock);
-
-            EGLBoolean success = eglSwapBuffers((EGLDisplay)displays[0]->dpy,
-                    (EGLSurface)displays[0]->sur);
-            if (!success) {
-                ALOGE("HWC_EGL_ERROR");
-                if (displays[0]) {
-                    pthread_mutex_lock(lock);
-                    queue->removeAt(0);
-                    pthread_mutex_unlock(lock);
-                    free(data);
-                }
-                return HWC_EGL_ERROR;
+    data = (exynos5_hwc_post_data_t *)
+            malloc(sizeof(exynos5_hwc_post_data_t));
+    memcpy(data, &pdev->bufs, sizeof(pdev->bufs));
+
+    data->fence = -1;
+    pthread_mutex_init(&data->completion_lock, NULL);
+    pthread_cond_init(&data->completion, NULL);
+
+    if (displays[0]->numHwLayers && pdev->bufs.fb_window == NO_FB_NEEDED) {
+        exynos5_post_callback(data, NULL);
+    } else {
+
+        struct hwc_callback_entry entry;
+        entry.callback = exynos5_post_callback;
+        entry.data = data;
+
+        queue = reinterpret_cast<hwc_callback_queue_t *>(
+            pdev->gralloc_module->queue);
+        lock = const_cast<pthread_mutex_t *>(
+            &pdev->gralloc_module->queue_lock);
+
+        pthread_mutex_lock(lock);
+        queue->push_front(entry);
+        pthread_mutex_unlock(lock);
+
+        EGLBoolean success = eglSwapBuffers((EGLDisplay)displays[0]->dpy,
+                (EGLSurface)displays[0]->sur);
+        if (!success) {
+            ALOGE("HWC_EGL_ERROR");
+            if (displays[0]) {
+                pthread_mutex_lock(lock);
+                queue->removeAt(0);
+                pthread_mutex_unlock(lock);
+                free(data);
             }
+            return HWC_EGL_ERROR;
         }
     }