S003: first launch on Xvfb, smoke harness, epaint glyph panic and quit segfault fixed

- tools/smoke.sh + tests/smoke/{launch,https,restore}.txt: hidden Xvfb run with a throwaway home
- vendor/epaint: render glyphs single-threaded (Servo enables vello_cpu/multithreading), D-006
- App::quit drops every Servo handle before the GL contexts, so Servo shuts down cleanly
- D-005: smoke runs use Xvfb

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
astar76 2026-11-11 18:01:15 -06:00
commit 8b2b2a5655
71 changed files with 19853 additions and 14 deletions

View file

@ -64,8 +64,8 @@ Never modify: `~/Documents/Apps/Nacre` (the original Python Nacre, reference onl
|---|---|---|
| `nice cargo build --release -j 2` | compile check, produces `target/release/nacre` | now |
| `nice cargo test --release -j 2` | unit tests (29, ~16 s test-profile build then <1 s run; shares the S001 build) (util, settings, history, bookmarks, permissions, vault, dns, bridge loopback, download, adblock, keys, scripts, updates, inject, hub, theme) | first successful build; not alongside a build |
| `src/selftest.rs` | in-app self test (smoke run) | check its current state first |
| Smoke test | launch offscreen, write status file and screenshots, look at them | first build |
| `src/selftest.rs` | in-app self test: `NACRE_SCRIPT=<file>` runs script commands (listed at its top) | now |
| `tools/smoke.sh <script> [outdir]` | smoke run on a hidden Xvfb display with a throwaway home and software GL; outdir (default `target/smoke/<name>-<time>`) gets `nacre.log`, `selftest.log`, `<shot>.png`, `<status>.json`, `home/`; exits non-zero on crash, panic or no `status done`. Scripts in `tests/smoke/` (`launch.txt` offline, `https.txt` needs internet, `restore.txt` with `SMOKE_HOME=<launch outdir>/home`); header documents env vars and commands. Read the PNGs | now (S003) |
| appimagetool, wine + Inno Setup, VM "Windows 10" | packaging and Windows checks | see the user's global CLAUDE.md "Building" |
Don't assume a tool exists: check first. When your plan creates a tool, add its row here.

2
Cargo.lock generated
View file

@ -2174,8 +2174,6 @@ dependencies = [
[[package]]
name = "epaint"
version = "0.37.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "97bac86ae3dde93fc3951e790951caea739ff39a6c89d909cdaf1d9278dbb1bd"
dependencies = [
"ahash",
"bytemuck",

View file

@ -87,3 +87,8 @@ opt-level = 1
[profile.dev.package."*"]
opt-level = 2
# epaint 0.37.0 panics when Servo's canvas enables vello_cpu/multithreading; the vendored copy renders glyphs
# single-threaded (vendor/epaint/src/text/font_face.rs, end of file). Drop when egui ships a fix.
[patch.crates-io]
epaint = { path = "vendor/epaint" }

View file

@ -12,14 +12,14 @@ Get the binary to start, render a real page and quit cleanly, offscreen, and tur
- User's global CLAUDE.md "Building" (offscreen runs, software GL)
## Steps
- [ ] Find an offscreen display that works here: `kwin_wayland --virtual` (preferred, nested and hidden) or Xvfb/`weston --backend=headless`; note which
- [ ] Write `tools/smoke.sh <script> [outdir]`: throwaway `XDG_CONFIG_HOME`/`XDG_DATA_HOME`/`XDG_CACHE_HOME`, `NACRE_SCRIPT`, timeout, starts the offscreen display, runs `target/release/nacre`, copies log/status/screenshots to outdir, exits non-zero on crash or missing `done` status
- [ ] Write `tests/smoke/launch.txt`: wait, `page nacre://newtab`, shot, `open` a local `file://` test page (bundled in `tests/smoke/pages/`), waitload, shot, status, quit
- [ ] Run it; fix startup crashes and panics in place until it reaches `quit`; look at both screenshots (Read the PNGs) and check the page content is visible
- [ ] Run once with `https://example.org` (plain HTTPS, no proxy, `NACRE_NO_BRIDGE` unset) to check networking through the bridge; screenshot shows the page
- [ ] Check a clean exit: no panic in the log, profile files written in the throwaway dirs, second launch restores the session
- [ ] Add the `tools/smoke.sh` row to CLAUDE.md §5 (usage, where outputs go) and document script commands in its header
- [ ] PROGRESS entry, INDEX line, commit `S003: …` and push
- [x] Find an offscreen display that works here: `kwin_wayland --virtual` (preferred, nested and hidden) or Xvfb/`weston --backend=headless`; note which → Xvfb (`xorg-server-xvfb`) + llvmpipe; no kwin_wayland/weston here (D-005)
- [x] Write `tools/smoke.sh <script> [outdir]`: throwaway `XDG_CONFIG_HOME`/`XDG_DATA_HOME`/`XDG_CACHE_HOME`, `NACRE_SCRIPT`, timeout, starts the offscreen display, runs `target/release/nacre`, copies log/status/screenshots to outdir, exits non-zero on crash or missing `done` status
- [x] Write `tests/smoke/launch.txt`: wait, `page nacre://newtab`, shot, `open` a local `file://` test page (bundled in `tests/smoke/pages/`), waitload, shot, status, quit
- [x] Run it; fix startup crashes and panics in place until it reaches `quit`; look at both screenshots (Read the PNGs) and check the page content is visible
- [x] Run once with `https://example.org` (plain HTTPS, no proxy, `NACRE_NO_BRIDGE` unset) to check networking through the bridge; screenshot shows the page
- [x] Check a clean exit: no panic in the log, profile files written in the throwaway dirs, second launch restores the session
- [x] Add the `tools/smoke.sh` row to CLAUDE.md §5 (usage, where outputs go) and document script commands in its header
- [x] PROGRESS entry, INDEX line, commit `S003: …` and push
## End criteria
- `tools/smoke.sh tests/smoke/launch.txt <dir>` exits 0 and `<dir>` has two non-blank PNGs.

View file

@ -7,7 +7,7 @@ Tracker: https://claude.ai/artifact/9AD7fPfwJ4ASFzVTJGKU4h
## 01 First build
- [x] [S001 — Compile to a binary](01%20First%20build/S001-compile.md) · Opus medium
- [x] [S002 — Unit tests green](01%20First%20build/S002-unit-tests.md) · Sonnet high
- [ ] [S003 — First launch and smoke harness](01%20First%20build/S003-first-launch.md) · Opus medium
- [x] [S003 — First launch and smoke harness](01%20First%20build/S003-first-launch.md) · Opus medium
- [ ] [S004 — Phase 1 review with the user](01%20First%20build/S004-phase1-review.md) · Sonnet medium · 🧑
## 02 Verify

View file

@ -6,3 +6,5 @@
- D-002 — 2026-11-11 — Of the phase-3 candidates only MPRIS media keys is planned; reader mode, split view, translate and gamepad rumble go to PROGRESS "Later". — User's choice. — S013
- D-003 — 2026-11-11 — The user reviews at the end of every phase in a separate 🧑 plan (S004, S010, S014, S021); review findings go to `docs/review/phaseN.md` as numbered items with `[open]`/`[fixed <commit>]`/`[wontfix: reason]` tags. — Keeps agent plans from blocking on the user. — S004, S010, S012, S014, S021
- D-004 — 2026-11-11 — The redesign keeps egui (custom painting) and bundles the Outfit font (OFL) from Google Fonts; agents may download it. — Answers UI-BRIEF's open questions. — S015–S020
- D-005 — 2026-11-11 — The hidden display for smoke runs is Xvfb (X11, `xorg-server-xvfb`), started by `tools/smoke.sh`. — No kwin_wayland/weston here; a nested niri shows on the user's screen and stops drawing while hidden; the orchestrator chose Xvfb. — S003 and every Verify plan
- D-006 — 2026-11-11 — egui's epaint is vendored (`vendor/epaint`, 0.37.0 + a patch rendering glyphs single-threaded) via `[patch.crates-io]`. — Servo's canvas enables vello_cpu/multithreading, which makes stock epaint 0.37.0 panic on every glyph; no fixed release exists. — any plan that upgrades egui: drop the patch once epaint fixes it, keep `theme::tests::egui_draws_text`

View file

@ -21,6 +21,20 @@ One entry per session, newest last, ≤ 15 lines: done, verified how, not done,
paths (history); URLs in tests are string constants. No test touches `~/.config/nacre*`, Tor or proxies.
- Not done: coverage is thin (29 tests across 16 modules; no tests for e.g. downloads dlm, session, apps).
## S003 — First launch and smoke harness (2026-11-11)
- Done: hidden display = Xvfb + llvmpipe (D-005). `tools/smoke.sh` + `tests/smoke/{launch,https,restore}.txt`
(CLAUDE.md §5). Launch renders nacre://newtab (egui) and a local file:// page (Servo); example.org loads through
the bridge (route Direct, ~205 KB); second launch restores the session; user profile untouched.
- Fixed: (1) every egui glyph panicked in vello_cpu ("rasterize before flushing"): servo-canvas turns on
vello_cpu/multithreading for epaint too. Vendored epaint 0.37.0 in `vendor/epaint` (`[patch.crates-io]`),
glyphs render single-threaded (D-006); regression test `theme::tests::egui_draws_text` (fails without it).
(2) segfault on quit: Hub<->Servo Rc cycle kept Servo alive; `App::quit` now drops every Servo handle before
the windows' GL contexts (src/app.rs).
- Verified: `tools/smoke.sh tests/smoke/launch.txt` exit 0 ×5, 2 non-blank PNGs, 0 `panicked`; 30 tests green.
- Not done: exit fix not A/B-checked by reverting (crash seen once before the fix, 5 clean runs after).
- Later: toolbar/tab icons draw as tofu boxes (icon font glyphs missing); new-tab clock text nearly invisible on the
light theme; tile letters ("Y", "G") above names look like missing favicons.
## Later
- Reader mode, split view, translate, real gamepad rumble (D-002: not planned for now).
- Packaging and first release (D-001: plan when the user asks).

View file

@ -1444,8 +1444,20 @@ impl App {
if let Some(mut presence) = self.presence.take() {
presence.stop();
}
for (_, mut win) in self.windows.drain() {
// Servo only shuts down (stops the constellation and script threads, deinits the painters) when its last
// handle is dropped, and WebViews, requests and the content manager each hold one. Drop them all while the
// windows' GL contexts still exist; exiting with Servo alive crashes in SpiderMonkey's teardown.
for win in self.windows.values_mut() {
win.tabs.clear();
}
self.window_requests.clear();
self.pending_nav.clear();
self.pending_files.clear();
self.hub.events.borrow_mut().clear();
self.ucm = None;
self.hub.servo.borrow_mut().take();
drop(self.servo.take());
for (_, mut win) in self.windows.drain() {
win.egui.destroy();
}
let _ = std::fs::remove_file(self.shared.paths.running_marker());

View file

@ -299,6 +299,17 @@ pub fn visuals(p: &Palette, corner_radius: u8) -> Visuals {
mod tests {
use super::*;
/// epaint 0.37.0 panicked rasterizing glyphs once Servo turned on vello_cpu's multithreading
/// (vendor/epaint patch). Laying out text renders glyphs.
#[test]
fn egui_draws_text() {
let ctx = egui::Context::default();
let output = ctx.run_ui(Default::default(), |ui| {
ui.label("Nacre");
});
assert!(!output.shapes.is_empty());
}
#[test]
fn colours() {
assert_eq!(parse_hex("#6750A4"), Some(Color32::from_rgb(0x67, 0x50, 0xA4)));

8
tests/smoke/https.txt Normal file
View file

@ -0,0 +1,8 @@
# Plain HTTPS through the network bridge (no VPN, no proxy). Needs internet. Run with tools/smoke.sh.
wait 2
open https://example.org/
waitload 45
wait 1
shot example
status done
quit

13
tests/smoke/launch.txt Normal file
View file

@ -0,0 +1,13 @@
# First launch: internal new tab page, then a local web page. Run with tools/smoke.sh.
wait 3
# Restore tabs on the next start, so a second run on the same home (restore.txt) can check the session.
set /startup/mode "restore"
page nacre://newtab
wait 1
shot newtab
open @PAGES@/hello.html
waitload 30
wait 1
shot page
status done
quit

View file

@ -0,0 +1,14 @@
<!doctype html>
<html>
<head><meta charset="utf-8"><title>Smoke page</title>
<style>
body { margin: 0; font: 32px sans-serif; background: #f4efe6; color: #222; }
h1 { margin: 40px; color: #1a5fb4; }
.box { margin: 40px; width: 300px; height: 150px; background: #e66100; }
</style></head>
<body>
<h1>Nacre smoke test</h1>
<p style="margin: 40px">If you can read this, the page rendered.</p>
<div class="box"></div>
</body>
</html>

5
tests/smoke/restore.txt Normal file
View file

@ -0,0 +1,5 @@
# Second launch: run after launch.txt on the same home (SMOKE_HOME=<launch outdir>/home); the session comes back.
wait 4
shot restored
status done
quit

88
tools/smoke.sh Executable file
View file

@ -0,0 +1,88 @@
#!/usr/bin/env bash
# Smoke run: start Nacre on a hidden X display (Xvfb) with a throwaway profile, play a NACRE_SCRIPT, collect results.
#
# Usage: tools/smoke.sh <script.txt> [outdir]
# outdir defaults to target/smoke/<script name>-<time>. It gets:
# nacre.log stdout + stderr of the browser (RUST_BACKTRACE=1)
# selftest.log every script line run, plus js results and warnings
# <name>.png `shot <name>` screenshots; <name>.json `status <name>` files
# home/ the throwaway HOME / XDG_* folders (profile, history, session)
# Exit 0 only if the browser exited by itself with status 0, no "panicked" is in nacre.log and the script
# wrote `status done` (so every script must end with `status done` then `quit`).
#
# Environment:
# SMOKE_HOME=dir reuse this throwaway home (e.g. a previous run's outdir/home) to test session restore
# SMOKE_TIMEOUT=s kill the browser after s seconds (default 180)
# SMOKE_SIZE=WxH screen size (default 1280x800)
# SMOKE_BIN=path browser binary (default target/release/nacre)
# NACRE_NO_BRIDGE=1 passed through: no network bridge
#
# Script commands (src/selftest.rs has the full list): wait <s>, waitload [s], open <url>, newtab <url>,
# page <nacre://...>, shot <name>, status <name>, set <json pointer> <json>, flyout <name>, do <action>,
# cmd <name> [arg], js <script>, click <x> <y>, log <text>, quit. Lines starting with # are notes.
# In the script, @PAGES@ is replaced by the file:// URL of tests/smoke/pages.
#
# Never uses the user's profile, display, Discord socket or session bus; never sets a proxy.
set -u
root=$(cd "$(dirname "$0")/.." && pwd)
script=${1:?usage: tools/smoke.sh <script.txt> [outdir]}
[ -f "$script" ] || { echo "smoke: no such script $script" >&2; exit 2; }
out=${2:-$root/target/smoke/$(basename "$script" .txt)-$(date +%Y%m%d-%H%M%S)}
bin=${SMOKE_BIN:-$root/target/release/nacre}
[ -x "$bin" ] || { echo "smoke: no binary at $bin (build first)" >&2; exit 2; }
command -v Xvfb >/dev/null || { echo "smoke: Xvfb is missing (pacman -S xorg-server-xvfb)" >&2; exit 2; }
mkdir -p "$out"
out=$(cd "$out" && pwd)
home=${SMOKE_HOME:-$out/home}
mkdir -p "$home"
home=$(cd "$home" && pwd)
rm -f "$out"/*.png "$out"/*.json "$out/selftest.log" "$out/nacre.log"
sed "s|@PAGES@|file://$root/tests/smoke/pages|g" "$script" >"$out/script.txt"
runtime=$(mktemp -d /tmp/nacre-smoke-XXXXXX)
chmod 700 "$runtime"
xvfb_pid=
cleanup() {
[ -n "$xvfb_pid" ] && kill "$xvfb_pid" 2>/dev/null
rm -rf "$runtime"
}
trap cleanup EXIT
# Xvfb picks a free display number and writes it to fd 3.
exec 3<>"$runtime/display"
Xvfb -displayfd 3 -screen 0 "${SMOKE_SIZE:-1280x800}x24" -nolisten tcp -noreset >"$out/xvfb.log" 2>&1 &
xvfb_pid=$!
for _ in $(seq 50); do
display=$(head -n1 "$runtime/display" 2>/dev/null)
[ -n "$display" ] && break
sleep 0.1
done
[ -n "${display:-}" ] || { echo "smoke: Xvfb did not start (see $out/xvfb.log)" >&2; exit 1; }
env -u WAYLAND_DISPLAY -u DBUS_SESSION_BUS_ADDRESS -u NACRE_HOME \
-u http_proxy -u https_proxy -u all_proxy -u HTTP_PROXY -u HTTPS_PROXY -u ALL_PROXY \
DISPLAY=":$display" XDG_SESSION_TYPE=x11 \
HOME="$home" XDG_CONFIG_HOME="$home/.config" XDG_DATA_HOME="$home/.local/share" \
XDG_CACHE_HOME="$home/.cache" XDG_RUNTIME_DIR="$runtime" \
LIBGL_ALWAYS_SOFTWARE=1 RUST_BACKTRACE=1 NACRE_SCRIPT="$out/script.txt" \
timeout -k 10 "${SMOKE_TIMEOUT:-180}" "$bin" >"$out/nacre.log" 2>&1
code=$?
fail=0
if [ "$code" -ne 0 ]; then
echo "smoke: browser exited with $code$([ "$code" -eq 124 ] && echo ' (timeout)')"
fail=1
fi
if grep -q panicked "$out/nacre.log"; then
echo "smoke: panic in nacre.log:"
grep -m3 -A2 panicked "$out/nacre.log"
fail=1
fi
if [ ! -f "$out/done.json" ]; then
echo "smoke: script did not reach 'status done'"
fail=1
fi
echo "smoke: $([ $fail -eq 0 ] && echo ok || echo FAILED), results in $out"
exit $fail

1
vendor/epaint/.cargo-ok vendored Normal file
View file

@ -0,0 +1 @@
{"v":1}

6
vendor/epaint/.cargo_vcs_info.json vendored Normal file
View file

@ -0,0 +1,6 @@
{
"git": {
"sha1": "7c0b40402271e8d40cda69f87cf3c2617c2e4382"
},
"path_in_vcs": "crates/epaint"
}

345
vendor/epaint/Cargo.toml vendored Normal file
View file

@ -0,0 +1,345 @@
# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
#
# When uploading crates to the registry Cargo will automatically
# "normalize" Cargo.toml files for maximal compatibility
# with all versions of Cargo and also rewrite `path` dependencies
# to registry (e.g., crates.io) dependencies.
#
# If you are reading this file be aware that the original Cargo.toml
# will likely look very different (and much more reasonable).
# See Cargo.toml.orig for the original contents.
[package]
edition = "2024"
rust-version = "1.95"
name = "epaint"
version = "0.37.0"
authors = ["Emil Ernerfeldt <[email protected]>"]
build = false
include = [
"../../LICENSE-APACHE",
"../../LICENSE-MIT",
"**/*.rs",
"Cargo.toml",
]
autolib = false
autobins = false
autoexamples = false
autotests = false
autobenches = false
description = "Minimal 2D graphics library for GUI work"
homepage = "https://github.com/emilk/egui/tree/main/crates/epaint"
readme = "README.md"
keywords = [
"graphics",
"gui",
"egui",
]
categories = [
"graphics",
"gui",
]
license = "MIT OR Apache-2.0"
repository = "https://github.com/emilk/egui/tree/main/crates/epaint"
resolver = "2"
[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--generate-link-to-definition"]
[features]
_override_unity = []
bytemuck = [
"dep:bytemuck",
"emath/bytemuck",
"ecolor/bytemuck",
]
cint = ["ecolor/cint"]
color-hex = ["ecolor/color-hex"]
color_fonts = [
"vello_cpu/png",
"vello_cpu/text",
]
default = []
default_fonts = ["epaint_default_fonts"]
mint = ["emath/mint"]
monochrome_emoji_fonts = [
"default_fonts",
"epaint_default_fonts/monochrome_emoji_fonts",
]
rayon = ["dep:rayon"]
serde = [
"dep:serde",
"ahash/serde",
"ecolor/serde",
"emath/serde",
"font-types/serde",
"smallvec/serde",
]
unity = []
[lib]
name = "epaint"
path = "src/lib.rs"
[[bench]]
name = "benchmark"
path = "benches/benchmark.rs"
harness = false
[dependencies.ahash]
version = "0.8.12"
features = [
"no-rng",
"std",
]
default-features = false
[dependencies.bytemuck]
version = "1.25"
features = ["derive"]
optional = true
[dependencies.document-features]
version = "0.2.12"
optional = true
[dependencies.ecolor]
version = "0.37.0"
default-features = false
[dependencies.emath]
version = "0.37.0"
default-features = false
[dependencies.epaint_default_fonts]
version = "0.37.0"
optional = true
[dependencies.font-types]
version = "0.12.4"
features = ["std"]
default-features = false
[dependencies.harfrust]
version = "0.12.0"
[dependencies.log]
version = "0.4.34"
features = ["std"]
[dependencies.nohash-hasher]
version = "0.2.0"
[dependencies.parking_lot]
version = "0.12.5"
[dependencies.profiling]
version = "1.0"
default-features = false
[dependencies.rayon]
version = "1.12"
optional = true
[dependencies.self_cell]
version = "1.3"
[dependencies.serde]
version = "1.0"
features = [
"derive",
"derive",
"rc",
]
optional = true
[dependencies.skrifa]
version = "0.44.0"
features = [
"std",
"autohint_shaping",
]
default-features = false
[dependencies.smallvec]
version = "1.16"
[dependencies.unicode-general-category]
version = "1.1"
[dependencies.unicode-properties]
version = "0.1.4"
features = ["emoji"]
default-features = false
[dependencies.unicode-segmentation]
version = "1.13"
[dependencies.vello_cpu]
version = "0.2.0"
features = [
"std",
"u8_pipeline",
"f32_pipeline",
]
default-features = false
[dev-dependencies.criterion]
version = "0.8.2"
default-features = false
[dev-dependencies.mimalloc]
version = "0.1.52"
[dev-dependencies.similar-asserts]
version = "2.0"
[lints.clippy]
allow_attributes = "warn"
as_ptr_cast_mut = "warn"
assigning_clones = "allow"
branches_sharing_code = "warn"
cast_lossless = "allow"
cast_possible_truncation = "allow"
cast_possible_wrap = "allow"
cast_precision_loss = "allow"
cast_sign_loss = "allow"
clear_with_drain = "warn"
clone_on_ref_ptr = "warn"
coerce_container_to_any = "warn"
comparison_chain = "allow"
dbg_macro = "warn"
debug_assert_with_mut_call = "warn"
default_trait_access = "allow"
default_union_representation = "warn"
derive_partial_eq_without_eq = "warn"
disallowed_script_idents = "warn"
doc_include_without_cfg = "warn"
empty_enum_variants_with_brackets = "warn"
equatable_if_let = "warn"
exit = "warn"
fallible_impl_from = "warn"
float_cmp = "allow"
float_cmp_const = "warn"
fn_to_numeric_cast_any = "warn"
get_unwrap = "warn"
imprecise_flops = "warn"
infinite_loop = "warn"
inline_always = "allow"
items_after_statements = "allow"
iter_on_empty_collections = "warn"
iter_on_single_items = "warn"
iter_over_hash_type = "warn"
large_include_file = "warn"
large_stack_frames = "warn"
let_underscore_must_use = "allow"
let_underscore_untyped = "allow"
literal_string_with_formatting_args = "warn"
lossy_float_literal = "warn"
manual_range_contains = "allow"
many_single_char_names = "allow"
map_err_ignore = "warn"
map_unwrap_or = "allow"
mem_forget = "warn"
missing_assert_message = "warn"
missing_panics_doc = "allow"
multiple_crate_versions = "allow"
must_use_candidate = "allow"
mutex_integer = "warn"
needless_pass_by_ref_mut = "warn"
needless_type_cast = "warn"
non_zero_suggestions = "warn"
nonstandard_macro_braces = "warn"
or_fun_call = "warn"
path_buf_push_overwrite = "warn"
pathbuf_init_then_push = "warn"
precedence_bits = "warn"
print_stderr = "warn"
print_stdout = "warn"
pub_without_shorthand = "warn"
rc_mutex = "warn"
redundant_closure_for_method_calls = "allow"
redundant_type_annotations = "warn"
ref_patterns = "warn"
rest_pat_in_fully_bound_structs = "warn"
return_and_then = "warn"
return_self_not_must_use = "allow"
self_named_module_files = "allow"
set_contains_or_insert = "warn"
should_panic_without_expect = "allow"
significant_drop_tightening = "allow"
similar_names = "allow"
single_option_map = "warn"
std_instead_of_core = "warn"
str_to_string = "warn"
string_add = "warn"
string_lit_as_bytes = "warn"
string_lit_chars_any = "warn"
struct_excessive_bools = "allow"
struct_field_names = "allow"
suspicious_xor_used_as_pow = "warn"
todo = "warn"
too_long_first_doc_paragraph = "warn"
too_many_lines = "allow"
trailing_empty_array = "warn"
trait_duplication_in_bounds = "warn"
trivially_copy_pass_by_ref = "allow"
tuple_array_conversions = "warn"
undocumented_unsafe_blocks = "warn"
unimplemented = "warn"
uninhabited_references = "warn"
unnecessary_safety_comment = "warn"
unnecessary_safety_doc = "warn"
unnecessary_self_imports = "warn"
unnecessary_struct_initialization = "warn"
unreadable_literal = "allow"
unused_peekable = "warn"
unused_rounding = "warn"
unused_trait_names = "warn"
unwrap_used = "warn"
use_self = "warn"
used_underscore_binding = "allow"
useless_let_if_seq = "warn"
verbose_file_reads = "warn"
wildcard_imports = "allow"
[lints.clippy.all]
level = "warn"
priority = -1
[lints.clippy.cargo]
level = "warn"
priority = -1
[lints.clippy.pedantic]
level = "warn"
priority = -1
[lints.rust]
trivial_casts = "allow"
trivial_numeric_casts = "warn"
unsafe_code = "deny"
unused_import_braces = "warn"
unused_lifetimes = "warn"
unused_qualifications = "allow"
[lints.rust.future_incompatible]
level = "warn"
priority = -1
[lints.rust.nonstandard_style]
level = "warn"
priority = -1
[lints.rust.rust_2018_idioms]
level = "warn"
priority = -1
[lints.rust.unexpected_cfgs]
level = "warn"
priority = 0
check-cfg = ["cfg(web_sys_unstable_apis)"]
[lints.rustdoc]
all = "warn"

123
vendor/epaint/Cargo.toml.orig generated vendored Normal file
View file

@ -0,0 +1,123 @@
[package]
name = "epaint"
version.workspace = true
authors = ["Emil Ernerfeldt <[email protected]>"]
description = "Minimal 2D graphics library for GUI work"
edition.workspace = true
rust-version.workspace = true
homepage = "https://github.com/emilk/egui/tree/main/crates/epaint"
license = "MIT OR Apache-2.0"
readme = "README.md"
repository = "https://github.com/emilk/egui/tree/main/crates/epaint"
categories = ["graphics", "gui"]
keywords = ["graphics", "gui", "egui"]
include = ["../../LICENSE-APACHE", "../../LICENSE-MIT", "**/*.rs", "Cargo.toml"]
[lints]
workspace = true
[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--generate-link-to-definition"]
[lib]
[features]
default = []
## [`bytemuck`](https://docs.rs/bytemuck) enables you to cast [`Vertex`] to `&[u8]`.
bytemuck = ["dep:bytemuck", "emath/bytemuck", "ecolor/bytemuck"]
## [`cint`](https://docs.rs/cint) enables interoperability with other color libraries.
cint = ["ecolor/cint"]
## Enable the [`hex_color`] macro.
color-hex = ["ecolor/color-hex"]
## Support bitmap (`sbix`, `CBDT`) and `COLR` glyphs, i.e. color emoji fonts like Apple Color Emoji and Segoe UI Emoji.
##
## Adds a PNG decoder to the binary, so it is off by default. `eframe` enables it on native via `egui_system_fonts`.
color_fonts = ["vello_cpu/png", "vello_cpu/text"]
## If set, epaint will use `include_bytes!` to bundle some fonts.
##
## This is off by default, because only the application should decide whether to pay for the
## bundled fonts. `eframe` enables it by default; an integration that is not `eframe` must
## either enable it, or install a [`text::FontProvider`] of its own.
default_fonts = ["epaint_default_fonts"]
## [`mint`](https://docs.rs/mint) enables interoperability with other math libraries such as [`glam`](https://docs.rs/glam) and [`nalgebra`](https://docs.rs/nalgebra).
mint = ["emath/mint"]
## Bundle the monochrome emoji fonts `NotoEmoji-Regular` and `emoji-icon-font`,
## and put them in the default [`text::FontDefinitions`].
##
## They add about 1 MB to the binary, and are only needed if you want the same
## (monochrome) emoji on every platform, instead of the platform's own color emoji
## (see [`text::GlyphRasterizer`] and [`text::FontProvider`]).
monochrome_emoji_fonts = ["default_fonts", "epaint_default_fonts/monochrome_emoji_fonts"]
## Enable parallel tessellation using [`rayon`](https://docs.rs/rayon).
##
## This can help performance for graphics-intense applications.
rayon = ["dep:rayon"]
## Allow serialization using [`serde`](https://docs.rs/serde).
serde = [
"dep:serde",
"ahash/serde",
"ecolor/serde",
"emath/serde",
"font-types/serde",
"smallvec/serde",
]
## Change Vertex layout to be compatible with unity
unity = []
## Override and disable the unity feature
## This exists, so that when testing with --all-features, snapshots render correctly.
_override_unity = []
[dependencies]
emath.workspace = true
ecolor.workspace = true
ahash.workspace = true
font-types.workspace = true
harfrust.workspace = true
log.workspace = true
nohash-hasher.workspace = true
parking_lot.workspace = true # Using parking_lot over std::sync::Mutex gives 50% speedups in some real-world scenarios.
profiling.workspace = true
self_cell.workspace = true
skrifa.workspace = true
smallvec.workspace = true
unicode-general-category.workspace = true
unicode-properties.workspace = true
unicode-segmentation.workspace = true
vello_cpu.workspace = true
#! ### Optional dependencies
bytemuck = { workspace = true, optional = true, features = ["derive"] }
## Enable this when generating docs.
document-features = { workspace = true, optional = true }
rayon = { workspace = true, optional = true }
## Allow serialization using [`serde`](https://docs.rs/serde) .
serde = { workspace = true, optional = true, features = ["derive", "rc"] }
epaint_default_fonts = { workspace = true, optional = true }
[dev-dependencies]
criterion.workspace = true
mimalloc.workspace = true
similar-asserts.workspace = true
[[bench]]
name = "benchmark"
harness = false

11
vendor/epaint/README.md vendored Normal file
View file

@ -0,0 +1,11 @@
# epaint - egui paint library
[![Latest version](https://img.shields.io/crates/v/epaint.svg)](https://crates.io/crates/epaint)
[![Documentation](https://docs.rs/epaint/badge.svg)](https://docs.rs/epaint)
[![unsafe forbidden](https://img.shields.io/badge/unsafe-forbidden-success.svg)](https://github.com/rust-secure-code/safety-dance/)
![MIT](https://img.shields.io/badge/license-MIT-blue.svg)
![Apache](https://img.shields.io/badge/license-Apache-blue.svg)
A bare-bones 2D graphics library for turning simple 2D shapes and text into textured triangles.
Made for [`egui`](https://github.com/emilk/egui/).

293
vendor/epaint/benches/benchmark.rs vendored Normal file
View file

@ -0,0 +1,293 @@
use criterion::{Criterion, criterion_group, criterion_main};
use epaint::{
ClippedShape, Color32, Mesh, PathStroke, Pos2, Rect, Shape, Stroke, TessellationOptions,
Tessellator, TextureAtlas, Vec2, pos2, tessellator::Path,
};
use core::hint::black_box;
#[global_allocator]
static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc; // Much faster allocator
fn single_dashed_lines(c: &mut Criterion) {
c.bench_function("single_dashed_lines", move |b| {
b.iter(|| {
let mut v = Vec::new();
let line = [pos2(0.0, 0.0), pos2(50.0, 0.0), pos2(100.0, 1.0)];
for _ in 0..100 {
v.extend(Shape::dashed_line(
&line,
Stroke::new(1.5, Color32::RED),
10.0,
2.5,
));
}
black_box(v);
});
});
}
fn many_dashed_lines(c: &mut Criterion) {
c.bench_function("many_dashed_lines", move |b| {
b.iter(|| {
let mut v = Vec::new();
let line = [pos2(0.0, 0.0), pos2(50.0, 0.0), pos2(100.0, 1.0)];
for _ in 0..100 {
Shape::dashed_line_many(&line, Stroke::new(1.5, Color32::RED), 10.0, 2.5, &mut v);
}
black_box(v);
});
});
}
fn tessellate_circles(c: &mut Criterion) {
c.bench_function("tessellate_circles_100k", move |b| {
let radii: [f32; 10] = [1.0, 2.0, 3.6, 4.0, 5.7, 8.0, 10.0, 13.0, 15.0, 17.0];
let mut clipped_shapes = vec![];
for r in radii {
for _ in 0..10_000 {
let clip_rect = Rect::from_min_size(Pos2::ZERO, Vec2::splat(1024.0));
let shape = Shape::circle_filled(Pos2::new(10.0, 10.0), r, Color32::WHITE);
clipped_shapes.push(ClippedShape::new(clip_rect, shape));
}
}
assert_eq!(
clipped_shapes.len(),
100_000,
"length of clipped shapes should be 100k, but was {}",
clipped_shapes.len()
);
let pixels_per_point = 2.0;
let options = TessellationOptions::default();
let atlas = TextureAtlas::new([4096, 256], Default::default());
let font_tex_size = atlas.size();
let prepared_discs = atlas.prepared_discs();
b.iter(|| {
let mut tessellator = Tessellator::new(
pixels_per_point,
options,
font_tex_size,
prepared_discs.clone(),
);
let clipped_primitives = tessellator.tessellate_shapes(clipped_shapes.clone());
black_box(clipped_primitives);
});
});
}
fn thick_line_solid(c: &mut Criterion) {
c.bench_function("thick_solid_line", move |b| {
let line = [pos2(0.0, 0.0), pos2(50.0, 0.0), pos2(100.0, 1.0)];
let mut path = Path::default();
path.add_open_points(&line);
b.iter(|| {
let mut mesh = Mesh::default();
path.stroke_closed(1.5, &Stroke::new(2.0, Color32::RED).into(), &mut mesh);
black_box(mesh);
});
});
}
fn thick_large_line_solid(c: &mut Criterion) {
c.bench_function("thick_large_solid_line", move |b| {
let line = (0..1000).map(|i| pos2(i as f32, 10.0)).collect::<Vec<_>>();
let mut path = Path::default();
path.add_open_points(&line);
b.iter(|| {
let mut mesh = Mesh::default();
path.stroke_closed(1.5, &Stroke::new(2.0, Color32::RED).into(), &mut mesh);
black_box(mesh);
});
});
}
fn thin_line_solid(c: &mut Criterion) {
c.bench_function("thin_solid_line", move |b| {
let line = [pos2(0.0, 0.0), pos2(50.0, 0.0), pos2(100.0, 1.0)];
let mut path = Path::default();
path.add_open_points(&line);
b.iter(|| {
let mut mesh = Mesh::default();
path.stroke_closed(1.5, &Stroke::new(0.5, Color32::RED).into(), &mut mesh);
black_box(mesh);
});
});
}
fn thin_large_line_solid(c: &mut Criterion) {
c.bench_function("thin_large_solid_line", move |b| {
let line = (0..1000).map(|i| pos2(i as f32, 10.0)).collect::<Vec<_>>();
let mut path = Path::default();
path.add_open_points(&line);
b.iter(|| {
let mut mesh = Mesh::default();
path.stroke_closed(1.5, &Stroke::new(0.5, Color32::RED).into(), &mut mesh);
black_box(mesh);
});
});
}
fn thick_line_uv(c: &mut Criterion) {
c.bench_function("thick_uv_line", move |b| {
let line = [pos2(0.0, 0.0), pos2(50.0, 0.0), pos2(100.0, 1.0)];
let mut path = Path::default();
path.add_open_points(&line);
b.iter(|| {
let mut mesh = Mesh::default();
path.stroke_closed(
1.5,
&PathStroke::new_uv(2.0, |_, p| {
black_box(p * 2.0);
Color32::RED
}),
&mut mesh,
);
black_box(mesh);
});
});
}
fn thick_large_line_uv(c: &mut Criterion) {
c.bench_function("thick_large_uv_line", move |b| {
let line = (0..1000).map(|i| pos2(i as f32, 10.0)).collect::<Vec<_>>();
let mut path = Path::default();
path.add_open_points(&line);
b.iter(|| {
let mut mesh = Mesh::default();
path.stroke_closed(
1.5,
&PathStroke::new_uv(2.0, |_, p| {
black_box(p * 2.0);
Color32::RED
}),
&mut mesh,
);
black_box(mesh);
});
});
}
fn thin_line_uv(c: &mut Criterion) {
c.bench_function("thin_uv_line", move |b| {
let line = [pos2(0.0, 0.0), pos2(50.0, 0.0), pos2(100.0, 1.0)];
let mut path = Path::default();
path.add_open_points(&line);
b.iter(|| {
let mut mesh = Mesh::default();
path.stroke_closed(
1.5,
&PathStroke::new_uv(2.0, |_, p| {
black_box(p * 2.0);
Color32::RED
}),
&mut mesh,
);
black_box(mesh);
});
});
}
fn thin_large_line_uv(c: &mut Criterion) {
c.bench_function("thin_large_uv_line", move |b| {
let line = (0..1000).map(|i| pos2(i as f32, 10.0)).collect::<Vec<_>>();
let mut path = Path::default();
path.add_open_points(&line);
b.iter(|| {
let mut mesh = Mesh::default();
path.stroke_closed(
1.5,
&PathStroke::new_uv(2.0, |_, p| {
black_box(p * 2.0);
Color32::RED
}),
&mut mesh,
);
black_box(mesh);
});
});
}
fn rgba_values() -> [[u8; 4]; 1000] {
core::array::from_fn(|i| [5, 7, 11, 13].map(|m| (i * m) as u8))
}
fn from_rgba_unmultiplied_0(c: &mut Criterion) {
c.bench_function("from_rgba_unmultiplied_0", move |b| {
let values = black_box(rgba_values().map(|[r, g, b, _]| [r, g, b, 0]));
b.iter(|| {
for [r, g, b, a] in values {
let color = ecolor::Color32::from_rgba_unmultiplied(r, g, b, a);
black_box(color);
}
});
});
}
fn from_rgba_unmultiplied_other(c: &mut Criterion) {
c.bench_function("from_rgba_unmultiplied_other", move |b| {
let values = black_box(rgba_values().map(|[r, g, b, a]| [r, g, b, a.clamp(1, 254)]));
b.iter(|| {
for [r, g, b, a] in values {
let color = ecolor::Color32::from_rgba_unmultiplied(r, g, b, a);
black_box(color);
}
});
});
}
fn from_rgba_unmultiplied_255(c: &mut Criterion) {
c.bench_function("from_rgba_unmultiplied_255", move |b| {
let values = black_box(rgba_values().map(|[r, g, b, _]| [r, g, b, 255]));
b.iter(|| {
for [r, g, b, a] in values {
let color = ecolor::Color32::from_rgba_unmultiplied(r, g, b, a);
black_box(color);
}
});
});
}
criterion_group!(
benches,
single_dashed_lines,
many_dashed_lines,
tessellate_circles,
thick_line_solid,
thick_large_line_solid,
thin_line_solid,
thin_large_line_solid,
thick_line_uv,
thick_large_line_uv,
thin_line_uv,
thin_large_line_uv,
from_rgba_unmultiplied_0,
from_rgba_unmultiplied_other,
from_rgba_unmultiplied_255,
);
criterion_main!(benches);

Some files were not shown because too many files have changed in this diff Show more