From e92f4e52ded54f3a36964137f71b40dbb8ec5ec9 Mon Sep 17 00:00:00 2001 From: Terra854 Date: Mon, 23 Nov 2026 05:29:25 +0800 Subject: [PATCH] pipeline: share HDR preview histogram binning (#4644) --- crates/pipeline/src/lib.rs | 10 +++++++++- crates/pipeline/src/tests_hdr.rs | 4 ++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/crates/pipeline/src/lib.rs b/crates/pipeline/src/lib.rs index 92f4634fd7..e3b4b67191 100644 --- a/crates/pipeline/src/lib.rs +++ b/crates/pipeline/src/lib.rs @@ -692,7 +692,15 @@ pub fn hdr_histogram(src: &Rgb32f, info: &SourceInfo, s: &DevelopSettings, req: }; let deep = render(src, info, s, &hreq).deep?; let DeepSamples::F32(v) = &deep.samples else { return None }; - Some(Histogram::of_hdr(v.as_chunks::<3>().0, lightcraft_develop::Hdr::MAX_EV_LIMIT as f32)) + let shared = craft_develop::raster::Histogram::of_hdr(v.as_chunks::<3>().0, lightcraft_develop::Hdr::MAX_EV_LIMIT as f32); + Some(Histogram { + r: shared.r, + g: shared.g, + b: shared.b, + luma: shared.luma, + total: shared.total, + hdr: shared.hdr.map(|bins| lightcraft_raster::HdrBins { from: bins.from, stops: bins.stops }), + }) } /// Render `src` with settings `s`. diff --git a/crates/pipeline/src/tests_hdr.rs b/crates/pipeline/src/tests_hdr.rs index 68c319b681..9922b12f28 100644 --- a/crates/pipeline/src/tests_hdr.rs +++ b/crates/pipeline/src/tests_hdr.rs @@ -150,10 +150,14 @@ fn hdr_histogram_shows_the_range_above_sdr_white_on_a_fixed_scale() { RenderRequest { depth: OutputDepth::U16, ..req }, RenderRequest { window: Some(crate::PixelWindow { x: 0, y: 0, w: 8, h: 8 }), ..req }, RenderRequest { proof: Some(crate::Proof::default()), ..req }, + RenderRequest { quality: crate::Quality::Draft, ..req }, ] { assert!(crate::hdr_histogram(&src, &raw(), &s, &other).is_none()); } let h = crate::hdr_histogram(&src, &raw(), &s, &req).expect("an HDR edit's histogram"); + let samples = deep(&src, &s, OutputDepth::F32Hdr); + let legacy = lightcraft_raster::Histogram::of_hdr(samples.as_chunks::<3>().0, lightcraft_develop::Hdr::MAX_EV_LIMIT as f32); + assert_eq!(h, legacy); let bins = h.hdr.expect("HDR bins"); assert_eq!(bins.stops, lightcraft_develop::Hdr::MAX_EV_LIMIT as f32, "the whole HDR range"); assert!(h.above_sdr() > 0.0, "highlights above SDR white: {}", h.above_sdr());