diff --git a/minui/Android.mk b/minui/Android.mk index d71cea2..44f9fa1 100644 --- a/minui/Android.mk +++ b/minui/Android.mk @@ -15,6 +15,10 @@ ifneq ($(BOARD_HAS_JANKY_BACKBUFFER),) LOCAL_CFLAGS += -DBOARD_HAS_JANKY_BACKBUFFER endif +ifeq ($(BOARD_HAS_FLIPPED_SCREEN), true) + LOCAL_CFLAGS += -DBOARD_HAS_FLIPPED_SCREEN +endif + LOCAL_MODULE := libminui include $(BUILD_STATIC_LIBRARY) diff --git a/minui/graphics.c b/minui/graphics.c index 915873b..8192d3f 100644 --- a/minui/graphics.c +++ b/minui/graphics.c @@ -144,6 +144,16 @@ void gr_flip(void) /* swap front and back buffers */ gr_active_fb = (gr_active_fb + 1) & 1; +#ifdef BOARD_HAS_FLIPPED_SCREEN + /* flip buffer 180 degrees for devices with physicaly inverted screens */ + unsigned int i; + for (i = 1; i < (vi.xres * vi.yres); i++) { + unsigned short tmp = gr_mem_surface.data[i]; + gr_mem_surface.data[i] = gr_mem_surface.data[(vi.xres * vi.yres * 2) - i]; + gr_mem_surface.data[(vi.xres * vi.yres * 2) - i] = tmp; + } +#endif + /* copy data from the in-memory surface to the buffer we're about * to make active. */ memcpy(gr_framebuffer[gr_active_fb].data, gr_mem_surface.data,