mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-10-29 20:47:32 -06:00
* M2: clip intersection starts its row walk at the first shared row clip::intersect in vello_common, the step every clipped path passes through, began its walk over strip rows at the earlier of the two paths' first rows. Each path therefore visited every row above it, although rows where one path has no strips produce no output. Every page is clipped (the crop box is a clip), so this ran for every stroke of every render: on the A1 engineering sample it was the hottest function in a full-page render. Start at the later first row, as vello_common 0.1 does. The strips and the pixels are unchanged; a test counts the rows the walk visits and fails without the change. vello_common 0.0.8 is vendored with that one-line PdfCraft patch (marked in the source), its unit test, the vendor/README.md row and an ATTRIBUTION.toml entry for its reference image. Cargo.lock records it as a path crate. Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com> * Refresh catalog hashes after merging main --------- Co-authored-by: Claude Haiku 5.5 <noreply@anthropic.com> Co-authored-by: Brandon Thomas <echelon@gmail.com>
57 lines
1.6 KiB
Rust
57 lines
1.6 KiB
Rust
// Copyright 2025 the Vello Authors
|
|
// SPDX-License-Identifier: Apache-2.0 OR MIT
|
|
|
|
//! Shared render state.
|
|
|
|
use crate::kurbo::{Affine, Cap, Join, Stroke};
|
|
use crate::paint::{PaintType, Tint};
|
|
use crate::peniko::color::palette::css::BLACK;
|
|
use crate::peniko::{BlendMode, Compose, Fill, Mix};
|
|
|
|
/// A render state which contains the style properties for path rendering and
|
|
/// the current transform.
|
|
#[derive(Debug, Clone)]
|
|
pub struct RenderState {
|
|
/// The paint type (solid color, gradient, or image).
|
|
pub paint: PaintType,
|
|
/// Transform applied to the paint coordinates.
|
|
pub paint_transform: Affine,
|
|
/// Stroke style for path stroking operations.
|
|
pub stroke: Stroke,
|
|
/// Transform applied to geometry.
|
|
pub transform: Affine,
|
|
/// Fill rule for path filling operations.
|
|
pub fill_rule: Fill,
|
|
/// Blend mode for compositing.
|
|
pub blend_mode: BlendMode,
|
|
/// The tint for image painting.
|
|
pub tint: Option<Tint>,
|
|
}
|
|
|
|
impl Default for RenderState {
|
|
fn default() -> Self {
|
|
Self {
|
|
paint: BLACK.into(),
|
|
paint_transform: Affine::IDENTITY,
|
|
stroke: Stroke {
|
|
width: 1.0,
|
|
join: Join::Bevel,
|
|
start_cap: Cap::Butt,
|
|
end_cap: Cap::Butt,
|
|
..Default::default()
|
|
},
|
|
transform: Affine::IDENTITY,
|
|
fill_rule: Fill::NonZero,
|
|
blend_mode: BlendMode::new(Mix::Normal, Compose::SrcOver),
|
|
tint: None,
|
|
}
|
|
}
|
|
}
|
|
|
|
impl RenderState {
|
|
/// Reset to default state.
|
|
pub fn reset(&mut self) {
|
|
*self = Self::default();
|
|
}
|
|
}
|