core: graphics: use AtomicPtr
This type is required to implement both the Send and Sync trait.
This commit is contained in:
parent
78f389beaa
commit
ab033c1f21
1 changed files with 5 additions and 4 deletions
|
|
@ -18,6 +18,7 @@ use std::fs::File;
|
||||||
use std::io::Read;
|
use std::io::Read;
|
||||||
use std::iter;
|
use std::iter;
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
|
use std::sync::atomic::AtomicPtr;
|
||||||
use xkeysym::Keysym;
|
use xkeysym::Keysym;
|
||||||
|
|
||||||
fn convert_gray_to_bgrx(mut dest: ImgRefMut<BGRA<u8>>, src: ImgRef<u8>, fg_color: BGR<f32>)
|
fn convert_gray_to_bgrx(mut dest: ImgRefMut<BGRA<u8>>, src: ImgRef<u8>, fg_color: BGR<f32>)
|
||||||
|
|
@ -79,7 +80,7 @@ pub struct Graphics<D: Display> {
|
||||||
fontbufs: Vec<Vec<u8>>,
|
fontbufs: Vec<Vec<u8>>,
|
||||||
labels: HashMap<Keysym, ImgVec<u8>>,
|
labels: HashMap<Keysym, ImgVec<u8>>,
|
||||||
sublabels: HashMap<Keysym, ImgVec<u8>>,
|
sublabels: HashMap<Keysym, ImgVec<u8>>,
|
||||||
ft: freetype::FT_Library,
|
ft: AtomicPtr<freetype::FT_LibraryRec_>,
|
||||||
|
|
||||||
x_scale: f64,
|
x_scale: f64,
|
||||||
y_scale: f64,
|
y_scale: f64,
|
||||||
|
|
@ -206,7 +207,7 @@ impl<D: Display> Graphics<D> {
|
||||||
panic!("FreeType error {}", err);
|
panic!("FreeType error {}", err);
|
||||||
}
|
}
|
||||||
|
|
||||||
ft
|
AtomicPtr::new(ft)
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -293,7 +294,7 @@ impl<D: Display> Graphics<D> {
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
let mut ftface = std::ptr::null_mut();
|
let mut ftface = std::ptr::null_mut();
|
||||||
freetype::FT_New_Memory_Face(self.ft,
|
freetype::FT_New_Memory_Face(*self.ft.get_mut(),
|
||||||
fontbuf.as_ptr(),
|
fontbuf.as_ptr(),
|
||||||
fontbuf.len() as freetype::FT_Long,
|
fontbuf.len() as freetype::FT_Long,
|
||||||
self.fonts[idx].1 as freetype::FT_Long,
|
self.fonts[idx].1 as freetype::FT_Long,
|
||||||
|
|
@ -686,7 +687,7 @@ impl<D: Display> Drop for Graphics<D> {
|
||||||
fn drop(&mut self)
|
fn drop(&mut self)
|
||||||
{
|
{
|
||||||
unsafe {
|
unsafe {
|
||||||
freetype::FT_Done_FreeType(self.ft);
|
freetype::FT_Done_FreeType(*self.ft.get_mut());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue