feat(domain): R4.6 ExportSession (incremental export, OD-2): rasters decoded and written on arrival, chunked file handed out in parts, views composed by the core, raster_size_of (O4); wasm ExportSession and CoreExportSession; R4 digests re-frozen (catalog and page tree written last, B2)
This commit is contained in:
1 parent
8d16be577c
commit
9e688b6801
38 files changed
+2421
-354
No files matched your search
@@ -10,11 +10,11 @@
|
||||
|
||||
mod common;
|
||||
|
||||
use common::r4::{repo_root, sha256_hex};
|
||||
use common::r4::{PngKeeper, repo_root, sha256_hex};
|
||||
use faunosteo_core::domain::archive::Locale;
|
||||
use faunosteo_core::domain::js::parse_json;
|
||||
use faunosteo_core::pdf::read::probe::{ProbeLimits, read_attached_document};
|
||||
use faunosteo_core::pdf::write::draw_log::{DrawLog, DrawOp};
|
||||
use faunosteo_core::pdf::write::draw_log::DrawOp;
|
||||
use faunosteo_core::pdf::write::input::{ExportInput, Rasters, check_input};
|
||||
use faunosteo_core::pdf::write::layout::layout;
|
||||
use serde_json::{Value, json};
|
||||
@@ -96,12 +96,12 @@ fn color(c: &faunosteo_core::pdf::write::draw_log::Rgb) -> Value {
|
||||
}
|
||||
|
||||
/// One op in the oracle's shape (without `seq`).
|
||||
fn op_json(op: &DrawOp, log: &DrawLog) -> Value {
|
||||
fn op_json(op: &DrawOp, pngs: &[Vec<u8>]) -> Value {
|
||||
match op {
|
||||
DrawOp::Text(t) => json!({ "op": "drawText", "text": t.text, "options": {
|
||||
"x": t.x, "y": t.y, "size": t.size, "font": t.font.as_str(), "color": color(&t.color) } }),
|
||||
DrawOp::Image(i) => json!({ "op": "drawImage",
|
||||
"image": { "embedIndex": i.embed, "pngSha256": sha256_hex(&log.embeds[i.embed].png) },
|
||||
"image": { "embedIndex": i.embed, "pngSha256": sha256_hex(&pngs[i.embed]) },
|
||||
"options": { "x": i.x, "y": i.y, "width": i.width, "height": i.height } }),
|
||||
DrawOp::Line(l) => json!({ "op": "drawLine", "options": {
|
||||
"start": { "x": l.start.x, "y": l.start.y }, "end": { "x": l.end.x, "y": l.end.y },
|
||||
@@ -153,7 +153,8 @@ fn compare_run(report: &str, locale: &str, mode: &str, mismatches: &mut Vec<Stri
|
||||
let input = export_input(report, locale, mode);
|
||||
let rasters = stub_rasters(&input, mode);
|
||||
let checked = check_input(input).unwrap();
|
||||
let drawn = layout(&checked, &rasters).unwrap();
|
||||
let mut keeper = PngKeeper::default();
|
||||
let drawn = layout(&checked, &rasters, &mut keeper).unwrap();
|
||||
assert!(drawn.warnings.is_empty(), "{name}: {:?}", drawn.warnings);
|
||||
let pages = oracle["pages"].as_array().unwrap();
|
||||
if pages.len() != drawn.log.pages.len() {
|
||||
@@ -177,7 +178,7 @@ fn compare_run(report: &str, locale: &str, mode: &str, mismatches: &mut Vec<Stri
|
||||
}
|
||||
for (i, (e, a)) in expected.iter().zip(actual).enumerate() {
|
||||
ops += 1;
|
||||
let a = op_json(a, &drawn.log);
|
||||
let a = op_json(a, &keeper.pngs);
|
||||
if !same(&without_seq(e), &a) {
|
||||
mismatches.push(format!(
|
||||
"{name} page {p} op {i}\n expected {}\n actual {a}",
|
||||
@@ -186,12 +187,11 @@ fn compare_run(report: &str, locale: &str, mode: &str, mismatches: &mut Vec<Stri
|
||||
}
|
||||
}
|
||||
}
|
||||
let embeds: Vec<Value> = drawn
|
||||
.log
|
||||
.embeds
|
||||
let embeds: Vec<Value> = keeper
|
||||
.pngs
|
||||
.iter()
|
||||
.enumerate()
|
||||
.map(|(i, e)| json!({ "embedIndex": i, "pngSha256": sha256_hex(&e.png) }))
|
||||
.map(|(i, png)| json!({ "embedIndex": i, "pngSha256": sha256_hex(png) }))
|
||||
.collect();
|
||||
if !same(&oracle["embeds"], &Value::Array(embeds.clone())) {
|
||||
mismatches.push(format!(
|
||||
@@ -256,7 +256,12 @@ fn step6_text_and_image_goldens_derive_from_the_log() {
|
||||
let name = format!("{report}.{locale}.{mode}");
|
||||
let input = export_input(report, locale, mode);
|
||||
let rasters = stub_rasters(&input, mode);
|
||||
let drawn = layout(&check_input(input).unwrap(), &rasters).unwrap();
|
||||
let drawn = layout(
|
||||
&check_input(input).unwrap(),
|
||||
&rasters,
|
||||
&mut PngKeeper::default(),
|
||||
)
|
||||
.unwrap();
|
||||
let text: Value = serde_json::from_str(
|
||||
&std::fs::read_to_string(goldens.join(format!("text.{name}.json"))).unwrap(),
|
||||
)
|
||||
@@ -328,7 +333,7 @@ fn page_caps_and_missing_rasters_behave_as_export_ts() {
|
||||
let first_key = rasters.views.keys().next().cloned().unwrap();
|
||||
rasters.views.remove(&first_key);
|
||||
let checked = check_input(input).unwrap();
|
||||
let drawn = layout(&checked, &rasters).unwrap();
|
||||
let drawn = layout(&checked, &rasters, &mut PngKeeper::default()).unwrap();
|
||||
assert_eq!(
|
||||
drawn.warnings,
|
||||
vec![
|
||||
@@ -363,13 +368,14 @@ fn layout_of_the_large_reports_stays_fast() {
|
||||
let checked = check_input(input).unwrap();
|
||||
let checks_ms = started.elapsed().as_millis();
|
||||
let started = std::time::Instant::now();
|
||||
let drawn = layout(&checked, &rasters).unwrap();
|
||||
let mut keeper = PngKeeper::default();
|
||||
let drawn = layout(&checked, &rasters, &mut keeper).unwrap();
|
||||
let layout_ms = started.elapsed().as_millis();
|
||||
let ops: usize = drawn.log.pages.iter().map(|p| p.ops.len()).sum();
|
||||
println!(
|
||||
"{name}: {} pages, {ops} ops, {} embeds; checks {checks_ms} ms, layout {layout_ms} ms",
|
||||
drawn.log.pages.len(),
|
||||
drawn.log.embeds.len()
|
||||
keeper.pngs.len()
|
||||
);
|
||||
assert!(layout_ms < cap_ms, "{name}: layout {layout_ms} ms");
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user