How mntone/inknit works
Project type and purpose
• This is an open-source, portable C library (“inknit”) providing high-performance 2D graphics (1bpp–4bpp) for embedded systems.
• It offers a consistent drawing API, template-based code generation, cross-platform abstraction, desktop testing, and benchmarks.
File structure
• Top-level directories and files
• CMakeLists.txt & cmake/: Build logic, toolchain definitions, scripts for generating code and configuring compilers.
• scripts/: Shell helpers (copying DLLs, debug wrappers).
• benchmarks/: C++20 benchmark executables, measurement utilities, platform simulators.
• src/inknit/: Core C implementation
– inc/inknit/: Public headers
– shared/: Common helpers (draw_line, helpers.h)
– templates/: .c.in/.h.in templates for code‐generation of drawing routines
– x1, x1lsb, x2, x2lsb, x4, x4lsb/: Bit-depth specific optimized backends in C/assembly
• src/inknit_cxx/: C++ wrapper API (drawable classes, format implementations)
• tests/inknit/: Unit tests using doctest, linking core C library and C++ wrapper
• Patterns
• Template‐driven generation → specialized .c/.h
• Modular backends per bit depth
• Platform abstraction under utils (platform-*.cpp/h)
README for additional insights
• Core library is built as a static C lib, optional C++ test & benchmark tools.
• Platform-agnostic: clients supply framebuffer.
• Configured via CMake options (LUT, unroll, target, benchmarks).
Main components
a. Build System Layer
• CMake core & cmake/ scripts
• Code‐generation stage (process *.in templates → .c/.h)
b. Core Graphics Library (“inknit”)
• Public headers (inc/)
• Shared utilities (shared/)
• Bit-depth modules (x1, x2, x4 variants)
• Platform abstraction (utils/platform-*.cpp)
c. C++ Wrapper Layer (inknit_cxx)
• Drawable API, format implementations
d. Unit Tests
• tests/inknit linking core + C++ wrapper
e. Benchmark Suite
• benchmarks/inknit and utility monitors/executors
f. External Client Integration
• User’s embedded project → add_subdirectory(inknit) → link libinknit.a → supply framebuffer
g. Target Environments
• Embedded: RP2040/RP2350, ARM, x86
• Host: Linux/WSL for tests & benchmarks
Relationships & interactions
• Build System → (1) Template code‐generation → (2) Compiled into Core Library
• Core Library → linked by
• C++ Wrapper → Unit Tests & Benchmarks
• External Client → runs on embedded targets
• Platform Abstraction module mediates between core calls and target‐specific implementations
Architectural patterns & design principles
• Template‐based code‐generation for algorithm specialization
• Modular backends for each bit depth
• Platform‐agnostic design via abstraction layer
• Build‐time configurability with CMake options
• Static library + header inclusion model
Essential elements to capture
• Build pipeline (generate, compile, link)
• Core library internals (inc/, shared/, xN modules)
• C++ wrapper, test harness, benchmark suite
• Client integration flow into embedded deployments
• Platform abstraction and supported targets