Skip to content

Commit

Permalink
Work around MSVS 2022 optimizer bug in wxImage::ShrinkBy()
Browse files Browse the repository at this point in the history
Move "alpha" initialization inside the conditional to ensure that it's
calculated correctly, as it was apparently hoisted out of the loop due
to an optimizer bug otherwise.

This commit is best viewed with Git --color-moved option.

Closes #23164.
  • Loading branch information
MaartenBent authored and MackBambu committed Jun 7, 2024
1 parent 761ba5f commit a8e20d0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/common/image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -383,11 +383,11 @@ wxImage wxImage::ShrinkBy( int xFactor , int yFactor ) const
unsigned char red = pixel[0] ;
unsigned char green = pixel[1] ;
unsigned char blue = pixel[2] ;
unsigned char alpha = 255 ;
if ( source_alpha )
alpha = *(source_alpha + y_offset + x * xFactor + x1) ;
if ( !hasMask || red != maskRed || green != maskGreen || blue != maskBlue )
{
unsigned char alpha = 255 ;
if ( source_alpha )
alpha = *(source_alpha + y_offset + x * xFactor + x1) ;
if ( alpha > 0 )
{
avgRed += red ;
Expand Down

0 comments on commit a8e20d0

Please sign in to comment.