Skip to main content

skia_safe/gpu/ganesh/
backend_semaphore.rs

1use std::fmt;
2
3use skia_bindings::{self as sb, GrBackendSemaphore};
4
5use crate::prelude::*;
6
7/// Wrapper type for passing into and receiving data from Ganesh about a
8/// backend semaphore object.
9pub type BackendSemaphore = Handle<GrBackendSemaphore>;
10unsafe_send_sync!(BackendSemaphore);
11
12impl NativeDrop for GrBackendSemaphore {
13    fn drop(&mut self) {
14        unsafe { sb::C_GrBackendSemaphore_destruct(self) }
15    }
16}
17
18impl NativeClone for GrBackendSemaphore {
19    fn clone(&self) -> Self {
20        construct(|semaphore| unsafe { sb::C_GrBackendSemaphore_CopyConstruct(semaphore, self) })
21    }
22}
23
24impl fmt::Debug for BackendSemaphore {
25    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
26        f.debug_struct("BackendSemaphore")
27            .field("backend", &self.backend())
28            .field("is_initialized", &self.is_initialized())
29            .finish()
30    }
31}
32
33impl BackendSemaphore {
34    pub fn backend(&self) -> sb::GrBackendApi {
35        unsafe { sb::C_GrBackendSemaphore_backend(self.native()) }
36    }
37
38    pub(crate) fn is_initialized(&self) -> bool {
39        unsafe { sb::C_GrBackendSemaphore_isInitialized(self.native()) }
40    }
41}