mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-19 22:50:21 +00:00
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:
@@ -338,6 +338,23 @@ public:
|
||||
void captureNextFrameToPng(const std::string& path, bool quit_after);
|
||||
bool pending_screenshot_quit_ = false;
|
||||
|
||||
// Encode a surface-to-buffer copy of the swapchain texture into the
|
||||
// supplied encoder. Returns the allocated readback buffer (caller
|
||||
// releases) and writes the row-aligned bytes-per-row through
|
||||
// `padded_bpr_out`. The caller is expected to wait for queue submit
|
||||
// before calling finalizeScreenshotCapture below.
|
||||
WGPUBuffer encodeScreenshotCapture(WGPUCommandEncoder enc,
|
||||
WGPUTexture surface_texture,
|
||||
std::uint32_t& padded_bpr_out);
|
||||
|
||||
// After queue submit, map the staging buffer back to host memory,
|
||||
// BGRA→RGBA-swap into a tightly-packed RGBA8 image, hand it to
|
||||
// host_->saveScreenshotRgba8, then release the staging buffer.
|
||||
// Clears pending_screenshot_path_ and (when pending_screenshot_quit_
|
||||
// was set) invokes host_->quit().
|
||||
void finalizeScreenshotCapture(WGPUBuffer capture_buffer,
|
||||
std::uint32_t padded_bpr);
|
||||
|
||||
// ---- Surface configuration (#84-u) ------------------------------------
|
||||
//
|
||||
// Configure the swapchain at the given physical size. Picks a present
|
||||
|
||||
Reference in New Issue
Block a user