summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--data.cpp4
-rw-r--r--minuitwrp/graphics.c18
2 files changed, 16 insertions, 6 deletions
diff --git a/data.cpp b/data.cpp
index 88c064b08..e7dafa1fe 100644
--- a/data.cpp
+++ b/data.cpp
@@ -629,14 +629,14 @@ void DataManager::SetDefaultValues()
if (strlen(EXPAND(SP2_DISPLAY_NAME))) mConstValues.insert(make_pair(TW_SP2_PARTITION_NAME_VAR, EXPAND(SP2_DISPLAY_NAME)));
#else
#ifdef SP2_NAME
- if (strlen(EXPAND(SP2_NAME))) mConstValues.insert(make_pair(TW_SP1_PARTITION_NAME_VAR, EXPAND(SP2_NAME)));
+ if (strlen(EXPAND(SP2_NAME))) mConstValues.insert(make_pair(TW_SP2_PARTITION_NAME_VAR, EXPAND(SP2_NAME)));
#endif
#endif
#ifdef SP3_DISPLAY_NAME
if (strlen(EXPAND(SP3_DISPLAY_NAME))) mConstValues.insert(make_pair(TW_SP3_PARTITION_NAME_VAR, EXPAND(SP3_DISPLAY_NAME)));
#else
#ifdef SP3_NAME
- if (strlen(EXPAND(SP3_NAME))) mConstValues.insert(make_pair(TW_SP1_PARTITION_NAME_VAR, EXPAND(SP3_NAME)));
+ if (strlen(EXPAND(SP3_NAME))) mConstValues.insert(make_pair(TW_SP3_PARTITION_NAME_VAR, EXPAND(SP3_NAME)));
#endif
#endif
diff --git a/minuitwrp/graphics.c b/minuitwrp/graphics.c
index b30a92ef0..dc79db881 100644
--- a/minuitwrp/graphics.c
+++ b/minuitwrp/graphics.c
@@ -51,6 +51,8 @@
#define PIXEL_SIZE 2
#endif
+#define NUM_BUFFERS 2
+
// #define PRINT_SCREENINFO 1 // Enables printing of screen info to log
typedef struct {
@@ -63,9 +65,10 @@ typedef struct {
static GRFont *gr_font = 0;
static GGLContext *gr_context = 0;
static GGLSurface gr_font_texture;
-static GGLSurface gr_framebuffer[2];
+static GGLSurface gr_framebuffer[NUM_BUFFERS];
static GGLSurface gr_mem_surface;
static unsigned gr_active_fb = 0;
+static unsigned double_buffering = 0;
static int gr_fb_fd = -1;
static int gr_vt_fd = -1;
@@ -199,6 +202,12 @@ static int get_framebuffer(GGLSurface *fb)
fb++;
+ /* check if we can use double buffering */
+ if (vi.yres * fi.line_length * 2 > fi.smem_len)
+ return fd;
+
+ double_buffering = 1;
+
fb->version = sizeof(*fb);
fb->width = vi.xres;
fb->height = vi.yres;
@@ -230,8 +239,8 @@ static void get_memory_surface(GGLSurface* ms) {
static void set_active_framebuffer(unsigned n)
{
- if (n > 1) return;
- vi.yres_virtual = vi.yres * 2;
+ if (n > 1 || !double_buffering) return;
+ vi.yres_virtual = vi.yres * NUM_BUFFERS;
vi.yoffset = n * vi.yres;
// vi.bits_per_pixel = PIXEL_SIZE * 8;
if (ioctl(gr_fb_fd, FBIOPUT_VSCREENINFO, &vi) < 0) {
@@ -244,7 +253,8 @@ void gr_flip(void)
GGLContext *gl = gr_context;
/* swap front and back buffers */
- gr_active_fb = (gr_active_fb + 1) & 1;
+ if (double_buffering)
+ gr_active_fb = (gr_active_fb + 1) & 1;
#ifdef BOARD_HAS_FLIPPED_SCREEN
/* flip buffer 180 degrees for devices with physicaly inverted screens */