@@ -572,7 +572,7 @@ impl DecodedImage {
572
572
}
573
573
574
574
// FIXME: this assumes PixelFormat::RgbA32
575
- pub ( crate ) fn apply_rgb24_bitmap (
575
+ pub ( crate ) fn apply_rgb24 < const REV : bool > (
576
576
& mut self ,
577
577
rgb24 : & [ u8 ] ,
578
578
update_rectangle : & InclusiveRectangle ,
@@ -587,28 +587,35 @@ impl DecodedImage {
587
587
588
588
let pointer_rendering_state = self . pointer_rendering_begin ( update_rectangle) ?;
589
589
590
- rgb24
591
- . chunks_exact ( rectangle_width * SRC_COLOR_DEPTH )
592
- . rev ( )
593
- . enumerate ( )
594
- . for_each ( |( row_idx, row) | {
595
- row. chunks_exact ( SRC_COLOR_DEPTH )
596
- . enumerate ( )
597
- . for_each ( |( col_idx, src_pixel) | {
598
- let dst_idx = ( ( top + row_idx) * image_width + left + col_idx) * DST_COLOR_DEPTH ;
590
+ let it = rgb24. chunks_exact ( rectangle_width * SRC_COLOR_DEPTH ) ;
591
+ // can it monomorphize this?
592
+ let it: Box < dyn Iterator < Item = _ > > = if REV { Box :: new ( it. rev ( ) ) } else { Box :: new ( it) } ;
593
+ it. enumerate ( ) . for_each ( |( row_idx, row) | {
594
+ row. chunks_exact ( SRC_COLOR_DEPTH )
595
+ . enumerate ( )
596
+ . for_each ( |( col_idx, src_pixel) | {
597
+ let dst_idx = ( ( top + row_idx) * image_width + left + col_idx) * DST_COLOR_DEPTH ;
599
598
600
- // Copy RGB channels as is
601
- self . data [ dst_idx..dst_idx + SRC_COLOR_DEPTH ] . copy_from_slice ( src_pixel) ;
602
- // Set alpha channel to opaque(0xFF)
603
- self . data [ dst_idx + 3 ] = 0xFF ;
604
- } )
605
- } ) ;
599
+ // Copy RGB channels as is
600
+ self . data [ dst_idx..dst_idx + SRC_COLOR_DEPTH ] . copy_from_slice ( src_pixel) ;
601
+ // Set alpha channel to opaque(0xFF)
602
+ self . data [ dst_idx + 3 ] = 0xFF ;
603
+ } )
604
+ } ) ;
606
605
607
606
let update_rectangle = self . pointer_rendering_end ( pointer_rendering_state) ?;
608
607
609
608
Ok ( update_rectangle)
610
609
}
611
610
611
+ pub ( crate ) fn apply_rgb24_bitmap (
612
+ & mut self ,
613
+ rgb24 : & [ u8 ] ,
614
+ update_rectangle : & InclusiveRectangle ,
615
+ ) -> SessionResult < InclusiveRectangle > {
616
+ self . apply_rgb24 :: < true > ( rgb24, update_rectangle)
617
+ }
618
+
612
619
// FIXME: this assumes PixelFormat::RgbA32
613
620
pub ( crate ) fn apply_rgb32_bitmap (
614
621
& mut self ,
0 commit comments