Merge "hwc: Move aspect ratio helper function to qdutils"
This commit is contained in:
committed by
Gerrit - the friendly Code Review server
commit
2f11754664
@@ -44,6 +44,7 @@
|
|||||||
#include "QService.h"
|
#include "QService.h"
|
||||||
#include "comptype.h"
|
#include "comptype.h"
|
||||||
#include "hwc_virtual.h"
|
#include "hwc_virtual.h"
|
||||||
|
#include "qd_utils.h"
|
||||||
|
|
||||||
using namespace qClient;
|
using namespace qClient;
|
||||||
using namespace qService;
|
using namespace qService;
|
||||||
@@ -400,34 +401,6 @@ void getActionSafePosition(hwc_context_t *ctx, int dpy, hwc_rect_t& rect) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Calculates the aspect ratio for based on src & dest */
|
|
||||||
void getAspectRatioPosition(int destWidth, int destHeight, int srcWidth,
|
|
||||||
int srcHeight, hwc_rect_t& rect) {
|
|
||||||
int x =0, y =0;
|
|
||||||
|
|
||||||
if (srcWidth * destHeight > destWidth * srcHeight) {
|
|
||||||
srcHeight = destWidth * srcHeight / srcWidth;
|
|
||||||
srcWidth = destWidth;
|
|
||||||
} else if (srcWidth * destHeight < destWidth * srcHeight) {
|
|
||||||
srcWidth = destHeight * srcWidth / srcHeight;
|
|
||||||
srcHeight = destHeight;
|
|
||||||
} else {
|
|
||||||
srcWidth = destWidth;
|
|
||||||
srcHeight = destHeight;
|
|
||||||
}
|
|
||||||
if (srcWidth > destWidth) srcWidth = destWidth;
|
|
||||||
if (srcHeight > destHeight) srcHeight = destHeight;
|
|
||||||
x = (destWidth - srcWidth) / 2;
|
|
||||||
y = (destHeight - srcHeight) / 2;
|
|
||||||
ALOGD_IF(HWC_UTILS_DEBUG, "%s: AS Position: x = %d, y = %d w = %d h = %d",
|
|
||||||
__FUNCTION__, x, y, srcWidth , srcHeight);
|
|
||||||
// Convert it back to hwc_rect_t
|
|
||||||
rect.left = x;
|
|
||||||
rect.top = y;
|
|
||||||
rect.right = srcWidth + rect.left;
|
|
||||||
rect.bottom = srcHeight + rect.top;
|
|
||||||
}
|
|
||||||
|
|
||||||
// This function gets the destination position for Seconday display
|
// This function gets the destination position for Seconday display
|
||||||
// based on the position and aspect ratio with orientation
|
// based on the position and aspect ratio with orientation
|
||||||
void getAspectRatioPosition(hwc_context_t* ctx, int dpy, int extOrientation,
|
void getAspectRatioPosition(hwc_context_t* ctx, int dpy, int extOrientation,
|
||||||
|
|||||||
@@ -262,9 +262,6 @@ bool isActionSafePresent(hwc_context_t *ctx, int dpy);
|
|||||||
/* Calculates the destination position based on the action safe rectangle */
|
/* Calculates the destination position based on the action safe rectangle */
|
||||||
void getActionSafePosition(hwc_context_t *ctx, int dpy, hwc_rect_t& dst);
|
void getActionSafePosition(hwc_context_t *ctx, int dpy, hwc_rect_t& dst);
|
||||||
|
|
||||||
void getAspectRatioPosition(int destWidth, int destHeight, int srcWidth,
|
|
||||||
int srcHeight, hwc_rect_t& rect);
|
|
||||||
|
|
||||||
void getAspectRatioPosition(hwc_context_t* ctx, int dpy, int extOrientation,
|
void getAspectRatioPosition(hwc_context_t* ctx, int dpy, int extOrientation,
|
||||||
hwc_rect_t& inRect, hwc_rect_t& outRect);
|
hwc_rect_t& inRect, hwc_rect_t& outRect);
|
||||||
|
|
||||||
|
|||||||
@@ -31,6 +31,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#define MAX_FRAME_BUFFER_NAME_SIZE (80)
|
#define MAX_FRAME_BUFFER_NAME_SIZE (80)
|
||||||
|
#define QD_UTILS_DEBUG 0
|
||||||
|
|
||||||
int getHDMINode(void)
|
int getHDMINode(void)
|
||||||
{
|
{
|
||||||
@@ -92,3 +93,31 @@ int getEdidRawData(char *buffer)
|
|||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Calculates the aspect ratio for based on src & dest */
|
||||||
|
void getAspectRatioPosition(int destWidth, int destHeight, int srcWidth,
|
||||||
|
int srcHeight, hwc_rect_t& rect) {
|
||||||
|
int x =0, y =0;
|
||||||
|
|
||||||
|
if (srcWidth * destHeight > destWidth * srcHeight) {
|
||||||
|
srcHeight = destWidth * srcHeight / srcWidth;
|
||||||
|
srcWidth = destWidth;
|
||||||
|
} else if (srcWidth * destHeight < destWidth * srcHeight) {
|
||||||
|
srcWidth = destHeight * srcWidth / srcHeight;
|
||||||
|
srcHeight = destHeight;
|
||||||
|
} else {
|
||||||
|
srcWidth = destWidth;
|
||||||
|
srcHeight = destHeight;
|
||||||
|
}
|
||||||
|
if (srcWidth > destWidth) srcWidth = destWidth;
|
||||||
|
if (srcHeight > destHeight) srcHeight = destHeight;
|
||||||
|
x = (destWidth - srcWidth) / 2;
|
||||||
|
y = (destHeight - srcHeight) / 2;
|
||||||
|
ALOGD_IF(QD_UTILS_DEBUG, "%s: AS Position: x = %d, y = %d w = %d h = %d",
|
||||||
|
__FUNCTION__, x, y, srcWidth , srcHeight);
|
||||||
|
// Convert it back to hwc_rect_t
|
||||||
|
rect.left = x;
|
||||||
|
rect.top = y;
|
||||||
|
rect.right = srcWidth + rect.left;
|
||||||
|
rect.bottom = srcHeight + rect.top;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -48,4 +48,7 @@
|
|||||||
|
|
||||||
int getEdidRawData(char *buffer);
|
int getEdidRawData(char *buffer);
|
||||||
|
|
||||||
|
void getAspectRatioPosition(int destWidth, int destHeight, int srcWidth,
|
||||||
|
int srcHeight, hwc_rect_t& rect);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user