mirror of
https://github.com/emilk/egui.git
synced 2026-06-26 14:49:06 -04:00
egui_kittest_mcp: pass through PNG frames; inherit child stderr
- Screenshots now arrive pre-encoded as PNG; drop the local re-encode helper and the direct `image` dependency. - Drop the now-removed egui_inspection `protocol` feature. - Inherit the spawned child's stderr so its panics and logs surface.
This commit is contained in:
@@ -1496,7 +1496,6 @@ dependencies = [
|
||||
"egui",
|
||||
"egui_inspection",
|
||||
"egui_kittest",
|
||||
"image",
|
||||
"interprocess",
|
||||
"rmcp",
|
||||
"rmp-serde",
|
||||
|
||||
@@ -18,12 +18,11 @@ path = "src/main.rs"
|
||||
|
||||
[dependencies]
|
||||
egui_kittest = { workspace = true, features = ["inspector_api", "wgpu", "snapshot"] }
|
||||
egui_inspection = { workspace = true, features = ["protocol", "transport"] }
|
||||
egui_inspection = { workspace = true, features = ["transport"] }
|
||||
egui.workspace = true
|
||||
interprocess = { version = "2.4", features = ["tokio"] }
|
||||
accesskit.workspace = true
|
||||
accesskit_consumer.workspace = true
|
||||
image = { workspace = true, features = ["png"] }
|
||||
rmp-serde.workspace = true
|
||||
serde = { workspace = true, features = ["derive"] }
|
||||
serde_json = "1.0"
|
||||
|
||||
@@ -453,7 +453,7 @@ impl Server {
|
||||
.env(egui_inspection::INSPECTION_SOCKET_ENV_VAR, &socket_target.name)
|
||||
.stdin(std::process::Stdio::null())
|
||||
.stdout(std::process::Stdio::null())
|
||||
.stderr(std::process::Stdio::null())
|
||||
.stderr(std::process::Stdio::inherit())
|
||||
.kill_on_drop(true);
|
||||
for (k, v) in &args.env {
|
||||
cmd.env(k, v);
|
||||
@@ -871,8 +871,7 @@ async fn screenshot_inner(bridge: &Bridge) -> anyhow::Result<(ScreenshotMeta, St
|
||||
height: shot.height,
|
||||
pixels_per_point: frame.pixels_per_point,
|
||||
};
|
||||
let png = encode_png(shot).context("encode PNG")?;
|
||||
return Ok((meta, base64::engine::general_purpose::STANDARD.encode(png)));
|
||||
return Ok((meta, base64::engine::general_purpose::STANDARD.encode(&shot.png)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -899,7 +898,6 @@ async fn screenshot_inner(bridge: &Bridge) -> anyhow::Result<(ScreenshotMeta, St
|
||||
}
|
||||
};
|
||||
let shot = frame.screenshot.as_ref().expect("checked above");
|
||||
let png = encode_png(shot).context("encode PNG")?;
|
||||
let meta = ScreenshotMeta {
|
||||
step: frame.step,
|
||||
width: shot.width,
|
||||
@@ -908,18 +906,10 @@ async fn screenshot_inner(bridge: &Bridge) -> anyhow::Result<(ScreenshotMeta, St
|
||||
};
|
||||
Ok((
|
||||
meta,
|
||||
base64::engine::general_purpose::STANDARD.encode(png),
|
||||
base64::engine::general_purpose::STANDARD.encode(&shot.png),
|
||||
))
|
||||
}
|
||||
|
||||
fn encode_png(shot: &egui_inspection::protocol::FrameScreenshot) -> anyhow::Result<Vec<u8>> {
|
||||
let img = image::RgbaImage::from_raw(shot.width, shot.height, shot.rgba.clone())
|
||||
.ok_or_else(|| anyhow!("frame rgba length mismatch"))?;
|
||||
let mut out = std::io::Cursor::new(Vec::new());
|
||||
img.write_to(&mut out, image::ImageFormat::Png)?;
|
||||
Ok(out.into_inner())
|
||||
}
|
||||
|
||||
fn parse_pointer_button(name: &str) -> anyhow::Result<egui::PointerButton> {
|
||||
match name.to_ascii_lowercase().as_str() {
|
||||
"primary" | "left" => Ok(egui::PointerButton::Primary),
|
||||
|
||||
Reference in New Issue
Block a user