mirror of
https://github.com/emilk/egui.git
synced 2026-09-02 14:50:03 -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",
|
||||||
"egui_inspection",
|
"egui_inspection",
|
||||||
"egui_kittest",
|
"egui_kittest",
|
||||||
"image",
|
|
||||||
"interprocess",
|
"interprocess",
|
||||||
"rmcp",
|
"rmcp",
|
||||||
"rmp-serde",
|
"rmp-serde",
|
||||||
|
|||||||
@@ -18,12 +18,11 @@ path = "src/main.rs"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
egui_kittest = { workspace = true, features = ["inspector_api", "wgpu", "snapshot"] }
|
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
|
egui.workspace = true
|
||||||
interprocess = { version = "2.4", features = ["tokio"] }
|
interprocess = { version = "2.4", features = ["tokio"] }
|
||||||
accesskit.workspace = true
|
accesskit.workspace = true
|
||||||
accesskit_consumer.workspace = true
|
accesskit_consumer.workspace = true
|
||||||
image = { workspace = true, features = ["png"] }
|
|
||||||
rmp-serde.workspace = true
|
rmp-serde.workspace = true
|
||||||
serde = { workspace = true, features = ["derive"] }
|
serde = { workspace = true, features = ["derive"] }
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
|
|||||||
@@ -453,7 +453,7 @@ impl Server {
|
|||||||
.env(egui_inspection::INSPECTION_SOCKET_ENV_VAR, &socket_target.name)
|
.env(egui_inspection::INSPECTION_SOCKET_ENV_VAR, &socket_target.name)
|
||||||
.stdin(std::process::Stdio::null())
|
.stdin(std::process::Stdio::null())
|
||||||
.stdout(std::process::Stdio::null())
|
.stdout(std::process::Stdio::null())
|
||||||
.stderr(std::process::Stdio::null())
|
.stderr(std::process::Stdio::inherit())
|
||||||
.kill_on_drop(true);
|
.kill_on_drop(true);
|
||||||
for (k, v) in &args.env {
|
for (k, v) in &args.env {
|
||||||
cmd.env(k, v);
|
cmd.env(k, v);
|
||||||
@@ -871,8 +871,7 @@ async fn screenshot_inner(bridge: &Bridge) -> anyhow::Result<(ScreenshotMeta, St
|
|||||||
height: shot.height,
|
height: shot.height,
|
||||||
pixels_per_point: frame.pixels_per_point,
|
pixels_per_point: frame.pixels_per_point,
|
||||||
};
|
};
|
||||||
let png = encode_png(shot).context("encode PNG")?;
|
return Ok((meta, base64::engine::general_purpose::STANDARD.encode(&shot.png)));
|
||||||
return Ok((meta, base64::engine::general_purpose::STANDARD.encode(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 shot = frame.screenshot.as_ref().expect("checked above");
|
||||||
let png = encode_png(shot).context("encode PNG")?;
|
|
||||||
let meta = ScreenshotMeta {
|
let meta = ScreenshotMeta {
|
||||||
step: frame.step,
|
step: frame.step,
|
||||||
width: shot.width,
|
width: shot.width,
|
||||||
@@ -908,18 +906,10 @@ async fn screenshot_inner(bridge: &Bridge) -> anyhow::Result<(ScreenshotMeta, St
|
|||||||
};
|
};
|
||||||
Ok((
|
Ok((
|
||||||
meta,
|
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> {
|
fn parse_pointer_button(name: &str) -> anyhow::Result<egui::PointerButton> {
|
||||||
match name.to_ascii_lowercase().as_str() {
|
match name.to_ascii_lowercase().as_str() {
|
||||||
"primary" | "left" => Ok(egui::PointerButton::Primary),
|
"primary" | "left" => Ok(egui::PointerButton::Primary),
|
||||||
|
|||||||
Reference in New Issue
Block a user