hwc: Calculate DPI values according to changed resolution
If dynamic FB feature is enabled, calculate xdpi, ydpi
values based on new resolution.
Change-Id: Icbc8d2161082f60983532d1a57d9142653c65e9a
diff --git a/libhwcomposer/hwc_utils.cpp b/libhwcomposer/hwc_utils.cpp
index 4708368..77d9312 100644
--- a/libhwcomposer/hwc_utils.cpp
+++ b/libhwcomposer/hwc_utils.cpp
@@ -83,7 +83,8 @@
(xres < MIN_DISPLAY_XRES || yres < MIN_DISPLAY_YRES));
}
-void changeResolution(hwc_context_t *ctx, int xres_orig, int yres_orig) {
+void changeResolution(hwc_context_t *ctx, int xres_orig, int yres_orig,
+ int width, int height) {
//Store original display resolution.
ctx->dpyAttr[HWC_DISPLAY_PRIMARY].xres_new = xres_orig;
ctx->dpyAttr[HWC_DISPLAY_PRIMARY].yres_new = yres_orig;
@@ -99,6 +100,12 @@
ctx->dpyAttr[HWC_DISPLAY_PRIMARY].xres_new = xres_new;
ctx->dpyAttr[HWC_DISPLAY_PRIMARY].yres_new = yres_new;
ctx->dpyAttr[HWC_DISPLAY_PRIMARY].customFBSize = true;
+
+ //Caluculate DPI according to changed resolution.
+ float xdpi = ((float)xres_new * 25.4f) / (float)width;
+ float ydpi = ((float)yres_new * 25.4f) / (float)height;
+ ctx->dpyAttr[HWC_DISPLAY_PRIMARY].xdpi = xdpi;
+ ctx->dpyAttr[HWC_DISPLAY_PRIMARY].ydpi = ydpi;
}
}
}
@@ -168,7 +175,7 @@
(uint32_t)(1000000000l / fps);
//To change resolution of primary display
- changeResolution(ctx, info.xres, info.yres);
+ changeResolution(ctx, info.xres, info.yres, info.width, info.height);
//Unblank primary on first boot
if(ioctl(fb_fd, FBIOBLANK,FB_BLANK_UNBLANK) < 0) {