fn clear_all_layers(&mut self) {
        let mut to_remove           = HashSet::new();
        let mut last_layer          = None;

        // Queue up any instruction that targets a layer for removal
        for (idx, (target_resource, draw)) in self.pending_drawing.iter().enumerate() {
            if let DrawResource::Layer(_) = target_resource {
                to_remove.insert(idx);
            }

            if let Draw::Layer(target_layer) = draw {
                last_layer = Some(*target_layer);
            }
        }

        // Remove any resources in the to_remove set
        if to_remove.len() > 0 {
            let old_drawing         = mem::take(&mut self.pending_drawing);
            self.pending_drawing    = old_drawing.into_iter()
                .enumerate()
                .filter(|(idx, _item)| !to_remove.contains(idx))
                .map(|(_idx, item)| item)
                .collect();
        }

        // Re-select the target layer if there is one
        if let Some(last_layer) = last_layer {
            self.pending_drawing.push((DrawResource::Layer(last_layer), Draw::Layer(last_layer)));
        }
    }
///
/// Removes any commands from the stream that have a source or target of a layer
///
Removes any commands from the stream that have a source or target of a layer
Removes any commands from the stream that have a source or target of a layer
fn clear_all_layers(&mut self) {
        let mut to_remove           = HashSet::new();
        let mut last_layer          = None;
        // Queue up any instruction that targets a layer for removal
        for (idx, (target_resource, draw)) in self.pending_drawing.iter().enumerate() {
            if let DrawResource::Layer(_) = target_resource {
                to_remove.insert(idx);
            }
            if let Draw::Layer(target_layer) = draw {
                last_layer = Some(*target_layer);
            }
        }
        // Remove any resources in the to_remove set
        if to_remove.len() > 0 {
            let old_drawing         = mem::take(&mut self.pending_drawing);
            self.pending_drawing    = old_drawing.into_iter()
                .enumerate()
                .filter(|(idx, _item)| !to_remove.contains(idx))
                .map(|(_idx, item)| item)
                .collect();
        }
        // Re-select the target layer if there is one
        if let Some(last_layer) = last_layer {
            self.pending_drawing.push((DrawResource::Layer(last_layer), Draw::Layer(last_layer)));
        }
    }
fn clear_all_layers ( & mut self ) { let mut to_remove = HashSet :: new ( ) ; let mut last_layer = None ; // Queue up any instruction that targets a layer for removal for ( idx , ( target_resource , draw ) ) in self . pending_drawing . iter ( ) . enumerate ( ) { if let DrawResource :: Layer ( _ ) = target_resource { to_remove . insert ( idx ) ; } if let Draw :: Layer ( target_layer ) = draw { last_layer = Some ( * target_layer ) ; } } // Remove any resources in the to_remove set if to_remove . len ( ) > 0 { let old_drawing = mem :: take ( & mut self . pending_drawing ) ; self . pending_drawing = old_drawing . into_iter ( ) . enumerate ( ) . filter ( | ( idx , _item ) | ! to_remove . contains ( idx ) ) . map ( | ( _idx , item ) | item ) . collect ( ) ; } // Re-select the target layer if there is one if let Some ( last_layer ) = last_layer { self . pending_drawing . push ( ( DrawResource :: Layer ( last_layer ) , Draw :: Layer ( last_layer ) ) ) ; } }
Removes any commands from the stream that have a source or target of a layer
Removes any commands from the stream that have a source or target of a layer
&mut self