From 875a92e98d801bd3cbbf020e02e64ee1fb3acc2a Mon Sep 17 00:00:00 2001 From: Sushil Chauhan Date: Fri, 25 Jul 2014 12:20:23 -0700 Subject: [PATCH] hwc: Configure MDP with updated crop and whf for PTOR layers 1. For PTOR layers, MDP needs to be configured with width, height and format of the Copybit render buffer, otherwise it will lead to artifacts due to incorrect render buffer reads, when PTOR layer handles have un-equal strides. 2. Remove render buffer offset for a PTOR layer and configure MDP with modified source crop, based on its position on render buffer. 3. A layer cannot qualify for PTOR feature, if none of below layers intersect with it. Change-Id: Idba65789b9ed3b699a5c70107881868c0385322d --- libhwcomposer/hwc_copybit.cpp | 8 ------ libhwcomposer/hwc_mdpcomp.cpp | 50 +++++++++++++++++++++++++++-------- libhwcomposer/hwc_utils.h | 1 - 3 files changed, 39 insertions(+), 20 deletions(-) diff --git a/libhwcomposer/hwc_copybit.cpp b/libhwcomposer/hwc_copybit.cpp index 33d460bc..d6e5e8a4 100644 --- a/libhwcomposer/hwc_copybit.cpp +++ b/libhwcomposer/hwc_copybit.cpp @@ -248,14 +248,6 @@ bool CopyBit::prepareOverlap(hwc_context_t *ctx, getBufferSizeAndDimensions(finalW, finalH, HAL_PIXEL_FORMAT_RGBA_8888, alignW, alignH); - int heightFromTop = 0; - for (int i = 0; i < ptorInfo->count; i++) { - // Offset depends on stride calculated by gralloc for RGBA (4 bpp) - ptorInfo->mRenderBuffOffset[i] = alignW * heightFromTop * 4; - heightFromTop += ALIGN((ptorInfo->displayFrame[i].bottom - - ptorInfo->displayFrame[i].top), 32); - } - if ((mAlignedWidth != alignW) || (mAlignedHeight != alignH)) { // Overlap rect has changed, so free render buffers freeRenderBuffers(); diff --git a/libhwcomposer/hwc_mdpcomp.cpp b/libhwcomposer/hwc_mdpcomp.cpp index adf30fe4..6f99a502 100644 --- a/libhwcomposer/hwc_mdpcomp.cpp +++ b/libhwcomposer/hwc_mdpcomp.cpp @@ -849,18 +849,19 @@ bool MDPComp::fullMDPCompWithPTOR(hwc_context_t *ctx, // Overlap area > (1/3 * FrameBuffer) area, based on Perf inputs. continue; } - // Found the PTOR layer - bool found = true; + bool found = false; for (int j = i-1; j >= 0; j--) { // Check if the layers below this layer qualifies for PTOR comp hwc_layer_1_t* layer = &list->hwLayers[j]; hwc_rect_t disFrame = layer->displayFrame; - //layer below PTOR is intersecting and has 90 degree transform or + // Layer below PTOR is intersecting and has 90 degree transform or // needs scaling cannot be supported. - if ((isValidRect(getIntersection(dispFrame, disFrame))) - && (has90Transform(layer) || needsScaling(layer))) { - found = false; - break; + if (isValidRect(getIntersection(dispFrame, disFrame))) { + if (has90Transform(layer) || needsScaling(layer)) { + found = false; + break; + } + found = true; } } // Store the minLayer Index @@ -903,11 +904,30 @@ bool MDPComp::fullMDPCompWithPTOR(hwc_context_t *ctx, sourceCrop[i] = integerizeSourceCrop(layer->sourceCropf); } + private_handle_t *renderBuf = ctx->mCopyBit[mDpy]->getCurrentRenderBuffer(); + Whf layerWhf[numPTORLayersFound]; // To store w,h,f of PTOR layers + for(int j = 0; j < numPTORLayersFound; j++) { int index = ctx->mPtorInfo.layerIndex[j]; + + // Update src crop of PTOR layer + hwc_layer_1_t* layer = &list->hwLayers[index]; + layer->sourceCropf.left = (float)ctx->mPtorInfo.displayFrame[j].left; + layer->sourceCropf.top = (float)ctx->mPtorInfo.displayFrame[j].top; + layer->sourceCropf.right = (float)ctx->mPtorInfo.displayFrame[j].right; + layer->sourceCropf.bottom =(float)ctx->mPtorInfo.displayFrame[j].bottom; + + // Store & update w, h, format of PTOR layer + private_handle_t *hnd = (private_handle_t *)layer->handle; + Whf whf(hnd->width, hnd->height, hnd->format, hnd->size); + layerWhf[j] = whf; + hnd->width = renderBuf->width; + hnd->height = renderBuf->height; + hnd->format = renderBuf->format; + // Remove overlap from crop & displayFrame of below layers for (int i = 0; i < index && index !=-1; i++) { - hwc_layer_1_t* layer = &list->hwLayers[i]; + layer = &list->hwLayers[i]; if(!isValidRect(getIntersection(layer->displayFrame, overlapRect[j]))) { continue; @@ -944,6 +964,15 @@ bool MDPComp::fullMDPCompWithPTOR(hwc_context_t *ctx, layer->sourceCropf.bottom = (float)sourceCrop[i].bottom; } + // Restore w,h,f of PTOR layers + for (int i = 0; i < numPTORLayersFound; i++) { + int idx = ctx->mPtorInfo.layerIndex[i]; + private_handle_t *hnd = (private_handle_t *)list->hwLayers[idx].handle; + hnd->width = layerWhf[i].w; + hnd->height = layerWhf[i].h; + hnd->format = layerWhf[i].format; + } + if (!result) { // reset PTOR ctx->mPtorInfo.count = 0; @@ -1928,8 +1957,7 @@ bool MDPCompNonSplit::draw(hwc_context_t *ctx, hwc_display_contents_1_t* list) { if (!mDpy && (index != -1)) { hnd = ctx->mCopyBit[mDpy]->getCurrentRenderBuffer(); fd = hnd->fd; - // Use the offset of the RenderBuffer - offset = ctx->mPtorInfo.mRenderBuffOffset[index]; + offset = 0; } ALOGD_IF(isDebug(),"%s: MDP Comp: Drawing layer: %p hnd: %p \ @@ -2180,7 +2208,7 @@ bool MDPCompSplit::draw(hwc_context_t *ctx, hwc_display_contents_1_t* list) { if (!mDpy && (index != -1)) { hnd = ctx->mCopyBit[mDpy]->getCurrentRenderBuffer(); fd = hnd->fd; - offset = ctx->mPtorInfo.mRenderBuffOffset[index]; + offset = 0; } if(ctx->mAD->draw(ctx, fd, offset)) { diff --git a/libhwcomposer/hwc_utils.h b/libhwcomposer/hwc_utils.h index dd55f8bb..528c5c09 100644 --- a/libhwcomposer/hwc_utils.h +++ b/libhwcomposer/hwc_utils.h @@ -137,7 +137,6 @@ struct ListStats { struct PtorInfo { int count; int layerIndex[MAX_PTOR_LAYERS]; - int mRenderBuffOffset[MAX_PTOR_LAYERS]; hwc_rect_t displayFrame[MAX_PTOR_LAYERS]; bool isActive() { return (count>0); } int getPTORArrayIndex(int index) {