From 61390825ec148eae2de4cbcfc08d7115b2a8e38a Mon Sep 17 00:00:00 2001 From: Naomi Luis Date: Fri, 29 Jul 2011 10:59:33 -0700 Subject: [PATCH] libhwcomposer: Move the skip composition logic to a separate API Create a new function to check if we need to skip the composition during overlay operations. Reset the previous compCount variable if there is no video layer present. Change-Id: Ibf570805114440f117f0fb98b5f2d53c1780ec84 CRs-fixed: 298014 --- libhwcomposer/hwcomposer.cpp | 38 +++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/libhwcomposer/hwcomposer.cpp b/libhwcomposer/hwcomposer.cpp index 557f566..63f6aec 100755 --- a/libhwcomposer/hwcomposer.cpp +++ b/libhwcomposer/hwcomposer.cpp @@ -272,6 +272,36 @@ static int prepareOverlay(hwc_context_t *ctx, hwc_layer_t *layer) { return 0; } +bool canSkipComposition(hwc_context_t* ctx, int yuvBufferCount, int currentLayerCount, + int numLayersNotUpdating) +{ + if (!ctx) { + LOGE("canSkipComposition invalid context"); + return false; + } + + bool compCountChanged = false; + if (yuvBufferCount == 1) { + if (currentLayerCount != ctx->previousLayerCount) { + compCountChanged = true; + ctx->previousLayerCount = currentLayerCount; + } + + if (!compCountChanged) { + if ((currentLayerCount == 1) || + ((currentLayerCount-1) == numLayersNotUpdating)) { + // We either have only one overlay layer or we have + // all the non-UI layers not updating. In this case + // we can skip the composition of the UI layers. + return true; + } + } + } else { + ctx->previousLayerCount = -1; + } + return false; +} + static int hwc_prepare(hwc_composer_device_t *dev, hwc_layer_list_t* list) { hwc_context_t* ctx = (hwc_context_t*)(dev); @@ -335,13 +365,7 @@ static int hwc_prepare(hwc_composer_device_t *dev, hwc_layer_list_t* list) { } } - bool compCountChanged = false; - if (list->numHwLayers != ctx->previousLayerCount) { - compCountChanged = true; - ctx->previousLayerCount = list->numHwLayers; - } - if ((yuvBufferCount == 1) && ((list->numHwLayers-1) == numLayersNotUpdating) - && !compCountChanged) { + if (canSkipComposition(ctx, yuvBufferCount, list->numHwLayers, numLayersNotUpdating)) { list->flags |= HWC_SKIP_COMPOSITION; } else { list->flags &= ~HWC_SKIP_COMPOSITION;