| 11 | |
| 12 | impl Capturer { |
| 13 | pub fn new(display: Display) -> io::Result<Capturer> { |
| 14 | let frame = Arc::new(Mutex::new(None)); |
| 15 | |
| 16 | let f = frame.clone(); |
| 17 | let inner = quartz::Capturer::new( |
| 18 | display.0, |
| 19 | display.width(), |
| 20 | display.height(), |
| 21 | quartz::PixelFormat::Argb8888, |
| 22 | Default::default(), |
| 23 | move |inner| { |
| 24 | if let Ok(mut f) = f.lock() { |
| 25 | *f = Some(inner); |
| 26 | } |
| 27 | }, |
| 28 | ) |
| 29 | .map_err(|_| io::Error::from(io::ErrorKind::Other))?; |
| 30 | |
| 31 | Ok(Capturer { |
| 32 | inner, |
| 33 | frame, |
| 34 | saved_raw_data: Vec::new(), |
| 35 | }) |
| 36 | } |
| 37 | |
| 38 | pub fn width(&self) -> usize { |
| 39 | self.inner.width() |