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

@@ -48,6 +48,7 @@
#include "overlayUtils.h"
#include "overlay.h"
#include "mdp_version.h"
#include "qd_utils.h"
using namespace android;
@@ -127,14 +128,25 @@ void VirtualDisplay::setToPrimary(uint32_t maxArea,
// by SUPPORTED_VIRTUAL_AREA).
if((maxArea == (priW * priH))
&& (maxArea <= SUPPORTED_VIRTUAL_AREA)) {
extW = priW;
extH = priH;
// tmpW and tmpH will hold the primary dimensions before we
// update the aspect ratio if necessary.
uint32_t tmpW = priW;
uint32_t tmpH = priH;
// If WFD is in landscape, assign the higher dimension
// to WFD's xres.
if(priH > priW) {
extW = priH;
extH = priW;
tmpW = priH;
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;
}
}