pub(crate) struct BaseRefreshDriver {
waiting_for_frame: Arc<AtomicBool>,
event_loop_waker: Box<dyn EventLoopWaker>,
observers: RefCell<Vec<Rc<dyn RefreshDriverObserver>>>,
refresh_driver: Rc<dyn RefreshDriver>,
}Expand description
The BaseRefreshDriver is a “base class” for RefreshDriver trait
implementations. It encapsulates shared behavior so that it does not have to be
implemented by all trait implementations. It is responsible for providing
RefreshDriver implementations with a callback that is used to wake up the event
loop and trigger frame readiness.
Fields§
§waiting_for_frame: Arc<AtomicBool>Whether or not the BaseRefreshDriver is waiting for a frame. Once the RefreshDriver
informs the base that a frame start happened, this becomes false.
event_loop_waker: Box<dyn EventLoopWaker>An [EventLooperWaker] which alerts the main UI event loop when a frame start occurs.
observers: RefCell<Vec<Rc<dyn RefreshDriverObserver>>>A list of internal observers that watch for frame starts.
refresh_driver: Rc<dyn RefreshDriver>The implementation of the RefreshDriver. By default this is a simple timer, but the
embedder can install a custom driver, such as one that is run via the hardware vsync signal.
Implementations§
Source§impl BaseRefreshDriver
impl BaseRefreshDriver
pub(crate) fn new( event_loop_waker: Box<dyn EventLoopWaker>, refresh_driver: Option<Rc<dyn RefreshDriver>>, ) -> Self
pub(crate) fn add_observer(&self, observer: Rc<dyn RefreshDriverObserver>)
pub(crate) fn notify_will_paint(&self, painter: &mut Painter)
fn observe_next_frame(&self)
Sourcepub(crate) fn wait_to_paint(&self, repaint_reason: RepaintReason) -> bool
pub(crate) fn wait_to_paint(&self, repaint_reason: RepaintReason) -> bool
Whether or not the renderer should trigger a message to the embedder to request a repaint. This might be true if we are animating and the repaint reason is just for a new frame. In that case, the renderer should wait until the frame timeout to ask the embedder to repaint.
Auto Trait Implementations§
impl !Freeze for BaseRefreshDriver
impl !RefUnwindSafe for BaseRefreshDriver
impl !Send for BaseRefreshDriver
impl !Sync for BaseRefreshDriver
impl Unpin for BaseRefreshDriver
impl !UnwindSafe for BaseRefreshDriver
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more