From 4b8a65268c34a040ef1f1e53411341b4f918d707 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Sat, 7 Nov 2020 14:06:14 +0100 Subject: [PATCH] Turn off anti-aliasing in debug builds by default --- CHANGELOG.md | 1 + egui/src/demos/mod.rs | 12 +----------- egui/src/lib.rs | 10 ++++++++++ egui/src/paint/tessellator.rs | 3 ++- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1aab8513..6b23d3c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ * `Context::begin_frame()` no longer returns anything. * Put your widgets into a `SidePanel`, `TopPanel`, `CentralPanel`, `Window` or `Area`. * `Context::end_frame()` now returns "paint jobs" that need to be converted to triangles with `Context::tesselate()`. +* Turn off anti-aliasing in debug builds by default. ## 0.2.0 - 2020-10-10 diff --git a/egui/src/demos/mod.rs b/egui/src/demos/mod.rs index a293af93..957d2d78 100644 --- a/egui/src/demos/mod.rs +++ b/egui/src/demos/mod.rs @@ -42,18 +42,8 @@ pub trait Demo { // ---------------------------------------------------------------------------- -#[cfg(debug_assertions)] -pub fn has_debug_assertions() -> bool { - true -} - -#[cfg(not(debug_assertions))] -pub fn has_debug_assertions() -> bool { - false -} - pub fn warn_if_debug_build(ui: &mut crate::Ui) { - if has_debug_assertions() { + if crate::has_debug_assertions() { ui.label( crate::Label::new("[Debug build]") .small() diff --git a/egui/src/lib.rs b/egui/src/lib.rs index 682cd460..06373138 100644 --- a/egui/src/lib.rs +++ b/egui/src/lib.rs @@ -122,3 +122,13 @@ pub fn text_egui_e2e() { assert!(!paint_jobs.is_empty()); } } + +#[cfg(debug_assertions)] +pub(crate) fn has_debug_assertions() -> bool { + true +} + +#[cfg(not(debug_assertions))] +pub(crate) fn has_debug_assertions() -> bool { + false +} diff --git a/egui/src/paint/tessellator.rs b/egui/src/paint/tessellator.rs index 4f3f6eef..fdbdc3ce 100644 --- a/egui/src/paint/tessellator.rs +++ b/egui/src/paint/tessellator.rs @@ -450,6 +450,7 @@ pub struct TesselationOptions { /// Size of a pixel in points, e.g. 0.5 pub aa_size: f32, /// Anti-aliasing makes shapes appear smoother, but requires more triangles and is therefore slower. + /// By default this is enabled in release builds and disabled in debug builds. pub anti_alias: bool, /// If `true` (default) cull certain primitives before tessellating them pub coarse_tessellation_culling: bool, @@ -463,7 +464,7 @@ impl Default for TesselationOptions { fn default() -> Self { Self { aa_size: 1.0, - anti_alias: true, + anti_alias: !crate::has_debug_assertions(), coarse_tessellation_culling: true, debug_paint_clip_rects: false, debug_ignore_clip_rects: false,