@@ -554,7 +554,7 @@ impl DecodedImage {
554
554
}
555
555
556
556
// FIXME: this assumes PixelFormat::RgbA32
557
- pub ( crate ) fn apply_rgb24_bitmap (
557
+ pub ( crate ) fn apply_rgb24 < const REV : bool > (
558
558
& mut self ,
559
559
rgb24 : & [ u8 ] ,
560
560
update_rectangle : & InclusiveRectangle ,
@@ -569,28 +569,35 @@ impl DecodedImage {
569
569
570
570
let pointer_rendering_state = self . pointer_rendering_begin ( update_rectangle) ?;
571
571
572
- rgb24
573
- . chunks_exact ( rectangle_width * SRC_COLOR_DEPTH )
574
- . rev ( )
575
- . enumerate ( )
576
- . for_each ( |( row_idx, row) | {
577
- row. chunks_exact ( SRC_COLOR_DEPTH )
578
- . enumerate ( )
579
- . for_each ( |( col_idx, src_pixel) | {
580
- let dst_idx = ( ( top + row_idx) * image_width + left + col_idx) * DST_COLOR_DEPTH ;
572
+ let it = rgb24. chunks_exact ( rectangle_width * SRC_COLOR_DEPTH ) ;
573
+ // can it monomorphize this?
574
+ let it: Box < dyn Iterator < Item = _ > > = if REV { Box :: new ( it. rev ( ) ) } else { Box :: new ( it) } ;
575
+ it. enumerate ( ) . for_each ( |( row_idx, row) | {
576
+ row. chunks_exact ( SRC_COLOR_DEPTH )
577
+ . enumerate ( )
578
+ . for_each ( |( col_idx, src_pixel) | {
579
+ let dst_idx = ( ( top + row_idx) * image_width + left + col_idx) * DST_COLOR_DEPTH ;
581
580
582
- // Copy RGB channels as is
583
- self . data [ dst_idx..dst_idx + SRC_COLOR_DEPTH ] . copy_from_slice ( src_pixel) ;
584
- // Set alpha channel to opaque(0xFF)
585
- self . data [ dst_idx + 3 ] = 0xFF ;
586
- } )
587
- } ) ;
581
+ // Copy RGB channels as is
582
+ self . data [ dst_idx..dst_idx + SRC_COLOR_DEPTH ] . copy_from_slice ( src_pixel) ;
583
+ // Set alpha channel to opaque(0xFF)
584
+ self . data [ dst_idx + 3 ] = 0xFF ;
585
+ } )
586
+ } ) ;
588
587
589
588
let update_rectangle = self . pointer_rendering_end ( pointer_rendering_state) ?;
590
589
591
590
Ok ( update_rectangle)
592
591
}
593
592
593
+ pub ( crate ) fn apply_rgb24_bitmap (
594
+ & mut self ,
595
+ rgb24 : & [ u8 ] ,
596
+ update_rectangle : & InclusiveRectangle ,
597
+ ) -> SessionResult < InclusiveRectangle > {
598
+ self . apply_rgb24 :: < true > ( rgb24, update_rectangle)
599
+ }
600
+
594
601
// FIXME: this assumes PixelFormat::RgbA32
595
602
pub ( crate ) fn apply_rgb32_bitmap (
596
603
& mut self ,
0 commit comments