summaryrefslogtreecommitdiffstats
path: root/minuitwrp/graphics.c
diff options
context:
space:
mode:
authorEthan Yonker <dees_troy@teamw.in>2015-10-05 17:16:27 +0200
committerDees Troy <dees_troy@teamw.in>2015-10-16 22:57:35 +0200
commitb7a54a30167f211647222c0a2f90b369e0e33e32 (patch)
treefa6464e7a16456936de1cfaa087fcfc2f9564ff2 /minuitwrp/graphics.c
parentUnion sepolicy within TWRP to make SELinux permissive (diff)
downloadandroid_bootable_recovery-b7a54a30167f211647222c0a2f90b369e0e33e32.tar
android_bootable_recovery-b7a54a30167f211647222c0a2f90b369e0e33e32.tar.gz
android_bootable_recovery-b7a54a30167f211647222c0a2f90b369e0e33e32.tar.bz2
android_bootable_recovery-b7a54a30167f211647222c0a2f90b369e0e33e32.tar.lz
android_bootable_recovery-b7a54a30167f211647222c0a2f90b369e0e33e32.tar.xz
android_bootable_recovery-b7a54a30167f211647222c0a2f90b369e0e33e32.tar.zst
android_bootable_recovery-b7a54a30167f211647222c0a2f90b369e0e33e32.zip
Diffstat (limited to '')
-rw-r--r--minuitwrp/graphics.c93
1 files changed, 73 insertions, 20 deletions
diff --git a/minuitwrp/graphics.c b/minuitwrp/graphics.c
index 5cc560e2f..fb86c1450 100644
--- a/minuitwrp/graphics.c
+++ b/minuitwrp/graphics.c
@@ -33,6 +33,7 @@
#include <pixelflinger/pixelflinger.h>
#include "minui.h"
+#include "../gui/placement.h"
#ifdef RECOVERY_BGRA
#define PIXEL_FORMAT GGL_PIXEL_FORMAT_BGRA_8888
@@ -93,14 +94,14 @@ int overlay_display_frame(int fd, GGLubyte* data, size_t size);
#ifdef PRINT_SCREENINFO
static void print_fb_var_screeninfo()
{
- printf("vi.xres: %d\n", vi.xres);
- printf("vi.yres: %d\n", vi.yres);
- printf("vi.xres_virtual: %d\n", vi.xres_virtual);
- printf("vi.yres_virtual: %d\n", vi.yres_virtual);
- printf("vi.xoffset: %d\n", vi.xoffset);
- printf("vi.yoffset: %d\n", vi.yoffset);
- printf("vi.bits_per_pixel: %d\n", vi.bits_per_pixel);
- printf("vi.grayscale: %d\n", vi.grayscale);
+ printf("vi.xres: %d\n", vi.xres);
+ printf("vi.yres: %d\n", vi.yres);
+ printf("vi.xres_virtual: %d\n", vi.xres_virtual);
+ printf("vi.yres_virtual: %d\n", vi.yres_virtual);
+ printf("vi.xoffset: %d\n", vi.xoffset);
+ printf("vi.yoffset: %d\n", vi.yoffset);
+ printf("vi.bits_per_pixel: %d\n", vi.bits_per_pixel);
+ printf("vi.grayscale: %d\n", vi.grayscale);
}
#endif
@@ -221,20 +222,20 @@ static int get_framebuffer(GGLSurface *fb)
vi.transp.length = 8;
} else if (PIXEL_FORMAT == GGL_PIXEL_FORMAT_RGB_565) {
#ifdef RECOVERY_RGB_565
- fprintf(stderr, "Pixel format: RGB_565\n");
- vi.blue.offset = 0;
- vi.green.offset = 5;
- vi.red.offset = 11;
+ fprintf(stderr, "Pixel format: RGB_565\n");
+ vi.blue.offset = 0;
+ vi.green.offset = 5;
+ vi.red.offset = 11;
#else
fprintf(stderr, "Pixel format: BGR_565\n");
- vi.blue.offset = 11;
- vi.green.offset = 5;
- vi.red.offset = 0;
+ vi.blue.offset = 11;
+ vi.green.offset = 5;
+ vi.red.offset = 0;
#endif
- if (PIXEL_SIZE != 2) fprintf(stderr, "E: Pixel Size mismatch!\n");
- vi.blue.length = 5;
- vi.green.length = 6;
- vi.red.length = 5;
+ if (PIXEL_SIZE != 2) fprintf(stderr, "E: Pixel Size mismatch!\n");
+ vi.blue.length = 5;
+ vi.green.length = 6;
+ vi.red.length = 5;
vi.blue.msb_right = 0;
vi.green.msb_right = 0;
vi.red.msb_right = 0;
@@ -331,7 +332,7 @@ static int get_framebuffer(GGLSurface *fb)
}
#ifdef PRINT_SCREENINFO
- print_fb_var_screeninfo();
+ print_fb_var_screeninfo();
#endif
return fd;
@@ -433,6 +434,58 @@ int gr_textEx(int x, int y, const char *s, void* pFont)
return gr_ttf_textExWH(gl, x, y, s, pFont, -1, -1);
}
+int gr_textEx_scaleW(int x, int y, const char *s, void* pFont, int max_width, int placement, int scale)
+{
+ GGLContext *gl = gr_context;
+ void* vfont = pFont;
+ GRFont *font = (GRFont*) pFont;
+ unsigned off;
+ unsigned cwidth;
+ int y_scale = 0, measured_width, measured_height, ret, new_height;
+
+ if (!s || strlen(s) == 0 || !font)
+ return 0;
+
+ measured_height = gr_ttf_getMaxFontHeight(font);
+
+ if (scale) {
+ measured_width = gr_ttf_measureEx(s, vfont);
+ if (measured_width > max_width) {
+ // Adjust font size down until the text fits
+ void *new_font = gr_ttf_scaleFont(vfont, max_width, measured_width);
+ if (!new_font) {
+ printf("gr_textEx_scaleW new_font is NULL\n");
+ return 0;
+ }
+ measured_width = gr_ttf_measureEx(s, new_font);
+ // These next 2 lines adjust the y point based on the new font's height
+ new_height = gr_ttf_getMaxFontHeight(new_font);
+ y_scale = (measured_height - new_height) / 2;
+ vfont = new_font;
+ }
+ } else
+ measured_width = gr_ttf_measureEx(s, vfont);
+
+ int x_adj = measured_width;
+ if (measured_width > max_width)
+ x_adj = max_width;
+
+ if (placement != TOP_LEFT && placement != BOTTOM_LEFT && placement != TEXT_ONLY_RIGHT) {
+ if (placement == CENTER || placement == CENTER_X_ONLY)
+ x -= (x_adj / 2);
+ else
+ x -= x_adj;
+ }
+
+ if (placement != TOP_LEFT && placement != TOP_RIGHT) {
+ if (placement == CENTER || placement == TEXT_ONLY_RIGHT)
+ y -= (measured_height / 2);
+ else if (placement == BOTTOM_LEFT || placement == BOTTOM_RIGHT)
+ y -= measured_height;
+ }
+ return gr_ttf_textExWH(gl, x, y + y_scale, s, vfont, measured_width + x, -1);
+}
+
int gr_textExW(int x, int y, const char *s, void* pFont, int max_width)
{
GGLContext *gl = gr_context;