]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/image.cpp
Add wxFont::Underlined() and MakeUnderlined() methods.
[wxWidgets.git] / src / common / image.cpp
index 89f35d5d5743ba4a0360fb514f6ea69f1a134aed..6b431715c3a21721c267c74e418d47d30fff7325 100644 (file)
@@ -1089,35 +1089,60 @@ wxImage wxImage::Rotate90( bool clockwise ) const
     }
 
     unsigned char *data = image.GetData();
-    const unsigned char *source_data = M_IMGDATA->m_data;
     unsigned char *target_data;
-    unsigned char *alpha_data = image.GetAlpha();
-    const unsigned char *source_alpha = M_IMGDATA->m_alpha;
-    unsigned char *target_alpha = 0 ;
 
-    for (long j = 0; j < height; j++)
+    // 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)
+    for (long ii = 0; ii < width; )
     {
-        for (long i = 0; i < width; i++)
+        long next_ii = wxMin(ii + 21, width);
+
+        for (long j = 0; j < height; j++)
         {
-            if (clockwise)
+            const unsigned char *source_data
+                                     = M_IMGDATA->m_data + (j*width + ii)*3;
+
+            for (long i = ii; i < next_ii; i++)
             {
-                target_data = data + (((i+1)*height) - j - 1)*3;
-                if (source_alpha)
-                    target_alpha = alpha_data + (((i+1)*height) - j - 1);
+                if ( clockwise )
+                {
+                    target_data = data + (((i+1)*height) - j - 1)*3;
+                }
+                else
+                {
+                    target_data = data + ((height*(width - 1 - i)) + j)*3;
+                }
+                memcpy( target_data, source_data, 3 );
+                source_data += 3;
             }
-            else
+        }
+
+        ii = next_ii;
+    }
+
+    const unsigned char *source_alpha = M_IMGDATA->m_alpha;
+
+    if ( source_alpha )
+    {
+        unsigned char *alpha_data = image.GetAlpha();
+        unsigned char *target_alpha = 0 ;
+
+        for (long j = 0; j < height; j++)
+        {
+            for (long i = 0; i < width; i++)
             {
-                target_data = data + ((height*(width-1)) + j - (i*height))*3;
-                if (source_alpha)
+                if ( clockwise )
+                {
+                    target_alpha = alpha_data + (((i+1)*height) - j - 1);
+                }
+                else
+                {
                     target_alpha = alpha_data + ((height*(width-1)) + j - (i*height));
-            }
-            memcpy( target_data, source_data, 3 );
-            source_data += 3;
+                }
 
-            if (source_alpha)
-            {
-                memcpy( target_alpha, source_alpha, 1 );
-                source_alpha += 1;
+                *target_alpha = *source_alpha++;
             }
         }
     }