mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-10-14 19:26:56 -04:00
Part of #1286: constant alpha masks are drawn white, so the page shows where soft masks are read by luminosity
A CMYK page with transparency is drawn through an alpha soft mask that covers the page (a non-isolated group). Its cover was black: opaque as alpha, but nothing shows in a reader that takes the mask's luminosity. A white cover is the same mask either way.
This commit is contained in:
1 parent
fecea5390d
commit
934d83405c
2 files changed
+11
-1
No files matched your search
@@ -605,10 +605,11 @@ fn cover(s: &mut Surface, page: Rect, level: u8, opacity: f32) {
|
||||
|
||||
/// An alpha mask of constant `alpha` over the page. A group drawn through it is a transparency
|
||||
/// group of that opacity that, unlike the writer's opacity groups, is not isolated.
|
||||
/// The cover is white, so a reader that takes every soft mask as a luminosity mask shows the same.
|
||||
fn constant_mask(s: &mut Surface, page: Rect, alpha: f32) -> krilla::mask::Mask {
|
||||
let mut sb = s.stream_builder();
|
||||
let mut ms = sb.surface();
|
||||
cover(&mut ms, page, 0, alpha);
|
||||
cover(&mut ms, page, 255, alpha);
|
||||
ms.finish();
|
||||
krilla::mask::Mask::new(sb.finish(), krilla::mask::MaskType::Alpha)
|
||||
}
|
||||
|
||||
@@ -76,3 +76,12 @@ fn soft_mask_groups_keep_screen_luminance() {
|
||||
// The page's group blends in CMYK; the mask's group measures luminance in RGB.
|
||||
assert!(t.contains("/CS/DeviceCMYK") && t.contains("/S/Luminosity") && t.contains("/CS/DeviceRGB"), "{t}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn constant_alpha_masks_are_white() {
|
||||
// #1286: a black cover hides the whole page in readers that take the mask's luminosity.
|
||||
for grouped in [true, false] {
|
||||
let t = text(&doc(ColorMode::Cmyk, grouped));
|
||||
assert!(t.contains("/S/Alpha") && t.contains("111rg") && !t.contains("000rg"), "grouped {grouped}: {t}");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user