From 85a2e2f0284ce5b5cc79b2db775d32cf03078029 Mon Sep 17 00:00:00 2001 From: Mathias Agopian Date: Tue, 15 Nov 2011 22:52:25 -0800 Subject: don't call eglSwapBufferss() when its not needed. eglSwapBuffers() copies the previous backbuffer, which consumes power and bandwidth. If there are no framebuffer layers there is no reason to do this. this should save power with full-screen videos. Change-Id: I7feb5a3f2d7d426dd93d2203849a6d591ce377db --- libhwcomposer/SecHWC.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'libhwcomposer') diff --git a/libhwcomposer/SecHWC.cpp b/libhwcomposer/SecHWC.cpp index 6fe39a0..0f81277 100644 --- a/libhwcomposer/SecHWC.cpp +++ b/libhwcomposer/SecHWC.cpp @@ -293,6 +293,8 @@ static int hwc_set(hwc_composer_device_t *dev, struct sec_rect dst_rect; + bool need_swap_buffers = ctx->num_of_fb_layer > 0; + /* * H/W composer documentation states: * There is an implicit layer containing opaque black @@ -312,13 +314,16 @@ static int hwc_set(hwc_composer_device_t *dev, glClearColor(0, 0, 0, 0); glClear(GL_COLOR_BUFFER_BIT); glEnable(GL_SCISSOR_TEST); + need_swap_buffers = true; } ctx->num_of_fb_layer_prev = ctx->num_of_fb_layer; - EGLBoolean sucess = eglSwapBuffers((EGLDisplay)dpy, (EGLSurface)sur); - if (!sucess) { - return HWC_EGL_ERROR; + if (need_swap_buffers || !list) { + EGLBoolean sucess = eglSwapBuffers((EGLDisplay)dpy, (EGLSurface)sur); + if (!sucess) { + return HWC_EGL_ERROR; + } } if (!list) { -- cgit v1.1