Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions quill/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,21 @@ QTINC="$SDKTARGETSYSROOT/usr/include"
$CXX -fPIC -shared -O2 \
-I "$QTINC" -I "$QTINC/QtCore" -I "$QTINC/QtGui" \
src/epfb.cpp src/quill_c.cpp \
-L vendor -lqsgepaper \
-L vendor -lqsgepaper -ldl \
-o build/libquill.so

# scribble: the C1 latency demo.
$CC -O2 src/scribble.c \
-L build -lquill \
-L vendor -lqsgepaper \
-L vendor -lqsgepaper -ldl \
-lQt6Gui -lQt6Core -lstdc++ \
-Wl,-rpath,/home/root/quill \
-o build/scribble

# map_demo: static full-screen map + tiny partial-update footsteps.
$CC -O2 src/map_demo.c \
-L build -lquill \
-L vendor -lqsgepaper \
-L vendor -lqsgepaper -ldl \
-lQt6Gui -lQt6Core -lstdc++ \
-Wl,-rpath,/home/root/quill \
-o build/map_demo
Expand All @@ -48,7 +48,7 @@ $CXX -O2 \
-I "$QTINC" -I "$QTINC/QtCore" -I "$QTINC/QtGui" \
src/image_demo.cpp \
-L build -lquill \
-L vendor -lqsgepaper \
-L vendor -lqsgepaper -ldl \
-lQt6Gui -lQt6Core -lstdc++ \
-Wl,-rpath,/home/root/quill \
-o build/image_demo
Expand All @@ -58,7 +58,7 @@ $CXX -O2 \
-I "$QTINC" -I "$QTINC/QtCore" -I "$QTINC/QtGui" \
src/image_anim_demo.cpp \
-L build -lquill \
-L vendor -lqsgepaper \
-L vendor -lqsgepaper -ldl \
-lQt6Gui -lQt6Core -lstdc++ \
-Wl,-rpath,/home/root/quill \
-o build/image_anim_demo
Expand All @@ -68,15 +68,15 @@ $CXX -O2 \
-I "$QTINC" -I "$QTINC/QtCore" -I "$QTINC/QtGui" \
src/gif_demo.cpp \
-L build -lquill \
-L vendor -lqsgepaper \
-L vendor -lqsgepaper -ldl \
-lQt6Gui -lQt6Core -lstdc++ \
-Wl,-rpath,/home/root/quill \
-o build/gif_demo

# drawlab: no-AI live drawing experiments.
$CC -O2 src/drawlab.c \
-L build -lquill \
-L vendor -lqsgepaper \
-L vendor -lqsgepaper -ldl \
-lQt6Gui -lQt6Core -lstdc++ \
-Wl,-rpath,/home/root/quill \
-o build/drawlab
Expand All @@ -86,7 +86,7 @@ $CXX -O2 \
-I "$QTINC" -I "$QTINC/QtCore" -I "$QTINC/QtGui" \
src/home.cpp \
-L build -lquill \
-L vendor -lqsgepaper \
-L vendor -lqsgepaper -ldl \
-lQt6Gui -lQt6Core -lstdc++ \
-Wl,-rpath,/home/root/quill \
-o build/home
Expand Down
1 change: 1 addition & 0 deletions quill/src/epframebuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class EPFramebuffer {
NoRefresh = 0,
CompleteRefresh = 1,
};
// Signature varies by OS (3.28 dropped EPContentType). quill_c resolves via dlsym.
unsigned long swapBuffers(QRect param_1, EPContentType epct, EPScreenMode type, QFlags<EPFramebuffer::UpdateFlag> flags);
#ifdef EPFB_INTERNAL
static EPFramebuffer *instance();
Expand Down
37 changes: 34 additions & 3 deletions quill/src/quill_c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,35 @@
#include "epframebuffer.h"
#include <QCoreApplication>
#include <QImage>
#include <dlfcn.h>
#include <cstring>
#include <cstdio>

static QCoreApplication *g_app = nullptr;
static EPFramebuffer *g_fb = nullptr;
static QImage *g_aux = nullptr;

// OS 3.27 and earlier:
// swapBuffers(QRect, EPContentType, EPScreenMode, QFlags<UpdateFlag>)
// OS 3.28+ dropped EPContentType from the QRect overload:
// swapBuffers(QRect, EPScreenMode, QFlags<UpdateFlag>)
using SwapOldFn = unsigned long (*)(EPFramebuffer *, QRect, EPContentType,
EPScreenMode, EPFramebuffer::UpdateFlag);
using SwapNewFn = unsigned long (*)(EPFramebuffer *, QRect, EPScreenMode,
EPFramebuffer::UpdateFlag);
static SwapOldFn g_swap_old = nullptr;
static SwapNewFn g_swap_new = nullptr;

static void resolve_swap() {
if (g_swap_old || g_swap_new) return;
g_swap_new = reinterpret_cast<SwapNewFn>(dlsym(
RTLD_DEFAULT,
"_ZN13EPFramebuffer11swapBuffersE5QRect12EPScreenMode6QFlagsINS_10UpdateFlagEE"));
g_swap_old = reinterpret_cast<SwapOldFn>(dlsym(
RTLD_DEFAULT,
"_ZN13EPFramebuffer11swapBuffersE5QRect13EPContentType12EPScreenMode6QFlagsINS_10UpdateFlagEE"));
}

extern "C" {

// Returns 0 on success. After this, quill_buffer()/quill_swap() are usable.
Expand Down Expand Up @@ -49,11 +71,20 @@ unsigned char *quill_buffer() {
// full_refresh != 0 forces a flashing clear of the region.
unsigned long quill_swap(int x, int y, int w, int h, int mode, int full_refresh) {
if (!g_fb) return 0;
QFlags<EPFramebuffer::UpdateFlag> flags = full_refresh
resolve_swap();
EPFramebuffer::UpdateFlag flag = full_refresh
? EPFramebuffer::UpdateFlag::CompleteRefresh
: EPFramebuffer::UpdateFlag::NoRefresh;
return g_fb->swapBuffers(QRect(x, y, w, h), EPContentType::Mono,
(EPScreenMode)mode, flags);
QRect rect(x, y, w, h);
EPScreenMode screen = static_cast<EPScreenMode>(mode);
if (g_swap_new) {
return g_swap_new(g_fb, rect, screen, flag);
}
if (g_swap_old) {
return g_swap_old(g_fb, rect, EPContentType::Mono, screen, flag);
}
fprintf(stderr, "quill: no EPFramebuffer::swapBuffers symbol found\n");
return 0;
}

void quill_process_events() {
Expand Down