Effects: a cached effect raster follows whether placed documents draw from background bitmaps

Placed documents draw exactly instead of from a background bitmap in
Overprint Preview, under a proof, in Outline and in other inks. A
raster's inputs now hold that choice, from the same check that draws
placed documents (placed_document::progressive_bitmaps), so turning
Overprint Preview on before a bitmap is ready no longer leaves its
placeholder in a raster kept across pans. The count of bitmaps made is
still hashed whenever background bitmaps are on, since art drawn in
another ink, such as an opacity mask, can still use them.
This commit is contained in:
dotCooCoo committed 2026-12-04 22:28:30 -08:00
1 parent 4f421c32ae
commit d445184a1f
3 files changed
+58 -13

No files matched your search

+16 -11
View File
@@ -599,16 +599,17 @@ impl Renderer {
/// a Rasterize or De-Interlace anywhere in the content follows), the knockout `n` inherits and,
/// while `n` holds the isolated group, isolation mode; the pattern definitions, symbols and
/// brush library it reads; for images and placed documents their pixels and files, the
/// layer's Dim Images, the options they are drawn with, and (with
/// [`crate::RenderOptions::kept_images_only`]) which pixels and undecodable notes the image
/// store holds; for content that holds placed documents, shows symbol art or uses brushed
/// strokes, the global bitmap generation ([`crate::placed_document::generation`]) while
/// progressive previews are on (pattern tiles draw with them off); for type the fonts and the
/// layer's Dim Images and the options they are drawn with (with
/// [`crate::RenderOptions::kept_images_only`], also which pixels and undecodable notes the
/// image store holds); for content that holds placed documents, shows symbol art or uses
/// brushed strokes, whether placed documents draw from background bitmaps
/// ([`crate::placed_document::progressive_bitmaps`]) and, when progressive previews are on,
/// how many bitmaps are ready ([`crate::placed_document::generation`]); for type the fonts and the
/// hyphenation exceptions, whether overprinting shows ([`crate::proof::overprints`]) and
/// Document Setup's substitution highlights; and the plug-ins installed, with the names of
/// the document's swatches and patterns and its pattern definitions (a plug-in's painted
/// pieces can name them), when an object in it has a plug-in effect, and when it shows symbol
/// or pattern art and an object in the document's symbol or pattern art has one.
/// Document Setup's substitution highlights; and the plug-ins installed, with the names of the
/// document's swatches and patterns and its pattern definitions (a plug-in's painted pieces
/// can name them), when an object in it has a plug-in effect, and when it shows symbol or
/// pattern art and an object in the document's symbol or pattern art has one.
pub(crate) fn raster_inputs(&mut self, f: &Frame, n: &Node, reads: Reads) -> Inputs {
let doc = self.doc_inputs(f.doc);
let mut h = DefaultHasher::new();
@@ -641,8 +642,12 @@ impl Renderer {
// or notes an image as undecodable.
o.kept_images_only.then(|| crate::images::store().added()).hash(&mut h);
}
if reads.placed_documents && o.progressive_placed {
crate::placed_document::generation().hash(&mut h);
if reads.placed_documents {
let progressive = crate::placed_document::progressive_bitmaps(f);
progressive.hash(&mut h);
if f.opts.progressive_placed {
crate::placed_document::generation().hash(&mut h);
}
}
if reads.brushes {
self.brushes.library_key(f.doc, self.stamp).hash(&mut h);
+6 -2
View File
@@ -550,6 +550,11 @@ fn mean_scale(a: Affine) -> f64 {
a.determinant().abs().sqrt()
}
/// Whether frame `f` allows placed documents to draw from progressive bitmaps.
pub(crate) fn progressive_bitmaps(f: &Frame) -> bool {
f.opts.progressive_placed && f.ink == Ink::Display && !f.opts.outline && f.opts.proof.is_none() && !f.opts.overprint_preview
}
impl Renderer {
/// Draw placed document `p` in frame `f`: from a cached bitmap on screen, else exactly; in
/// Outline mode without Document Setup → Show Images in Outline Mode, its box crossed from
@@ -558,8 +563,7 @@ impl Renderer {
if self.crosses_placed(f) {
return self.draw_crossed_placed(ctx, f, p);
}
let plain = f.ink == Ink::Display && !f.opts.outline && f.opts.proof.is_none() && !f.opts.overprint_preview;
if f.opts.progressive_placed && plain && depth() == 0 && self.draw_placed_bitmap(ctx, f, p) {
if progressive_bitmaps(f) && depth() == 0 && self.draw_placed_bitmap(ctx, f, p) {
return;
}
let Some(blob) = f.doc.images.get(&p.key) else { return };
@@ -614,6 +614,42 @@ fn a_ready_placed_bitmap_filters_the_whole_object_raster_again_after_a_pan() {
assert!(pixels == fresh, "a ready placed bitmap filters the content again after a whole-pixel pan");
}
/// A group with a whole-object effect that holds a placed document's placeholder filters its
/// content again when Overprint Preview turns on and the view pans by whole pixels before the
/// bitmap is ready.
#[test]
fn overprint_preview_filters_the_whole_object_raster_again_after_a_pan() {
let _serial = serial();
vectorcraft_doc::placed_document::set_loader(gated_blue_page);
let mut d = Document::new(100.0, 100.0);
let key = "whole-object-overprint-preview-1";
d.images.insert(key.into(), ImageBlob::new("application/json", b"blue whole-object overprint preview".to_vec()));
let white = Node::path(
d.alloc_id(),
shapes::rectangle(Rect::new(100.0, 100.0, 300.0, 250.0)),
Appearance::basic(Paint::solid(Color::WHITE), Paint::None, 0.0),
);
let placed = placed_node(d.alloc_id().0, key, 40.0, 20.0, Affine::translate((280.0, 170.0)) * Affine::scale(0.5));
let mut group = Node::group(d.alloc_id(), vec![Arc::new(white), Arc::new(placed)]);
group.appearance.effects =
vec![vectorcraft_doc::Effect { id: "blur.radial".into(), params: serde_json::json!({"amount": 1, "quality": "draft"}), visible: true }];
let l = d.layers[0].id;
d.insert(Some(l), 0, group).unwrap();
let opts = RenderOptions { background: Some([255, 255, 255, 255]), progressive_placed: true, ..Default::default() };
let view = |dx: f64| Affine::translate((640.0 + dx, 400.0)) * Affine::scale(64.0) * Affine::translate((-290.0, -175.0));
let gate = shut_gate();
let mut r = Renderer::new();
let _ = r.render(&d, 1280, 800, view(0.0), &opts);
let placeholder = Renderer::new().render(&d, 1280, 800, view(40.0), &opts).pixels;
let opts = RenderOptions { overprint_preview: true, ..opts };
let fresh = Renderer::new().render(&d, 1280, 800, view(40.0), &opts).pixels;
assert!(fresh != placeholder, "Overprint Preview draws the placed art before its bitmap is ready");
let pixels = r.render(&d, 1280, 800, view(40.0), &opts).pixels;
assert!(pixels == fresh, "Overprint Preview filters the content again after a whole-pixel pan");
drop(gate);
settle();
}
/// A group with a whole-object effect that holds only an ordinary image keeps its raster after a
/// placed document's bitmap in another document is ready and the view pans by whole pixels.
#[test]