@@ -128,13 +128,15 @@ impl Scene {
128
128
}
129
129
130
130
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 ) ;
138
140
}
139
141
140
142
#[ cfg_attr(
@@ -196,7 +198,7 @@ pub(crate) enum PaintOperation {
196
198
EndLayer ,
197
199
}
198
200
199
- #[ derive( Clone , Ord , PartialOrd , Eq , PartialEq ) ]
201
+ #[ derive( Clone ) ]
200
202
pub ( crate ) enum Primitive {
201
203
Shadow ( Shadow ) ,
202
204
Quad ( Quad ) ,
@@ -449,7 +451,7 @@ pub(crate) enum PrimitiveBatch<'a> {
449
451
Surfaces ( & ' a [ PaintSurface ] ) ,
450
452
}
451
453
452
- #[ derive( Default , Debug , Clone , Eq , PartialEq ) ]
454
+ #[ derive( Default , Debug , Clone ) ]
453
455
#[ repr( C ) ]
454
456
pub ( crate ) struct Quad {
455
457
pub order : DrawOrder ,
@@ -462,25 +464,13 @@ pub(crate) struct Quad {
462
464
pub border_widths : Edges < ScaledPixels > ,
463
465
}
464
466
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
-
477
467
impl From < Quad > for Primitive {
478
468
fn from ( quad : Quad ) -> Self {
479
469
Primitive :: Quad ( quad)
480
470
}
481
471
}
482
472
483
- #[ derive( Debug , Clone , Eq , PartialEq ) ]
473
+ #[ derive( Debug , Clone ) ]
484
474
#[ repr( C ) ]
485
475
pub ( crate ) struct Underline {
486
476
pub order : DrawOrder ,
@@ -492,25 +482,13 @@ pub(crate) struct Underline {
492
482
pub wavy : bool ,
493
483
}
494
484
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
-
507
485
impl From < Underline > for Primitive {
508
486
fn from ( underline : Underline ) -> Self {
509
487
Primitive :: Underline ( underline)
510
488
}
511
489
}
512
490
513
- #[ derive( Debug , Clone , Eq , PartialEq ) ]
491
+ #[ derive( Debug , Clone ) ]
514
492
#[ repr( C ) ]
515
493
pub ( crate ) struct Shadow {
516
494
pub order : DrawOrder ,
@@ -521,18 +499,6 @@ pub(crate) struct Shadow {
521
499
pub color : Hsla ,
522
500
}
523
501
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
-
536
502
impl From < Shadow > for Primitive {
537
503
fn from ( shadow : Shadow ) -> Self {
538
504
Primitive :: Shadow ( shadow)
@@ -642,7 +608,7 @@ impl Default for TransformationMatrix {
642
608
}
643
609
}
644
610
645
- #[ derive( Clone , Debug , Eq , PartialEq ) ]
611
+ #[ derive( Clone , Debug ) ]
646
612
#[ repr( C ) ]
647
613
pub ( crate ) struct MonochromeSprite {
648
614
pub order : DrawOrder ,
@@ -654,28 +620,13 @@ pub(crate) struct MonochromeSprite {
654
620
pub transformation : TransformationMatrix ,
655
621
}
656
622
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
-
672
623
impl From < MonochromeSprite > for Primitive {
673
624
fn from ( sprite : MonochromeSprite ) -> Self {
674
625
Primitive :: MonochromeSprite ( sprite)
675
626
}
676
627
}
677
628
678
- #[ derive( Clone , Debug , PartialEq ) ]
629
+ #[ derive( Clone , Debug ) ]
679
630
#[ repr( C ) ]
680
631
pub ( crate ) struct PolychromeSprite {
681
632
pub order : DrawOrder ,
@@ -687,30 +638,14 @@ pub(crate) struct PolychromeSprite {
687
638
pub corner_radii : Corners < ScaledPixels > ,
688
639
pub tile : AtlasTile ,
689
640
}
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
- }
706
641
707
642
impl From < PolychromeSprite > for Primitive {
708
643
fn from ( sprite : PolychromeSprite ) -> Self {
709
644
Primitive :: PolychromeSprite ( sprite)
710
645
}
711
646
}
712
647
713
- #[ derive( Clone , Debug , Eq , PartialEq ) ]
648
+ #[ derive( Clone , Debug ) ]
714
649
pub ( crate ) struct PaintSurface {
715
650
pub order : DrawOrder ,
716
651
pub bounds : Bounds < ScaledPixels > ,
@@ -719,18 +654,6 @@ pub(crate) struct PaintSurface {
719
654
pub image_buffer : media:: core_video:: CVImageBuffer ,
720
655
}
721
656
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
-
734
657
impl From < PaintSurface > for Primitive {
735
658
fn from ( surface : PaintSurface ) -> Self {
736
659
Primitive :: Surface ( surface)
@@ -859,26 +782,6 @@ impl Path<Pixels> {
859
782
}
860
783
}
861
784
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
-
882
785
impl From < Path < ScaledPixels > > for Primitive {
883
786
fn from ( path : Path < ScaledPixels > ) -> Self {
884
787
Primitive :: Path ( path)
0 commit comments