Keep the overlay on the photograph when the view moves
The overlay is a source-space picture; the canvas beside it shows whatever the crop, the zoom and the pan selected out of that same space. Drawn whole it stayed frame-sized while the photograph moved underneath, so zooming in left a map of the whole picture stretched over a detail of it. It now reports the visible rectangle as a clip, which the compositor applies for nothing. Resampling on the CPU instead would mean rebuilding a megapixel image on every frame of a drag, and putting it on the GPU would add a second texture to keep in step with the view. Pushed from the render path rather than the panel's sync: a pan changes no mask and no row, so nothing else needs to run, and rebuilding the row models on every frame of a drag would be waste. Straightening is handled by rotating the image. A quarter turn or a flip permutes the axes and a clip rectangle cannot say that — noted where it happens rather than left to be discovered. The proper fix is to run the overlay through the same shader prologue the photograph goes through, which is the right answer and a larger one than this. Four tests, and the one that matters asserts the clip *narrows* when zoomed — which is precisely what it failed to do.
This commit is contained in:
@@ -84,6 +84,25 @@ pub(crate) fn sync(window: &AppWindow, session: &Rc<RefCell<Option<DevelopSessio
|
||||
}
|
||||
None => window.set_overlay_on(false),
|
||||
}
|
||||
|
||||
// Which part of it the view is showing. Pushed on every sync *and* on
|
||||
// every redraw, because zooming and panning change this without changing
|
||||
// anything else the panel shows.
|
||||
sync_overlay_view(window, s);
|
||||
}
|
||||
|
||||
/// Push the overlay's clip rectangle and angle.
|
||||
///
|
||||
/// Separate from [`sync`] because it is called from the render path too: a pan
|
||||
/// changes no mask and no row, so nothing else in `sync` needs to run, and
|
||||
/// rebuilding the row models on every frame of a drag would be wasteful.
|
||||
pub(crate) fn sync_overlay_view(window: &AppWindow, session: &DevelopSession) {
|
||||
let (x, y, w, h) = session.overlay_clip();
|
||||
window.set_overlay_clip_x(x);
|
||||
window.set_overlay_clip_y(y);
|
||||
window.set_overlay_clip_w(w);
|
||||
window.set_overlay_clip_h(h);
|
||||
window.set_overlay_angle(session.angle());
|
||||
}
|
||||
|
||||
/// Install the panel's callbacks.
|
||||
|
||||
Reference in New Issue
Block a user