hqd: Adjust resolution based on aspect ratio

When the MDP downscale path is enabled we assign the primary
resolution as the external display's dimensions. However, the
aspect ratios of the external and primary displays can be different.
As a result, directly assigning primary resolution could lead
to an incorrect final image.

We get around this by calculating a new resolution by
keeping aspect ratio intact.

Change-Id: I217718a5474862154fe60837fc6518408d2c32c7
This commit is contained in:
Tatenda Chipeperekwa
2014-03-05 19:32:33 -08:00
parent a7dd23cc7e
commit f080b79508
2 changed files with 34 additions and 8 deletions

View File

@@ -35,6 +35,7 @@
#include "overlayUtils.h" #include "overlayUtils.h"
#include "overlay.h" #include "overlay.h"
#include "mdp_version.h" #include "mdp_version.h"
#include "qd_utils.h"
using namespace android; using namespace android;
@@ -594,14 +595,27 @@ void ExternalDisplay::setAttributes() {
// Restrict this upto 1080p resolution max // Restrict this upto 1080p resolution max
if(((priW * priH) > (width * height)) && if(((priW * priH) > (width * height)) &&
((priW * priH) <= SUPPORTED_DOWNSCALE_EXT_AREA)) { ((priW * priH) <= SUPPORTED_DOWNSCALE_EXT_AREA)) {
mHwcContext->dpyAttr[HWC_DISPLAY_EXTERNAL].xres = priW; // tmpW and tmpH will hold the primary dimensions before we
mHwcContext->dpyAttr[HWC_DISPLAY_EXTERNAL].yres = priH; // update the aspect ratio if necessary.
int tmpW = priW;
int tmpH = priH;
// HDMI is always in landscape, so always assign the higher // HDMI is always in landscape, so always assign the higher
// dimension to hdmi's xres // dimension to hdmi's xres
if(priH > priW) { if(priH > priW) {
mHwcContext->dpyAttr[HWC_DISPLAY_EXTERNAL].xres = priH; tmpW = priH;
mHwcContext->dpyAttr[HWC_DISPLAY_EXTERNAL].yres = priW; tmpH = priW;
} }
// The aspect ratios of the external and primary displays
// can be different. As a result, directly assigning primary
// resolution could lead to an incorrect final image.
// We get around this by calculating a new resolution by
// keeping aspect ratio intact.
hwc_rect r = {0, 0, 0, 0};
getAspectRatioPosition(tmpW, tmpH, width, height, r);
mHwcContext->dpyAttr[HWC_DISPLAY_EXTERNAL].xres =
r.right - r.left;
mHwcContext->dpyAttr[HWC_DISPLAY_EXTERNAL].yres =
r.bottom - r.top;
// Set External Display MDP Downscale mode indicator // Set External Display MDP Downscale mode indicator
mHwcContext->dpyAttr[HWC_DISPLAY_EXTERNAL].mDownScaleMode =true; mHwcContext->dpyAttr[HWC_DISPLAY_EXTERNAL].mDownScaleMode =true;
} }

View File

@@ -48,6 +48,7 @@
#include "overlayUtils.h" #include "overlayUtils.h"
#include "overlay.h" #include "overlay.h"
#include "mdp_version.h" #include "mdp_version.h"
#include "qd_utils.h"
using namespace android; using namespace android;
@@ -127,14 +128,25 @@ void VirtualDisplay::setToPrimary(uint32_t maxArea,
// by SUPPORTED_VIRTUAL_AREA). // by SUPPORTED_VIRTUAL_AREA).
if((maxArea == (priW * priH)) if((maxArea == (priW * priH))
&& (maxArea <= SUPPORTED_VIRTUAL_AREA)) { && (maxArea <= SUPPORTED_VIRTUAL_AREA)) {
extW = priW; // tmpW and tmpH will hold the primary dimensions before we
extH = priH; // update the aspect ratio if necessary.
uint32_t tmpW = priW;
uint32_t tmpH = priH;
// If WFD is in landscape, assign the higher dimension // If WFD is in landscape, assign the higher dimension
// to WFD's xres. // to WFD's xres.
if(priH > priW) { if(priH > priW) {
extW = priH; tmpW = priH;
extH = priW; tmpH = priW;
} }
// The aspect ratios of the external and primary displays
// can be different. As a result, directly assigning primary
// resolution could lead to an incorrect final image.
// We get around this by calculating a new resolution by
// keeping aspect ratio intact.
hwc_rect r = {0, 0, 0, 0};
getAspectRatioPosition(tmpW, tmpH, extW, extH, r);
extW = r.right - r.left;
extH = r.bottom - r.top;
} }
} }