+
+ // The offset added due to zoom may have changed with the size.
+ update_offset_and_zoom();
+}
+
+void ResampleEffect::update_offset_and_zoom()
+{
+ bool ok = true;
+
+ // Zoom from the right origin. (zoom_center is given in normalized coordinates,
+ // i.e. 0..1.)
+ float extra_offset_x = zoom_center_x * (1.0f - 1.0f / zoom_x) * input_width;
+ float extra_offset_y = (1.0f - zoom_center_y) * (1.0f - 1.0f / zoom_y) * input_height;
+
+ ok |= hpass->set_float("offset", extra_offset_x + offset_x);
+ ok |= vpass->set_float("offset", extra_offset_y - offset_y); // Compensate for the bottom-left origin.
+ ok |= hpass->set_float("zoom", zoom_x);
+ ok |= vpass->set_float("zoom", zoom_y);
+
+ assert(ok);