// we rotate the image in 21-pixel (63-byte) wide strips
// to make better use of cpu cache - memory transfers
// (note: while much better than single-pixel "strips",
- // our vertical strips will still generally straddle cachelines)
+ // our vertical strips will still generally straddle 64-byte cachelines)
for (long ii = 0; ii < width; )
{
long next_ii = wxMin(ii + 21, width);
{
if ( clockwise )
{
- target_data = data + (((i+1)*height) - j - 1)*3;
+ target_data = data + ((i + 1)*height - j - 1)*3;
}
else
{
- target_data = data + ((height*(width - 1 - i)) + j)*3;
+ target_data = data + (height*(width - 1 - i) + j)*3;
}
memcpy( target_data, source_data, 3 );
source_data += 3;
unsigned char *alpha_data = image.GetAlpha();
unsigned char *target_alpha = 0 ;
- for (long j = 0; j < height; j++)
+ for (long ii = 0; ii < width; )
{
- for (long i = 0; i < width; i++)
+ long next_ii = wxMin(ii + 64, width);
+
+ for (long j = 0; j < height; j++)
{
- if ( clockwise )
- {
- target_alpha = alpha_data + (((i+1)*height) - j - 1);
- }
- else
+ source_alpha = M_IMGDATA->m_alpha + j*width + ii;
+
+ for (long i = ii; i < next_ii; i++)
{
- target_alpha = alpha_data + ((height*(width-1)) + j - (i*height));
- }
+ if ( clockwise )
+ {
+ target_alpha = alpha_data + (i+1)*height - j - 1;
+ }
+ else
+ {
+ target_alpha = alpha_data + height*(width - i - 1) + j;
+ }
- *target_alpha = *source_alpha++;
+ *target_alpha = *source_alpha++;
+ }
}
+
+ ii = next_ii;
}
}
if (width < 1) return;
if (height < 1) return;
- if ((!HasMask() && !image.HasMask()) ||
- (HasMask() && !image.HasMask()) ||
- ((HasMask() && image.HasMask() &&
+ // If we can, copy the data using memcpy() as this is the fastest way. But
+ // for this the image being pasted must have "compatible" mask with this
+ // one meaning that either it must not have one at all or it must use the
+ // same masked colour.
+ if ( !image.HasMask() ||
+ ((HasMask() &&
(GetMaskRed()==image.GetMaskRed()) &&
(GetMaskGreen()==image.GetMaskGreen()) &&
- (GetMaskBlue()==image.GetMaskBlue()))))
+ (GetMaskBlue()==image.GetMaskBlue()))) )
{
const unsigned char* source_data = image.GetData() + 3*(xx + yy*image.GetWidth());
int source_step = image.GetWidth()*3;