1
0
mirror of https://github.com/emilk/egui.git synced 2026-06-28 07:23:13 -04:00

Remove epaint::mutex::Arc type alias

This commit is contained in:
Emil Ernerfeldt
2022-04-15 15:18:04 +02:00
parent 5a78213421
commit 2355828d41
18 changed files with 35 additions and 42 deletions

View File

@@ -142,11 +142,6 @@ mod rw_lock_impl {
}
}
#[cfg(not(target_arch = "wasm32"))]
mod arc_impl {
pub use std::sync::Arc;
}
// ----------------------------------------------------------------------------
#[cfg(target_arch = "wasm32")]
@@ -211,15 +206,8 @@ mod rw_lock_impl {
}
}
#[cfg(target_arch = "wasm32")]
mod arc_impl {
// pub use std::rc::Rc as Arc; // TODO(emilk): optimize single threaded code by using `Rc` instead of `Arc`.
pub use std::sync::Arc;
}
// ----------------------------------------------------------------------------
pub use arc_impl::Arc;
pub use mutex_impl::{Mutex, MutexGuard};
pub use rw_lock_impl::{RwLock, RwLockReadGuard, RwLockWriteGuard};

View File

@@ -1,5 +1,7 @@
//! The different shapes that can be painted.
use std::sync::Arc;
use crate::{
text::{FontId, Fonts, Galley},
Color32, Mesh, Stroke, TextureId,
@@ -175,17 +177,13 @@ impl Shape {
}
#[inline]
pub fn galley(pos: Pos2, galley: crate::mutex::Arc<Galley>) -> Self {
pub fn galley(pos: Pos2, galley: Arc<Galley>) -> Self {
TextShape::new(pos, galley).into()
}
#[inline]
/// The text color in the [`Galley`] will be replaced with the given color.
pub fn galley_with_color(
pos: Pos2,
galley: crate::mutex::Arc<Galley>,
text_color: Color32,
) -> Self {
pub fn galley_with_color(pos: Pos2, galley: Arc<Galley>, text_color: Color32) -> Self {
TextShape {
override_text_color: Some(text_color),
..TextShape::new(pos, galley)
@@ -549,7 +547,7 @@ pub struct TextShape {
pub pos: Pos2,
/// The layed out text, from [`Fonts::layout_job`].
pub galley: crate::mutex::Arc<Galley>,
pub galley: Arc<Galley>,
/// Add this underline to the whole text.
/// You can also set an underline when creating the galley.
@@ -567,7 +565,7 @@ pub struct TextShape {
impl TextShape {
#[inline]
pub fn new(pos: Pos2, galley: crate::mutex::Arc<Galley>) -> Self {
pub fn new(pos: Pos2, galley: Arc<Galley>) -> Self {
Self {
pos,
galley,
@@ -734,7 +732,7 @@ pub struct PaintCallback {
///
/// The rendering backend is also responsible for restoring any state,
/// such as the bound shader program and vertex array.
pub callback: std::sync::Arc<dyn Fn(&PaintCallbackInfo, &dyn std::any::Any) + Send + Sync>,
pub callback: Arc<dyn Fn(&PaintCallbackInfo, &dyn std::any::Any) + Send + Sync>,
}
impl PaintCallback {
@@ -758,7 +756,7 @@ impl std::cmp::PartialEq for PaintCallback {
// can only happen if we do dynamic casts back and forth on the pointers, and we don't do that.
#[allow(clippy::vtable_address_comparisons)]
{
self.rect.eq(&other.rect) && std::sync::Arc::ptr_eq(&self.callback, &other.callback)
self.rect.eq(&other.rect) && Arc::ptr_eq(&self.callback, &other.callback)
}
}
}

View File

@@ -1,10 +1,11 @@
use crate::{
mutex::{Arc, Mutex, RwLock},
mutex::{Mutex, RwLock},
TextureAtlas,
};
use ahash::AHashMap;
use emath::{vec2, Vec2};
use std::collections::BTreeSet;
use std::sync::Arc;
// ----------------------------------------------------------------------------

View File

@@ -1,7 +1,8 @@
use std::collections::BTreeMap;
use std::sync::Arc;
use crate::{
mutex::{Arc, Mutex, MutexGuard},
mutex::{Mutex, MutexGuard},
text::{
font::{Font, FontImpl},
Galley, LayoutJob,

View File

@@ -1,7 +1,8 @@
use std::ops::RangeInclusive;
use std::sync::Arc;
use super::{FontsImpl, Galley, Glyph, LayoutJob, LayoutSection, Row, RowVisuals};
use crate::{mutex::Arc, Color32, Mesh, Stroke, Vertex};
use crate::{Color32, Mesh, Stroke, Vertex};
use emath::*;
// ----------------------------------------------------------------------------

View File

@@ -1,9 +1,10 @@
#![allow(clippy::derive_hash_xor_eq)] // We need to impl Hash for f32, but we don't implement Eq, which is fine
use std::ops::Range;
use std::sync::Arc;
use super::{cursor::*, font::UvRect};
use crate::{mutex::Arc, Color32, FontId, Mesh, Stroke};
use crate::{Color32, FontId, Mesh, Stroke};
use emath::*;
/// Describes the task of laying out text.

View File

@@ -1,8 +1,6 @@
use crate::{
emath::NumExt,
mutex::{Arc, RwLock},
ImageData, ImageDelta, TextureId, TextureManager,
};
use std::sync::Arc;
use crate::{emath::NumExt, mutex::RwLock, ImageData, ImageDelta, TextureId, TextureManager};
/// Used to paint images.
///