Skip to content

Commit

Permalink
Remove some debug asserts (emilk#4826)
Browse files Browse the repository at this point in the history
* Closes emilk#4825
  • Loading branch information
emilk authored and 486c committed Oct 9, 2024
1 parent b713f50 commit 70061e4
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions crates/ecolor/src/color32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ impl Color32 {
/// This is perceptually even, and faster that [`Self::linear_multiply`].
#[inline]
pub fn gamma_multiply(self, factor: f32) -> Self {
debug_assert!(0.0 <= factor && factor <= 1.0);
debug_assert!(0.0 <= factor && factor.is_finite());
let Self([r, g, b, a]) = self;
Self([
(r as f32 * factor + 0.5) as u8,
Expand All @@ -217,7 +217,7 @@ impl Color32 {
/// You likely want to use [`Self::gamma_multiply`] instead.
#[inline]
pub fn linear_multiply(self, factor: f32) -> Self {
debug_assert!(0.0 <= factor && factor <= 1.0);
debug_assert!(0.0 <= factor && factor.is_finite());
// As an unfortunate side-effect of using premultiplied alpha
// we need a somewhat expensive conversion to linear space and back.
Rgba::from(self).multiply(factor).into()
Expand Down
2 changes: 0 additions & 2 deletions crates/egui/src/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,6 @@ impl Layout {

pub(crate) fn region_from_max_rect(&self, max_rect: Rect) -> Region {
debug_assert!(!max_rect.any_nan());
debug_assert!(max_rect.is_finite());
let mut region = Region {
min_rect: Rect::NOTHING, // temporary
max_rect,
Expand Down Expand Up @@ -452,7 +451,6 @@ impl Layout {
fn available_from_cursor_max_rect(&self, cursor: Rect, max_rect: Rect) -> Rect {
debug_assert!(!cursor.any_nan());
debug_assert!(!max_rect.any_nan());
debug_assert!(max_rect.is_finite());

// NOTE: in normal top-down layout the cursor has moved below the current max_rect,
// but the available shouldn't be negative.
Expand Down
5 changes: 4 additions & 1 deletion crates/egui/src/placer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,10 @@ impl Placer {
/// This is what you then pass to `advance_after_rects`.
/// Use `justify_and_align` to get the inner `widget_rect`.
pub(crate) fn next_space(&self, child_size: Vec2, item_spacing: Vec2) -> Rect {
debug_assert!(child_size.is_finite() && child_size.x >= 0.0 && child_size.y >= 0.0);
debug_assert!(
0.0 <= child_size.x && 0.0 <= child_size.y,
"Negative child size: {child_size:?}"
);
self.region.sanity_check();
if let Some(grid) = &self.grid {
grid.next_cell(self.region.cursor, child_size)
Expand Down
3 changes: 2 additions & 1 deletion crates/egui/src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1144,6 +1144,7 @@ impl Ui {
}

/// Allocated the given rectangle and then adds content to that rectangle.
///
/// If the contents overflow, more space will be allocated.
/// When finished, the amount of space actually used (`min_rect`) will be allocated.
/// So you can request a lot of space and then use less.
Expand Down Expand Up @@ -2607,7 +2608,7 @@ impl Ui {
/// });
/// # });
/// ```
///
///
///
/// See also: [`Self::close_menu`] and [`Response::context_menu`].
#[inline]
Expand Down

0 comments on commit 70061e4

Please sign in to comment.