mirror of
https://github.com/emilk/egui.git
synced 2026-09-02 06:40:06 -04:00
Refactor TessellationOptions to expose slider for feathering size (#1408)
The epaint tessellator uses "feathering" to accomplish anti-aliasing. This PS allows you to control the feathering size, i.e. how blurry the edges of epaint shapes are. This changes the interface of Tessellator slightly, and renames some options in TessellationOptions.
This commit is contained in:
@@ -807,14 +807,16 @@ impl Context {
|
||||
// shapes are the same, but just comparing the shapes takes about 50% of the time
|
||||
// it takes to tessellate them, so it is not a worth optimization.
|
||||
|
||||
let mut tessellation_options = *self.tessellation_options();
|
||||
tessellation_options.pixels_per_point = self.pixels_per_point();
|
||||
tessellation_options.aa_size = 1.0 / self.pixels_per_point();
|
||||
let pixels_per_point = self.pixels_per_point();
|
||||
let tessellation_options = *self.tessellation_options();
|
||||
let font_image_size = self.fonts().font_image_size();
|
||||
|
||||
let paint_stats = PaintStats::from_shapes(&shapes);
|
||||
let clipped_primitives = tessellator::tessellate_shapes(
|
||||
shapes,
|
||||
pixels_per_point,
|
||||
tessellation_options,
|
||||
self.fonts().font_image_size(),
|
||||
shapes,
|
||||
font_image_size,
|
||||
);
|
||||
self.write().paint_stats = paint_stats.with_clipped_primitives(&clipped_primitives);
|
||||
clipped_primitives
|
||||
|
||||
@@ -139,9 +139,8 @@ impl Widget for &mut epaint::TessellationOptions {
|
||||
fn ui(self, ui: &mut Ui) -> Response {
|
||||
ui.vertical(|ui| {
|
||||
let epaint::TessellationOptions {
|
||||
pixels_per_point: _,
|
||||
aa_size: _,
|
||||
anti_alias,
|
||||
feathering,
|
||||
feathering_size_in_pixels,
|
||||
coarse_tessellation_culling,
|
||||
round_text_to_pixels,
|
||||
debug_paint_clip_rects,
|
||||
@@ -150,8 +149,15 @@ impl Widget for &mut epaint::TessellationOptions {
|
||||
bezier_tolerance,
|
||||
epsilon: _,
|
||||
} = self;
|
||||
ui.checkbox(anti_alias, "Antialias")
|
||||
|
||||
ui.checkbox(feathering, "Feathering (antialias)")
|
||||
.on_hover_text("Apply feathering to smooth out the edges of shapes. Turn off for small performance gain.");
|
||||
let feathering_slider = crate::Slider::new(feathering_size_in_pixels, 0.0..=10.0)
|
||||
.smallest_positive(0.1)
|
||||
.logarithmic(true)
|
||||
.text("Feathering size in pixels");
|
||||
ui.add_enabled(*feathering, feathering_slider);
|
||||
|
||||
ui.add(
|
||||
crate::widgets::Slider::new(bezier_tolerance, 0.0001..=10.0)
|
||||
.logarithmic(true)
|
||||
|
||||
Reference in New Issue
Block a user