void setListStats(hwc_context_t *ctx, const hwc_display_contents_1_t *list, int dpy) { ctx->listStats[dpy].numAppLayers = list->numHwLayers - 1; ctx->listStats[dpy].fbLayerIndex = list->numHwLayers - 1; ctx->listStats[dpy].yuvCount = 0; ctx->listStats[dpy].yuvIndex = -1; ctx->listStats[dpy].skipCount = 0; for (size_t i = 0; i < list->numHwLayers; i++) { private_handle_t *hnd = (private_handle_t *)list->hwLayers[i].handle; if(list->hwLayers[i].compositionType == HWC_FRAMEBUFFER_TARGET) { continue; //We disregard FB being skip for now! so the else if } else if (isSkipLayer(&list->hwLayers[i])) { ctx->listStats[dpy].skipCount++; } if (UNLIKELY(isYuvBuffer(hnd))) { ctx->listStats[dpy].yuvCount++; ctx->listStats[dpy].yuvIndex = i; } } }
void getLayerStats(hwc_context_t *ctx, const hwc_layer_list_t *list) { //Video specific stats int yuvCount = 0; int yuvLayerIndex = -1; bool isYuvLayerSkip = false; for (size_t i = 0; i < list->numHwLayers; i++) { private_handle_t *hnd = (private_handle_t *)list->hwLayers[i].handle; if (isYuvBuffer(hnd)) { yuvCount++; yuvLayerIndex = i; //Animating if (isSkipLayer(&list->hwLayers[i])) { isYuvLayerSkip = true; } } else if (isSkipLayer(&list->hwLayers[i])) { //Popups //If video layer is below a skip layer if(yuvLayerIndex != -1 && yuvLayerIndex < (ssize_t)i) { isYuvLayerSkip = true; } } } VideoOverlay::setStats(yuvCount, yuvLayerIndex, isYuvLayerSkip); CopyBit::setStats(yuvCount, yuvLayerIndex, isYuvLayerSkip); ctx->numHwLayers = list->numHwLayers; return; }
void setListStats(hwc_context_t *ctx, const hwc_display_contents_1_t *list, int dpy) { ctx->listStats[dpy].numAppLayers = list->numHwLayers - 1; ctx->listStats[dpy].fbLayerIndex = list->numHwLayers - 1; ctx->listStats[dpy].skipCount = 0; ctx->listStats[dpy].needsAlphaScale = false; ctx->listStats[dpy].yuvCount = 0; for (size_t i = 0; i < list->numHwLayers; i++) { hwc_layer_1_t const* layer = &list->hwLayers[i]; private_handle_t *hnd = (private_handle_t *)layer->handle; //reset stored yuv index ctx->listStats[dpy].yuvIndices[i] = -1; if(list->hwLayers[i].compositionType == HWC_FRAMEBUFFER_TARGET) { continue; //We disregard FB being skip for now! so the else if } else if (isSkipLayer(&list->hwLayers[i])) { ctx->listStats[dpy].skipCount++; } else if (UNLIKELY(isYuvBuffer(hnd))) { int& yuvCount = ctx->listStats[dpy].yuvCount; ctx->listStats[dpy].yuvIndices[yuvCount] = i; yuvCount++; } if(!ctx->listStats[dpy].needsAlphaScale) ctx->listStats[dpy].needsAlphaScale = isAlphaScaled(layer); } }
void setListStats(hwc_context_t *ctx, const hwc_display_contents_1_t *list, int dpy) { const int prevYuvCount = ctx->listStats[dpy].yuvCount; ctx->listStats[dpy].numAppLayers = list->numHwLayers - 1; ctx->listStats[dpy].fbLayerIndex = list->numHwLayers - 1; ctx->listStats[dpy].skipCount = 0; ctx->listStats[dpy].needsAlphaScale = false; ctx->listStats[dpy].preMultipliedAlpha = false; ctx->listStats[dpy].planeAlpha = false; ctx->listStats[dpy].yuvCount = 0; //reset yuv indices memset(ctx->listStats[dpy].yuvIndices, -1, MAX_NUM_APP_LAYERS); for (size_t i = 0; i < (list->numHwLayers - 1); i++) { hwc_layer_1_t const* layer = &list->hwLayers[i]; private_handle_t *hnd = (private_handle_t *)layer->handle; // continue if i reaches MAX_NUM_APP_LAYERS if(i >= MAX_NUM_APP_LAYERS) continue; if(list->hwLayers[i].compositionType == HWC_FRAMEBUFFER_TARGET) { continue; //We disregard FB being skip for now! so the else if } else if (isSkipLayer(&list->hwLayers[i])) { ctx->listStats[dpy].skipCount++; } else if (UNLIKELY(isYuvBuffer(hnd))) { int& yuvCount = ctx->listStats[dpy].yuvCount; ctx->listStats[dpy].yuvIndices[yuvCount] = i; yuvCount++; if(layer->transform & HWC_TRANSFORM_ROT_90) ctx->mNeedsRotator = true; } if(layer->blending == HWC_BLENDING_PREMULT) ctx->listStats[dpy].preMultipliedAlpha = true; if(layer->planeAlpha < 0xFF) ctx->listStats[dpy].planeAlpha = true; if(!ctx->listStats[dpy].needsAlphaScale) ctx->listStats[dpy].needsAlphaScale = isAlphaScaled(layer); } //The marking of video begin/end is useful on some targets where we need //to have a padding round to be able to shift pipes across mixers. if(prevYuvCount != ctx->listStats[dpy].yuvCount) { ctx->mVideoTransFlag = true; } if (dpy == HWC_DISPLAY_PRIMARY) configurePPD(ctx, ctx->listStats[dpy].yuvCount); }
void setMdpFlags(hwc_layer_1_t *layer, ovutils::eMdpFlags &mdpFlags, int rotDownscale) { private_handle_t *hnd = (private_handle_t *)layer->handle; MetaData_t *metadata = (MetaData_t *)hnd->base_metadata; const int& transform = layer->transform; if(layer->blending == HWC_BLENDING_PREMULT) { ovutils::setMdpFlags(mdpFlags, ovutils::OV_MDP_BLEND_FG_PREMULT); } if(isYuvBuffer(hnd)) { if(isSecureBuffer(hnd)) { ovutils::setMdpFlags(mdpFlags, ovutils::OV_MDP_SECURE_OVERLAY_SESSION); } if(metadata && (metadata->operation & PP_PARAM_INTERLACED) && metadata->interlaced) { ovutils::setMdpFlags(mdpFlags, ovutils::OV_MDP_DEINTERLACE); } //Pre-rotation will be used using rotator. if(transform & HWC_TRANSFORM_ROT_90) { ovutils::setMdpFlags(mdpFlags, ovutils::OV_MDP_SOURCE_ROTATED_90); } } //No 90 component and no rot-downscale then flips done by MDP //If we use rot then it might as well do flips if(!(layer->transform & HWC_TRANSFORM_ROT_90) && !rotDownscale) { if(layer->transform & HWC_TRANSFORM_FLIP_H) { ovutils::setMdpFlags(mdpFlags, ovutils::OV_MDP_FLIP_H); } if(layer->transform & HWC_TRANSFORM_FLIP_V) { ovutils::setMdpFlags(mdpFlags, ovutils::OV_MDP_FLIP_V); } } if(metadata && ((metadata->operation & PP_PARAM_HSIC) || (metadata->operation & PP_PARAM_IGC) || (metadata->operation & PP_PARAM_SHARP2))) { ovutils::setMdpFlags(mdpFlags, ovutils::OV_MDP_PP_EN); } }
void getLayerStats(hwc_context_t *ctx, const hwc_layer_list_t *list) { //Video specific stats int yuvCount = 0; int yuvLayerIndex = -1; int pipLayerIndex = -1; //2nd video in pip scenario bool isYuvLayerSkip = false; int skipCount = 0; int ccLayerIndex = -1; //closed caption int extLayerIndex = -1; //ext-only or block except closed caption int extCount = 0; //ext-only except closed caption bool isExtBlockPresent = false; //is BLOCK layer present bool yuvSecure = false; for (size_t i = 0; i < list->numHwLayers; i++) { private_handle_t *hnd = (private_handle_t *)list->hwLayers[i].handle; if (UNLIKELY(isYuvBuffer(hnd))) { yuvCount++; if(yuvCount==1) { //Set the primary video to the video layer in //lower z-order yuvLayerIndex = i; } if(yuvCount == 2) { //In case of two videos, set the pipLayerIndex to the //second video pipLayerIndex = i; } yuvSecure = isSecureBuffer(hnd); //Animating //Do not mark as SKIP if it is secure buffer if (isSkipLayer(&list->hwLayers[i]) && !yuvSecure) { isYuvLayerSkip = true; } } else if(UNLIKELY(isExtCC(hnd))) { ccLayerIndex = i; } else if(UNLIKELY(isExtBlock(hnd))) { extCount++; extLayerIndex = i; isExtBlockPresent = true; } else if(UNLIKELY(isExtOnly(hnd))) { extCount++; //If BLOCK layer present, dont cache index, display BLOCK only. if(isExtBlockPresent == false) extLayerIndex = i; } else if (isSkipLayer(&list->hwLayers[i])) { //Popups skipCount++; } } VideoOverlay::setStats(yuvCount, yuvLayerIndex, isYuvLayerSkip, ccLayerIndex); VideoPIP::setStats(yuvCount, yuvLayerIndex, isYuvLayerSkip, pipLayerIndex); ExtOnly::setStats(extCount, extLayerIndex, isExtBlockPresent); CopyBit::setStats(skipCount); MDPComp::setStats(skipCount); ctx->numHwLayers = list->numHwLayers; return; }
int configureLowRes(hwc_context_t *ctx, hwc_layer_1_t *layer, const int& dpy, eMdpFlags& mdpFlags, const eZorder& z, const eIsFg& isFg, const eDest& dest, Rotator **rot) { private_handle_t *hnd = (private_handle_t *)layer->handle; if(!hnd) { ALOGE("%s: layer handle is NULL", __FUNCTION__); return -1; } MetaData_t *metadata = (MetaData_t *)hnd->base_metadata; hwc_rect_t crop = layer->sourceCrop; hwc_rect_t dst = layer->displayFrame; int transform = layer->transform; eTransform orient = static_cast<eTransform>(transform); int downscale = 0; int rotFlags = ovutils::ROT_FLAGS_NONE; Whf whf(getWidth(hnd), getHeight(hnd), getMdpFormat(hnd->format), hnd->size); bool forceRot = false; if(isYuvBuffer(hnd) && ctx->mMDP.version >= qdutils::MDP_V4_2 && ctx->mMDP.version < qdutils::MDSS_V5) { downscale = getDownscaleFactor( crop.right - crop.left, crop.bottom - crop.top, dst.right - dst.left, dst.bottom - dst.top); if(downscale) { rotFlags = ROT_DOWNSCALE_ENABLED; } unsigned int& prevWidth = ctx->mPrevWHF[dpy].w; unsigned int& prevHeight = ctx->mPrevWHF[dpy].h; if(prevWidth != (uint32_t)getWidth(hnd) || prevHeight != (uint32_t)getHeight(hnd)) { uint32_t prevBufArea = (prevWidth * prevHeight); if(prevBufArea) { forceRot = true; } prevWidth = (uint32_t)getWidth(hnd); prevHeight = (uint32_t)getHeight(hnd); } } setMdpFlags(layer, mdpFlags, downscale); trimLayer(ctx, dpy, transform, crop, dst); if(isYuvBuffer(hnd) && //if 90 component or downscale, use rot ((transform & HWC_TRANSFORM_ROT_90) || downscale || forceRot)) { *rot = ctx->mRotMgr->getNext(); if(*rot == NULL) return -1; //Configure rotator for pre-rotation Whf origWhf(hnd->width, hnd->height, getMdpFormat(hnd->format), hnd->size); if(configRotator(*rot, whf, origWhf, mdpFlags, orient, downscale) < 0) return -1; ctx->mLayerRotMap[dpy]->add(layer, *rot); whf.format = (*rot)->getDstFormat(); updateSource(orient, whf, crop); rotFlags |= ovutils::ROT_PREROTATED; } //For the mdp, since either we are pre-rotating or MDP does flips orient = OVERLAY_TRANSFORM_0; transform = 0; PipeArgs parg(mdpFlags, whf, z, isFg, static_cast<eRotFlags>(rotFlags), layer->planeAlpha, (ovutils::eBlending) getBlending(layer->blending)); if(configMdp(ctx->mOverlay, parg, orient, crop, dst, metadata, dest) < 0) { ALOGE("%s: commit failed for low res panel", __FUNCTION__); ctx->mLayerRotMap[dpy]->reset(); return -1; } return 0; }
int configureHighRes(hwc_context_t *ctx, hwc_layer_1_t *layer, const int& dpy, eMdpFlags& mdpFlagsL, const eZorder& z, const eIsFg& isFg, const eDest& lDest, const eDest& rDest, Rotator **rot) { private_handle_t *hnd = (private_handle_t *)layer->handle; if(!hnd) { ALOGE("%s: layer handle is NULL", __FUNCTION__); return -1; } MetaData_t *metadata = (MetaData_t *)hnd->base_metadata; int hw_w = ctx->dpyAttr[dpy].xres; int hw_h = ctx->dpyAttr[dpy].yres; hwc_rect_t crop = layer->sourceCrop; hwc_rect_t dst = layer->displayFrame; int transform = layer->transform; eTransform orient = static_cast<eTransform>(transform); const int downscale = 0; int rotFlags = ROT_FLAGS_NONE; Whf whf(getWidth(hnd), getHeight(hnd), getMdpFormat(hnd->format), hnd->size); setMdpFlags(layer, mdpFlagsL); trimLayer(ctx, dpy, transform, crop, dst); if(isYuvBuffer(hnd) && (transform & HWC_TRANSFORM_ROT_90)) { (*rot) = ctx->mRotMgr->getNext(); if((*rot) == NULL) return -1; //Configure rotator for pre-rotation Whf origWhf(hnd->width, hnd->height, getMdpFormat(hnd->format), hnd->size); if(configRotator(*rot, whf, origWhf, mdpFlagsL, orient, downscale) < 0) return -1; ctx->mLayerRotMap[dpy]->add(layer, *rot); whf.format = (*rot)->getDstFormat(); updateSource(orient, whf, crop); rotFlags |= ROT_PREROTATED; } eMdpFlags mdpFlagsR = mdpFlagsL; setMdpFlags(mdpFlagsR, OV_MDSS_MDP_RIGHT_MIXER); hwc_rect_t tmp_cropL, tmp_dstL; hwc_rect_t tmp_cropR, tmp_dstR; if(lDest != OV_INVALID) { tmp_cropL = crop; tmp_dstL = dst; hwc_rect_t scissor = {0, 0, hw_w/2, hw_h }; qhwc::calculate_crop_rects(tmp_cropL, tmp_dstL, scissor, 0); } if(rDest != OV_INVALID) { tmp_cropR = crop; tmp_dstR = dst; hwc_rect_t scissor = {hw_w/2, 0, hw_w, hw_h }; qhwc::calculate_crop_rects(tmp_cropR, tmp_dstR, scissor, 0); } //When buffer is flipped, contents of mixer config also needs to swapped. //Not needed if the layer is confined to one half of the screen. //If rotator has been used then it has also done the flips, so ignore them. if((orient & OVERLAY_TRANSFORM_FLIP_V) && lDest != OV_INVALID && rDest != OV_INVALID && rot == NULL) { hwc_rect_t new_cropR; new_cropR.left = tmp_cropL.left; new_cropR.right = new_cropR.left + (tmp_cropR.right - tmp_cropR.left); hwc_rect_t new_cropL; new_cropL.left = new_cropR.right; new_cropL.right = tmp_cropR.right; tmp_cropL.left = new_cropL.left; tmp_cropL.right = new_cropL.right; tmp_cropR.left = new_cropR.left; tmp_cropR.right = new_cropR.right; } //For the mdp, since either we are pre-rotating or MDP does flips orient = OVERLAY_TRANSFORM_0; transform = 0; //configure left mixer if(lDest != OV_INVALID) { PipeArgs pargL(mdpFlagsL, whf, z, isFg, static_cast<eRotFlags>(rotFlags), layer->planeAlpha, (ovutils::eBlending) getBlending(layer->blending)); if(configMdp(ctx->mOverlay, pargL, orient, tmp_cropL, tmp_dstL, metadata, lDest) < 0) { ALOGE("%s: commit failed for left mixer config", __FUNCTION__); return -1; } } //configure right mixer if(rDest != OV_INVALID) { PipeArgs pargR(mdpFlagsR, whf, z, isFg, static_cast<eRotFlags>(rotFlags), layer->planeAlpha, (ovutils::eBlending) getBlending(layer->blending)); tmp_dstR.right = tmp_dstR.right - tmp_dstR.left; tmp_dstR.left = 0; if(configMdp(ctx->mOverlay, pargR, orient, tmp_cropR, tmp_dstR, metadata, rDest) < 0) { ALOGE("%s: commit failed for right mixer config", __FUNCTION__); return -1; } } return 0; }