summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher N. Hesse <raymanfx@gmail.com>2016-06-27 14:35:34 +0200
committerAndreas Schneider <asn@cryptomilk.org>2016-07-08 07:39:35 +0200
commitba8e5f2537da560e1164216c7f1cb6a2b6d38488 (patch)
tree3ccfaea69528905e42bbd78bfc53b8b7d3151019
parent2f90f03073597afde602ee668487fa5bd691dd9a (diff)
downloadandroid_hardware_samsung_slsi_exynos5430-ba8e5f2537da560e1164216c7f1cb6a2b6d38488.tar.gz
android_hardware_samsung_slsi_exynos5430-ba8e5f2537da560e1164216c7f1cb6a2b6d38488.tar.xz
android_hardware_samsung_slsi_exynos5430-ba8e5f2537da560e1164216c7f1cb6a2b6d38488.zip
gralloc: Avoid swapping buffers in background threads
Finish all current drawcalls for the composition thread and continue once the operation is complete. Change-Id: I6bc46ae0e6ee7150f7452c170fdb4a5283a0b8ff
-rw-r--r--gralloc/Android.mk2
-rw-r--r--gralloc/framebuffer.cpp23
2 files changed, 23 insertions, 2 deletions
diff --git a/gralloc/Android.mk b/gralloc/Android.mk
index e1edc61..c35b7d7 100644
--- a/gralloc/Android.mk
+++ b/gralloc/Android.mk
@@ -20,7 +20,7 @@ LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR_SHARED_LIBRARIES)/hw
-LOCAL_SHARED_LIBRARIES := liblog libcutils libion libutils
+LOCAL_SHARED_LIBRARIES := liblog libcutils libion libutils libGLESv1_CM
LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/../include \
diff --git a/gralloc/framebuffer.cpp b/gralloc/framebuffer.cpp
index b34a6b6..1fc133e 100644
--- a/gralloc/framebuffer.cpp
+++ b/gralloc/framebuffer.cpp
@@ -24,6 +24,8 @@
#include <hardware/hardware.h>
#include <hardware/gralloc.h>
+#include <GLES/gl.h>
+
#include <fcntl.h>
#include <errno.h>
#include <sys/ioctl.h>
@@ -271,6 +273,25 @@ int init_fb(struct private_module_t* module)
return 0;
}
+int compositionComplete(struct framebuffer_device_t* dev)
+{
+ /* By doing a finish here we force the GL driver to start rendering
+ all the drawcalls up to this point, and to wait for the rendering to be complete.*/
+ glFinish();
+ /* The rendering of the backbuffer is now completed.
+ When SurfaceFlinger later does a call to eglSwapBuffer(), the swap will be done
+ synchronously in the same thread, and not asynchronoulsy in a background thread later.
+ The SurfaceFlinger requires this behaviour since it releases the lock on all the
+ SourceBuffers (Layers) after the compositionComplete() function returns.
+ However this "bad" behaviour by SurfaceFlinger should not affect performance,
+ since the Applications that render the SourceBuffers (Layers) still get the
+ full renderpipeline using asynchronous rendering. So they perform at maximum speed,
+ and because of their complexity compared to the Surface flinger jobs, the Surface flinger
+ is normally faster even if it does everyhing synchronous and serial.
+ */
+ return 0;
+}
+
int fb_device_open(hw_module_t const* module, const char* name,
hw_device_t** device)
{
@@ -321,7 +342,7 @@ int fb_device_open(hw_module_t const* module, const char* name,
dev->setSwapInterval = fb_setSwapInterval;
dev->post = fb_post;
dev->setUpdateRect = 0;
- dev->compositionComplete = 0;
+ dev->compositionComplete = &compositionComplete;
m->queue = new hwc_callback_queue_t;
pthread_mutex_init(&m->queue_lock, NULL);