@@ -128,13 +128,15 @@ impl Scene {
128128 }
129129
130130 pub fn finish ( & mut self ) {
131- self . shadows . sort ( ) ;
132- self . quads . sort ( ) ;
133- self . paths . sort ( ) ;
134- self . underlines . sort ( ) ;
135- self . monochrome_sprites . sort ( ) ;
136- self . polychrome_sprites . sort ( ) ;
137- self . surfaces . sort ( ) ;
131+ self . shadows . sort_by_key ( |shadow| shadow. order ) ;
132+ self . quads . sort_by_key ( |quad| quad. order ) ;
133+ self . paths . sort_by_key ( |path| path. order ) ;
134+ self . underlines . sort_by_key ( |underline| underline. order ) ;
135+ self . monochrome_sprites
136+ . sort_by_key ( |sprite| ( sprite. order , sprite. tile . tile_id ) ) ;
137+ self . polychrome_sprites
138+ . sort_by_key ( |sprite| ( sprite. order , sprite. tile . tile_id ) ) ;
139+ self . surfaces . sort_by_key ( |surface| surface. order ) ;
138140 }
139141
140142 #[ cfg_attr(
@@ -196,7 +198,7 @@ pub(crate) enum PaintOperation {
196198 EndLayer ,
197199}
198200
199- #[ derive( Clone , Ord , PartialOrd , Eq , PartialEq ) ]
201+ #[ derive( Clone ) ]
200202pub ( crate ) enum Primitive {
201203 Shadow ( Shadow ) ,
202204 Quad ( Quad ) ,
@@ -449,7 +451,7 @@ pub(crate) enum PrimitiveBatch<'a> {
449451 Surfaces ( & ' a [ PaintSurface ] ) ,
450452}
451453
452- #[ derive( Default , Debug , Clone , Eq , PartialEq ) ]
454+ #[ derive( Default , Debug , Clone ) ]
453455#[ repr( C ) ]
454456pub ( crate ) struct Quad {
455457 pub order : DrawOrder ,
@@ -462,25 +464,13 @@ pub(crate) struct Quad {
462464 pub border_widths : Edges < ScaledPixels > ,
463465}
464466
465- impl Ord for Quad {
466- fn cmp ( & self , other : & Self ) -> std:: cmp:: Ordering {
467- self . order . cmp ( & other. order )
468- }
469- }
470-
471- impl PartialOrd for Quad {
472- fn partial_cmp ( & self , other : & Self ) -> Option < std:: cmp:: Ordering > {
473- Some ( self . cmp ( other) )
474- }
475- }
476-
477467impl From < Quad > for Primitive {
478468 fn from ( quad : Quad ) -> Self {
479469 Primitive :: Quad ( quad)
480470 }
481471}
482472
483- #[ derive( Debug , Clone , Eq , PartialEq ) ]
473+ #[ derive( Debug , Clone ) ]
484474#[ repr( C ) ]
485475pub ( crate ) struct Underline {
486476 pub order : DrawOrder ,
@@ -492,25 +482,13 @@ pub(crate) struct Underline {
492482 pub wavy : bool ,
493483}
494484
495- impl Ord for Underline {
496- fn cmp ( & self , other : & Self ) -> std:: cmp:: Ordering {
497- self . order . cmp ( & other. order )
498- }
499- }
500-
501- impl PartialOrd for Underline {
502- fn partial_cmp ( & self , other : & Self ) -> Option < std:: cmp:: Ordering > {
503- Some ( self . cmp ( other) )
504- }
505- }
506-
507485impl From < Underline > for Primitive {
508486 fn from ( underline : Underline ) -> Self {
509487 Primitive :: Underline ( underline)
510488 }
511489}
512490
513- #[ derive( Debug , Clone , Eq , PartialEq ) ]
491+ #[ derive( Debug , Clone ) ]
514492#[ repr( C ) ]
515493pub ( crate ) struct Shadow {
516494 pub order : DrawOrder ,
@@ -521,18 +499,6 @@ pub(crate) struct Shadow {
521499 pub color : Hsla ,
522500}
523501
524- impl Ord for Shadow {
525- fn cmp ( & self , other : & Self ) -> std:: cmp:: Ordering {
526- self . order . cmp ( & other. order )
527- }
528- }
529-
530- impl PartialOrd for Shadow {
531- fn partial_cmp ( & self , other : & Self ) -> Option < std:: cmp:: Ordering > {
532- Some ( self . cmp ( other) )
533- }
534- }
535-
536502impl From < Shadow > for Primitive {
537503 fn from ( shadow : Shadow ) -> Self {
538504 Primitive :: Shadow ( shadow)
@@ -642,7 +608,7 @@ impl Default for TransformationMatrix {
642608 }
643609}
644610
645- #[ derive( Clone , Debug , Eq , PartialEq ) ]
611+ #[ derive( Clone , Debug ) ]
646612#[ repr( C ) ]
647613pub ( crate ) struct MonochromeSprite {
648614 pub order : DrawOrder ,
@@ -654,28 +620,13 @@ pub(crate) struct MonochromeSprite {
654620 pub transformation : TransformationMatrix ,
655621}
656622
657- impl Ord for MonochromeSprite {
658- fn cmp ( & self , other : & Self ) -> std:: cmp:: Ordering {
659- match self . order . cmp ( & other. order ) {
660- std:: cmp:: Ordering :: Equal => self . tile . tile_id . cmp ( & other. tile . tile_id ) ,
661- order => order,
662- }
663- }
664- }
665-
666- impl PartialOrd for MonochromeSprite {
667- fn partial_cmp ( & self , other : & Self ) -> Option < std:: cmp:: Ordering > {
668- Some ( self . cmp ( other) )
669- }
670- }
671-
672623impl From < MonochromeSprite > for Primitive {
673624 fn from ( sprite : MonochromeSprite ) -> Self {
674625 Primitive :: MonochromeSprite ( sprite)
675626 }
676627}
677628
678- #[ derive( Clone , Debug , PartialEq ) ]
629+ #[ derive( Clone , Debug ) ]
679630#[ repr( C ) ]
680631pub ( crate ) struct PolychromeSprite {
681632 pub order : DrawOrder ,
@@ -687,30 +638,14 @@ pub(crate) struct PolychromeSprite {
687638 pub corner_radii : Corners < ScaledPixels > ,
688639 pub tile : AtlasTile ,
689640}
690- impl Eq for PolychromeSprite { }
691-
692- impl Ord for PolychromeSprite {
693- fn cmp ( & self , other : & Self ) -> std:: cmp:: Ordering {
694- match self . order . cmp ( & other. order ) {
695- std:: cmp:: Ordering :: Equal => self . tile . tile_id . cmp ( & other. tile . tile_id ) ,
696- order => order,
697- }
698- }
699- }
700-
701- impl PartialOrd for PolychromeSprite {
702- fn partial_cmp ( & self , other : & Self ) -> Option < std:: cmp:: Ordering > {
703- Some ( self . cmp ( other) )
704- }
705- }
706641
707642impl From < PolychromeSprite > for Primitive {
708643 fn from ( sprite : PolychromeSprite ) -> Self {
709644 Primitive :: PolychromeSprite ( sprite)
710645 }
711646}
712647
713- #[ derive( Clone , Debug , Eq , PartialEq ) ]
648+ #[ derive( Clone , Debug ) ]
714649pub ( crate ) struct PaintSurface {
715650 pub order : DrawOrder ,
716651 pub bounds : Bounds < ScaledPixels > ,
@@ -719,18 +654,6 @@ pub(crate) struct PaintSurface {
719654 pub image_buffer : media:: core_video:: CVImageBuffer ,
720655}
721656
722- impl Ord for PaintSurface {
723- fn cmp ( & self , other : & Self ) -> std:: cmp:: Ordering {
724- self . order . cmp ( & other. order )
725- }
726- }
727-
728- impl PartialOrd for PaintSurface {
729- fn partial_cmp ( & self , other : & Self ) -> Option < std:: cmp:: Ordering > {
730- Some ( self . cmp ( other) )
731- }
732- }
733-
734657impl From < PaintSurface > for Primitive {
735658 fn from ( surface : PaintSurface ) -> Self {
736659 Primitive :: Surface ( surface)
@@ -859,26 +782,6 @@ impl Path<Pixels> {
859782 }
860783}
861784
862- impl Eq for Path < ScaledPixels > { }
863-
864- impl PartialEq for Path < ScaledPixels > {
865- fn eq ( & self , other : & Self ) -> bool {
866- self . order == other. order
867- }
868- }
869-
870- impl Ord for Path < ScaledPixels > {
871- fn cmp ( & self , other : & Self ) -> std:: cmp:: Ordering {
872- self . order . cmp ( & other. order )
873- }
874- }
875-
876- impl PartialOrd for Path < ScaledPixels > {
877- fn partial_cmp ( & self , other : & Self ) -> Option < std:: cmp:: Ordering > {
878- Some ( self . cmp ( other) )
879- }
880- }
881-
882785impl From < Path < ScaledPixels > > for Primitive {
883786 fn from ( path : Path < ScaledPixels > ) -> Self {
884787 Primitive :: Path ( path)
0 commit comments