Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0e34880c authored by Octavian Purdila's avatar Octavian Purdila Committed by Andrew Boie
Browse files

graphics: add support for "single buffering"



When we don't have enough video memory for double buffering we
fallback to "single buffering".

Change-Id: I8bfab6d8cd6b54f0cc6c67edc41a4c37d8fbd4ba
Signed-off-by: default avatarOctavian Purdila <octavian.purdila@intel.com>
Signed-off-by: default avatarAndrew Boie <andrew.p.boie@intel.com>
parent ea17e320
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -57,6 +57,7 @@ static GGLSurface gr_font_texture;
static GGLSurface gr_framebuffer[2];
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;
@@ -139,6 +140,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;
@@ -161,7 +168,7 @@ static void get_memory_surface(GGLSurface* ms) {

static void set_active_framebuffer(unsigned n)
{
    if (n > 1) return;
    if (n > 1 || !double_buffering) return;
    vi.yres_virtual = vi.yres * PIXEL_SIZE;
    vi.yoffset = n * vi.yres;
    vi.bits_per_pixel = PIXEL_SIZE * 8;
@@ -175,6 +182,7 @@ void gr_flip(void)
    GGLContext *gl = gr_context;

    /* swap front and back buffers */
    if (double_buffering)
        gr_active_fb = (gr_active_fb + 1) & 1;

    /* copy data from the in-memory surface to the buffer we're about