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>>, timer_refresh_driver: &LazyCell<Rc<TimerRefreshDriver>>, ) -> Self
pub(crate) fn add_observer(&self, observer: Rc<dyn RefreshDriverObserver>)
Sourcepub(crate) fn notify_will_paint(&self, painter: &mut Painter) -> bool
pub(crate) fn notify_will_paint(&self, painter: &mut Painter) -> bool
Notify the observers that a frame is about to be painted. Returns whether they were notified, which they are not while waiting for the next frame to start. When they are not notified, it is the caller’s responsibility to ensure that a paint happens once the next frame starts, so that the observers are notified then.
fn observe_next_frame(&self)
Sourcepub(crate) fn wait_to_paint(&self) -> bool
pub(crate) fn wait_to_paint(&self) -> 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 we are still waiting for a new
frame from the RefreshDriver.
Auto Trait Implementations§
impl !Freeze for BaseRefreshDriver
impl !RefUnwindSafe for BaseRefreshDriver
impl !Send for BaseRefreshDriver
impl !Sync for BaseRefreshDriver
impl !UnwindSafe for BaseRefreshDriver
impl Unpin for BaseRefreshDriver
impl UnsafeUnpin 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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> ErasedDestructor for Twhere
T: 'static,
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