summaryrefslogtreecommitdiffstats
path: root/minuitwrp/truetype.cpp (unfollow)
Commit message (Collapse)AuthorFilesLines
2019-03-18TW_ROTATION: add flag to handle hardware-rotated display panelsVladimir Oltean1-3/+47
* The existence of TW_ROTATION that implements this feature at the level of calls to libpixelflinger API closely mirrors the existence of ro.sf.hwrotation for surfaceflinger in LineageOS. * A brute-force approach was previously attempted via the BOARD_HAS_FLIPPED_SCREEN makefile flag. That code iterated over the active display surface in a double-buffered setup, and performed a "smart" memcpy from the UI drawing surface (gr_draw) onto the display surface. The problem was that, without heavy loop optimizations, that code could have never scaled for 90 and 270 degree rotation. I tried and you could literally see the for loop with the naked eye while the display surface was updating. * That code is now gone, but support for BOARD_HAS_FLIPPED_SCREEN := true is still there (now means TW_ROTATION := 180). * This patch relies on the assumption that it is impossibly difficult and non-portable to rotate whole framebuffer display surfaces, in a way that is not dependent upon the graphics backend (adf, fbdev, drm, overlay etc). Therefore, it identifies the rendering primitives that the TWRP graphics stack exposes to the GUI application above, and implements hwrotation inside each of those calls instead: - gr_line(), gr_fill() - 2D geometric shapes (lines, rectangles) - gr_blit() - graphical image resources - gr_ttf_textExWH() - font rendering - gr_fb_width(), gr_fb_height() - framebuffer resolution * The gist is to keep the backend and framebuffer (dimensions, row size etc) unchanged (because making changes there is asking for trouble), but present an altogether different reality to the calling API, according to the compile-time constant TW_ROTATION. * All (x, y) API coordinates and shapes are transformed before being actually rendered as (x_disp, y_disp) display coordinates. * With TW_ROTATION := 90 or 270 you can turn a landscape device into a portrait one, because the GUI is fooled by the reversed dimensions reported by gr_fb_width() and gr_fb_height() and renders the UI as for a different device. * For blit and text rendering operations, figuring out the transformed coordinates in display space is not enough, as the surfaces that are to be rendered have to be rotated themselves. This is handled by allocating an intermediary rotated surface on each rendering operation (not ideal), so the code with the intermediary surface is compiled out for the TW_ROTATION := 0 case. * This is still not as bad as rotating the whole framebuffer though, and on a msm8976 device the performance hit is not even noticeable (for software rendering). * Currently there is no attempt to make a connection between the TW_ROTATION and the { RECOVERY_TOUCHSCREEN_SWAP_XY, RECOVERY_TOUCHSCREEN_FLIP_X, RECOVERY_TOUCHSCREEN_FLIP_Y } settings. Change-Id: Ic8966ad5360c8a499649fdb16e242286640fd992 Signed-off-by: Vladimir Oltean <olteanv@gmail.com>
2016-01-27Update minuitwrp graphics in line with latest minuiEthan Yonker1-45/+46
Note: events.cpp is still old code renamed to cpp to make it easier to call functions like gr_fb_width(). I had to modify AOSP fbdev code to provide a separate memory surface for drawing to as drawing directly to the framebuffer resulted in rendering taking about 5 times longer. I also modified AOSP adf code to provide a separate memory surface for drawing for the same performance reasons. The Nexus 9 supports adf graphics. Overlay graphics work on at least one device. Overlay provides a separate memory buffer already so performance is good. I do not have a drm device yet that I know of. I made some attempt to update the drm code to determine the correct pixel format based on the drm graphics format, but what is available in pixel flinger and what is available in drm do not line up all that well. Reports are that the Pixel C is using drm graphics, but performance is slow, likely due to the use of a mmap instead of a memory buffyer. Change-Id: Ibd45bccca6ac2cb826037aa9b2aa5065cf683eed
2015-10-16Allow text to scale to fitEthan Yonker1-0/+15
Change-Id: Iacd4bb78f551b51d092ecde09521b5541e7dadcd
2015-06-04avoid possible dead loop for invalid utf8Xuefer1-4/+5
Change-Id: Ida48b7ff119030312836aa109072ac4de7c5b9d6
2015-03-19Fix invalid memory access when rendering a ttf glyph with 'left' < 0Vojtech Bocek1-0/+5
* Fixes for example 'j' in Roboto-Regular Change-Id: I0cf778c99f391900e164be743165cf8aad891020 Signed-off-by: Vojtech Bocek <vbocek@gmail.com>
2015-03-19Fix deadlock in gr_ttf_measureEx if called before the height is cachedVojtech Bocek1-52/+54
Change-Id: I2691e2ee4b272e7425d318b05404360598e2ea92
2015-03-11Properly disable GGL_TEXTURE_2D after using it in minuitwrpVojtech Bocek1-1/+2
Change-Id: Ib100ccf3c8f6c622beb40b37ba3f61aad69d7d93 Signed-off-by: Vojtech Bocek <vbocek@gmail.com>
2015-03-05minuitwrp: fix crash issue, when the console use TTF font to display unicode font.xiaolu1-20/+33
gui: fix terminal command unusual line breaks and missing characters at the end of a read buf. Change-Id: I8d3d740b6066b1594c5148b2012f0e7bcbecc22b
2014-12-09add support unicode font not only asciisoyu1-7/+55
need to define custom theme(include custom ttf files) in device tree : TW_CUSTOM_THEME := device/xxxx/yyyy/recovery/res For example: https://github.com/twrp/android_device_xiaomi_armani Change-Id: I6bebdfbdd75c99bfe216a8c0789af63c6fe4b9de
2014-10-14Add support for TrueType fontsVojtech Bocek1-0/+731
* Keeps original font system in place * Uses the same API as original font system: - You can render only one line at a time - You can only use one font and color for one gr_text* call * Caches all rendered text, with a string cache limited to 400 entries, then it trucates to 250, which results in memory usage hovering around 5-10MB Change-Id: I36107b9dcd8d57bae4486fce8b8f64e49ef3d906 Signed-off-by: Vojtech Bocek <vbocek@gmail.com>