summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlijuang <lijuang@codeaurora.org>2019-06-18 13:46:55 +0800
committerlijuang <lijuang@codeaurora.org>2019-06-26 11:25:04 +0800
commit45882c3300df21650a5d27c22435b55e5d254562 (patch)
tree33f6e013478a511a222ed6c79fce0d5c6bd29257
parent30cac35d19bef2d2cf01cd988c1372a404120981 (diff)
QcomModulePkg: Add max row check when chosening font scale factor
Add max row check when chosening the font scale factor. Base on the max support row and the character number per line to chosen the best font scale factor. Change-Id: I261782574826cf487c0bdbeb66bd6364f8793c3b
-rw-r--r--QcomModulePkg/Include/Library/DrawUI.h24
-rw-r--r--QcomModulePkg/Library/BootLib/DrawUI.c43
2 files changed, 61 insertions, 6 deletions
diff --git a/QcomModulePkg/Include/Library/DrawUI.h b/QcomModulePkg/Include/Library/DrawUI.h
index 770d75f2a0..72260dd086 100644
--- a/QcomModulePkg/Include/Library/DrawUI.h
+++ b/QcomModulePkg/Include/Library/DrawUI.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2016, 2017, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2016, 2017, 2019, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -48,10 +48,32 @@
*/
#define CHAR_NUM_PERROW_HOR 80
+/* Max row for portrait orientation
+ * "720 (W) 1280(H)" : "sysfont2x" -- 1280/(19*2) = 33
+ * "1080(W) 1920(H)" : "sysfont3x" -- 1920/(19*3) = 33
+ * "1440(W) 2560(H)" : "sysfont4x" -- 2560/(19*4) = 33
+ * "2160(W) 3840(H)" : "sysfont6x" -- 3840/(19*6) = 33
+ */
+#define MAX_ROW_FOR_POR 33
+
+/* Max row for horizontal orientation
+ * "480 (H) 640 (W)" : "" -- 480/(19*1) = 25
+ * "720 (H) 1280(W)" : "" -- 720/(19*1) = 37
+ * "1080(H) 1920(W)" : "sysfont2" -- 1080/(19*2) = 28
+ * "1440(H) 2560(W)" : "sysfont3" -- 1440/(19*3) = 25
+ * "2160(H) 3840(W)" : "sysfont4" -- 2160/(19*4) = 28
+ */
+#define MAX_ROW_FOR_HOR 25
+
#define MAX_MSG_SIZE 256
#define MAX_RSP_SIZE 64
typedef enum {
+ PORTRAIT_MODE = 0,
+ HORIZONTAL_MODE
+} DISPLAY_MODE;
+
+typedef enum {
DISPLAY_MENU_YELLOW = 0,
DISPLAY_MENU_ORANGE,
DISPLAY_MENU_RED,
diff --git a/QcomModulePkg/Library/BootLib/DrawUI.c b/QcomModulePkg/Library/BootLib/DrawUI.c
index ab594a18ec..e4be16a688 100644
--- a/QcomModulePkg/Library/BootLib/DrawUI.c
+++ b/QcomModulePkg/Library/BootLib/DrawUI.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2016-2018, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2016-2019, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -220,6 +220,33 @@ VOID FreeBootLogoBltBuffer (VOID)
}
}
+STATIC UINT32 GetDisplayMode (VOID)
+{
+ if (GetResolutionWidth () < GetResolutionHeight ()) {
+ return PORTRAIT_MODE;
+ }
+
+ return HORIZONTAL_MODE;
+}
+
+/* Get max row */
+STATIC UINT32 GetMaxRow (VOID)
+{
+ EFI_STATUS Status;
+ UINT32 FontBaseHeight = EFI_GLYPH_HEIGHT;
+ UINT32 MaxRow = 0;
+ EFI_IMAGE_OUTPUT *Blt = NULL;
+
+ Status = gHiiFont->GetGlyph (gHiiFont, 'a', NULL, &Blt, NULL);
+ if (!EFI_ERROR (Status)) {
+ if (Blt) {
+ FontBaseHeight = Blt->Height;
+ }
+ }
+ MaxRow = GetResolutionHeight() / FontBaseHeight;
+ return MaxRow;
+}
+
/* Get Max font count per row */
STATIC UINT32 GetMaxFontCount (VOID)
{
@@ -248,14 +275,20 @@ GetFontScaleFactor (UINT32 ScaleFactorType)
{
UINT32 NumPerRow = 0;
UINT32 ScaleFactor = 0;
+ UINT32 ScaleFactor1 = 0;
+ UINT32 ScaleFactor2 = 0;
+ UINT32 MaxRow = 0;
- if (GetResolutionWidth () < GetResolutionHeight ()) {
- NumPerRow = CHAR_NUM_PERROW_POR;
- } else {
+ NumPerRow = CHAR_NUM_PERROW_POR;
+ MaxRow = MAX_ROW_FOR_POR;
+ if (GetDisplayMode () == HORIZONTAL_MODE) {
NumPerRow = CHAR_NUM_PERROW_HOR;
+ MaxRow = MAX_ROW_FOR_HOR;
}
- ScaleFactor = GetMaxFontCount () / NumPerRow;
+ ScaleFactor1 = GetMaxFontCount () / NumPerRow;
+ ScaleFactor2 = GetMaxRow () / MaxRow;
+ ScaleFactor = ScaleFactor1 > ScaleFactor2 ? ScaleFactor2 : ScaleFactor1;
if (ScaleFactor < 2) {
ScaleFactor = 1;
} else if (ScaleFactor > ((ARRAY_SIZE (mFactorName) - 1) / MAX_FACTORTYPE)) {