4. WIP Drawing Thread

This describes a dedicated drawing thread. Basically, this thread sits and waits for the cue to update the framebuffer. When it happens, it copies the internal buffer to the saved framebuffer.

4.1. TODO Drawing Thread Data

4.1.1. DONE typedef + struct

CLOSED: [2019-11-22 Fri 16:30]

<<norns_typedefs>>=
typedef struct norns_drawthread norns_drawthread;
<<norns_structs>>=
struct norns_drawthread {
<<norns_drawthread_contents>>
};

4.1.2. new/del

<<norns_funcdefs>>=
void norns_drawthread_new(norns_drawthread **pndt);
void norns_drawthread_del(norns_drawthread **pndt);
<<norns_functions>>=
void norns_drawthread_new(norns_drawthread **pndt)
{
    norns_drawthread *ndt;
    ndt = calloc(1, sizeof(norns_drawthread));
    *pndt = ndt;
}

void norns_drawthread_del(norns_drawthread **pndt)
{
    free(*pndt);
}

4.1.3. TODO Thread Data init + cleanup

<<norns_funcdefs>>=
void norns_drawthread_init(norns_drawthread *ndt);
<<norns_functions>>=
void norns_drawthread_init(norns_drawthread *ndt)
{
<<norns_drawthread_init>>
}
<<norns_funcdefs>>=
void norns_drawthread_clean(norns_drawthread *ndt);
<<norns_functions>>=
void norns_drawthread_clean(norns_drawthread *ndt)
{
<<norns_drawthread_clean>>
}

4.1.4. TODO Update Flag

In order for any changes to the video buffer to appear on the framebuffer, the update flag must be explicitely be set. This is an integer value, set to be 0 by default.

<<norns_drawthread_contents>>=
int update;
<<norns_drawthread_init>>=
ndt->update = 0;

4.1.5. DONE Video Buffer

CLOSED: [2019-11-22 Fri 20:18] A local instance of a video buffer.

<<norns_drawthread_contents>>=
norns_videobuf vb;
<<norns_drawthread_init>>=
norns_videobuf_init(&ndt->vb);

Retrieved via norns_drawthread_videobuf.

<<norns_funcdefs>>=
norns_videobuf *norns_drawthread_videobuf(norns_drawthread *ndt);
<<norns_functions>>=
norns_videobuf *norns_drawthread_videobuf(norns_drawthread *ndt)
{
    return &ndt->vb;
}

4.1.6. DONE Framebuffer

CLOSED: [2019-11-22 Fri 20:18] A local instance of a framebuffer.

<<norns_drawthread_contents>>=
norns_framebuffer fb;
<<norns_drawthread_init>>=
norns_framebuffer_open(&ndt->fb);
<<norns_drawthread_clean>>=
norns_framebuffer_close(&ndt->fb);

Retrieved via norns_drawthread_framebuffer.

<<norns_funcdefs>>=
norns_framebuffer *norns_drawthread_framebuffer(norns_drawthread *ndt);
<<norns_functions>>=
norns_framebuffer *norns_drawthread_framebuffer(norns_drawthread *ndt)
{
    return &ndt->fb;
}

4.1.7. TODO pthread data

4.2. TODO Draw Callback Loop

This is the actual render loop, probably called inside of the posix thread callback.

<<norns_funcdefs>>=
void norns_drawthread_loop(norns_drawthread *ndt);

4.3. TODO pthread callback

This is the callback to be used by the pthread callback.

4.4. TODO Starting/stopping the thread

<<norns_funcdefs>>=
void norns_drawthread_start(norns_drawthread *ndt);
<<norns_funcdefs>>=
void norns_drawthread_stop(norns_drawthread *ndt);



prev | home | next