M13.30: Content-Aware Fill in a job worker on its GPU

contentFill.generate sends its plan (FillPlan) to a browser job worker:
the layer's frames render in passes on the worker's WebGPU device, the PNG
sequence goes back to browser storage (Services::store_file), and the page
adds the fill layer when the plan returns (WorkerReply::Fill). The smoke
test checks it; docs updated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Brandon Thomas
2026-10-04 03:15:54 -04:00
co-authored by Claude Opus 5.5
parent 91f4a603a9
commit 3921e6c680
10 changed files with 350 additions and 71 deletions
+4
View File
@@ -126,6 +126,10 @@ impl Services for WebServices {
}
fn store_file(&self, path: &str, data: &[u8]) -> std::io::Result<()> {
put(path, data.into());
// A job worker's files (Content-Aware Fill) go to the page's storage.
if crate::is_worker() {
crate::worker::post_store(path, data);
}
Ok(())
}
}
+13
View File
@@ -88,6 +88,12 @@ impl Offload for WorkerOffload {
crate::files::add_output(&p, b.to_vec().into());
}
}
"store" => {
// A file the job keeps (Content-Aware Fill's sequence): browser storage.
if let (Some(p), Ok(b)) = (path.as_string(), bytes.dyn_into::<js_sys::Uint8Array>()) {
crate::files::put(&p, b.to_vec().into());
}
}
_ => {
inbox.push(WorkerReply::Failed { error: json.as_string().unwrap_or_else(|| "worker failed".into()) });
inbox.push(WorkerReply::Done);
@@ -135,6 +141,13 @@ fn obj(pairs: &[(&str, JsValue)]) -> JsValue {
o.into()
}
/// Send a file the job keeps to the page's storage (`Services::store_file` in a job worker).
pub(crate) fn post_store(path: &str, data: &[u8]) {
let bytes = js_sys::Uint8Array::from(data);
let buf = bytes.buffer();
post(&obj(&[("type", "store".into()), ("path", path.into()), ("bytes", buf.clone().into())]), Some(&js_sys::Array::of1(&buf)));
}
/// Set up the worker's engine session (called once by `web/worker.js`).
#[wasm_bindgen(js_name = workerInit)]
pub fn worker_init() {