Add #[inline(always)] here and there
This commit is contained in:
parent
0f1df90d90
commit
1681769329
4 changed files with 24 additions and 0 deletions
|
@ -455,6 +455,7 @@ impl Context {
|
|||
}
|
||||
|
||||
/// The number of physical pixels for each logical point.
|
||||
#[inline(always)]
|
||||
pub fn pixels_per_point(&self) -> f32 {
|
||||
self.input.pixels_per_point()
|
||||
}
|
||||
|
|
|
@ -110,6 +110,7 @@ impl InputState {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn screen_rect(&self) -> Rect {
|
||||
self.screen_rect
|
||||
}
|
||||
|
@ -160,17 +161,20 @@ impl InputState {
|
|||
}
|
||||
|
||||
/// Also known as device pixel ratio, > 1 for high resolution screens.
|
||||
#[inline(always)]
|
||||
pub fn pixels_per_point(&self) -> f32 {
|
||||
self.pixels_per_point
|
||||
}
|
||||
|
||||
/// Size of a physical pixel in logical gui coordinates (points).
|
||||
#[inline(always)]
|
||||
pub fn physical_pixel_size(&self) -> f32 {
|
||||
1.0 / self.pixels_per_point()
|
||||
}
|
||||
|
||||
/// How imprecise do we expect the mouse/touch input to be?
|
||||
/// Returns imprecision in points.
|
||||
#[inline(always)]
|
||||
pub fn aim_radius(&self) -> f32 {
|
||||
// TODO: multiply by ~3 for touch inputs because fingers are fat
|
||||
self.physical_pixel_size()
|
||||
|
@ -488,10 +492,12 @@ impl PointerState {
|
|||
// }
|
||||
|
||||
/// Is this button currently down?
|
||||
#[inline(always)]
|
||||
pub fn button_down(&self, button: PointerButton) -> bool {
|
||||
self.down[button as usize]
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub(crate) fn could_any_button_be_click(&self) -> bool {
|
||||
self.could_be_click
|
||||
}
|
||||
|
|
|
@ -83,43 +83,51 @@ impl Painter {
|
|||
|
||||
/// ## Accessors etc
|
||||
impl Painter {
|
||||
#[inline(always)]
|
||||
pub(crate) fn ctx(&self) -> &CtxRef {
|
||||
&self.ctx
|
||||
}
|
||||
|
||||
/// Available fonts
|
||||
#[inline(always)]
|
||||
pub(crate) fn fonts(&self) -> &Fonts {
|
||||
self.ctx.fonts()
|
||||
}
|
||||
|
||||
/// Where we paint
|
||||
#[inline(always)]
|
||||
pub fn layer_id(&self) -> LayerId {
|
||||
self.layer_id
|
||||
}
|
||||
|
||||
/// Everything painted in this `Painter` will be clipped against this.
|
||||
/// This means nothing outside of this rectangle will be visible on screen.
|
||||
#[inline(always)]
|
||||
pub fn clip_rect(&self) -> Rect {
|
||||
self.clip_rect
|
||||
}
|
||||
|
||||
/// Everything painted in this `Painter` will be clipped against this.
|
||||
/// This means nothing outside of this rectangle will be visible on screen.
|
||||
#[inline(always)]
|
||||
pub fn set_clip_rect(&mut self, clip_rect: Rect) {
|
||||
self.clip_rect = clip_rect;
|
||||
}
|
||||
|
||||
/// Useful for pixel-perfect rendering
|
||||
#[inline(always)]
|
||||
pub fn round_to_pixel(&self, point: f32) -> f32 {
|
||||
self.ctx().round_to_pixel(point)
|
||||
}
|
||||
|
||||
/// Useful for pixel-perfect rendering
|
||||
#[inline(always)]
|
||||
pub fn round_vec_to_pixels(&self, vec: Vec2) -> Vec2 {
|
||||
self.ctx().round_vec_to_pixels(vec)
|
||||
}
|
||||
|
||||
/// Useful for pixel-perfect rendering
|
||||
#[inline(always)]
|
||||
pub fn round_pos_to_pixels(&self, pos: Pos2) -> Pos2 {
|
||||
self.ctx().round_pos_to_pixels(pos)
|
||||
}
|
||||
|
|
|
@ -99,11 +99,13 @@ impl Ui {
|
|||
// -------------------------------------------------
|
||||
|
||||
/// A unique identity of this `Ui`.
|
||||
#[inline(always)]
|
||||
pub fn id(&self) -> Id {
|
||||
self.id
|
||||
}
|
||||
|
||||
/// Style options for this `Ui` and its children.
|
||||
#[inline(always)]
|
||||
pub fn style(&self) -> &std::sync::Arc<Style> {
|
||||
&self.style
|
||||
}
|
||||
|
@ -131,6 +133,7 @@ impl Ui {
|
|||
|
||||
/// The current spacing options for this `Ui`.
|
||||
/// Short for `ui.style().spacing`.
|
||||
#[inline(always)]
|
||||
pub fn spacing(&self) -> &crate::style::Spacing {
|
||||
&self.style.spacing
|
||||
}
|
||||
|
@ -149,6 +152,7 @@ impl Ui {
|
|||
|
||||
/// The current visuals settings of this `Ui`.
|
||||
/// Short for `ui.style().visuals`.
|
||||
#[inline(always)]
|
||||
pub fn visuals(&self) -> &crate::Visuals {
|
||||
&self.style.visuals
|
||||
}
|
||||
|
@ -168,17 +172,20 @@ impl Ui {
|
|||
}
|
||||
|
||||
/// Get a reference to the parent [`CtxRef`].
|
||||
#[inline(always)]
|
||||
pub fn ctx(&self) -> &CtxRef {
|
||||
self.painter.ctx()
|
||||
}
|
||||
|
||||
/// Use this to paint stuff within this `Ui`.
|
||||
#[inline(always)]
|
||||
pub fn painter(&self) -> &Painter {
|
||||
&self.painter
|
||||
}
|
||||
|
||||
/// If `false`, the `Ui` does not allow any interaction and
|
||||
/// the widgets in it will draw with a gray look.
|
||||
#[inline(always)]
|
||||
pub fn enabled(&self) -> bool {
|
||||
self.enabled
|
||||
}
|
||||
|
@ -210,6 +217,7 @@ impl Ui {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn layout(&self) -> &Layout {
|
||||
self.placer.layout()
|
||||
}
|
||||
|
@ -242,6 +250,7 @@ impl Ui {
|
|||
|
||||
/// The `Input` of the `Context` associated with the `Ui`.
|
||||
/// Equivalent to `.ctx().input()`.
|
||||
#[inline(always)]
|
||||
pub fn input(&self) -> &InputState {
|
||||
self.ctx().input()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue