pub fn update(&mut self, pixels_per_point: f32) -> Option<EguiFrame> {
        if self.fonts.is_none() {
            self.fonts = Some(Fonts::new(pixels_per_point, self.font_definitions.clone()));
        }
        let fonts = self.fonts.as_mut().unwrap();
        if pixels_per_point != fonts.pixels_per_point() {
            *fonts = Fonts::new(pixels_per_point, self.font_definitions.clone());
        }

        while let Ok(msg) = self.incoming_msg_rx.try_recv() {
            match msg {
                ServerToClientMessage::Fonts { font_definitions } => {
                    self.font_definitions = font_definitions;
                    *fonts = Fonts::new(pixels_per_point, self.font_definitions.clone());
                }
                ServerToClientMessage::Frame {
                    frame_index,
                    output,
                    clipped_net_shapes,
                    client_time,
                } => {
                    let clipped_shapes =
                        crate::net_shape::from_clipped_net_shapes(fonts, clipped_net_shapes);
                    let tesselator_options =
                        egui::epaint::tessellator::TessellationOptions::from_pixels_per_point(
                            pixels_per_point,
                        );
                    let tex_size = fonts.font_image().size();
                    let clipped_meshes = egui::epaint::tessellator::tessellate_shapes(
                        clipped_shapes,
                        tesselator_options,
                        tex_size,
                    );

                    let latest_frame = self.latest_frame.get_or_insert_with(EguiFrame::default);
                    latest_frame.frame_index = frame_index;
                    latest_frame.output.append(output);
                    latest_frame.clipped_meshes = clipped_meshes;

                    if let Some(client_time) = client_time {
                        let rtt = (now() - client_time) as f32;
                        self.latency_history.add(now(), rtt);
                    }

                    self.frame_history.add(now(), ());
                }
            }
        }

        fonts.end_frame(); // make sure to evict galley cache

        self.bandwidth_history.lock().flush(now());
        self.frame_size_history.lock().flush(now());
        self.latency_history.flush(now());
        self.frame_history.flush(now());

        self.latest_frame.take()
    }
/// Retrieved new events, and gives back what to do.
///
/// Return `None` when there is nothing new.
Retrieved new events, and gives back what to do.
Return `None` when there is nothing new.
Retrieved new events and gives back what to do . Return ` None ` when there is nothing new .
pub fn update(&mut self, pixels_per_point: f32) -> Option<EguiFrame> {
        if self.fonts.is_none() {
            self.fonts = Some(Fonts::new(pixels_per_point, self.font_definitions.clone()));
        }
        let fonts = self.fonts.as_mut().unwrap();
        if pixels_per_point != fonts.pixels_per_point() {
            *fonts = Fonts::new(pixels_per_point, self.font_definitions.clone());
        }
        while let Ok(msg) = self.incoming_msg_rx.try_recv() {
            match msg {
                ServerToClientMessage::Fonts { font_definitions } => {
                    self.font_definitions = font_definitions;
                    *fonts = Fonts::new(pixels_per_point, self.font_definitions.clone());
                }
                ServerToClientMessage::Frame {
                    frame_index,
                    output,
                    clipped_net_shapes,
                    client_time,
                } => {
                    let clipped_shapes =
                        crate::net_shape::from_clipped_net_shapes(fonts, clipped_net_shapes);
                    let tesselator_options =
                        egui::epaint::tessellator::TessellationOptions::from_pixels_per_point(
                            pixels_per_point,
                        );
                    let tex_size = fonts.font_image().size();
                    let clipped_meshes = egui::epaint::tessellator::tessellate_shapes(
                        clipped_shapes,
                        tesselator_options,
                        tex_size,
                    );
                    let latest_frame = self.latest_frame.get_or_insert_with(EguiFrame::default);
                    latest_frame.frame_index = frame_index;
                    latest_frame.output.append(output);
                    latest_frame.clipped_meshes = clipped_meshes;
                    if let Some(client_time) = client_time {
                        let rtt = (now() - client_time) as f32;
                        self.latency_history.add(now(), rtt);
                    }
                    self.frame_history.add(now(), ());
                }
            }
        }
        fonts.end_frame(); // make sure to evict galley cache
        self.bandwidth_history.lock().flush(now());
        self.frame_size_history.lock().flush(now());
        self.latency_history.flush(now());
        self.frame_history.flush(now());
        self.latest_frame.take()
    }
pub fn update ( & mut self , pixels_per_point : f32 ) -> Option < EguiFrame > { if self . fonts . is_none ( ) { self . fonts = Some ( Fonts :: new ( pixels_per_point , self . font_definitions . clone ( ) ) ) ; } let fonts = self . fonts . as_mut ( ) . unwrap ( ) ; if pixels_per_point != fonts . pixels_per_point ( ) { * fonts = Fonts :: new ( pixels_per_point , self . font_definitions . clone ( ) ) ; } while let Ok ( msg ) = self . incoming_msg_rx . try_recv ( ) { match msg { ServerToClientMessage :: Fonts { font_definitions } => { self . font_definitions = font_definitions ; * fonts = Fonts :: new ( pixels_per_point , self . font_definitions . clone ( ) ) ; } ServerToClientMessage :: Frame { frame_index , output , clipped_net_shapes , client_time , } => { let clipped_shapes = crate :: net_shape :: from_clipped_net_shapes ( fonts , clipped_net_shapes ) ; let tesselator_options = egui :: epaint :: tessellator :: TessellationOptions :: from_pixels_per_point ( pixels_per_point , ) ; let tex_size = fonts . font_image ( ) . size ( ) ; let clipped_meshes = egui :: epaint :: tessellator :: tessellate_shapes ( clipped_shapes , tesselator_options , tex_size , ) ; let latest_frame = self . latest_frame . get_or_insert_with ( EguiFrame :: default ) ; latest_frame . frame_index = frame_index ; latest_frame . output . append ( output ) ; latest_frame . clipped_meshes = clipped_meshes ; if let Some ( client_time ) = client_time { let rtt = ( now ( ) - client_time ) as f32 ; self . latency_history . add ( now ( ) , rtt ) ; } self . frame_history . add ( now ( ) , ( ) ) ; } } } fonts . end_frame ( ) ; // make sure to evict galley cache self . bandwidth_history . lock ( ) . flush ( now ( ) ) ; self . frame_size_history . lock ( ) . flush ( now ( ) ) ; self . latency_history . flush ( now ( ) ) ; self . frame_history . flush ( now ( ) ) ; self . latest_frame . take ( ) }
Retrieved new events, and gives back what to do.
Retrieved new events and gives back what to do .
&mut self
pixels_per_point
f32
&mut self
pixels_per_point
f32