Merge "hwc: Fix to avoid heap corruption"
diff --git a/libhwcomposer/hwc_fbupdate.cpp b/libhwcomposer/hwc_fbupdate.cpp
index ba46bf5..8707edf 100644
--- a/libhwcomposer/hwc_fbupdate.cpp
+++ b/libhwcomposer/hwc_fbupdate.cpp
@@ -126,13 +126,13 @@
displayFrame.top,
displayFrame.right - displayFrame.left,
displayFrame.bottom - displayFrame.top);
- // Calculate the actionsafe dimensions for External(dpy = 1 or 2)
- if(mDpy && !ctx->mExtOrientation)
- getActionSafePosition(ctx, mDpy, dpos.x, dpos.y, dpos.w, dpos.h);
if(mDpy) {
+ // Get Aspect Ratio for external
getAspectRatioPosition(ctx, mDpy, ctx->mExtOrientation, dpos.x,
dpos.y, dpos.w, dpos.h);
+ // Calculate the actionsafe dimensions for External(dpy = 1 or 2)
+ getActionSafePosition(ctx, mDpy, dpos.x, dpos.y, dpos.w, dpos.h);
// Convert dim to hwc_rect_t
displayFrame.left = dpos.x;
displayFrame.top = dpos.y;
diff --git a/libhwcomposer/hwc_utils.cpp b/libhwcomposer/hwc_utils.cpp
index d07db5d..ec61a78 100644
--- a/libhwcomposer/hwc_utils.cpp
+++ b/libhwcomposer/hwc_utils.cpp
@@ -248,6 +248,18 @@
if(ctx->mExtDisplay->isCEUnderscanSupported())
return;
+ char value[PROPERTY_VALUE_MAX];
+ // Read action safe properties
+ property_get("persist.sys.actionsafe.width", value, "0");
+ int asWidthRatio = atoi(value);
+ property_get("persist.sys.actionsafe.height", value, "0");
+ int asHeightRatio = atoi(value);
+
+ if(!asWidthRatio && !asHeightRatio) {
+ //No action safe ratio set, return
+ return;
+ }
+
float wRatio = 1.0;
float hRatio = 1.0;
float xRatio = 1.0;
@@ -256,17 +268,15 @@
float fbWidth = ctx->dpyAttr[dpy].xres;
float fbHeight = ctx->dpyAttr[dpy].yres;
+ // Since external is rotated 90, need to swap width/height
+ if(ctx->mExtOrientation & HWC_TRANSFORM_ROT_90)
+ swap(fbWidth, fbHeight);
+
float asX = 0;
float asY = 0;
float asW = fbWidth;
float asH= fbHeight;
- char value[PROPERTY_VALUE_MAX];
- // Apply action safe parameters
- property_get("persist.sys.actionsafe.width", value, "0");
- int asWidthRatio = atoi(value);
- property_get("persist.sys.actionsafe.height", value, "0");
- int asHeightRatio = atoi(value);
// based on the action safe ratio, get the Action safe rectangle
asW = fbWidth * (1.0f - asWidthRatio / 100.0f);
asH = fbHeight * (1.0f - asHeightRatio / 100.0f);
@@ -884,14 +894,16 @@
}
}
- uint32_t x = dst.left, y = dst.right;
+ uint32_t x = dst.left, y = dst.top;
uint32_t w = dst.right - dst.left;
uint32_t h = dst.bottom - dst.top;
- if(dpy && ctx->mExtOrientation) {
+ if(dpy) {
// Just need to set the position to portrait as the transformation
// will already be set to required orientation on TV
getAspectRatioPosition(ctx, dpy, ctx->mExtOrientation, x, y, w, h);
+ // Calculate the actionsafe dimensions for External(dpy = 1 or 2)
+ getActionSafePosition(ctx, dpy, x, y, w, h);
// Convert position to hwc_rect_t
dst.left = x;
dst.top = y;