ifcviewer: extract screenshot capture encode + readback into ViewportCore (#84-w)

The inline screenshot path inside render() — surface-to-buffer copy,
async map, BGRA->RGBA swap into a tightly-packed RGBA8 image — moves
into core_.encodeScreenshotCapture / finalizeScreenshotCapture. render()
calls the two new helpers around its existing queueSubmit.

The PNG write itself stays Qt-bound, but it's now reached through a
new ViewportHost::saveScreenshotRgba8 virtual. The QtViewportHost
override (ViewportWindow::saveScreenshotRgba8) constructs a QImage
around the host-buffer and calls QImage::save("PNG") with the same
log lines as before; a future WebViewportHost will route the bytes
through stb_image_write or a download-URL emit instead. Either way,
the wgpu-side capture path never touches Qt again.

quit-after-screenshot now goes through host_->quit() too, so the
--screenshot CLI exit no longer reaches QCoreApplication::quit()
from render() directly.
This commit is contained in:
Dion Moult
2026-06-06 19:48:51 +10:00
parent b9d77b2e3d
commit 8fb0a4b24f
5 changed files with 161 additions and 94 deletions
+2
View File
@@ -88,6 +88,8 @@ public:
void onSurfacePickedInTool(int x_px, int y_px, int modifiers) override;
void onToolModeChanged(int tool_mode) override;
void onToolBackspacePressed() override;
void saveScreenshotRgba8(const std::string& path, const std::uint8_t* rgba,
int w, int h) override;
void setBackgroundColor(float r, float g, float b, float a = 1.0f);