LR-EDIT-CURVE: show the selected Tone Curve's sampled input histogram (#987) (#2531)

* LR-EDIT-CURVE: show sampled Tone Curve input (#987)

Keep the output Histogram separate. Sample each selected curve's input
with the production prefix LUT builder and strict request identity.
Preserve current main's source facts, mask behavior and render output.

Credit @zelefogs for the request and @aiongg for the input/output
clarification. Human contributor credit remains @AlexChambers.

Co-Authored-By: GPT-6-Astra <[email protected]>

* LR-EDIT-CURVE: refresh curve input source after relink (#987)

Rebuild the prepared diagnostic job when its origin changes, even if
the content hash and render key stay the same. Retain completed
histograms for identical content.

Add a real-file regression through import, relink, the prepared-job
caller flow and the native worker. Check the actual retry path,
source facts and successful recovery.

Co-Authored-By: GPT-6-Astra <[email protected]>

* LR-EDIT-CURVE: bound histogram UI test work (#987)

Use two small generated PNGs for the input-histogram tests. Keep the
production decoder, render queue and pipeline, and retain the 20-second
settle budget. The full demo library adds unrelated thumbnail and
neighbor work when the failure gate opens.

Assert that stale cached histograms stay hidden during pending and
failed replacements, and verify that clearing the selection leaves
no active photo. Keep the existing histogram stage checks.

Human contributor credit remains @AlexChambers.

Co-Authored-By: GPT-6-Astra <[email protected]>

* LR-EDIT-CURVE: adapt the histogram to main's render parameters (#987)

Carry the curve input source, edit panel and tests into the module layout and
render-parameter API on current main.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* LR-EDIT-CURVE: register the histogram label with the panel's Ui (#987)

Main's register now takes the Ui, not its Context.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* LR-EDIT-CURVE: match unknown channels to the Point input (#987)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* LR-EDIT-CURVE: refresh the parity summary after the merge

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* LR-EDIT-CURVE: fit the merge to main's three-argument file loader; histogram-only slots in one helper (#987)

Main's loaders take the camera profile as a third argument, so the curve tests' loaders take it too. Keeping the Tone Curve and HDR histograms moves into keep_histogram, which brings Renderer::collect back under the cognitive complexity limit.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* LR-EDIT-CURVE: the input diagnostic's pixels are dithered like the render's (#987)

Main's finish dithers its 8-bit output with an 8x8 Bayer pattern (#3509). The diagnostic's image used plain rounding, so it no longer matched a render with the later curves removed; it now encodes with finish's dither at the same output position. Its histogram still bins the undithered samples.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* LR-EDIT-CURVE: refresh the parity summary after the merge

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* LR-EDIT-CURVE: refresh the parity summary after the merge

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* LR-EDIT-CURVE: refresh the parity summary after the merge

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Trim duplicate Tone Curve histogram tests (#987)

* LR-EDIT-CURVE: check the brush budget before sampling a curve's input (#987)

The Tone Curve input diagnostic went straight into mask preparation in
both the native render job and the web worker, skipping
check_brush_budget. An over-budget brush then lost its later strokes and
the backdrop showed that partial sample as the curve's input.

curve_input::render now runs check_brush_budget on its own clamped,
full-crop request (at most 256 px, no window) and returns a Result, so
both callers fail the request and the UI shows "Input histogram
unavailable". Regression tests cover the pipeline, the native job, the
worker and the headless UI.

* LR-EDIT-CURVE: tell screen readers the selected channel and the input status (#987)

The Tone Curve's channel buttons now report which channel is selected
(toggled), through the same helper the segmented controls use. The input
histogram's caption is a polite live region, so screen readers read it
when it changes between loading, sampled and unavailable, and the focus
stays where it is. A new announce_live helper sets the live region; the
AccessKit adapters read a live node only when its text changes.

The headless test view keeps the last frame's AccessKit tree in test
builds, and a new test checks both behaviours through it.

---------

Co-authored-by: GPT-6-Astra <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: FredApps <[email protected]>
This commit is contained in:
authored and GitHub committed 2026-12-01 11:03:57 +01:00
1 parent 88d457db4c
commit 6f3819ab4c
23 files changed
+1220 -62

No files matched your search

+1
View File
@@ -203,6 +203,7 @@ Ranked toward beta; detail in [docs/roadmap.md](docs/roadmap.md), gaps in [docs/
| 2026-10-24 | minor | Priority 7 (lens profile database) links its tracking issue #329; headline numbers unchanged |
| 2026-10-24 | patch | Alpha rationale: tests run in CI on Linux x64 (#2667) and FreeBSD nightly, not on macOS or Windows; ranked item 8 now reads "Tests in CI on macOS and Windows, and the GPU tests in CI"; percentages and hours unchanged |
| 2026-10-22 | minor | Print: Japanese photo and postcard paper sizes (L判, 2L判, KG判, はがき, 往復はがき, 六切, 四切, 名刺) in the page setup, Print dialog and PDF output; headline numbers unchanged |
| 2026-10-22 | minor | Tone Curve input histogram (#987); headline counts and readiness estimates unchanged. See [the stage contract](docs/tone-curve-input.md). |
| 2026-10-19 | minor | Indonesian interface (`id`): every plain and formats message, plus 69 command labels, locale, menu command and tests; What's New left in English; Localization ~55% → ~64% (mean of the 12 key languages), 8 of 12 present |
| 2026-10-13 | minor | Canon CRW decoded (clean-room): 6 bodies verified pixel-exact, G5 preview; 551 models verified after merging the coverage sweep |
| 2026-10-12 | minor | Italian interface (`it`, #1192): 2,201 of 2,398 messages, locale, menu command and tests; headline numbers unchanged |
+57 -6
View File
@@ -64,6 +64,8 @@ pub struct WireJob {
/// Render only this window `[x, y, w, h]` of the output `max_w × max_h` describes (a zoomed view).
#[serde(default)]
pub window: Option<[usize; 4]>,
#[serde(default)]
pub curve_input: Option<lightcraft_engine::pipeline::curve_input::CurveInput>,
}
impl WireJob {
@@ -102,6 +104,7 @@ impl WireJob {
stages: job.stages.is_some().then(|| view.to_string()),
overlay: job.request.overlay.to_parts(),
window: job.request.window.map(|w| [w.x, w.y, w.w, w.h]),
curve_input: job.curve_input,
}
}
@@ -211,6 +214,11 @@ impl WorkerCore {
None => src,
};
let info = src.info_or(job.info());
if let Some(input) = job.curve_input {
let stages = job.stages.as_ref().map(|view| self.stages.entry(view.clone()).or_default().clone());
// (checks the brush budget at the diagnostic's own size, so an over-budget mask fails as below)
return lightcraft_engine::pipeline::curve_input::render(&src.image, &info, &job.settings, &job.request(), stages.as_deref(), input);
}
// an over-budget brush mask is an error for the caller, not a preview missing its later strokes
lightcraft_engine::pipeline::check_brush_budget(&src.image, &info, &job.settings, &job.request())?;
let mut rendered = match &job.stages {
@@ -391,6 +399,28 @@ mod tests {
use super::*;
use lightcraft_engine::Session;
#[test]
fn curve_input_survives_the_worker_boundary_and_is_not_replaced_by_hdr_output() {
use lightcraft_engine::pipeline::curve_input::CurveInput;
let mut s = Session::with_demo();
let id = s.active().unwrap();
s.execute("develop.curve", &serde_json::json!({"channel":"master", "points":[[0,0],[0.25,0.7],[1,1]]})).unwrap();
s.execute("develop.hdr", &serde_json::json!({"enabled":true})).unwrap();
let job = s.thumb_job(id, 128).unwrap().with_curve_input(CurveInput::Master);
let wire = WireJob::from_job(&job, false, "CurveHistogram");
let wire: WireJob = serde_json::from_str(&serde_json::to_string(&wire).unwrap()).unwrap();
assert_eq!(wire.curve_input, Some(CurveInput::Master));
assert!(wire.thumb.is_none());
let native = job.run().rendered.unwrap();
let remote = WorkerCore::default().render(&wire, None).unwrap();
assert_eq!(native.histogram, remote.histogram);
assert_eq!(native.image, remote.image);
assert!(remote.histogram.hdr.is_none(), "the backdrop's axes stay 0..1 for the preview rendition");
let mut old = serde_json::to_value(&wire).unwrap();
old.as_object_mut().unwrap().remove("curve_input");
assert!(serde_json::from_value::<WireJob>(old).unwrap().curve_input.is_none());
}
// Issue #229: a failed worker attempt must not shift the positions of the workers after it
#[test]
fn a_failed_worker_attempt_leaves_no_gap_in_the_slots() {
@@ -445,17 +475,37 @@ mod tests {
assert!(max.is_some_and(|m| m <= 3), "max channel difference {max:?}");
}
// an over-budget brush mask is an error for the caller, as on native
#[test]
fn an_over_budget_brush_mask_fails_the_render() {
/// Give `wire` a visible brush mask past its dab budget: ten far-flung strokes.
fn add_over_budget_brush(wire: &mut WireJob) {
use lightcraft_engine::develop::{BrushStroke, Mask, MaskComponent, MaskShape};
let mut s = Session::with_demo();
let id = s.visible_cloned()[0];
let mut wire = WireJob::from_job(&s.thumb_job(id, 128).unwrap(), false, "Thumb");
let points = serde_json::from_value(serde_json::json!([{"x": -4000.0, "y": 0.5}, {"x": 4000.0, "y": 0.5}])).unwrap();
let far = BrushStroke { points, size: 0.05, ..Default::default() };
let component = MaskComponent { name: None, op: Default::default(), invert: false, shape: MaskShape::Brush { strokes: vec![far; 10] } };
Arc::make_mut(&mut wire.settings).masks.push(Mask { visible: true, components: vec![component], ..Default::default() });
}
// an over-budget brush mask is an error for the caller, as on native
#[test]
fn an_over_budget_brush_mask_fails_the_render() {
let mut s = Session::with_demo();
let id = s.visible_cloned()[0];
let mut wire = WireJob::from_job(&s.thumb_job(id, 128).unwrap(), false, "Thumb");
add_over_budget_brush(&mut wire);
let err = WorkerCore::default().render(&wire, None).err().unwrap_or_default();
assert!(err.contains("dabs"), "{err}");
}
// Review of #987: the Tone Curve's input sample fails too, at its own 256 px size, rather than
// sampling a mask that is missing its later strokes
#[test]
fn an_over_budget_brush_mask_fails_the_curve_input_render() {
use lightcraft_engine::pipeline::curve_input::{CurveInput, EDGE};
let mut s = Session::with_demo();
let id = s.visible_cloned()[0];
let job = s.thumb_job(id, EDGE).unwrap().with_curve_input(CurveInput::Master);
let mut wire = WireJob::from_job(&job, false, "CurveHistogram");
assert_eq!(wire.curve_input, Some(CurveInput::Master));
add_over_budget_brush(&mut wire);
let err = WorkerCore::default().render(&wire, None).err().unwrap_or_default();
assert!(err.contains("dabs"), "{err}");
}
@@ -525,6 +575,7 @@ mod tests {
stages: Some("Main".into()),
overlay: (0, 0.0),
window: None,
curve_input: None,
};
let mut core = WorkerCore::default();
assert_eq!(core.needs_original(&job).as_deref(), Some(hash.as_str()));
+1
View File
@@ -659,6 +659,7 @@ impl Session {
preview_cut: None,
display_fit: None,
ai_defringe: None,
curve_input: None,
};
let embedded = match (&self.media.preview_loader, c.kind) {
(Some(l), MediaKind::Raw) => Some((c.path.clone(), l.clone(), edge)),
+3
View File
@@ -110,3 +110,6 @@ mod thumbnail_hash_tests;
#[cfg(test)]
mod tests;
#[cfg(test)]
mod curve_input_tests;
@@ -0,0 +1,52 @@
use super::*;
use lightcraft_pipeline::curve_input::{CurveInput, EDGE};
use serde_json::json;
#[test]
fn curve_input_jobs_never_read_or_write_photo_caches_and_key_on_preceding_edits() {
let mut s = crate::Session::with_demo();
let id = s.active().unwrap();
let normal = s.thumb_job(id, EDGE).unwrap();
let (cache, key) = normal.cache.clone().unwrap();
let sentinel = Arc::new(Rgba8::from_fn(3, 3, |_, _| [255, 0, 255, 255]));
cache.put_at(normal.cache_generation, key, sentinel.clone());
let input = normal.with_curve_input(CurveInput::Master);
let input_key = input.key;
let source_key = input.source_key;
assert!(input.cache.is_none() && input.view_cache.is_none());
assert_eq!(input.level, SourceLevel::Thumb);
assert_eq!(input.clone().with_curve_input(CurveInput::Master).key, input_key, "idempotent mode selection");
let r = input.run();
assert_eq!(r.source_key, source_key);
assert!(r.gpu_fallback.is_none(), "diagnostics use the CPU reference intentionally");
let image = &r.rendered.as_ref().unwrap().image;
assert!(image.width <= EDGE && image.height <= EDGE);
assert_ne!(image, &*sentinel, "a cached output thumbnail is never input data");
assert_eq!(&*cache.get_at(s.media.rendered.generation(), key).unwrap(), &*sentinel);
s.accept(&r);
s.execute("develop.curve", &json!({"channel":"master", "points":[[0,0],[0.25,0.7],[1,1]]})).unwrap();
let same = s.thumb_job(id, EDGE).unwrap().with_curve_input(CurveInput::Master);
assert_eq!(same.key, input_key, "moving this curve needs no extra diagnostic render");
s.execute("develop.set", &json!({"control":"curve.lights", "value":40})).unwrap();
let changed = s.thumb_job(id, EDGE).unwrap().with_curve_input(CurveInput::Master);
assert_ne!(changed.key, input_key, "the preceding parametric curve invalidates master input");
}
// Review of #987: an over-budget brush mask fails the diagnostic job, as it fails every other render
// job, instead of returning a sample of a mask that is missing its later strokes
#[test]
fn an_over_budget_brush_mask_fails_the_curve_input_job() {
use lightcraft_develop::{BrushStroke, Mask, MaskComponent, MaskShape};
use lightcraft_geom::Point;
let mut s = crate::Session::with_demo();
let id = s.active().unwrap();
// ten far-flung strokes, 640,000 dabs each at 256 px: past the mask's budget of two million
let far = BrushStroke { points: vec![Point::new(-4000.0, 0.5), Point::new(4000.0, 0.5)], size: 0.05, ..Default::default() };
let component = MaskComponent { name: None, op: Default::default(), invert: false, shape: MaskShape::Brush { strokes: vec![far; 10] } };
let mut edit = (*s.develop_of(id).unwrap()).clone();
edit.masks.push(Mask { visible: true, components: vec![component], ..Default::default() });
s.set_develop(id, edit, "brush").unwrap();
let r = s.thumb_job(id, EDGE).unwrap().with_curve_input(CurveInput::Master).run();
let err = r.rendered.err().unwrap_or_default();
assert!(err.contains("dabs"), "{err}");
}
+40
View File
@@ -48,6 +48,8 @@ pub struct RenderJob {
/// AI Defringe's correction of the source picture ([`crate::aidefringe`]), when it is on and the photo has one
/// (or, for an export, will make one).
pub ai_defringe: Option<crate::aidefringe::ForRender>,
/// A bounded diagnostic at a Tone Curve input, never a cached photo render.
pub curve_input: Option<lightcraft_pipeline::curve_input::CurveInput>,
}
/// `img` shrunk to fit `max_w × max_h` with a Lanczos filter (see [`RenderJob::display_fit`]).
@@ -100,6 +102,26 @@ pub struct RenderResult {
}
impl RenderJob {
/// Sample the selected curve's input using this job's source. Frontends start with a
/// thumbnail job to reuse the thumbnail-level source. No rendered thumbnail or view cache is read
/// or written; changing this curve or a later one retains the same diagnostic key.
pub fn with_curve_input(mut self, input: lightcraft_pipeline::curve_input::CurveInput) -> Self {
let salt = |c: lightcraft_pipeline::curve_input::CurveInput| (c as u64 + 1).wrapping_mul(0xa24b_aed4_963e_e407);
if let Some(previous) = self.curve_input {
self.key ^= previous.settings_key(&self.settings) ^ salt(previous);
} else {
self.key ^= self.settings.hash64();
}
self.key ^= input.settings_key(&self.settings) ^ salt(input);
self.curve_input = Some(input);
self.cache = None;
self.view_cache = None;
self.preview_cut = None;
self.slide = None;
self.display_fit = None;
self
}
/// Render at draft quality (interactive drags). Gets its own result key.
/// Shrink the full-quality result to fit `w × h` pixels with a Lanczos filter (see
/// [`Self::display_fit`]). Gets its own result key, so a change of drawn size renders again.
@@ -366,6 +388,24 @@ impl RenderJob {
};
let src = corrected.as_ref().unwrap_or(src);
let info = source.info_or(self.info);
if let Some(input) = self.curve_input {
// (an over-budget brush mask fails here, as below, rather than sampling a mask missing its later strokes)
let rendered = lightcraft_pipeline::curve_input::render(src, &info, &self.settings, &self.request, self.stages.as_deref(), input);
return RenderResult {
request_id: self.request_id,
source_key: self.source_key,
photo: self.photo,
level: self.level,
key: self.key,
rendered,
gpu_fallback: None,
loaded: (!was_loaded).then_some(source),
quick: None,
display: self.display.as_ref().map(|d| d.id()),
frame: None,
slide_photo: None,
};
}
// Views and exports use the GPU when there is one (waiting for the device if it is
// still being created). Thumbnails (grid, filmstrip, preset and profile previews)
// use it once it is ready - ~20-30 % faster than the CPU at 256 px with six jobs
+3
View File
@@ -119,6 +119,7 @@ impl crate::Session {
preview_cut: None,
display_fit: None,
ai_defringe,
curve_input: None,
})
}
@@ -228,6 +229,7 @@ impl crate::Session {
preview_cut: None,
display_fit: None,
ai_defringe,
curve_input: None,
})
}
@@ -291,6 +293,7 @@ impl crate::Session {
preview_cut,
display_fit: None,
ai_defringe,
curve_input: None,
})
}
+31
View File
@@ -198,6 +198,37 @@ fn check_warned(name: &str, src: &Arc<Rgb32f>, info: &SourceInfo, s: &DevelopSet
type Edit = fn(&mut DevelopSettings);
#[test]
fn curve_input_matches_the_gpu_prefix_and_keeps_later_operations_out() {
use lightcraft_pipeline::curve_input::{self, CurveInput};
if !gpu() {
return;
}
let src = Arc::new(Rgb32f::from_fn(128, 64, |x, y| {
let v = 0.01 + x as f32 / 500.0;
[v, v * (0.25 + y as f32 / 100.0), v * 0.4]
}));
let mut s = DevelopSettings::default();
s.light.exposure = 0.5;
s.curve.shadows = 45.0;
s.curve.master = vec![Point::new(0.0, 0.04), Point::new(0.25, 0.65), Point::new(1.0, 0.95)];
s.curve.red = s.curve.master.clone();
s.curve.refine_saturation = 25.0;
s.grain.amount = 60.0;
let info = SourceInfo::default();
let req = RenderRequest::fit(128, 64);
for ch in [CurveInput::Parametric, CurveInput::Master, CurveInput::Red, CurveInput::Green, CurveInput::Blue] {
let input = curve_input::render(&src, &info, &s, &req, None, ch).unwrap();
let mut previous = s.clone();
previous.curve = ch.predecessors(&s.curve);
previous.grain = Default::default();
let reference = lightcraft_gpu::render(&src, &info, &previous, &req, None).expect("GPU prefix");
let (mean, max, _) = diff(&input.image, &reference.image);
eprintln!("curve input {ch:?}: mean {mean:.4}, max {max} LSB");
assert!(mean < MEAN_LSB && max <= MAX_LSB, "{ch:?}: mean {mean}, max {max}");
}
}
fn typical(s: &mut DevelopSettings) {
s.light.exposure = 0.3;
s.light.highlights = -40.0;
+142
View File
@@ -0,0 +1,142 @@
//! Diagnostic samples at the selected Tone Curve's input, in the preview's encoded domain.
//!
//! The normal renderer is unchanged. A small, separate render shares its spatial stages and
//! per-pixel code, stopping before the selected curve and everything that follows it.
use lightcraft_develop::{DevelopSettings, ToneCurve};
use lightcraft_raster::{Histogram, Rgb32f, Rgba8};
use serde::{Deserialize, Serialize};
use std::sync::Arc;
use crate::finish::{FinishParams, FinishParamsInput};
use crate::{RenderRequest, Rendered, SourceInfo, StageCache};
/// Maximum long edge of the diagnostic render. The UI starts from a thumbnail-level source.
pub const EDGE: usize = 256;
/// The curve whose input is sampled. RGB curves are independent and share the same predecessor.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum CurveInput {
Parametric,
Master,
Red,
Green,
Blue,
}
impl CurveInput {
/// Only curves before this one, in the renderer's order: parametric, master, RGB.
/// Call after profile expansion when evaluating pixels: a profile can contribute to curves.
pub fn predecessors(self, curve: &ToneCurve) -> ToneCurve {
if self == Self::Parametric {
return ToneCurve::default();
}
let mut c = curve.clone();
if self == Self::Master {
c.master.clear();
}
c.red.clear();
c.green.clear();
c.blue.clear();
c.refine_saturation = 100.0;
c
}
/// Settings identity for this diagnostic. The selected curve, its successors, Refine
/// Saturation and grain cannot affect its input. Retain the profile: its upstream look can.
pub fn settings_key(self, settings: &DevelopSettings) -> u64 {
let mut s = settings.clone();
s.curve = self.predecessors(&s.curve);
s.grain = Default::default();
s.hash64()
}
}
/// Sample the whole cropped frame, at most [`EDGE`] pixels per edge. A zoom window is deliberately
/// ignored: panning does not change the photo's tonal distribution. Uses the request's rendition
/// and output primaries (including display/proof transforms), with no diagnostic overlays.
///
/// The image is a diagnostic view of the encoded input; its histogram is binned from floats,
/// before quantization. For Master/Parametric, `luma` is an encoded luminance summary (the actual
/// curves act on each RGB component). Values outside 0..1 and nonfinite values are not plotted.
/// An 8-bit preview request of an HDR edit uses its SDR rendition, like the main preview.
///
/// Fails when a visible brush mask is over its dab budget at this diagnostic's own size and crop
/// ([`crate::check_brush_budget`]): mask preparation would drop the later strokes, and the caller
/// would show a sample of the wrong mask as the curve's input.
pub fn render(
src: &Arc<Rgb32f>,
info: &SourceInfo,
settings: &DevelopSettings,
request: &RenderRequest,
cache: Option<&StageCache>,
input: CurveInput,
) -> Result<Rendered, String> {
let request = RenderRequest {
max_w: request.max_w.clamp(1, EDGE),
max_h: request.max_h.clamp(1, EDGE),
window: None,
overlay: crate::Overlay::None,
..*request
};
crate::check_brush_budget(src, info, settings, &request)?;
Ok(crate::render_impl(crate::Src::Shared(src), info, settings, &request, cache, Some(input)))
}
pub(crate) fn finish(
p: &crate::Prepared,
settings: &DevelopSettings,
frame: &crate::geometry::Frame,
info: &SourceInfo,
request: &RenderRequest,
input: CurveInput,
) -> Rendered {
let (w, h) = (p.img.width, p.img.height);
let mut fp = FinishParams::new(FinishParamsInput {
settings,
frame,
info,
image_size: (w, h),
px_per_long: p.px_per_long,
air_pre: p.air,
space: request.space,
draft: request.quality == crate::Quality::Draft,
});
fp.proof = request.proof.map(|proof| proof.params(request.space));
if let Some(display) = &request.display {
fp.for_display(display, request.proof);
}
fp.curves = crate::finish::curve_luts(&input.predecessors(&settings.curve));
fp.refine_sat = 1.0;
// the samples, and the 8-bit pixels as `finish` dithers them at the same place in the output
let samples = crate::finish::finish_with(p, &fp, false, true, |x, y, e| {
let d = crate::finish::bayer_dither_offset(x, y);
(e, [crate::finish::enc(e[0], d), crate::finish::enc(e[1], d), crate::finish::enc(e[2], d), 255])
});
let (samples, data): (Vec<[f32; 3]>, Vec<[u8; 4]>) = samples.into_iter().unzip();
let histogram = of_encoded(&samples, fp.out_luma);
let image = Rgba8 { width: w, height: h, data };
Rendered { image, histogram, deep: None }
}
fn of_encoded(samples: &[[f32; 3]], weights: [f32; 3]) -> Histogram {
let mut h = Histogram { r: vec![0; 256], g: vec![0; 256], b: vec![0; 256], luma: vec![0; 256], total: 0, hdr: None };
for &[r, g, b] in samples.iter().take(EDGE * EDGE) {
let y = r * weights[0] + g * weights[1] + b * weights[2];
for (bins, value) in [(&mut h.r, r), (&mut h.g, g), (&mut h.b, b), (&mut h.luma, y)] {
if value.is_finite()
&& (0.0..=1.0).contains(&value)
&& let Some(count) = bins.get_mut((value * 255.0 + 0.5) as usize)
{
*count += 1;
}
}
h.total += 1;
}
h
}
#[cfg(test)]
#[path = "curve_input_tests.rs"]
mod tests;
+222
View File
@@ -0,0 +1,222 @@
use super::*;
use crate::{OutputDepth, OutputSpace, PixelWindow, Proof};
use lightcraft_geom::Point;
fn source() -> Arc<Rgb32f> {
Arc::new(Rgb32f::from_fn(128, 32, |x, y| {
let v = 0.01 + x as f32 / 500.0;
[v, v * (0.3 + y as f32 / 50.0), v * 0.4]
}))
}
fn bent() -> Vec<Point> {
vec![Point::new(0.0, 0.04), Point::new(0.25, 0.65), Point::new(1.0, 0.95)]
}
fn sample(s: &DevelopSettings, ch: CurveInput) -> Rendered {
render(&source(), &SourceInfo::default(), s, &RenderRequest::fit(128, 32), None, ch).unwrap()
}
#[test]
fn input_follows_exposure_but_not_its_own_curve_or_later_curves() {
let base = DevelopSettings::default();
for ch in [CurveInput::Parametric, CurveInput::Master, CurveInput::Red, CurveInput::Green, CurveInput::Blue] {
let mut s = base.clone();
if ch != CurveInput::Parametric {
s.curve.lights = 45.0;
}
if !matches!(ch, CurveInput::Parametric | CurveInput::Master) {
s.curve.master = bent();
}
let before = sample(&s, ch).histogram;
let key = ch.settings_key(&s);
if ch == CurveInput::Parametric {
s.curve.shadows = 65.0;
s.curve.split_mid = 60.0;
}
if matches!(ch, CurveInput::Parametric | CurveInput::Master) {
s.curve.master = bent();
}
s.curve.red = bent();
s.curve.green = bent();
s.curve.blue = bent();
s.curve.refine_saturation = 0.0;
s.grain.amount = 90.0;
assert_eq!(sample(&s, ch).histogram, before, "own and later curves: {ch:?}");
assert_eq!(ch.settings_key(&s), key, "do not rerender for this curve's drag: {ch:?}");
s.light.exposure = 1.0;
assert_ne!(sample(&s, ch).histogram, before, "upstream exposure: {ch:?}");
assert_ne!(ch.settings_key(&s), key);
}
let mut changed = base.clone();
changed.curve.master = bent();
let req = RenderRequest::fit(128, 32);
let a = crate::render(&source(), &SourceInfo::default(), &base, &req);
let b = crate::render(&source(), &SourceInfo::default(), &changed, &req);
assert_ne!(a.histogram, b.histogram, "the separate output histogram must follow the curve");
assert_ne!(a.image, b.image);
}
#[test]
fn each_curve_sees_exactly_its_predecessors_including_profile_contributions() {
let mut s = DevelopSettings::default();
s.profile.id = "lc.film.golden-hour".into();
s.curve.shadows = 45.0;
s.curve.master = bent();
s.curve.red = vec![Point::new(0.0, 0.0), Point::new(0.6, 0.2), Point::new(1.0, 1.0)];
s.curve.green = bent();
s.curve.blue = bent();
let req = RenderRequest::fit(128, 32);
let mut images = Vec::new();
for ch in [CurveInput::Parametric, CurveInput::Master, CurveInput::Red, CurveInput::Green, CurveInput::Blue] {
let input = sample(&s, ch);
// In this fixture, remove every operation after the desired boundary explicitly.
// Expanding the profile first preserves its upstream tone/colour and preceding curves.
let mut previous = crate::profiles::effective(&s).into_owned();
previous.profile.id = "lc.color".into();
previous.curve = ch.predecessors(&previous.curve);
let reference = crate::render(&source(), &SourceInfo::default(), &previous, &req);
assert_eq!(input.image, reference.image, "boundary {ch:?}");
images.push(input.image);
}
assert_ne!(images[0], images[1], "parametric contributes before master");
assert_ne!(images[1], images[2], "master contributes before RGB");
assert_eq!(images[2], images[3], "the RGB curves have a common predecessor");
assert_eq!(images[3], images[4]);
assert_ne!(sample(&s, CurveInput::Red).histogram.r, sample(&s, CurveInput::Red).histogram.b);
}
#[test]
fn grain_lut_and_proof_warning_colours_are_after_the_sample() {
let s = DevelopSettings::default();
let before = sample(&s, CurveInput::Master);
let mut changed = s.clone();
changed.grain.amount = 100.0;
changed.profile.id = "lut:curve-input-regression".into();
crate::lut::register(
&changed.profile.id,
crate::lut::Lut3d { size: 2, data: vec![[0.9, 0.1, 0.8]; 8], domain_min: [0.0; 3], domain_max: [1.0; 3], title: None },
);
let after = sample(&changed, CurveInput::Master);
let output = crate::render(&source(), &SourceInfo::default(), &changed, &RenderRequest::fit(128, 32));
crate::lut::unregister(&changed.profile.id);
assert_eq!(before.histogram, after.histogram);
assert_ne!(output.image, after.image);
let mut req = RenderRequest::fit(128, 32);
req.proof = Some(Proof { space: OutputSpace::Srgb, dest_warning: true, display_warning: true, ..Default::default() });
let warning = render(&source(), &SourceInfo::default(), &s, &req, None, CurveInput::Master).unwrap();
req.proof.as_mut().unwrap().dest_warning = false;
req.proof.as_mut().unwrap().display_warning = false;
assert_eq!(warning.histogram, render(&source(), &SourceInfo::default(), &s, &req, None, CurveInput::Master).unwrap().histogram);
}
#[test]
fn crop_changes_the_sample_but_zoom_windows_do_not_and_sizes_are_bounded() {
let mut s = DevelopSettings::default();
let req = RenderRequest::fit(128, 32);
let whole = render(&source(), &SourceInfo::default(), &s, &req, None, CurveInput::Master).unwrap();
let window = RenderRequest { window: Some(PixelWindow { x: 32, y: 0, w: 32, h: 32 }), ..req };
assert_eq!(whole.histogram, render(&source(), &SourceInfo::default(), &s, &window, None, CurveInput::Master).unwrap().histogram);
s.crop.geometry.rect = lightcraft_geom::Rect::new(0.5, 0.0, 1.0, 1.0);
let cropped = render(&source(), &SourceInfo::default(), &s, &req, None, CurveInput::Master).unwrap();
assert_ne!(whole.histogram, cropped.histogram);
let uncropped = RenderRequest { apply_crop: false, ..req };
assert_eq!(whole.histogram, render(&source(), &SourceInfo::default(), &s, &uncropped, None, CurveInput::Master).unwrap().histogram);
let huge = RenderRequest::fit(usize::MAX, usize::MAX);
let bounded = render(&source(), &SourceInfo::default(), &s, &huge, None, CurveInput::Master).unwrap();
assert!(bounded.image.width <= EDGE && bounded.image.height <= EDGE);
assert!(bounded.histogram.total <= (EDGE * EDGE) as u32);
}
#[test]
fn hdr_preview_uses_its_sdr_rendition_and_bins_do_not_alias_headroom_to_white() {
let mut s = DevelopSettings::default();
s.hdr.enabled = true;
s.hdr.sdr_brightness = -50.0;
let preview = sample(&s, CurveInput::Master);
assert_eq!(preview.histogram, sample(&s.sdr_rendition(), CurveInput::Master).histogram);
s.hdr.sdr_brightness = 50.0;
assert_ne!(preview.histogram, sample(&s, CurveInput::Master).histogram);
let samples = [[0.0; 3], [0.5; 3], [1.0; 3], [1.01; 3], [f32::NAN; 3], [f32::INFINITY; 3], [-0.1; 3]];
let h = of_encoded(&samples, [0.25, 0.5, 0.25]);
assert_eq!(h.r.iter().sum::<u32>(), 3);
assert_eq!(h.r[0], 1);
assert_eq!(h.r[128], 1);
assert_eq!(h.r[255], 1);
assert_eq!(h.luma, h.r);
let src = Arc::new(Rgb32f::from_fn(8, 8, |_, _| [4.0; 3]));
let req = RenderRequest { depth: OutputDepth::F32Hdr, ..RenderRequest::fit(8, 8) };
let high = render(&src, &SourceInfo::default(), &s, &req, None, CurveInput::Parametric).unwrap();
assert_eq!(high.histogram.r.iter().sum::<u32>(), 0, "HDR values lie beyond the curve axes");
}
#[test]
fn diagnostic_and_normal_renders_share_spatial_cache_without_changing_pixels() {
let src = source();
let mut s = DevelopSettings::default();
s.curve.master = bent();
s.curve.lights = 60.0;
s.grain.amount = 50.0;
let info = SourceInfo::default();
let req = RenderRequest::fit(128, 32);
let cache = StageCache::default();
let before = crate::render_cached(&src, &info, &s, &req, &cache);
let a = render(&src, &info, &s, &req, Some(&cache), CurveInput::Red).unwrap();
let b = render(&src, &info, &s, &req, None, CurveInput::Red).unwrap();
let after = crate::render_cached(&src, &info, &s, &req, &cache);
assert_eq!(a.histogram, b.histogram);
assert_eq!(before.image, after.image);
assert_eq!(before.histogram, after.histogram);
}
#[test]
fn input_uses_the_display_primaries_and_effective_edit() {
let src = source();
let info = SourceInfo::default();
let mut s = DevelopSettings::default();
s.light.exposure = 1.0;
s.curve.lights = 55.0;
s.curve.master = bent();
s.set_section_enabled("light", false);
let req = RenderRequest::fit(128, 32);
let disabled = render(&src, &info, &s, &req, None, CurveInput::Red).unwrap();
let mut effective = s.effective().into_owned();
effective.curve = CurveInput::Red.predecessors(&effective.curve);
assert_eq!(disabled.image, crate::render(&src, &info, &effective, &req).image);
let mut previous = DevelopSettings::default();
previous.curve.lights = 45.0;
let srgb = render(&src, &info, &previous, &req, None, CurveInput::Red).unwrap();
for space in [OutputSpace::DisplayP3, OutputSpace::Rec2020] {
let display = RenderRequest { display: crate::DisplaySpace::of(space, 7), ..req };
let input = render(&src, &info, &previous, &display, None, CurveInput::Red).unwrap();
let normal = crate::render(&src, &info, &previous, &display);
assert_eq!(input.image, normal.image, "the prefix is encoded in the actual preview primaries");
assert_ne!(input.histogram, srgb.histogram);
let proof = RenderRequest { proof: Some(Proof { space: OutputSpace::Srgb, ..Default::default() }), ..display };
let proof_input = render(&src, &info, &previous, &proof, None, CurveInput::Red).unwrap();
assert_eq!(proof_input.image, crate::render(&src, &info, &previous, &proof).image);
}
}
/// A visible brush mask of `strokes`.
fn brush(strokes: Vec<lightcraft_develop::BrushStroke>) -> lightcraft_develop::Mask {
use lightcraft_develop::{Mask, MaskComponent, MaskShape};
let component = MaskComponent { name: None, op: Default::default(), invert: false, shape: MaskShape::Brush { strokes } };
Mask { visible: true, components: vec![component], ..Default::default() }
}
// Review of #987: mask preparation drops the strokes past the budget, so a sample of an over-budget
// brush is not this edit's input. It fails, like the normal preview, at the diagnostic's own size.
#[test]
fn an_over_budget_brush_mask_fails_the_sample_instead_of_dropping_strokes() {
use lightcraft_develop::BrushStroke;
let stroke = |x0: f64, x1: f64| BrushStroke { points: vec![Point::new(x0, 0.5), Point::new(x1, 0.5)], size: 0.05, ..Default::default() };
let full_size = RenderRequest::fit(4096, 4096);
// ten far-flung strokes, 640,000 dabs each at the sample's 256 px: past the mask's budget of two million
let mut s = DevelopSettings::default();
s.masks.push(brush(vec![stroke(-4000.0, 4000.0); 10]));
let err = render(&source(), &SourceInfo::default(), &s, &full_size, None, CurveInput::Master).err().unwrap_or_default();
assert!(err.contains("dabs"), "{err}");
// a brush within its budget still samples
let mut s = DevelopSettings::default();
s.masks.push(brush(vec![stroke(0.2, 0.6)]));
assert!(render(&source(), &SourceInfo::default(), &s, &full_size, None, CurveInput::Master).is_ok());
}
+50 -35
View File
@@ -26,7 +26,7 @@ fn smooth(e0: f32, e1: f32, x: f32) -> f32 {
}
/// Parametric region curve (encoded domain) composed with the master point curve.
fn curve_luts(c: &ToneCurve) -> Option<[Lut1; 3]> {
pub(crate) fn curve_luts(c: &ToneCurve) -> Option<[Lut1; 3]> {
let parametric = c.highlights != 0.0 || c.lights != 0.0 || c.darks != 0.0 || c.shadows != 0.0;
let master = !ToneCurve::point_curve_is_identity(&c.master);
let chans = [&c.red, &c.green, &c.blue].map(|p| !ToneCurve::point_curve_is_identity(p));
@@ -128,6 +128,41 @@ fn crystal_row(fp: &FinishParams, y: usize, w: usize) -> Vec<f32> {
out
}
/// Film grain on display-encoded colour `e` at output pixel `(x, y)`, the model of the photo's
/// process ([`GrainModel`]). `crystal_row`: that row's crystal grain ([`crystal_row`]; empty: the
/// pixel takes it alone).
#[inline]
fn add_grain(fp: &FinishParams, crystal_row: &[f32], x: usize, y: usize, mut e: [f32; 3], hdr: bool) -> [f32; 3] {
let (out_to_norm, long) = (fp.out_to_norm, fp.ow.max(fp.oh));
match &fp.grain {
Some(GrainModel::Value(g)) => {
// V1/V2 (frozen): exactly the arithmetic those processes always had
let n = out_to_norm.apply(Point::new(x as f64 + 0.5, y as f64 + 0.5));
let (gx, gy) = ((n.x * fp.ow) as f32 / long as f32, (n.y * fp.oh) as f32 / long as f32);
let sc = fp.px_per_long as f32 / g.cell;
let mut v = grain_noise(gx * sc, gy * sc, g.seed);
v = v * (1.0 - g.rough * 0.5) + grain_noise(gx * sc * 2.3, gy * sc * 2.3, g.seed ^ 0x55) * g.rough * 0.7;
let mut lum = 0.2126 * e[0] + 0.7152 * e[1] + 0.0722 * e[2];
if hdr {
lum = lum.clamp(0.0, 1.0);
}
let k = g.amt * v * (0.35 + 2.6 * lum * (1.0 - lum));
if k.is_finite() {
e = e.map(|v| v + k);
}
}
Some(GrainModel::Crystal(g)) => match crystal_row.get(x) {
Some(&f) => e = g.apply_field(e, f),
None => {
let n = out_to_norm.apply(Point::new(x as f64 + 0.5, y as f64 + 0.5));
e = g.apply(e, (n.x * fp.ow / long) as f32, (n.y * fp.oh / long) as f32);
}
},
None => {}
}
e
}
/// Number of per-mask terms in [`mask_terms`].
pub const MASK_TERMS: usize = 21;
@@ -413,7 +448,7 @@ pub(crate) fn finish(p: &Prepared, s: &DevelopSettings, frame: &Frame, info: &So
fp.for_display(d, proof);
}
let trc = fp.out_trc;
let data = finish_with(p, &fp, false, |x, y, e| {
let data = finish_with(p, &fp, false, false, |x, y, e| {
let d = bayer_dither_offset(x, y);
match trc {
OutputTrc::Srgb => [enc(e[0], d), enc(e[1], d), enc(e[2], d), 255],
@@ -446,18 +481,18 @@ pub(crate) fn finish_deep(p: &Prepared, s: &DevelopSettings, frame: &Frame, info
let trc = fp.out_trc;
let samples = match depth {
OutputDepth::F32Linear => {
let v = finish_with(p, &fp, true, |_x, _y, e| e.map(|v| srgb_to_linear(v.clamp(0.0, 1.0))));
let v = finish_with(p, &fp, true, false, |_x, _y, e| e.map(|v| srgb_to_linear(v.clamp(0.0, 1.0))));
DeepSamples::F32(v.into_flattened())
}
OutputDepth::F32Hdr => {
// the sRGB curve extended past 1 (it is unbounded), so values up to `peak` survive
let peak = fp.peak;
let v = finish_with(p, &fp, true, |_x, _y, e| e.map(|v| srgb_to_linear(v.max(0.0)).clamp(0.0, peak)));
let v = finish_with(p, &fp, true, false, |_x, _y, e| e.map(|v| srgb_to_linear(v.max(0.0)).clamp(0.0, peak)));
DeepSamples::F32(v.into_flattened())
}
_ => {
let q = |v: f32| (v.clamp(0.0, 1.0) * 65535.0 + 0.5) as u16;
let v = finish_with(p, &fp, true, |_x, _y, e| match trc {
let v = finish_with(p, &fp, true, false, |_x, _y, e| match trc {
OutputTrc::Srgb => e.map(q),
t => e.map(|v| q(t.encode(srgb_to_linear(v.clamp(0.0, 1.0))))),
});
@@ -474,14 +509,13 @@ pub(crate) fn finish_with<T: Copy + Default + Send>(
p: &Prepared,
fp: &FinishParams,
exact: bool,
stop_after_curves: bool,
store: impl Fn(usize, usize, [f32; 3]) -> T + Sync + Send,
) -> Vec<T> {
let (w, h) = (p.img.width, p.img.height);
let p_lut = fp.lut.clone();
let FinishParams { light, curves, vig, to_out, out_luma, grain, .. } = fp;
let FinishParams { light, curves, vig, to_out, out_luma, .. } = fp;
let terms: Vec<[f32; MASK_TERMS]> = p.masks.iter().map(|m| mask_terms(&m.adjust)).collect();
let out_to_norm = fp.out_to_norm;
let long = fp.ow.max(fp.oh);
let [vx, vy, vw, vh] = fp.view;
let (vx_u, vy_u) = (vx.round() as usize, vy.round() as usize);
// the vignette belongs to the whole output frame, not to the window being drawn
@@ -629,32 +663,13 @@ pub(crate) fn finish_with<T: Copy + Default + Send>(
e = refine_saturation(e0, e, fp.refine_sat);
}
}
match grain {
Some(GrainModel::Value(g)) => {
// V1/V2 (frozen): exactly the arithmetic those processes always had
let n = out_to_norm.apply(Point::new(x as f64 + 0.5, y as f64 + 0.5));
let (gx, gy) = ((n.x * fp.ow) as f32 / long as f32, (n.y * fp.oh) as f32 / long as f32);
let sc = fp.px_per_long as f32 / g.cell;
let mut v = grain_noise(gx * sc, gy * sc, g.seed);
v = v * (1.0 - g.rough * 0.5) + grain_noise(gx * sc * 2.3, gy * sc * 2.3, g.seed ^ 0x55) * g.rough * 0.7;
let mut lum = 0.2126 * e[0] + 0.7152 * e[1] + 0.0722 * e[2];
if hdr {
lum = lum.clamp(0.0, 1.0);
}
let k = g.amt * v * (0.35 + 2.6 * lum * (1.0 - lum));
if k.is_finite() {
e = e.map(|v| v + k);
}
}
Some(GrainModel::Crystal(g)) => match crystal_row.get(x) {
Some(&f) => e = g.apply_field(e, f),
None => {
let n = out_to_norm.apply(Point::new(x as f64 + 0.5, y as f64 + 0.5));
e = g.apply(e, (n.x * fp.ow / long) as f32, (n.y * fp.oh / long) as f32);
}
},
None => {}
if stop_after_curves {
// A diagnostic supplies only the selected curve's predecessors. Do not include
// grain, a LUT profile, proof warning colours or final output re-encoding.
*px = store(vx_u + x, vy_u + y, e);
continue;
}
e = add_grain(fp, &crystal_row, x, y, e, hdr);
let e = match &p_lut {
Some((l, k)) if hdr => {
// the LUT sees SDR values; the part above SDR white is carried over
@@ -893,14 +908,14 @@ const BAYER_8X8: [u8; 64] = [
/// Returns the ordered Bayer 8×8 dither threshold offset in `0..1` for pixel `(x, y)`.
#[inline]
fn bayer_dither_offset(x: usize, y: usize) -> f32 {
pub(crate) fn bayer_dither_offset(x: usize, y: usize) -> f32 {
let idx = (y & 7) * 8 + (x & 7);
(BAYER_8X8[idx] as f32 + 0.5) / 64.0
}
/// Quantizes display-curve-encoded value `v` (0..1) to 8-bit integer with 8×8 ordered Bayer dithering.
#[inline]
fn enc(v: f32, dither: f32) -> u8 {
pub(crate) fn enc(v: f32, dither: f32) -> u8 {
let y = v.clamp(0.0, 1.0) * 255.0;
// Guard against floating point rounding error (e.g. sRGB <-> Rec.2020 matrix conversion)
// where numerical white (1.0) evaluates to ~254.95.
+14 -3
View File
@@ -30,6 +30,7 @@ pub mod colorops;
pub mod crystal;
pub mod cull;
pub mod curve;
pub mod curve_input;
pub mod dust;
pub mod finish;
pub mod geometry;
@@ -748,13 +749,13 @@ pub fn hdr_histogram(src: &Rgb32f, info: &SourceInfo, s: &DevelopSettings, req:
/// Render `src` with settings `s`.
pub fn render(src: &Rgb32f, info: &SourceInfo, s: &DevelopSettings, req: &RenderRequest) -> Rendered {
render_impl(Src::Borrowed(src), info, s, req, None)
render_impl(Src::Borrowed(src), info, s, req, None, None)
}
/// [`render`], reusing (and refreshing) the intermediate results in `cache`. The output is
/// identical to [`render`]'s.
pub fn render_cached(src: &Arc<Rgb32f>, info: &SourceInfo, s: &DevelopSettings, req: &RenderRequest, cache: &StageCache) -> Rendered {
render_impl(Src::Shared(src), info, s, req, Some(cache))
render_impl(Src::Shared(src), info, s, req, Some(cache), None)
}
enum Src<'a> {
@@ -762,7 +763,14 @@ enum Src<'a> {
Shared(&'a Arc<Rgb32f>),
}
fn render_impl(src: Src<'_>, info: &SourceInfo, s: &DevelopSettings, req: &RenderRequest, cache: Option<&StageCache>) -> Rendered {
fn render_impl(
src: Src<'_>,
info: &SourceInfo,
s: &DevelopSettings,
req: &RenderRequest,
cache: Option<&StageCache>,
input: Option<curve_input::CurveInput>,
) -> Rendered {
// sections switched off with their eye render as if at their defaults (issue #316)
let effective = s.effective();
let edit: &DevelopSettings = &effective;
@@ -828,6 +836,9 @@ fn render_impl(src: Src<'_>, info: &SourceInfo, s: &DevelopSettings, req: &Rende
if let Some((a, c)) = shared {
c.put(CacheEntry { src: a.clone(), geo, sampled, lin: Some((lin_key, lin)), colour_noise, planes });
}
if let Some(input) = input {
return curve_input::finish(&prep, s, frame, info, req, input);
}
if req.depth != OutputDepth::U8 {
let deep = finish::finish_deep(&prep, s, frame, info, req);
let deep = match plan.keep {
+9
View File
@@ -89,6 +89,9 @@ pub struct HeadlessView {
pub clipboard: String,
/// Events the host owes the next frame (a paste request's paste, as a desktop host sends it).
owed: Vec<egui::Event>,
/// The last frame's AccessKit tree, once a test has turned AccessKit on (`ctx.enable_accesskit()`).
#[cfg(test)]
pub(crate) accesskit: Option<egui::accesskit::TreeUpdate>,
}
impl Default for HeadlessView {
@@ -111,6 +114,8 @@ impl HeadlessView {
frames: 0,
clipboard: String::new(),
owed: vec![],
#[cfg(test)]
accesskit: None,
}
}
@@ -157,6 +162,10 @@ impl HeadlessView {
self.textures.apply(std::mem::take(&mut out.textures_delta));
self.shapes = std::mem::take(&mut out.shapes);
self.pixels_per_point = out.pixels_per_point;
#[cfg(test)]
{
self.accesskit = out.platform_output.accesskit_update.take();
}
for c in &out.platform_output.commands {
if let egui::OutputCommand::CopyText(text) = c {
self.clipboard.clone_from(text);
+43 -6
View File
@@ -1,9 +1,9 @@
use super::histogram::preview_histogram;
use super::sliders::control;
use super::{
Align2, Color32, DevelopSettings, Icon, LightcraftApp, Mesh, PARAM_AMOUNTS, ParametricCurve, PhotoId, Point, Pos2, Rect, RichText, Sense, Stroke,
Tokens, Vertex, controls, hex, json, paint, pos2, register, text_button, vec2,
};
use super::{Histogram, Slot};
// ------------------------------------------------------------------------------ tone curve
@@ -28,8 +28,7 @@ fn curve_histogram_profile(h: &lightcraft_raster::Histogram, channel: &str) -> [
samples.map(|v| (v / peak).sqrt())
}
/// Show the currently rendered photo's tonal distribution behind the editable
/// curve, without requesting another render or blocking pointer interactions.
/// Draw the selected curve's input behind its handles. Sampling is asynchronous.
fn draw_curve_histogram(p: &egui::Painter, r: Rect, h: &lightcraft_raster::Histogram, channel: &str) {
let profile = curve_histogram_profile(h, channel);
let color = match channel {
@@ -162,6 +161,27 @@ fn param_drag(app: &mut LightcraftApp, ui: &mut egui::Ui, r: Rect, resp: &egui::
}
}
/// Request a small diagnostic of the whole crop. Never fall back to output pixels or to another
/// photo/edit/channel while this request is pending, even when a late completion has just landed.
fn curve_input_histogram(app: &mut LightcraftApp, id: PhotoId, channel: &str) -> Option<Histogram> {
use lightcraft_engine::pipeline::curve_input::{CurveInput, EDGE};
let input = match channel {
"master" => CurveInput::Master,
"red" => CurveInput::Red,
"green" => CurveInput::Green,
"blue" => CurveInput::Blue,
"parametric" => CurveInput::Parametric,
_ => CurveInput::Master,
};
let job =
app.session.thumb_job(id, EDGE)?.with_hidden_grading(app.ui.grading_hidden_for(id)).with_proof(app.ui.soft_proof.then_some(app.ui.proof));
let job = app.renderer.curve_input_job(job, input);
let job = app.renderer.job_for(Slot::CurveHistogram, job);
let key = job.key;
app.renderer.request(Slot::CurveHistogram, job, 90);
app.renderer.curve_histogram.as_ref().filter(|h| h.0 == id && h.1 == key).map(|h| h.2.clone())
}
pub(super) fn curve_editor(app: &mut LightcraftApp, ui: &mut egui::Ui, id: PhotoId, d: &DevelopSettings) {
let t = Tokens::get(ui.ctx());
// channel selector
@@ -175,9 +195,9 @@ pub(super) fn curve_editor(app: &mut LightcraftApp, ui: &mut egui::Ui, id: Photo
("blue", hex("#3377ee")),
] {
let (r, resp) = ui.allocate_exact_size(vec2(24.0, 24.0), Sense::click());
crate::widgets::announce(&resp, format!("{} {ch}", crate::i18n::tr("Curve channel")));
register(ui, format!("curveChannel:{ch}"), r);
let sel = app.ui.curve_channel == ch;
crate::widgets::announce_selected(&resp, format!("{} {ch}", crate::i18n::tr("Curve channel")), sel);
register(ui, format!("curveChannel:{ch}"), r);
if ch == "parametric" {
paint(ui.painter(), r.shrink(4.0), Icon::Curve, if sel { t.text } else { t.icon });
} else {
@@ -210,6 +230,23 @@ pub(super) fn curve_editor(app: &mut LightcraftApp, ui: &mut egui::Ui, id: Photo
});
});
let ch = app.ui.curve_channel.clone();
let input_histogram = curve_input_histogram(app, id, &ch);
let status = if input_histogram.is_some() {
"Sampled input"
} else if app.renderer.failure_of(Slot::CurveHistogram, id).is_some() && !app.renderer.is_pending(Slot::CurveHistogram) {
"Input histogram unavailable"
} else {
"Loading input histogram..."
};
let label = ui
.horizontal(|ui| {
ui.add_space(24.0);
ui.label(RichText::new(crate::i18n::tr(status)).small().color(t.text_label))
})
.inner;
register(ui, "curve:inputHistogram", label.rect);
crate::widgets::announce_live(&label);
label.on_hover_text(crate::i18n::tr("Sampled tones entering the selected curve, across the whole crop. Parametric comes first, then Point, then Red, Green and Blue. Point and Parametric show a luminance summary. HDR edits use the SDR preview rendition."));
let w = ui.available_width();
let side = (w - 48.0).max(80.0);
let (outer, _) = ui.allocate_exact_size(vec2(w, side + 12.0), Sense::hover());
@@ -220,7 +257,7 @@ pub(super) fn curve_editor(app: &mut LightcraftApp, ui: &mut egui::Ui, id: Photo
crate::widgets::context_menu(&resp, |ui| curve_reset_menu(app, ui, &ch));
let p = ui.painter();
p.rect_filled(r, 2.0, t.canvas);
if let Some(hist) = preview_histogram(app, id) {
if let Some(hist) = input_histogram {
draw_curve_histogram(p, r, &hist, &ch);
}
for i in 1..4 {
+1 -1
View File
@@ -8,7 +8,7 @@ use super::{
// ------------------------------------------------------------------------------ histogram
/// The current photo's existing preview histogram, shared by Histogram and Tone Curve.
/// The current photo's output histogram (separate from the Tone Curve's input).
pub(super) fn preview_histogram(app: &LightcraftApp, id: PhotoId) -> Option<lightcraft_raster::Histogram> {
app.renderer
.textures
+46 -7
View File
@@ -71,6 +71,8 @@ pub enum Slot {
/// A slider drag's live HDR histogram: a small full-quality render of an HDR edit, beside the
/// drafts (which have no HDR histogram), with no texture ([`Renderer::live_hdr_histogram`]).
HdrHistogram,
/// Input of the selected Tone Curve. Strict request identity, no displayed texture.
CurveHistogram,
}
/// Settings that can change the rendered frame. Colour-only edits, including temporarily
@@ -293,6 +295,10 @@ pub struct Renderer {
pub textures: HashMap<Slot, Tex>,
/// The last [`Slot::HdrHistogram`] result: (photo, job key, histogram).
pub live_hdr_histogram: Option<(PhotoId, u64, Histogram)>,
/// Current curve diagnostic: photo, request key and unquantized input histogram.
pub curve_histogram: Option<(PhotoId, u64, Histogram)>,
/// Last diagnostic job, so idle frames do not clone and hash the full edit again.
curve_input_request: Option<(u64, lightcraft_engine::pipeline::curve_input::CurveInput, RenderJob)>,
pub last_main_ms: f64,
/// Jobs finished since start (for inspect/perf).
pub completed: u64,
@@ -422,6 +428,8 @@ impl Renderer {
pending: HashMap::new(),
textures: HashMap::new(),
live_hdr_histogram: None,
curve_histogram: None,
curve_input_request: None,
last_main_ms: 0.0,
completed: 0,
discarded: 0,
@@ -602,6 +610,7 @@ impl Renderer {
| Slot::CompareRegion(_)
| Slot::Second
| Slot::Slide(_)
| Slot::CurveHistogram
)
}
@@ -627,6 +636,20 @@ impl Renderer {
self.screen.is_some()
}
pub fn curve_input_job(&mut self, job: RenderJob, input: lightcraft_engine::pipeline::curve_input::CurveInput) -> RenderJob {
if let Some((key, channel, prepared)) = &self.curve_input_request
&& *key == job.key
&& *channel == input
&& prepared.origin == job.origin
{
return prepared.clone();
}
let key = job.key;
let prepared = job.with_curve_input(input);
self.curve_input_request = Some((key, input, prepared.clone()));
prepared
}
/// The display profile in use (id).
pub fn display_id(&self) -> Option<u64> {
self.display.as_ref().map(|d| d.id())
@@ -661,7 +684,9 @@ impl Renderer {
if let Some(&(k, p)) = self.pending.get(&slot) {
return k != key || (p != priority && self.is_queued(slot));
}
!(self.textures.get(&slot).is_some_and(|t| t.key == key) || self.failed.get(&slot).is_some_and(|f| f.0 == key && f.2 == self.catalog_rev))
!((slot == Slot::CurveHistogram && self.curve_histogram.as_ref().is_some_and(|h| h.1 == key))
|| self.textures.get(&slot).is_some_and(|t| t.key == key)
|| self.failed.get(&slot).is_some_and(|f| f.0 == key && f.2 == self.catalog_rev))
}
/// Free a view slot's texture and stage cache (the view is no longer shown).
pub fn release(&mut self, slot: Slot) {
@@ -718,7 +743,7 @@ impl Renderer {
Requested { look: Some((geometry_look(&job.settings), job.request.apply_crop)), id: job.request_id, source: Some(job.origin.clone()) },
);
// (an offload keeps its own per-view stage caches; the flag tells it to)
let job = if slot.is_view() { job.with_stages(self.stages.entry(slot).or_default().clone()) } else { job };
let job = if slot.is_view() || slot == Slot::CurveHistogram { job.with_stages(self.stages.entry(slot).or_default().clone()) } else { job };
if self.offload.is_some() {
self.seq += 1;
self.queue.retain(|q| q.slot != slot);
@@ -979,6 +1004,8 @@ impl Renderer {
self.pool.reprioritize(|_, _| None);
self.thumb_inputs.clear();
self.textures.clear();
self.curve_histogram = None;
self.curve_input_request = None;
self.stages.clear();
self.quick_tried.clear();
self.failed.clear();
@@ -1269,6 +1296,21 @@ impl Renderer {
finished
}
/// Keep the result of a histogram-only slot ([`Slot::CurveHistogram`], [`Slot::HdrHistogram`]);
/// whether it changed anything.
fn keep_histogram(&mut self, slot: Slot, photo: PhotoId, key: u64, histogram: Histogram) -> bool {
if slot == Slot::CurveHistogram {
self.curve_histogram = Some((photo, key, histogram));
return true;
}
// (an HDR histogram slot whose render has no HDR histogram changes nothing)
let hdr = histogram.hdr.is_some();
if hdr {
self.live_hdr_histogram = Some((photo, key, histogram));
}
hdr
}
/// The slot a finished job goes to. Made ahead for the photo the loupe is now waiting for, it is
/// the loupe's stand-in (the loupe's own request for it, if one was started, is dropped when it
/// arrives); also when the loupe's own request failed and it still wants that photo: the
@@ -1452,11 +1494,8 @@ impl Renderer {
if matches!(slot, Slot::Prefetch(_)) {
continue;
}
if slot == Slot::HdrHistogram {
if rendered.histogram.hdr.is_some() {
self.live_hdr_histogram = Some((r.photo, r.key, rendered.histogram));
changed = true;
}
if matches!(slot, Slot::CurveHistogram | Slot::HdrHistogram) {
changed |= self.keep_histogram(slot, r.photo, r.key, rendered.histogram);
continue;
}
if let Slot::ThumbQuick(id) = slot {
@@ -1543,6 +1543,232 @@ fn undo_to_embedded_thumb_rejects_late_full_render() {
assert!(!app.renderer.is_pending(full_slot));
}
#[test]
fn curve_input_rejects_late_edits_photos_channels_and_library_results() {
use lightcraft_engine::pipeline::curve_input::CurveInput;
let (mut app, work, ctx) = fixture();
let mut other = (*photo()).clone();
other.id = PhotoId(2);
app.session.catalog.apply(Op::AddPhoto { photo: Box::new(other) }).unwrap();
let slot = Slot::CurveHistogram;
let mut jobs = Vec::new();
for (id, exposure, input) in [
(PhotoId(1), 0.0, CurveInput::Master),
(PhotoId(1), 1.0, CurveInput::Master),
(PhotoId(2), 1.0, CurveInput::Master),
(PhotoId(2), 1.0, CurveInput::Red),
] {
let mut settings = lightcraft_develop::DevelopSettings::default();
settings.light.exposure = exposure;
app.session.catalog.apply(Op::SetDevelop { id, settings: Arc::new(settings), label: "input".into(), edited: None }).unwrap();
let job = app.session.thumb_job(id, 32).unwrap().with_curve_input(input);
app.renderer.request(slot, job, 90);
jobs.push(take_job(&work).1);
}
let last = jobs.pop().unwrap();
let key = last.key;
let oldest = jobs.remove(0);
finish(&mut app, &work, &ctx, slot, oldest.run());
assert!(app.renderer.curve_histogram.is_none(), "even a newer-than-shown result must match the current request");
finish(&mut app, &work, &ctx, slot, last.run());
let current = app.renderer.curve_histogram.clone().unwrap();
assert_eq!((current.0, current.1), (PhotoId(2), key));
for late in jobs {
finish(&mut app, &work, &ctx, slot, late.run());
}
assert_eq!(app.renderer.curve_histogram.as_ref(), Some(&current));
assert!(!app.renderer.textures.contains_key(&slot), "diagnostics never replace a photo texture");
let job = app.session.thumb_job(PhotoId(1), 32).unwrap().with_curve_input(CurveInput::Blue);
app.renderer.request(slot, job, 90);
let old_library = take_job(&work).1;
app.renderer.forget_all();
finish(&mut app, &work, &ctx, slot, old_library.run());
assert!(app.renderer.curve_histogram.is_none());
assert!(app.renderer.curve_input_request.is_none());
}
#[test]
fn curve_input_cache_generation_discards_pending_work_and_recovers() {
use lightcraft_engine::pipeline::curve_input::CurveInput;
let (mut app, work, ctx) = fixture();
let slot = Slot::CurveHistogram;
let job = app.session.thumb_job(PhotoId(1), 32).unwrap();
let job = app.renderer.curve_input_job(job, CurveInput::Master);
app.renderer.request(slot, job, 90);
let (_, obsolete) = take_job(&work);
app.session.media.rendered.clear();
app.renderer.poll(&ctx, &mut app.session);
assert!(app.renderer.curve_input_request.is_none());
assert!(!app.renderer.requests.contains_key(&slot));
finish(&mut app, &work, &ctx, slot, obsolete.run());
assert!(app.renderer.curve_histogram.is_none());
let job = app.session.thumb_job(PhotoId(1), 32).unwrap();
let job = app.renderer.curve_input_job(job, CurveInput::Master);
let key = job.key;
app.renderer.request(slot, job, 90);
let (_, current) = take_job(&work);
finish(&mut app, &work, &ctx, slot, current.run());
assert_eq!(app.renderer.curve_histogram.as_ref().map(|h| (h.0, h.1)), Some((PhotoId(1), key)));
}
#[cfg(not(target_arch = "wasm32"))]
#[test]
fn curve_input_native_worker_keeps_request_identity_through_failure_and_recovery() {
use lightcraft_engine::pipeline::curve_input::CurveInput;
use std::sync::{Mutex, mpsc};
use std::time::Duration;
let (mut app, _, ctx) = fixture();
app.renderer.offload = None;
app.renderer.pool = JobPool::new(1);
let slot = Slot::CurveHistogram;
let timeout = Duration::from_secs(10);
let (entered, started) = mpsc::channel();
let (release, held) = mpsc::channel();
let held = Mutex::new(held);
app.session.media.file_loader = Some(Arc::new(move |path, _, _| {
entered.send(path.to_string()).unwrap();
held.lock().unwrap().recv_timeout(timeout).unwrap();
Err("controlled curve input failure".into())
}));
let ask = |app: &mut crate::LightcraftApp| {
let job = app.session.thumb_job(PhotoId(1), 32).unwrap().with_curve_input(CurveInput::Master);
let key = job.key;
app.renderer.request(slot, job, 90);
key
};
ask(&mut app);
assert_eq!(started.recv_timeout(timeout).unwrap(), "audit.jpg");
let replacement = relink_destination();
app.session.execute("photo.relink", &serde_json::json!({"id": 1, "path": replacement})).unwrap();
ask(&mut app);
let current_id = app.renderer.requests[&slot].id;
release.send(()).unwrap();
assert!(app.renderer.pool.wait(timeout));
app.renderer.poll(&ctx, &mut app.session);
assert!(app.renderer.failure_messages.is_empty(), "obsolete failures cannot take the current request's identity");
assert_eq!(app.renderer.requests[&slot].id, current_id);
assert!(app.renderer.curve_histogram.is_none());
assert_eq!(started.recv_timeout(timeout).unwrap(), replacement.to_str().unwrap());
let later = relink_destination();
app.session.execute("photo.relink", &serde_json::json!({"id": 1, "path": later})).unwrap();
release.send(()).unwrap();
assert!(app.renderer.pool.wait(timeout));
app.renderer.poll(&ctx, &mut app.session);
let message = app.renderer.failure_messages.last().unwrap();
assert!(message.contains(replacement.to_str().unwrap()), "{message}");
assert!(!message.contains(later.to_str().unwrap()), "the catalog changed after submission: {message}");
assert!(!app.renderer.requests.contains_key(&slot));
assert!(!app.renderer.is_pending(slot));
app.session.media.file_loader =
Some(Arc::new(|_, _, _| Ok((lightcraft_raster::Rgb32f::from_fn(32, 16, |x, _| [0.02 + x as f32 / 100.0; 3]), Default::default()))));
let key = ask(&mut app);
assert!(app.renderer.pool.wait(timeout));
app.renderer.poll(&ctx, &mut app.session);
assert_eq!(app.renderer.curve_histogram.as_ref().map(|h| (h.0, h.1)), Some((PhotoId(1), key)));
assert!(app.renderer.failure_of(slot, PhotoId(1)).is_none());
assert!(app.renderer.live_workers() > 0);
assert!(!app.renderer.textures.contains_key(&slot));
std::fs::remove_file(replacement).unwrap();
std::fs::remove_file(later).unwrap();
}
#[cfg(not(target_arch = "wasm32"))]
#[test]
fn curve_input_relink_retries_current_file_with_retained_content_hash() {
use lightcraft_engine::media::SourceRef;
use lightcraft_engine::pipeline::curve_input::CurveInput;
use std::time::Duration;
let dir = std::env::temp_dir().join(format!("lc-curve-relink-{}-{}", std::process::id(), lightcraft_preview::next_tick()));
std::fs::create_dir(&dir).unwrap();
let original = dir.join("original.png");
let replacement = dir.join("moved.png");
let pixels = lightcraft_raster::Rgba8 { width: 8, height: 4, data: vec![[90, 120, 160, 255]; 32] };
let bytes = lightcraft_codecs::encode_png(&lightcraft_codecs::EncodeImage::rgba8(&pixels), &Default::default()).unwrap();
std::fs::write(&original, bytes).unwrap();
let mut session = Session::new().with_fs();
let imported = session.execute("library.import", &serde_json::json!({"paths": [original]})).unwrap();
let id = PhotoId(imported["imported"][0].as_u64().unwrap());
let hash = session.catalog.photo(id).unwrap().content_hash.clone();
assert!(hash.is_some(), "the real file probe must record content identity");
std::fs::rename(&original, &replacement).unwrap();
// Record the actual filesystem loader path, including failed attempts. Keep the same
// loader across relinking so recovery depends on the new job's source.
let (loaded, paths) = std::sync::mpsc::channel();
let loader = session.media.file_loader.clone().unwrap();
session.media.file_loader = Some(Arc::new(move |path, edge, profile| {
loaded.send(path.to_owned()).unwrap();
loader(path, edge, profile)
}));
session.media.reduced_loader = None;
let mut app = crate::LightcraftApp::new(session, crate::Services::default());
app.renderer.pool = JobPool::new(1);
let ctx = egui::Context::default();
let slot = Slot::CurveHistogram;
let timeout = Duration::from_secs(10);
app.renderer.poll(&ctx, &mut app.session);
let incoming = app.session.thumb_job(id, 256).unwrap();
let old = incoming.clone();
let job = app.renderer.curve_input_job(incoming, CurveInput::Master);
let key = job.key;
app.renderer.request(slot, job, 90);
assert!(app.renderer.pool.wait(timeout));
app.renderer.poll(&ctx, &mut app.session);
assert_eq!(paths.recv_timeout(timeout).unwrap(), original.to_str().unwrap());
assert!(app.renderer.failure_of(slot, id).is_some());
assert!(app.renderer.failure_messages.last().unwrap().contains(original.to_str().unwrap()));
assert!(app.renderer.curve_histogram.is_none());
app.session.execute("photo.relink", &serde_json::json!({"id": id.0, "path": replacement})).unwrap();
app.renderer.poll(&ctx, &mut app.session);
assert_eq!(app.session.catalog.photo(id).unwrap().content_hash, hash);
let incoming = app.session.thumb_job(id, 256).unwrap();
assert_eq!(incoming.key, old.key, "same content retains the render key");
assert_eq!(incoming.source_key, old.source_key);
assert_ne!(incoming.origin, old.origin, "the command changed the source location");
let current = incoming.clone();
let job = app.renderer.curve_input_job(incoming, CurveInput::Master);
let prepared = job.clone();
app.renderer.request(slot, job, 90);
assert!(app.renderer.pool.wait(timeout));
app.renderer.poll(&ctx, &mut app.session);
let retried_path = paths.recv_timeout(timeout).unwrap();
eprintln!(
"relink: incoming keys equal={}, origin changed={}, loader={retried_path:?}, failure={:?}, histogram={}",
current.key == old.key,
current.origin != old.origin,
app.renderer.failure_of(slot, id),
app.renderer.curve_histogram.is_some()
);
assert_eq!(retried_path, replacement.to_str().unwrap(), "the retry must load the relinked file");
assert_eq!(prepared.origin, current.origin);
assert_eq!(prepared.source_key, current.source_key);
assert_eq!(prepared.info, current.info);
assert!(matches!(&prepared.source, SourceRef::File { path, .. } if path == replacement.to_str().unwrap()));
assert_eq!(app.renderer.curve_histogram.as_ref().map(|h| (h.0, h.1)), Some((id, key)));
assert!(app.renderer.failure_of(slot, id).is_none());
assert!(app.session.media.has_source(id, current.level), "the current decoded source was accepted");
assert!(!app.renderer.textures.contains_key(&slot));
// Moving identical content again needs a new prepared source, but a completed
// histogram remains valid and must not trigger another decode.
let completed = app.renderer.completed;
let histogram = app.renderer.curve_histogram.clone();
std::fs::rename(&replacement, &original).unwrap();
app.session.execute("photo.relink", &serde_json::json!({"id": id.0, "path": original})).unwrap();
app.renderer.poll(&ctx, &mut app.session);
let incoming = app.session.thumb_job(id, 256).unwrap();
let job = app.renderer.curve_input_job(incoming, CurveInput::Master);
assert_eq!(job.origin, old.origin);
app.renderer.request(slot, job, 90);
assert!(!app.renderer.is_pending(slot));
assert_eq!(app.renderer.completed, completed);
assert_eq!(app.renderer.curve_histogram, histogram);
assert!(paths.try_recv().is_err());
std::fs::remove_dir_all(dir).unwrap();
}
/// PERF-CULL-2: the loupe's stand-ins made ahead are taken over at the step (no job, the texture
/// at once), a photo still wanted keeps its slot as the photos shift, and a step to a photo whose
/// stand-in is still being made shows it when it arrives.
+188 -1
View File
@@ -12,8 +12,12 @@ const T: Duration = Duration::from_secs(20);
/// Detail view with the Edit panel's Curve flyout open on `channel`.
fn curve_open(channel: &str) -> Headless {
curve_open_with(lightcraft_engine::Session::with_demo(), channel)
}
fn curve_open_with(session: lightcraft_engine::Session, channel: &str) -> Headless {
let services = Services { png: None, ..Default::default() };
let app = LightcraftApp::new(lightcraft_engine::Session::with_demo(), services);
let app = LightcraftApp::new(session, services);
let mut h = Headless::new(app, [1200.0, 1400.0], 1.0);
let r = h.request("ui.set", json!({"view": "detail"}), T);
assert_eq!(r["ok"], true, "{r}");
@@ -589,3 +593,186 @@ fn the_four_regions_tile_the_graph() {
prev = r;
}
}
/// Keep native decode and render jobs, but bound the fixture's work: settling a whole demo library
/// also waits for unrelated procedural thumbnails and neighbour previews on slow CI machines.
fn curve_input_open() -> Headless {
use lightcraft_catalog::{Op, Photo, PhotoId, Source};
use std::sync::Arc;
let mut session = lightcraft_engine::Session::new();
let mut files = std::collections::HashMap::new();
for id in 1..=2 {
let path = format!("curve-{id}.png");
let pixels = lightcraft_raster::Rgba8::from_fn(64, 48, |x, y| [(x * 3 + 20) as u8, (y * 4 + 10) as u8, (id * 60) as u8, 255]);
let bytes = lightcraft_codecs::encode_png(&lightcraft_codecs::EncodeImage::rgba8(&pixels), &Default::default()).unwrap();
files.insert(path.clone(), bytes);
let photo = Photo::new(PhotoId(id), Source::File { path: path.clone() }, &path, "PNG", 64, 48, "2026-10-22");
session.catalog.apply(Op::AddPhoto { photo: Box::new(photo) }).unwrap();
}
session.media.file_loader = Some(Arc::new(move |path, edge, _| {
let bytes = files.get(path).ok_or_else(|| format!("unknown curve fixture: {path}"))?;
lightcraft_engine::files::load_bytes(bytes, edge)
}));
session.execute("library.select", &json!({"ids": [1], "active": 1})).unwrap();
curve_open_with(session, "master")
}
#[test]
fn curve_input_backdrop_stays_steady_while_its_output_and_upstream_edits_change() {
use crate::render::Slot;
let mut h = curve_input_open();
assert!(h.settle(T), "curve fixture still pending: {:?}", h.app.renderer.pending_slots());
let before = h.app.renderer.curve_histogram.clone().unwrap();
let output = h.app.renderer.textures.get(&Slot::Main).unwrap().histogram.clone();
exec(&mut h, "develop.curve", json!({"channel":"master", "points":[[0,0],[0.25,0.7],[1,1]]}));
assert!(h.settle(T));
assert_eq!(h.app.renderer.curve_histogram.as_ref(), Some(&before));
assert_ne!(h.app.renderer.textures.get(&Slot::Main).unwrap().histogram, output);
assert!(h.painted_text().iter().any(|s| s == "Sampled input"));
click_widget(&mut h, "curveChannel:red", 1);
assert!(h.settle(T));
let red = h.app.renderer.curve_histogram.clone().unwrap();
assert_ne!(red.1, before.1);
assert_ne!(red.2, before.2, "red's input includes the changed master curve");
exec(&mut h, "develop.set", json!({"control":"light.exposure", "value":1}));
assert!(h.settle(T));
assert_ne!(h.app.renderer.curve_histogram.as_ref().unwrap().2, red.2);
click_widget(&mut h, "curveChannel:parametric", 1);
assert!(h.settle(T));
let parametric = h.app.renderer.curve_histogram.clone().unwrap();
exec(&mut h, "develop.set", json!({"control":"curve.shadows", "value":60}));
assert!(h.settle(T));
assert_eq!(h.app.renderer.curve_histogram.as_ref(), Some(&parametric));
}
#[test]
fn curve_input_shows_loading_failure_and_no_photo_without_reusing_a_backdrop() {
use crate::headless::RenderGate;
use crate::render::Slot;
use std::{cell::Cell, rc::Rc};
let mut h = curve_input_open();
assert!(h.settle(T), "curve fixture still pending: {:?}", h.app.renderer.pending_slots());
assert!(h.painted_text().iter().any(|t| t == "Sampled input"));
let before = h.app.renderer.curve_histogram.clone().expect("a real input histogram before the gate");
assert_eq!(Some(before.0), h.app.session.active());
let open = Rc::new(Cell::new(false));
h.app.renderer.set_offload(Box::new(RenderGate::failing(open.clone(), |s| s == Slot::CurveHistogram)));
exec(&mut h, "develop.set", json!({"control":"light.exposure", "value":1}));
h.step();
assert!(h.app.renderer.is_pending(Slot::CurveHistogram));
assert_eq!(h.app.renderer.curve_histogram.as_ref(), Some(&before), "the old result remains cached while its replacement is pending");
assert!(h.painted_text().iter().any(|t| t == "Loading input histogram..."));
assert!(!h.painted_text().iter().any(|t| t == "Sampled input"));
exec(&mut h, "library.select", json!({"ids":[2], "active":2}));
h.step();
assert!(h.app.renderer.is_pending(Slot::CurveHistogram));
assert!(h.painted_text().iter().any(|t| t == "Loading input histogram..."));
assert!(!h.painted_text().iter().any(|t| t == "Sampled input"));
open.set(true);
assert!(h.settle(T));
assert!(!h.app.renderer.is_pending(Slot::CurveHistogram));
assert!(h.app.renderer.failure_of(Slot::CurveHistogram, lightcraft_catalog::PhotoId(2)).is_some());
assert_eq!(h.app.renderer.curve_histogram.as_ref(), Some(&before), "a failed replacement must not expose the cached backdrop");
assert!(h.painted_text().iter().any(|t| t == "Input histogram unavailable"));
assert!(!h.painted_text().iter().any(|t| t == "Sampled input"));
exec(&mut h, "library.select", json!({"ids":[]}));
assert!(h.settle(T));
assert!(h.app.session.active().is_none());
assert!(!h.painted_text().iter().any(|t| t.contains("input histogram") || t == "Sampled input"));
}
#[test]
fn review_unknown_curve_channel_uses_point_input_and_default_stays_parametric() {
let mut h = curve_input_open();
exec(&mut h, "develop.set", json!({"control":"curve.shadows", "value":60}));
assert!(h.settle(T));
let point = h.app.renderer.curve_histogram.clone().unwrap();
h.app.ui.curve_channel = "unknown-saved-channel".into();
h.step();
assert!(h.settle(T));
assert_eq!(h.app.renderer.curve_histogram.as_ref(), Some(&point), "unknown channels draw the Point curve and must sample its input");
h.app.ui.curve_channel = crate::state::UiState::default().curve_channel;
assert_eq!(h.app.ui.curve_channel, "parametric");
h.step();
assert!(h.settle(T));
let parametric = h.app.renderer.curve_histogram.clone().unwrap();
assert_ne!(parametric.1, point.1);
assert_ne!(parametric.2, point.2);
assert!(h.painted_text().iter().any(|s| s == "Sampled input"));
}
// Review of #987: a brush mask past its dab budget fails the input sample, as it fails the preview,
// and the backdrop shows its unavailable state instead of a sample of a mask missing later strokes
#[test]
fn an_over_budget_brush_mask_leaves_the_input_histogram_unavailable() {
use crate::render::Slot;
use lightcraft_catalog::PhotoId;
use lightcraft_develop::{BrushStroke, Mask, MaskComponent, MaskShape};
let mut h = curve_input_open();
assert!(h.settle(T), "curve fixture still pending: {:?}", h.app.renderer.pending_slots());
let before = h.app.renderer.curve_histogram.clone().expect("a real input histogram before the brush");
// ten far-flung strokes, 640,000 dabs each at 256 px: past the mask's budget of two million
let far = BrushStroke {
points: vec![lightcraft_geom::Point::new(-4000.0, 0.5), lightcraft_geom::Point::new(4000.0, 0.5)],
size: 0.05,
..Default::default()
};
let component = MaskComponent { name: None, op: Default::default(), invert: false, shape: MaskShape::Brush { strokes: vec![far; 10] } };
let mut edit = (*h.app.session.develop_of(PhotoId(1)).unwrap()).clone();
edit.masks.push(Mask { visible: true, components: vec![component], ..Default::default() });
h.app.session.set_develop(PhotoId(1), edit, "brush").unwrap();
assert!(h.settle(T), "still pending: {:?}", h.app.renderer.pending_slots());
let failure = h.app.renderer.failure_of(Slot::CurveHistogram, PhotoId(1)).unwrap_or_default();
assert!(failure.contains("dabs"), "{failure}");
assert_eq!(h.app.renderer.curve_histogram.as_ref(), Some(&before), "the rejected request stores no sample");
assert!(h.painted_text().iter().any(|t| t == "Input histogram unavailable"));
assert!(!h.painted_text().iter().any(|t| t == "Sampled input"));
}
// Review of #987: the backdrop follows the selected channel, so a screen reader hears which channel
// is selected. The caption, which a background sample changes away from focus, stays one live node
// whose text changes in place: that change is what the platform adapters read out.
#[test]
fn curve_channels_report_the_selection_and_the_input_caption_is_a_live_region() {
use crate::headless::RenderGate;
use crate::render::Slot;
use egui::accesskit::{Live, NodeId, Toggled, TreeUpdate};
use std::{cell::Cell, rc::Rc};
fn tree(h: &Headless) -> &TreeUpdate {
h.view.accesskit.as_ref().expect("AccessKit is on")
}
fn channel(h: &Headless, ch: &str) -> Option<Toggled> {
let name = format!("Curve channel {ch}");
let node = tree(h).nodes.iter().find(|(_, n)| n.label() == Some(name.as_str()));
node.unwrap_or_else(|| panic!("{name} has no node")).1.toggled()
}
// the caption's node, its text and live setting, and the focused node
fn caption(h: &Headless) -> (NodeId, String, Option<Live>, NodeId) {
const STATUSES: [&str; 3] = ["Sampled input", "Loading input histogram...", "Input histogram unavailable"];
let tree = tree(h);
let (id, node) = tree.nodes.iter().find(|(_, n)| n.value().is_some_and(|v| STATUSES.contains(&v))).expect("the caption has a node");
(*id, node.value().unwrap_or_default().to_string(), node.live(), tree.focus)
}
let mut h = curve_input_open();
h.view.ctx.enable_accesskit();
assert!(h.settle(T), "curve fixture still pending: {:?}", h.app.renderer.pending_slots());
assert_eq!((channel(&h, "master"), channel(&h, "red")), (Some(Toggled::True), Some(Toggled::False)));
click_widget(&mut h, "curveChannel:red", 1);
assert!(h.settle(T));
assert_eq!((channel(&h, "master"), channel(&h, "red")), (Some(Toggled::False), Some(Toggled::True)), "the selection follows the click");
let sampled = caption(&h);
assert_eq!(sampled.2, Some(Live::Polite), "the caption is a live region");
let open = Rc::new(Cell::new(false));
h.app.renderer.set_offload(Box::new(RenderGate::failing(open.clone(), |s| s == Slot::CurveHistogram)));
exec(&mut h, "develop.set", json!({"control":"light.exposure", "value":1}));
h.step();
let loading = caption(&h);
open.set(true);
assert!(h.settle(T));
let unavailable = caption(&h);
for (before, after) in [(&sampled, &loading), (&loading, &unavailable)] {
assert_eq!((after.0, after.2, after.3), (before.0, before.2, before.3), "the same live node, and the focus stays: {before:?} then {after:?}");
assert_ne!(after.1, before.1, "its text changes, which is what a screen reader hears");
}
}
+8
View File
@@ -1370,6 +1370,14 @@ pub(crate) fn announce_selected(resp: &egui::Response, name: impl Into<String>,
resp.widget_info(|| egui::WidgetInfo::selected(egui::Role::Button, resp.enabled(), selected, name.clone()));
}
/// Makes the text `resp` shows a polite live region, for a status that changes away from focus (a
/// background job's state): screen readers read the new text when it changes, and the focus stays
/// where it is. The platform adapters compare each frame's tree with the one before, so text that
/// stays the same is not read again.
pub(crate) fn announce_live(resp: &egui::Response) {
resp.ctx.accesskit_node_builder(resp.id, |node| node.set_live(egui::accesskit::Live::Polite));
}
/// `r`, named `name` for screen readers: a plain egui field or slider whose caption is drawn
/// beside it, or whose hint is all it shows.
pub(crate) fn named(r: egui::Response, name: &str) -> egui::Response {
+5
View File
@@ -72,6 +72,10 @@ Beta-blocking gaps (B) total **~230–430 h**; with the stability and platform w
element text before parsing. Malformed or undeclared references return an error; CDATA stays
literal. Track positions and timestamps no longer silently change or lose points.
- 2026-10-22: Tone Curve backdrop samples the selected curve input (#987). RGB follows Parametric
and Point; Point follows Parametric. The output Histogram panel stays separate. The sample uses
a bounded thumbnail rendition, including SDR preview adjustments for HDR edits. This was not a
separate ranked gap; readiness estimates stay unchanged. See [the contract](tone-curve-input.md).
- 2026-10-20: the import review album picker follows the sidebar folder hierarchy and searches album paths (#2362, LR-IMP-ADD-DIALOG), retaining None/New album and existing destination IDs. This closes a usability subgap; no ranked gap or headline feature count closes.
- 2026-10-12: original-pixel detail at 100% (gap 4, LR-VIEW-ZOOM, #323): soft proofing gets zoom windows like
@@ -132,6 +136,7 @@ Beta-blocking gaps (B) total **~230–430 h**; with the stability and platform w
| 2026-10-22 | patch | Issue #2519: PSD/PSB EXIF resource 1058 and XMP resource 1060 now use the common metadata extractor, and `.psb` files are accepted by import; no ranked gap or readiness count changes |
| 2026-10-22 | minor | Gap 30 added: multi-select metadata editing — Info panel and All Metadata dialog show one photo's values with no mixed-value indication |
| 2026-10-22 | patch | LR-MAP-TRACKLOG: GPX coordinate attributes and point text decode XML references; malformed / unknown references return errors; CDATA remains literal; ranked gaps unchanged |
| 2026-10-22 | minor | Tone Curve input histogram (#987); no ranked gap or readiness estimate changes. See [the stage contract](tone-curve-input.md). |
| 2026-10-21 | minor | Gap 28 shrinks: F8 shows / hides the right panel (`view.rightPanel`); rating `[` `]`, flag cycling and F1 help were already bound, so the entry lists only filter-bar keys, Tab / ⇧Tab and F5; 2–4 h (was 4–8) |
| 2026-10-20 | minor | Gap 22 shrinks (11–22 → 9–18 h): on Windows, previews follow the profile Windows Color System assigns to the window's monitor (sRGB while Windows colour-manages the desktop: HDR, Auto Color Management) |
| 2026-10-20 | minor | #2362: import destination albums use the shared hierarchy/search picker instead of a flat name list; existing import workflows retained; ranked gaps/readiness counts unchanged |
+4 -3
View File
@@ -190,9 +190,9 @@ differences and missing bindings are in [ui-parity.md](ui-parity.md#shortcuts).
| LR-EDIT-LIGHT-SHADOWS | Shadows | P0 | ✅ | `ctl:light.shadows` | From process V2, the same base as Highlights: dark areas keep their local contrast when lifted (#632); from process V8, the gaps in dark lettering on a bright panel are not lifted into bright blocks. Alt/Option-drag shows shadow clipping (white, clipped channels in colour). From process V13 the global amount eases off as it grows: the operator's strength is `a / (1 + 1.33·abs(a))` for `a` = slider / 100 (0.43 at +100, against 1 up to V10), fitted to Lightroom exports (#523). |
| LR-EDIT-LIGHT-WHITES | Whites | P0 | 🟡 | `ctl:light.whites`, `crates/pipeline/src/visualize.rs` | V4 preserves V2 Whites for both signs. Calibration is a planned follow-up; measured V2 check response error is 0.075 stops on the Sony test photos (`docs/light-v3.md`). Alt/Option-drag shows highlight clipping (black, clipped channels in colour) |
| LR-EDIT-LIGHT-BLACKS | Blacks | P0 | 🟡 | `ctl:light.blacks`, `crates/pipeline/src/visualize.rs` | From process V4, global Blacks on the camera-look path uses a fitted per-channel/luminance mix. Check response error 0.424 to 0.077 stops on six held-out Sony photos; deepest tones still differ. Other sources and local adjustments retain V2 (`docs/light-v3.md`). Alt/Option-drag shows shadow clipping (white, clipped channels in colour) |
| LR-EDIT-LIGHT-CURVE-PARAM | Parametric curve | P0 | ✅ | `ctl:curve.highlights`, `ctl:curve.lights`, `ctl:curve.darks`, `ctl:curve.shadows`, `ctl:curve.split*`, `crates/pipeline/src/curve.rs` | the graph draws the renderer's own curve model; dragging the line moves the region under the pointer (one undo step) |
| LR-EDIT-LIGHT-CURVE-POINT | Point curve | P0 | ✅ | `cmd:develop.curve`, `cmd:curve.reset`, `cmd:curve.presets`, `cmd:curve.applyPreset`, `cmd:curve.savePreset`, `cmd:curve.deletePreset`, `cmd:curve.importPresets`, `cmd:curve.exportPresets`, `cmd:file.importCurvePresets`, `cmd:file.exportCurvePresets`, `crates/engine/src/cmd/curves.rs`, `crates/ui-egui/src/panels/edit.rs` | click to add a point; drag a point in both axes (between its neighbours, input / output readout, one undo step per drag; ⌥-drag moves it a tenth as far for fine adjustment, issue #1363); drag empty space to add and drag; double-click removes; reset: double-click a channel selector (that channel), the Reset button under the graph (every curve incl. parametric) or right-click the graph (channel / all); Point Curve preset dropdown: own Linear / Medium Contrast / Strong Contrast, user presets (save the current point curves, delete by right-click; saved with the library), import / export as `.lccurve` JSON |
| LR-EDIT-LIGHT-CURVE-RGB | Per-channel curves | P0 | ✅ | `cmd:develop.curve` (`channel`) | |
| LR-EDIT-LIGHT-CURVE-PARAM | Parametric curve | P0 | ✅ | `ctl:curve.highlights`, `ctl:curve.lights`, `ctl:curve.darks`, `ctl:curve.shadows`, `ctl:curve.split*`, `crates/pipeline/src/curve.rs` | the graph draws the renderer's own curve model; dragging the line moves the region under the pointer (one undo step); sampled selected-curve input backdrop (#987); [stage and sampling limits](tone-curve-input.md) |
| LR-EDIT-LIGHT-CURVE-POINT | Point curve | P0 | ✅ | `cmd:develop.curve`, `cmd:curve.reset`, `cmd:curve.presets`, `cmd:curve.applyPreset`, `cmd:curve.savePreset`, `cmd:curve.deletePreset`, `cmd:curve.importPresets`, `cmd:curve.exportPresets`, `cmd:file.importCurvePresets`, `cmd:file.exportCurvePresets`, `crates/engine/src/cmd/curves.rs`, `crates/ui-egui/src/panels/edit.rs` | click to add a point; drag a point in both axes (between its neighbours, input / output readout, one undo step per drag; ⌥-drag moves it a tenth as far for fine adjustment, issue #1363); drag empty space to add and drag; double-click removes; reset: double-click a channel selector (that channel), the Reset button under the graph (every curve incl. parametric) or right-click the graph (channel / all); Point Curve preset dropdown: own Linear / Medium Contrast / Strong Contrast, user presets (save the current point curves, delete by right-click; saved with the library), import / export as `.lccurve` JSON; sampled input after Parametric, independent of this curve (#987); [stage and sampling limits](tone-curve-input.md) |
| LR-EDIT-LIGHT-CURVE-RGB | Per-channel curves | P0 | ✅ | `cmd:develop.curve` (`channel`) | sampled selected-curve input backdrop (#987); [stage and sampling limits](tone-curve-input.md) |
| LR-EDIT-LIGHT-CURVE-REFINESAT | Curve saturation compensation | P1 | ✅ | `ctl:curve.refineSaturation` | |
| LR-EDIT-LIGHT-CURVE-TAT | Drag-on-image curve adjust | P1 | ✅ | `cmd:develop.targeted` (`target: curve`) | |
| LR-EDIT-COLOR-WB-PRESET | White-balance presets | P0 | ✅ | `cmd:develop.wb` | |
@@ -884,6 +884,7 @@ Latin stays upright. Advanced Japanese composition remains open. Regression cove
| 2026-10-22 | patch | LR-EXP-PSD, LR-META-EXIF-FULL: PSD/PSB imports and image resources 1058/1060 now supply EXIF and XMP to metadata readers and All Metadata; Original with Remove Location Info refuses detected PSD/PSB GPS; statuses and feature counts unchanged |
| 2026-10-21 | patch | LR-LIB-CAPTURETIME: a capture time that doesn't fully read is left as it is and counted (`unreadable`) instead of shifted into a wrong one; it can't anchor a set that moves other photos; status unchanged |
| 2026-10-22 | patch | LR-MAP-TRACKLOG: character references in GPX coordinate attributes and point text decode correctly; malformed / unknown references fail cleanly; CDATA stays literal; command dry-run, tagging and undo covered |
| 2026-10-22 | minor | Curve backdrop samples the selected curve input (#987); row statuses unchanged. See [the stage contract](tone-curve-input.md). |
| 2026-10-21 | patch | LR-IMP-ADD-DIALOG: reconcile #2362 with current main; deleted-album guard and hierarchical picker retained; counts unchanged |
| 2026-10-21 | patch | KEY-SLIDER-NUDGE: vertical wheel nudges need a click or drag in the slider's row; leaving it (even between two frames) or Tab focus alone does not arm them (issue #1355); status unchanged |
| 2026-10-21 | minor | KEYC-PANELS: F8 shows / hides the right panel (`view.rightPanel`), with F6 / F7 already bound; ⬜ → 🟡 |
+1
View File
@@ -307,6 +307,7 @@ P2 items 12–25 h; look tuning, performance, packaging, hardening 25–45 h.
| 2026-10-23 | minor | AI Denoise runs without a model (built-in denoiser); percentages unchanged, since it is a classical filter and Bayer-only |
| 2026-10-13 | minor | Canon CRW decoded (clean-room, craft-libs `crates/crw/clean-room/`): 551 models verified with the coverage sweep (557 with MRW after merging main), Canon preview rows 21 → 6; RAW decoding unchanged |
| 2026-10-19 | patch | Stability note: tests run in CI on Linux x64 (every PR) as well as FreeBSD; macOS and Windows remain (gap 9) |
| 2026-10-22 | minor | Tone Curve input histogram (#987); headline counts and readiness estimates unchanged. See [the stage contract](tone-curve-input.md). |
| 2026-10-19 | minor | Localization ~55% → ~64% (mean of the 12 key languages): Indonesian (`id`) catalog, every message but What's New; full target 61.2% → 61.5% (still ~61%) |
| 2026-10-19 | patch | Platforms: the Windows installer is no longer listed as unverified (the 0.9.1 x64 MSI is tested on Windows 11; a confirmation after uninstalling from Settings → Apps, #892, remains); #790 noted as fixed in 0.9.1; percentages and hours unchanged |
| 2026-10-17 | minor | Object / Describe masks: SAM 3's text detector mask decoder also on the GPU outside macOS; status unchanged |
+73
View File
@@ -0,0 +1,73 @@
# Tone Curve input histogram
The backdrop shows sampled tones entering the selected curve. The Histogram panel still shows
rendered output. Issue [#987](https://github.com/storytold/lightcraft/issues/987), reported by
@zelefogs, requested this distinction; #1091 supplied the earlier output backdrop.
## Where the sample comes from
The CPU pipeline shares its existing geometry, white balance, noise reduction and spatial stages.
Its finish stage applies exposure, local adjustments, detail, tone, colour, vignette and the output
gamut or proof transform. It then applies the sRGB transfer function in the preview's output
primaries. These encoded component values are the curve axes.
| Selected curve | Sampled values |
|---|---|
| Parametric | Before every curve |
| Point (master) | After Parametric, before Point |
| Red, Green or Blue | That component after Parametric and Point, before the independent RGB curves |
Point and Parametric display a luminance summary of the encoded components, using the output
primaries' luminance weights. Both curves actually act on each RGB component. The normal renderer
composes the curves into 1,024-entry lookup tables. The diagnostic constructs the same tables with
only the preceding curves, after built-in profile expansion. It does not change the normal tables
or how existing edits render.
The renderer does not store an intermediate image between its fused curves. This reconstructed
prefix does not imply that applying the selected curve separately reproduces every output bit;
table interpolation and nonlinear composition can differ.
Refine Saturation, grain, LUT profiles, proof warning colours, diagnostic overlays and final output
re-encoding are excluded. Built-in profiles can change upstream settings and preceding curves;
those contributions remain. This is why simply disabling curves and measuring final output would
not measure the requested stage.
## Sampling and identity
The UI uses the existing thumbnail source and a separate render request, with at most 256 pixels
per edge (65,536 samples). It samples the whole crop. Zoom windows and panning do not change the
distribution. Float values are binned before quantization. Nonfinite values and values outside
0..1 are excluded rather than placed at the graph's endpoints.
This is an approximation from a downsampled development, not a full-resolution pixel count.
Initial thumbnail loading follows the normal source loader and can require decoding an original.
Subsequent diagnostics reuse the thumbnail source and spatial cache. Moving the selected curve or
its successors does not invalidate the diagnostic key. Upstream settings, source identity, photo,
channel, crop, display profile and proof settings do. An idle frame reuses the prepared job.
The diagnostic has its own preview slot and accepts only its current request. The UI also checks
the current photo and key before drawing. Loading or failure leaves an empty backdrop with a status
label; a previous photo's distribution is never used as a fallback. Library and display resets
clear the diagnostic. It never reads or writes rendered thumbnail or view caches.
Before it prepares local masks, the diagnostic checks every visible brush mask against its dab
budget at the diagnostic's own size and crop, as the normal preview does. Past the budget, mask
preparation would drop the later strokes, so the request fails instead, in the native renderer and
in the browser worker. The backdrop then shows "Input histogram unavailable".
Native previews use the selected monitor primaries and proof transform. Browser worker previews
currently use their existing sRGB request semantics. HDR edits use the SDR preview rendition,
including its brightness and contrast offsets; this graph does not represent the HDR export's
headroom. The help text states this limit. No output toggle or new edit setting is added.
## Verification and limits
Procedural regressions cover exposure, nonidentity curves and their order, built-in and LUT
profiles, crop and window handling, size bounds, HDR and nonfinite boundaries, display primaries,
proof transforms, over-budget brush masks, cache separation and late completions across edits,
photos, channels and library resets. A GPU comparison checks each curve prefix against the existing
GPU renderer. Headless UI tests check channel selection, output separation, loading, failure
(including an over-budget brush) and no-photo states.
These tests establish LightCraft's stage contract. They do not establish Lightroom colour parity,
real-camera accuracy or performance on every platform.