summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--minuitwrp/graphics_fbdev.cpp40
1 files changed, 29 insertions, 11 deletions
diff --git a/minuitwrp/graphics_fbdev.cpp b/minuitwrp/graphics_fbdev.cpp
index e653c5a4a..5da329bf1 100644
--- a/minuitwrp/graphics_fbdev.cpp
+++ b/minuitwrp/graphics_fbdev.cpp
@@ -243,19 +243,20 @@ static GRSurface* fbdev_init(minui_backend* backend) {
}
static GRSurface* fbdev_flip(minui_backend* backend __unused) {
- if (double_buffered) {
#if defined(RECOVERY_BGRA)
- // In case of BGRA, do some byte swapping
- unsigned int idx;
- unsigned char tmp;
- unsigned char* ucfb_vaddr = (unsigned char*)gr_draw->data;
- for (idx = 0 ; idx < (gr_draw->height * gr_draw->row_bytes);
- idx += 4) {
- tmp = ucfb_vaddr[idx];
- ucfb_vaddr[idx ] = ucfb_vaddr[idx + 2];
- ucfb_vaddr[idx + 2] = tmp;
- }
+ // In case of BGRA, do some byte swapping
+ unsigned int idx;
+ unsigned char tmp;
+ unsigned char* ucfb_vaddr = (unsigned char*)gr_draw->data;
+ for (idx = 0 ; idx < (gr_draw->height * gr_draw->row_bytes);
+ idx += 4) {
+ tmp = ucfb_vaddr[idx];
+ ucfb_vaddr[idx ] = ucfb_vaddr[idx + 2];
+ ucfb_vaddr[idx + 2] = tmp;
+ }
#endif
+#ifndef BOARD_HAS_FLIPPED_SCREEN
+ if (double_buffered) {
// Copy from the in-memory surface to the framebuffer.
memcpy(gr_framebuffer[1-displayed_buffer].data, gr_draw->data,
gr_draw->height * gr_draw->row_bytes);
@@ -265,6 +266,23 @@ static GRSurface* fbdev_flip(minui_backend* backend __unused) {
memcpy(gr_framebuffer[0].data, gr_draw->data,
gr_draw->height * gr_draw->row_bytes);
}
+#else
+ int gr_active_fb = 0;
+ if (double_buffered)
+ gr_active_fb = 1-displayed_buffer;
+
+ /* flip buffer 180 degrees for devices with physicaly inverted screens */
+ unsigned int i, j;
+ for (i = 0; i < vi.yres; i++) {
+ for (j = 0; j < vi.xres; j++) {
+ memcpy(gr_framebuffer[gr_active_fb].data + (i * vi.xres_virtual + j) * gr_framebuffer[0].pixel_bytes,
+ gr_draw->data + ((vi.yres - i - 1) * vi.xres_virtual + vi.xres - j - 1) * gr_framebuffer[0].pixel_bytes,
+ gr_framebuffer[0].pixel_bytes);
+ }
+ }
+ if (double_buffered)
+ set_displayed_framebuffer(1-displayed_buffer);
+#endif
return gr_draw;
}