Skip to content

Commit

Permalink
Remove full feature. (#754)
Browse files Browse the repository at this point in the history
This was needed for an integration and according to Raph is no longer
needed.
  • Loading branch information
waywardmonkeys authored Nov 30, 2024
1 parent c52751b commit d112fa1
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 99 deletions.
1 change: 0 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
},
"wgsl-analyzer.diagnostics.nagaVersion": "main",
"wgsl-analyzer.preprocessor.shaderDefs": [
"full",
"msaa16",
"msaa"
],
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ This is the first step towards providing richer color functionality, better hand

- Breaking: Updated `wgpu` to 23.0.1 ([#735][], [#743][] by [@waywardmonkeys])
- Breaking: Updated to new `peniko` and `color` is now used for all colors ([#742][] by [@waywardmonkeys])
- Breaking: The `full` feature is no longer present as the full pipeline is now always built ([#754][] by [@waywardmonkeys])

### Fixed

Expand Down Expand Up @@ -210,6 +211,7 @@ This release has an [MSRV][] of 1.75.
[#740]: https://github.com/linebender/vello/pull/740
[#742]: https://github.com/linebender/vello/pull/742
[#743]: https://github.com/linebender/vello/pull/743
[#754]: https://github.com/linebender/vello/pull/754

[Unreleased]: https://github.com/linebender/vello/compare/v0.3.0...HEAD
<!-- Note that this still comparing against 0.2.0, because 0.2.1 is a cherry-picked patch -->
Expand Down
12 changes: 3 additions & 9 deletions vello_encoding/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,6 @@ default-target = "x86_64-unknown-linux-gnu"
targets = []

[features]
default = ["full"]

# Enables support for the full pipeline including late-bound
# resources (gradients, images and glyph runs)
full = ["dep:skrifa", "dep:guillotiere", "dep:smallvec"]

# Enables an optional GPU memory usage estimation utility. This can be used to
# perform additional computations in order to estimate the minimum required allocations
# for buffers backing bump-allocated GPU memory.
Expand All @@ -32,7 +26,7 @@ workspace = true

[dependencies]
bytemuck = { workspace = true }
skrifa = { workspace = true, optional = true }
skrifa = { workspace = true }
peniko = { workspace = true }
guillotiere = { version = "0.6.2", optional = true }
smallvec = { workspace = true, optional = true }
guillotiere = { version = "0.6.2" }
smallvec = { workspace = true }
39 changes: 7 additions & 32 deletions vello_encoding/src/encoding.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
// Copyright 2022 the Vello Authors
// SPDX-License-Identifier: Apache-2.0 OR MIT

use super::{DrawBlurRoundedRect, DrawColor, DrawTag, PathEncoder, PathTag, Style, Transform};
use super::{
DrawBlurRoundedRect, DrawColor, DrawImage, DrawLinearGradient, DrawRadialGradient,
DrawSweepGradient, DrawTag, Glyph, GlyphRun, Patch, PathEncoder, PathTag, Style, Transform,
};

use peniko::color::{palette, DynamicColor};
use peniko::kurbo::{Shape, Stroke};
use peniko::{BlendMode, BrushRef, Fill};

#[cfg(feature = "full")]
use {
super::{
DrawImage, DrawLinearGradient, DrawRadialGradient, DrawSweepGradient, Glyph, GlyphRun,
Patch,
},
peniko::color::{palette, DynamicColor},
peniko::{ColorStop, Extend, GradientKind, Image},
skrifa::instance::NormalizedCoord,
};
use peniko::{BlendMode, BrushRef, ColorStop, Extend, Fill, GradientKind, Image};
use skrifa::instance::NormalizedCoord;

/// Encoded data streams for a scene.
///
Expand All @@ -38,7 +32,6 @@ pub struct Encoding {
/// The style stream
pub styles: Vec<Style>,
/// Late bound resource data.
#[cfg(feature = "full")]
pub resources: Resources,
/// Number of encoded paths.
pub n_paths: u32,
Expand Down Expand Up @@ -87,13 +80,11 @@ impl Encoding {
self.n_clips = 0;
self.n_open_clips = 0;
self.flags = 0;
#[cfg(feature = "full")]
self.resources.reset();
}

/// Appends another encoding to this one with an optional transform.
pub fn append(&mut self, other: &Self, transform: &Option<Transform>) {
#[cfg(feature = "full")]
let glyph_runs_base = {
let offsets = self.stream_offsets();
let stops_base = self.resources.color_stops.len();
Expand Down Expand Up @@ -164,7 +155,6 @@ impl Encoding {
if let Some(transform) = *transform {
self.transforms
.extend(other.transforms.iter().map(|x| transform * *x));
#[cfg(feature = "full")]
for run in &mut self.resources.glyph_runs[glyph_runs_base..] {
run.transform = transform * run.transform;
}
Expand Down Expand Up @@ -266,7 +256,6 @@ impl Encoding {

/// Encodes a brush with an optional alpha modifier.
pub fn encode_brush<'b>(&mut self, brush: impl Into<BrushRef<'b>>, alpha: f32) {
#[cfg(feature = "full")]
use super::math::point_to_f32;
match brush.into() {
BrushRef::Solid(color) => {
Expand All @@ -277,7 +266,6 @@ impl Encoding {
};
self.encode_color(color);
}
#[cfg(feature = "full")]
BrushRef::Gradient(gradient) => match gradient.kind {
GradientKind::Linear { start, end } => {
self.encode_linear_gradient(
Expand Down Expand Up @@ -329,13 +317,9 @@ impl Encoding {
);
}
},
#[cfg(feature = "full")]
BrushRef::Image(image) => {
#[cfg(feature = "full")]
self.encode_image(image, alpha);
}
#[cfg(not(feature = "full"))]
_ => panic!("brushes other than solid require the 'full' feature to be enabled"),
}
}

Expand All @@ -347,7 +331,6 @@ impl Encoding {
}

/// Encodes a linear gradient brush.
#[cfg(feature = "full")]
pub fn encode_linear_gradient(
&mut self,
gradient: DrawLinearGradient,
Expand All @@ -369,7 +352,6 @@ impl Encoding {
}

/// Encodes a radial gradient brush.
#[cfg(feature = "full")]
pub fn encode_radial_gradient(
&mut self,
gradient: DrawRadialGradient,
Expand All @@ -395,7 +377,6 @@ impl Encoding {
}

/// Encodes a radial gradient brush.
#[cfg(feature = "full")]
pub fn encode_sweep_gradient(
&mut self,
gradient: DrawSweepGradient,
Expand All @@ -420,7 +401,6 @@ impl Encoding {
}

/// Encodes an image brush.
#[cfg(feature = "full")]
pub fn encode_image(&mut self, image: &Image, alpha: f32) {
let _alpha = alpha * image.alpha;
// TODO: feed the alpha multiplier through the full pipeline for consistency
Expand Down Expand Up @@ -493,7 +473,6 @@ impl Encoding {
self.path_tags.swap(len - 1, len - 2);
}

#[cfg(feature = "full")]
fn add_ramp(
&mut self,
color_stops: impl Iterator<Item = ColorStop>,
Expand Down Expand Up @@ -525,7 +504,6 @@ impl Encoding {
}
}

#[cfg(feature = "full")]
/// Result for adding a sequence of color stops.
enum RampStops {
/// Color stop sequence was empty.
Expand All @@ -537,7 +515,6 @@ enum RampStops {
}

/// Encoded data for late bound resources.
#[cfg(feature = "full")]
#[derive(Clone, Default)]
pub struct Resources {
/// Draw data patches for late bound resources.
Expand All @@ -552,7 +529,6 @@ pub struct Resources {
pub normalized_coords: Vec<NormalizedCoord>,
}

#[cfg(feature = "full")]
impl Resources {
#[doc(alias = "clear")]
// This is not called "clear" because "clear" has other implications
Expand Down Expand Up @@ -584,7 +560,6 @@ pub struct StreamOffsets {
}

impl StreamOffsets {
#[cfg(feature = "full")]
pub(crate) fn add(&mut self, other: &Self) {
self.path_tags += other.path_tags;
self.path_data += other.path_data;
Expand Down
18 changes: 4 additions & 14 deletions vello_encoding/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,13 @@ mod draw;
mod encoding;
#[cfg(feature = "bump_estimate")]
mod estimate;
#[cfg(feature = "full")]
mod glyph;
#[cfg(feature = "full")]
mod glyph_cache;
#[cfg(feature = "full")]
mod image_cache;
mod mask;
pub mod math;
mod monoid;
mod path;
#[cfg(feature = "full")]
mod ramp_cache;
mod resolve;

Expand All @@ -69,23 +65,17 @@ pub use draw::{
DrawBbox, DrawBeginClip, DrawBlurRoundedRect, DrawColor, DrawImage, DrawLinearGradient,
DrawMonoid, DrawRadialGradient, DrawSweepGradient, DrawTag, DRAW_INFO_FLAGS_FILL_RULE_BIT,
};
pub use encoding::{Encoding, StreamOffsets};
pub use encoding::{Encoding, Resources, StreamOffsets};
pub use glyph::{Glyph, GlyphRun};
pub use mask::{make_mask_lut, make_mask_lut_16};
pub use math::Transform;
pub use monoid::Monoid;
pub use path::{
Cubic, LineSoup, Path, PathBbox, PathEncoder, PathMonoid, PathSegment, PathSegmentType,
PathTag, SegmentCount, Style, Tile,
};
pub use resolve::{resolve_solid_paths_only, Layout};

#[cfg(feature = "full")]
pub use {
encoding::Resources,
glyph::{Glyph, GlyphRun},
ramp_cache::Ramps,
resolve::{Patch, Resolver},
};
pub use ramp_cache::Ramps;
pub use resolve::{resolve_solid_paths_only, Layout, Patch, Resolver};

#[cfg(feature = "bump_estimate")]
pub use estimate::BumpEstimator;
1 change: 0 additions & 1 deletion vello_encoding/src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -807,7 +807,6 @@ impl<'a> PathEncoder<'a> {
}
}

#[cfg(feature = "full")]
impl skrifa::outline::OutlinePen for PathEncoder<'_> {
fn move_to(&mut self, x: f32, y: f32) {
self.move_to(x, y);
Expand Down
23 changes: 6 additions & 17 deletions vello_encoding/src/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,15 @@
// SPDX-License-Identifier: Apache-2.0 OR MIT

use bytemuck::{Pod, Zeroable};
use peniko::{Extend, Image};
use std::ops::Range;
use std::sync::Arc;

use super::{DrawTag, Encoding, PathTag, StreamOffsets, Style, Transform};

#[cfg(feature = "full")]
use {
super::{
glyph_cache::GlyphCache,
image_cache::{ImageCache, Images},
ramp_cache::{RampCache, Ramps},
},
peniko::{Extend, Image},
std::ops::Range,
std::sync::Arc,
};
use crate::glyph_cache::GlyphCache;
use crate::image_cache::{ImageCache, Images};
use crate::ramp_cache::{RampCache, Ramps};

/// Layout of a packed encoding.
#[derive(Clone, Copy, Debug, Default, Zeroable, Pod)]
Expand Down Expand Up @@ -110,7 +105,6 @@ impl Layout {
/// Panics if the encoding contains any late bound resources (gradients, images
/// or glyph runs).
pub fn resolve_solid_paths_only(encoding: &Encoding, packed: &mut Vec<u8>) -> Layout {
#[cfg(feature = "full")]
assert!(
encoding.resources.patches.is_empty(),
"this resolve function doesn't support late bound resources"
Expand Down Expand Up @@ -160,7 +154,6 @@ pub fn resolve_solid_paths_only(encoding: &Encoding, packed: &mut Vec<u8>) -> La
}

/// Resolver for late bound resources.
#[cfg(feature = "full")]
#[derive(Default)]
pub struct Resolver {
glyph_cache: GlyphCache,
Expand All @@ -171,7 +164,6 @@ pub struct Resolver {
patches: Vec<ResolvedPatch>,
}

#[cfg(feature = "full")]
impl Resolver {
/// Creates a new resource cache.
pub fn new() -> Self {
Expand Down Expand Up @@ -507,7 +499,6 @@ impl Resolver {
}

/// Patch for a late bound resource.
#[cfg(feature = "full")]
#[derive(Clone)]
pub enum Patch {
/// Gradient ramp resource.
Expand All @@ -534,14 +525,12 @@ pub enum Patch {
}

/// Image to be allocated in the atlas.
#[cfg(feature = "full")]
#[derive(Clone, Debug)]
struct PendingImage {
image: Image,
xy: Option<(u32, u32)>,
}

#[cfg(feature = "full")]
#[derive(Clone, Debug)]
enum ResolvedPatch {
Ramp {
Expand Down
7 changes: 1 addition & 6 deletions vello_shaders/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,9 @@ default-target = "x86_64-unknown-linux-gnu"
targets = []

[features]
default = ["wgsl", "full", "cpu"]
default = ["wgsl", "cpu"]
compile = ["dep:naga", "dep:thiserror"]

# Enables the complete imaging model. When this feature is disabled, the fine rasterization
# stage only supports drawing paths with a solid brush and clipping, and the shaders can
# not be run with an encoding that contains gradient fills and images.
full = []

# Target shading language variants of the vello shaders to link into the library.
wgsl = []
msl = ["naga?/msl-out"]
Expand Down
Loading

0 comments on commit d112fa1

Please sign in to comment.