From 857f8a5f0b1674c5534481e0d7323938cbb61b02 Mon Sep 17 00:00:00 2001 From: "Sravan Kumar D.V.N" Date: Tue, 31 Jul 2012 17:38:47 +0530 Subject: [PATCH] display : Avoid calling eglGetRenderBufferANDROID for each layer Currently eglGetRenderBufferANDROID is being called for each layer which is not needed. This change calls this API once in set call, and passes the 'render buffer' to drawLayerUsingCopybit. Change-Id: I310163db02df13e8c03b51d73f291588fbf08160 --- libhwcomposer/hwc_copybit.cpp | 12 +++++------- libhwcomposer/hwc_copybit.h | 5 ++--- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/libhwcomposer/hwc_copybit.cpp b/libhwcomposer/hwc_copybit.cpp index 1ca77b9..430da0c 100644 --- a/libhwcomposer/hwc_copybit.cpp +++ b/libhwcomposer/hwc_copybit.cpp @@ -213,13 +213,15 @@ bool CopyBit::draw(hwc_context_t *ctx, hwc_layer_list_t *list, EGLDisplay dpy, EGLSurface sur){ // draw layers marked for COPYBIT int retVal = true; + EGLSurface eglSurface = LINK_eglGetCurrentSurface(EGL_DRAW); + android_native_buffer_t *renderBuffer = + (android_native_buffer_t *)LINK_eglGetRenderBufferANDROID(dpy, eglSurface); for (size_t i=0; inumHwLayers; i++) { if (list->hwLayers[i].compositionType == HWC_USE_COPYBIT) { retVal = drawLayerUsingCopybit(ctx, &(list->hwLayers[i]), (EGLDisplay)dpy, (EGLSurface)sur, - LINK_eglGetRenderBufferANDROID, - LINK_eglGetCurrentSurface); + renderBuffer); if(retVal<0) { ALOGE("%s : drawLayerUsingCopybit failed", __FUNCTION__); } @@ -231,8 +233,7 @@ bool CopyBit::draw(hwc_context_t *ctx, hwc_layer_list_t *list, EGLDisplay dpy, int CopyBit::drawLayerUsingCopybit(hwc_context_t *dev, hwc_layer_t *layer, EGLDisplay dpy, EGLSurface surface, - functype_eglGetRenderBufferANDROID& LINK_eglGetRenderBufferANDROID, - functype_eglGetCurrentSurface LINK_eglGetCurrentSurface) + android_native_buffer_t *renderBuffer) { hwc_context_t* ctx = (hwc_context_t*)(dev); if(!ctx) { @@ -254,9 +255,6 @@ int CopyBit::drawLayerUsingCopybit(hwc_context_t *dev, hwc_layer_t *layer, return -1; } //render buffer - EGLSurface eglSurface = LINK_eglGetCurrentSurface(EGL_DRAW); - android_native_buffer_t *renderBuffer = - (android_native_buffer_t *)LINK_eglGetRenderBufferANDROID(dpy, eglSurface); if (!renderBuffer) { ALOGE("%s: eglGetRenderBuffer returned NULL buffer", __FUNCTION__); genlock_unlock_buffer(hnd); diff --git a/libhwcomposer/hwc_copybit.h b/libhwcomposer/hwc_copybit.h index 8390968..d020091 100644 --- a/libhwcomposer/hwc_copybit.h +++ b/libhwcomposer/hwc_copybit.h @@ -48,9 +48,8 @@ public: static void updateEglHandles(void*); static int drawLayerUsingCopybit(hwc_context_t *dev, hwc_layer_t *layer, - EGLDisplay dpy, EGLSurface surface, - functype_eglGetRenderBufferANDROID& LINK_eglGetRenderBufferANDROID, - functype_eglGetCurrentSurface LINK_eglGetCurrentSurface); + EGLDisplay dpy, EGLSurface surface, + android_native_buffer_t *renderBuffer); static bool canUseCopybitForYUV (hwc_context_t *ctx); static bool canUseCopybitForRGB (hwc_context_t *ctx, hwc_layer_list_t *list);