Merge pull request #6404 from AJ0070/fix-stream-zoom-reset

fix: reset the stream crop when zoom returns to 100%
This commit is contained in:
Isaac Connor authored and GitHub committed 2026-11-16 21:30:26 -05:00
commit ef2165f57b
2 files changed
+35

No files matched your search

+6
View File
@@ -220,6 +220,12 @@ Image *StreamBase::prepareImage(Image *image, int pre_scaled_by) {
const unsigned short cur_x = x.load();
const unsigned short cur_y = y.load();
if (cur_zoom == ZM_SCALE_BASE) {
// Not zoomed, so a later zoom-in starts from the whole frame
last_crop = Box();
last_crop_width = last_crop_height = 0;
}
if (cur_zoom != 100) {
int base_image_width = image->Width(),
base_image_height = image->Height(),
+29
View File
@@ -343,6 +343,35 @@ TEST_CASE("StreamBase::prepareImage keeps a zoom across a change of resolution")
CHECK(sent->Height() == 480);
}
TEST_CASE("StreamBase::prepareImage starts a new zoom from the whole frame", "[StreamBase]") {
// Zooming out to 100% shows the whole frame again. A later zoom-in click is
// in that whole-frame view, so it must not be mapped through the crop left
// behind by the earlier zoom.
EnsureImageInit();
Image frame(640, 480, ZM_COLOUR_RGB32, ZM_SUBPIX_ORDER_RGBA);
TestStream fresh;
fresh.setView(ZM_SCALE_BASE, 200);
fresh.setClick(320, 240);
fresh.prepare(&frame);
const Box expected = fresh.crop();
TestStream used;
used.setView(ZM_SCALE_BASE, 200);
used.setClick(600, 440);
used.prepare(&frame);
used.setView(ZM_SCALE_BASE, 100);
used.prepare(&frame);
used.setView(ZM_SCALE_BASE, 200);
used.setClick(320, 240);
used.prepare(&frame);
CHECK(used.crop().Lo().x_ == expected.Lo().x_);
CHECK(used.crop().Lo().y_ == expected.Lo().y_);
CHECK(used.crop().Hi().x_ == expected.Hi().x_);
CHECK(used.crop().Hi().y_ == expected.Hi().y_);
}
TEST_CASE("StreamBase::preScaleDimensions") {
const int kWidth = 640;
const int kHeight = 480;