jovian / venusian-lvgl
LVGL for Venusian Topside: the lvgl drawing engine, through ext-lvgl.
Requires
- php: ~8.4.27||^8.5.12
- ext-lvgl: ^0.11.0
- venusian/topside: ^0.11.5
Requires (Dev)
- pestphp/pest: ^4
- venusian/framework: ^0.11.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-12-02 17:03:27 UTC
README
LVGL for Venusian Topside, through ext-lvgl: the lvgl drawing engine. It draws a draw list on the CPU into memory of its own or memory a surface lends it, in 16-bit, 8-bit gray and 32-bit formats, and 1-bit rows and vertical pages in memory of its own: the formats small panels take, with no conversion between the engine and the panel.
Requirements
- Linux or macOS, PHP 8.4+.
- ext-lvgl 0.11, which builds the LVGL 9.6.0 it ships with, with its
lv_vector_path_append_segments(),lv_obj_set_style_bg_color()andlv_matrix_t::$m. - venusian/topside 0.11.
Install
composer require jovian/venusian-lvgl
The provider registers lvgl on topside's engine manager. Name it in config to make it the default:
// config/engines.php return ['default' => 'lvgl'];
There is nothing to configure: LVGL draws on the calling thread.
Usage
use Surface\NutsAndBolts\Color; use Surface\Engines\PixelMemory; use Surface\Engines\FrameRequest; use Surface\Engines\OffscreenSurface; use Surface\Contracts\Graphics\Painter; $recorder = app('graphics.recorders')->driver(); $root = $recorder->group()->add($recorder->record( fn (Painter $painter) => $painter->fill( $painter->path()->moveTo(10, 10)->lineTo(90, 10)->lineTo(50, 90)->close(), new Color(1.0, 0.0, 0.0), ), )); $engine = app('engines')->driver('lvgl'); $frame = $engine->frame(new OffscreenSurface(100, 100)); $engine->execute(new FrameRequest($frame, [$recorder->list($root)])); $memory = $frame->give(PixelMemory::class); // address, width, height, stride, 16-bit rows, low byte first
Behavior
- One route for every format. LVGL's
lv_draw_vector()is correct only on a 32-bit layer: on any other, LVGL blends ThorVG's premultiplied output back as straight, and into RGB565 and RGB888 only (lv_draw_sw_vector.c396-427, 500-509; recorded in ext-lvgl's README). So a frame draws a list's paths into a 32-bit buffer of its own, declaredARGB8888, where ThorVG writes directly; a second header over the same memory says what it truly holds,ARGB8888_PREMULTIPLIED; and LVGL's image blend composites it into the frame's memory in the memory's own format. No pixel passes through PHP. - Formats.
draws()andmakes(): 16-bit rows low byte first (LVGL's RGB565), 16-bit rows high byte first (RGB565_SWAPPED), 8-bit gray rows (L8),FormatSpec::bgra8Straight()(ARGB8888) andFormatSpec::bgra8Premultiplied()(ARGB8888_PREMULTIPLIED), in that order: RGB565 is LVGL's 16-bit format, and the rest follow by what LVGL's composite into each costs.makes()also answers 1-bit rows, high bit first (I1): LVGL keeps a palette 8 bytes before an I1 buffer's pixels, which lent memory has not, so 1-bit is drawn only into LVGL's own buffer, and itsPixelMemorystates the first pixel's address and LVGL's stride,ceil(width / 8). LVGL pads no rows.makes()also answers vertical pages (an SSD1306's layout: a byte a column of 8 rows, a page a band of 8 rows), low bit first and high bit first: the frame draws into its own I1 frame, rows grown to the next multiple of 8 and zeroed, and after each draw LVGL'slv_draw_i1_convert_to_vtiled()makes each page the flushed areas touch from its 8-row band. ItsPixelMemoryis the page buffer, from LVGL's allocator:ceil(height / 8)pages ofwidthbytes, stridewidth, the rows past the height zero. The width is a multiple of 8, as LVGL's conversion takes it (lv_draw_utils.c240); another width is refused. A frame of its own is in the first format the surface wants (DrawingSurface::formats()) thatmakes()names, else the first ofmakes(), zeroed, outside PHP'smemory_limit, and lives while aPixelMemoryit gave is held. - Lent memory is drawn into only at the surface's size, in a format
draws()answers, with rows no shorter than LVGL's for the width, at a non-zero address that is a multiple of 4 (whatlv_draw_buf_alignasks for in every format); any other is refused when the frame is made, naming the rule, before LVGL is handed it. - Values. ThorVG 0.15.3, which LVGL bundles, writes a pixel it calls opaque as 254, and the 32-bit formats keep it; LVGL reads a 16-bit or 8-bit pixel back widened to 8 bits a channel. A gradient stop's place is kept to 1/255.
- Requests.
execute()draws a request's lists in order:NOTHING: drawn whole through an LVGL display in DIRECT mode on the frame's memory; what nothing covers is zero in every format (the display's bottom layer, which LVGL paints under a format without alpha, is black); the whole frame changed.LAST_DRAW: only the areas a change covers are redrawn, in the frame's source and through the display, and the response'schangedis the areas LVGL wrote, none when nothing changed (a 1-bit frame's widened to whole bytes, a frame in pages' also grown to whole pages, inside the frame). The same list objects at the same revisions (DrawList::revision()) are answered at once, with no walk and nothing drawn. A change is a picture that appeared, left, moved, changed its transform or the opacity of a group above it, or changed its place in the order. It is drawn whole, the whole frame changed, unless the last request drawn into this memory was a finished draw through the display, and when a change covers more areas than a display holds (LV_INV_BUF_SIZE, 32), past which LVGL refreshes the whole screen itself.BACKDROP: composited through a canvas layer over the frame's memory, which clears nothing and paints no bottom layer: every pixel the lists do not cover keeps what the frame held; the whole frame changed. It never reads the request's$formats: the memory is in the format it is, and converting it is a middleware's work. It draws only into a frame of its own class.
- Drawing. Paths with quadratic and cubic segments, both fill rules, solid colors, linear and radial gradients with every spread and up to
LV_GRADIENT_MAX_STOPS(16) stops, hard stops, caps, joins, whole-number miter limits, dashes, group opacity, save, restore and transforms are LVGL's own. A path reaches LVGL from its own memory in one call; a transform is written into LVGL's matrix as[a, c, e, b, d, f, 0, 0, 1]. - What LVGL lacks is left out, and the rest is drawn:
| Capability | Left out |
|---|---|
CLIP_TO_PATH |
what a clip covers, until the restore of its save, and a group with a clip, with all it holds: LVGL's vector descriptor has no clip path |
STROKE_DASHES |
a stroke whose dash offset is not 0: LVGL takes no offset |
STROKE_MITER_LIMIT |
a stroke with a miter join whose limit is not a whole number from 1 to 65535: LVGL takes a uint16_t, and a rounded limit would draw another join |
GRADIENT_UNLIMITED_STOPS |
the fill or stroke painted with more than 16 stops |
The response's missed names the capabilities it missed; supports() answers beforehand, and one CapabilityMissing mail (engine.capability.missing.lvgl) goes out the first time each is missed, through topside's RenderingEngineAdapter. The design, with its evidence, is .okf/design/driver.md.
Testing
See .okf/runbooks/testing.md. The tests need ext-lvgl.
License
MIT. See LICENSE.