Mosaic: motore di rendering proprio, gusci desktop e Sailfish
Primo commit del progetto: motore Rust con parser HTML, cascata CSS, layout, raster CPU, formulari, bidi, flex, tabelle, JavaScript (Boa) con eventi e costruzione di nodi, rete HTTP/HTTPS con TLS, sotto-risorse, invio dei formulari; guscio grafico per Sailfish (QML/Silica) e per desktop (minifb, distribuito come AppImage), con 11 documenti di specifica e 91 casi di reftest.
This commit is contained in:
commit
577682ae22
173 files changed
+23685
No files matched your search
@@ -0,0 +1,61 @@
|
||||
/* API C del motore di rendering — M0.
|
||||
* Unico confine fra il motore (Rust) e il guscio (C++/Qt).
|
||||
* Ogni immagine restituita va liberata con engine_image_free(). */
|
||||
#ifndef ENGINE_H
|
||||
#define ENGINE_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct EngineImage {
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
uint8_t *pixels; /* RGBA8, len byte; NULL in caso di errore */
|
||||
uintptr_t len;
|
||||
char *error; /* messaggio di errore o NULL */
|
||||
char *controls; /* JSON [{key,kind,x,y,w,h}], pixel CSS; NULL se nessuno */
|
||||
} EngineImage;
|
||||
|
||||
const char *engine_version(void);
|
||||
|
||||
/* Renderizza html/css nel viewport indicato. Non fa I/O di rete e non tocca il DOM
|
||||
* del guscio: è una funzione pura byte -> pixel.
|
||||
* scale: pixel CSS -> pixel dispositivo (zoom/DPI).
|
||||
* auto_height: se diverso da 0 l'immagine cresce fino all'altezza del documento
|
||||
* (height diventa il minimo), così il guscio può scorrere il contenuto.
|
||||
* font_path deve puntare a un TTF leggibile dal processo.
|
||||
* base_dir è la cartella con cui si risolvono i `src` relativi delle immagini
|
||||
* (stringa vuota = directory corrente). */
|
||||
EngineImage *engine_render(const char *html, const char *css,
|
||||
uint32_t width, uint32_t height,
|
||||
float scale, int auto_height,
|
||||
const char *font_path, const char *base_dir);
|
||||
|
||||
/* Come engine_render, con lo stato dei moduli.
|
||||
* state_json: {"values": {"chiave": "valore"}, "focus": "chiave"} oppure NULL.
|
||||
* Nel risultato, `controls` elenca i controlli con tipo e rettangolo in pixel CSS. */
|
||||
EngineImage *engine_render_form(const char *html, const char *css,
|
||||
uint32_t width, uint32_t height,
|
||||
float scale, int auto_height,
|
||||
const char *font_path, const char *base_dir,
|
||||
const char *state_json);
|
||||
|
||||
void engine_image_free(EngineImage *img);
|
||||
|
||||
/* Scarica un documento (http:// o https://) e ne restituisce il testo UTF-8.
|
||||
* Liberare con engine_string_free(). In caso di errore restituisce NULL e scrive
|
||||
* il messaggio in *error (anch'esso da liberare). *status riceve il codice HTTP,
|
||||
* 0 se la richiesta non è arrivata a risposta. */
|
||||
char *engine_fetch(const char *url, int *status, char **error);
|
||||
|
||||
/* Libera una stringa restituita da engine_fetch(). */
|
||||
void engine_string_free(char *s);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* ENGINE_H */
|
||||
Reference in new issue
Block a user