[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    koffice/krita/core
From:       Adrian Page <adrian () pagenet ! plus ! com>
Date:       2006-02-25 23:51:18
Message-ID: 1140911478.362336.9412.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 513661 by page:

Speed up rendering with the QPaintDevice and zoom < 1.


 M  +4 -4      kis_background.cc  
 M  +17 -2     kis_image.cc  
 M  +12 -10    kis_selection.cc  


--- trunk/koffice/krita/core/kis_background.cc #513660:513661
@@ -130,15 +130,15 @@
 
         for (Q_INT32 x = 0; x < scaledImageRect.width(); ++x) {
 
-            Q_INT32 scaledX = scaledImageRect.x() + x;
-            Q_INT32 srcX = (scaledX * imageWidth) / scaledImageSize.width();
-            Q_INT32 patternX = srcX % PATTERN_WIDTH;
-
             QRgb imagePixel = *imagePixelPtr;
             Q_UINT8 imagePixelAlpha = qAlpha(imagePixel);
 
             if (imagePixelAlpha != 255) {
 
+                Q_INT32 scaledX = scaledImageRect.x() + x;
+                Q_INT32 srcX = (scaledX * imageWidth) / scaledImageSize.width();
+                Q_INT32 patternX = srcX % PATTERN_WIDTH;
+
                 QRgb patternPixel = patternScanLine[patternX];
                 Q_UINT8 imageRed = UINT8_BLEND(qRed(imagePixel), qRed(patternPixel), \
                imagePixelAlpha);
                 Q_UINT8 imageGreen = UINT8_BLEND(qGreen(imagePixel), \
                qGreen(patternPixel), imagePixelAlpha);
--- trunk/koffice/krita/core/kis_image.cc #513660:513661
@@ -1286,6 +1286,9 @@
     KisPaintDevice imageArea(colorSpace(), "imageArea");
     KisPaintDeviceSP mergedImage = m_rootLayer->projection(srcRect);
 
+    //QTime t;
+    //t.start();
+
     for (Q_INT32 y = 0; y < r.height(); ++y) {
 
         KisHLineIterator it = imageArea.createHLineIterator(0, y, r.width(), true);
@@ -1293,31 +1296,43 @@
         Q_INT32 dstX = r.x();
         Q_INT32 srcY = (dstY * imageHeight) / scaledImageSize.height();
 
+        KisHLineIterator srcIt = mergedImage->createHLineIterator(0, srcY, m_width, \
false); +        Q_INT32 oldSrcX = 0;
+
         while (!it.isDone()) {
 
             Q_INT32 srcX = (dstX * imageWidth) / scaledImageSize.width();
+            srcIt += srcX - oldSrcX;
+            oldSrcX = srcX;
 
-            KisColor pixelColor = mergedImage->colorAt(srcX, srcY);
-            memcpy(it.rawData(), pixelColor.data(), pixelSize);
+            memcpy(it.rawData(), srcIt.rawData(), pixelSize);
 
             ++it;
             ++dstX;
         }
     }
 
+    //kdDebug(41010) << "Scaling image took " << t.restart() << endl;
+
     QImage image = imageArea.convertToQImage(profile, 0, 0, r.width(), r.height(), \
exposure);  
+    //kdDebug(41010) << "Convert to QImage image took " << t.restart() << endl;
+
     if (paintFlags & PAINT_BACKGROUND) {
         m_bkg -> paintBackground(image, r, scaledImageSize, QSize(imageWidth, \
imageHeight));  image.setAlphaBuffer(false);
     }
 
+    //kdDebug(41010) << "Paint background took " << t.restart() << endl;
+
     if (paintFlags & PAINT_SELECTION) {
         if (m_activeLayer != 0) {
             m_activeLayer -> paintSelection(image, r, scaledImageSize, \
QSize(imageWidth, imageHeight));  }
     }
 
+    //kdDebug(41010) << "Paint selection took " << t.restart() << endl;
+
     /*if (paintFlags & PAINT_MASKINACTIVELAYERS) {
         if (m_activeLayer != 0) {
             m_activeLayer -> paintMaskInactiveLayers(img, x1, y1, w, h);
--- trunk/koffice/krita/core/kis_selection.cc #513660:513661
@@ -267,25 +267,17 @@
             Q_INT32 srcX = (scaledX * imageWidth) / scaledImageSize.width();
 
             KisHLineIteratorPixel hit = createHLineIterator(srcX - 1, srcY, 3, \
                false);
-            KisVLineIteratorPixel vit = createVLineIterator(srcX, srcY - 1, 3, \
false);  
             Q_UINT8 left = *(hit.rawData());
             ++hit;
             Q_UINT8 centre = *(hit.rawData());
-            ++hit;
-            Q_UINT8 right = *(hit.rawData());
 
-            Q_UINT8 above = *(vit.rawData());
-            ++vit;
-            ++vit;
-            Q_UINT8 below = *(vit.rawData());
-
-            uchar *j = img.scanLine(y) + x * sizeof(QRgb);
-
             if (centre != MAX_SELECTED) {
 
                 // this is where we come if the pixels should be blue or bluish
 
+                uchar *j = img.scanLine(y) + x * sizeof(QRgb);
+
                 Q_UINT8 g = (*(j + 0)  + *(j + 1 ) + *(j + 2 )) / 9;
                 Q_UINT8 alpha = *(j + 3);
 
@@ -296,6 +288,16 @@
                 {
                     //this is where we come if the pixels should be blue (or red \
outline)  
+                    ++hit;
+                    Q_UINT8 right = *(hit.rawData());
+
+                    KisVLineIteratorPixel vit = createVLineIterator(srcX, srcY - 1, \
3, false); +
+                    Q_UINT8 above = *(vit.rawData());
+                    ++vit;
+                    ++vit;
+                    Q_UINT8 below = *(vit.rawData());
+
                     // now for a simple outline based on 4-connectivity
                     if (left != MIN_SELECTED
                         || right != MIN_SELECTED


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic