Merge pull request #19511

Co-authored-by: autocraft-bot[bot] <354215646+autocraft-bot[bot]@users.noreply.github.com>
This commit is contained in:
davidmann4andautocraft-bot[bot] authored and autocraft-bot[bot] committed 2026-12-03 07:03:48 +00:00
commit b22ee1636b
2 files changed
+85 -43

No files matched your search

+2 -3
View File
@@ -132,15 +132,14 @@ filter = '''
(package(photocraft-gpu) & test(=camera_raw::clarity_texture_and_dehaze_with_shadows_highlights_and_per_pixel_stages)) |
(package(photocraft-engine-paint) & test(=cmd::retouch_cmds::content_aware_move::tests::a_coarse_preview_keeps_a_faint_sparse_selection)) |
(package(photocraft-engine) & test(=crop_content_aware_layers::unmeasured_active_targets_and_delete_off_keep_the_legacy_target)) |
(package(photocraft-engine-paint) & test(=cmd::retouch_cmds::content_aware_move::color_tests::a_flat_patch_matches_the_new_surroundings_at_color_ten)) |
(package(photocraft-engine-paint) & test(/^cmd::retouch_cmds::content_aware_move::color_tests::/)) |
(package(photocraft-ui-egui) & test(=tools::type_tool::canvas_tests::every_paragraph_box_handle_resizes_the_box_with_snapping_on)) |
(package(photocraft-ui-egui) & test(=gpu_tests::checker_canvas::pixel_grid_is_solid_and_visible_gpu_2x)) |
(package(photocraft-engine-paint) & test(=cmd::retouch_cmds::tests::content_aware_move_coarse_preview_handles_transform_extend_and_limits)) |
(package(photocraft-ui-egui) & test(=gpu_tests::checker_canvas::pixel_grid_is_solid_and_visible_cpu_2x)) |
(package(photocraft-ui-egui) & test(=gpu_tests::drag_preview_canvas::marquee_previews_show_while_dragging_on_white_and_black_at_1x_and_2x)) |
(package(photocraft-gpu) & test(=camera_raw::shadows_and_highlights_with_per_pixel_stages)) |
(package(photocraft-engine-paint) & test(=cmd::retouch_cmds::content_aware_move::color_tests::a_brightness_change_shifts_the_middle_only_past_color_five)) |
(package(photocraft-engine-paint) & test(=cmd::retouch_cmds::tests::content_aware_move_previews_large_selections_coarse_then_exact_at_all_depths)) |
(package(photocraft-engine-paint) & test(=cmd::retouch_cmds::tests::content_aware_move_previews_large_selections_coarse_then_exact)) |
(package(photocraft-ui-egui) & test(=gpu_tests::live_stroke_canvas::live_tool_camera_navigation_is_visible_in_the_input_frame)) |
(package(photocraft-ui-egui) & test(=gpu_tests::live_stroke_canvas::the_canvas_shows_the_committed_stroke_part_0)) |
(package(photocraft-ui-egui) & test(=gpu_tests::full_res_preview::adjustment_layer_drag_previews_at_full_resolution_when_low_res_is_off)) |
@@ -114,20 +114,37 @@ fn the_core_fit_shifts_brightness_and_leaves_a_hue_alone() {
assert_eq!(cam_core_fit(1, &[200.0 / 255.0], &[51.0 / 255.0], 10, None)[0].0, 1.0);
}
// Each move solves a fill over the whole canvas, so the cases below are one test each: three or
// four of them in one test ran past the CI profile's time limit on the Linux gate (#19510).
/// The green document's selection 120,120 40×40 dragged (140,140) → (600,420). Row y 420 is the
/// middle of the landing.
fn green_moved(color: u64, mode: &str) -> Session {
let mut s = green_doc();
select_and_move(&mut s, [120, 120, 40, 40], [460, 280], color, mode);
s
}
/// The checker cells the landing's middle shows on row y 420, by x.
const GREEN_MIDDLE: [(i32, i32); 5] = [(590, 200), (595, 200), (600, 60), (605, 60), (610, 200)];
#[test]
fn color_ten_on_green_leaves_the_middle_and_blends_the_edge() {
// Selection 120,120 40×40 dragged (140,140) → (600,420). Row y 420 is the middle of the landing.
fn color_zero_on_green_keeps_the_checker() {
// Color 0 is only read at the landing, which Extend makes as Move does (`run_move` step 1),
// without Move's second fill of the old place.
let mut kept = green_doc();
select_and_move(&mut kept, [120, 120, 40, 40], [460, 280], 0, "extend");
let mut fitted = green_doc();
select_and_move(&mut fitted, [120, 120, 40, 40], [460, 280], 10, "move");
// Color 0 keeps today's copy of the checker. Color 10 stays within ±5 of that, not a green tint.
for (x, v) in [(590, 200), (595, 200), (600, 60), (605, 60), (610, 200)] {
let kept = green_moved(0, "extend");
for (x, v) in GREEN_MIDDLE {
assert_eq!(levels(&kept, x, 420), [v, v, v], "color 0 keeps the checker at x {x}");
assert_near(levels(&fitted, x, 420), levels(&kept, x, 420), 5, "color 10 middle");
}
}
#[test]
fn color_ten_on_green_leaves_the_middle_and_blends_the_edge() {
let fitted = green_moved(10, "move");
// Color 10 stays within ±5 of Color 0's copy of the checker (`color_zero_on_green_keeps_the_checker`
// holds it to these levels exactly), not a green tint.
for (x, v) in GREEN_MIDDLE {
assert_near(levels(&fitted, x, 420), [v, v, v], 5, "color 10 middle");
}
// Edge band at Color 10. x 585 matches 55,86,60. x 610 is kept core (200), within ±20 of
// 188,197,189. x 615's reference is 134,181,142; the existing fill already misses it at
@@ -137,60 +154,86 @@ fn color_ten_on_green_leaves_the_middle_and_blends_the_edge() {
assert_near(levels(&fitted, 610, 420), [188, 197, 189], 20, "x 610");
let edge = levels(&fitted, 615, 420);
assert!((90..=150).contains(&edge[0]) && (150..=195).contains(&edge[1]) && (100..=155).contains(&edge[2]), "x 615 blends into the green: {edge:?}");
}
#[test]
fn color_ten_on_green_extend_leaves_the_middle_as_move_does() {
// Extend uses the same landing, so the middle stays too.
let mut extended = green_doc();
select_and_move(&mut extended, [120, 120, 40, 40], [460, 280], 10, "extend");
let fitted = green_moved(10, "move");
let extended = green_moved(10, "extend");
for x in [590, 600, 610] {
assert_near(levels(&extended, x, 420), levels(&fitted, x, 420), 5, "extend matches move");
}
}
/// The ramp document's checker moved by `offset` at `color` in `mode`, read at the landing's
/// light and dark cells on row y 420 (`at` holds their x).
fn ramp_moved(offset: [i32; 2], color: u64, mode: &str, at: [i32; 2]) -> ([i32; 3], [i32; 3]) {
let mut s = ramp_doc();
select_and_move(&mut s, [120, 120, 40, 40], offset, color, mode);
(levels(&s, at[0], 420), levels(&s, at[1], 420))
}
// Every check of the brightness cases reads the landing, which Move and Extend make with the same
// code (`run_move` step 1); Extend skips Move's fill of the old place, which nothing here reads.
// The drop straight down stays a Move.
fn ramp_row(color: u64) -> ([i32; 3], [i32; 3]) {
ramp_moved([460, 280], color, "extend", [590, 600])
}
#[test]
fn a_brightness_change_keeps_the_checker_at_color_zero() {
assert_eq!(ramp_row(0), ([200, 200, 200], [60, 60, 60]), "color 0 keeps the checker");
}
#[test]
fn a_brightness_change_leaves_the_middle_at_color_five() {
assert_eq!(ramp_row(5), ([200, 200, 200], [60, 60, 60]), "color 5 leaves the middle");
}
#[test]
fn a_brightness_change_shifts_the_middle_only_past_color_five() {
// Every check reads the landing, which Move and Extend make with the same code (`run_move`
// step 1); Extend skips Move's fill of the old place, which nothing here reads. The drop
// straight down below stays a Move.
let row = |color: u64| {
let mut s = ramp_doc();
select_and_move(&mut s, [120, 120, 40, 40], [460, 280], color, "extend");
(levels(&s, 590, 420), levels(&s, 600, 420))
};
let (light, dark) = row(0);
assert_eq!((light, dark), ([200, 200, 200], [60, 60, 60]), "color 0 keeps the checker");
assert_eq!(row(5), ([200, 200, 200], [60, 60, 60]), "color 5 leaves the middle");
let (light, dark) = row(10);
let (light, dark) = ramp_row(10);
// Measured about +43 (242 / 104); the ring mean predicts about +46. Either is a real shift.
assert!((230..=252).contains(&light[0]), "color 10 light cell: {light:?}");
assert!((90..=112).contains(&dark[0]), "color 10 dark cell: {dark:?}");
assert_eq!(light, [light[0]; 3]);
assert_eq!(dark, [dark[0]; 3]);
}
#[test]
fn a_brightness_change_dropped_straight_down_darkens_the_middle() {
// Same lighting, dropped straight down: the middle darkens (about −63; dark cells clip).
let mut s = ramp_doc();
select_and_move(&mut s, [120, 120, 40, 40], [0, 280], 10, "move");
let (light, dark) = (levels(&s, 130, 420), levels(&s, 140, 420));
let (light, dark) = ramp_moved([0, 280], 10, "move", [130, 140]);
assert!(light[0] >= 120 && light[0] <= 155, "same lighting light cell: {light:?}");
assert!(dark[0] <= 12, "same lighting dark cell clips near 0: {dark:?}");
assert_eq!(light, [light[0]; 3]);
assert_eq!(dark, [dark[0]; 3]);
}
// Move and Extend land the content with the same code (`run_move` step 1); Move only adds the
// fill of the old place, away from the landing. So Colors 0 and 3 run once (Extend, one fill
// instead of two), and Color 10 runs in both modes, whose landings are compared pixel by pixel.
fn flat_moved(color: u64, mode: &str) -> Session {
let mut s = flat_doc();
select_and_move(&mut s, [150, 250, 100, 100], [400, 0], color, mode);
s
}
#[test]
fn a_flat_patch_keeps_its_level_at_color_zero() {
assert_eq!(levels(&flat_moved(0, "extend"), 600, 300), [204, 204, 204], "color 0 keeps 204");
}
#[test]
fn a_flat_patch_keeps_its_level_at_color_three() {
assert_eq!(levels(&flat_moved(3, "extend"), 600, 300), [204, 204, 204], "color 3 leaves the middle");
}
#[test]
fn a_flat_patch_matches_the_new_surroundings_at_color_ten() {
let moved_with = |color: u64, mode: &str| {
let mut s = flat_doc();
select_and_move(&mut s, [150, 250, 100, 100], [400, 0], color, mode);
s
};
// Move and Extend land the content with the same code (`run_move` step 1); Move only adds
// the fill of the old place, away from the landing. So Colors 0 and 3 run once (Extend, one
// fill instead of two), and Color 10 runs in both modes, whose landings are compared pixel
// by pixel below.
assert_eq!(levels(&moved_with(0, "extend"), 600, 300), [204, 204, 204], "color 0 keeps 204");
assert_eq!(levels(&moved_with(3, "extend"), 600, 300), [204, 204, 204], "color 3 leaves the middle");
let moved = moved_with(10, "move");
let extended = moved_with(10, "extend");
let moved = flat_moved(10, "move");
let extended = flat_moved(10, "extend");
for (mode, s) in [("move", &moved), ("extend", &extended)] {
assert_eq!(levels(s, 600, 300), [51, 51, 51], "{mode} color 10 becomes 51");
}