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

List:       kde-commits
Subject:    koffice/krita/ui/canvas
From:       Dmitry Kazakov <dimula73 () gmail ! com>
Date:       2010-05-22 21:33:58
Message-ID: 20100522213358.A447FAC8BD () svn ! kde ! org
[Download RAW message or body]

SVN commit 1129568 by dkazakov:

Fixed a bug seen on small zooms (<50%)

Old (bigger) bart of the canvas was not cleared when zooming out


 M  +18 -16    kis_prescaled_projection.cpp  
 M  +2 -1      kis_prescaled_projection.h  


--- trunk/koffice/krita/ui/canvas/kis_prescaled_projection.cpp #1129567:1129568
@@ -290,7 +290,7 @@
                 // enough image to draw in them.
                 gc.fillRect(r, QColor(0, 0, 0, 0));
                 dbgRender << "render on rect" << r;
-                UpdateInformation info = getUpdateInformation(r);
+                UpdateInformation info = getUpdateInformation(r, QRect());
                 drawUsingBackend(gc, info);
             }
         }
@@ -343,7 +343,8 @@
 
     m_d->projectionBackend->setDirty(rc);
 
-    UpdateInformation info = getUpdateInformation(rc);
+    QRect rawViewRect = toAlignedRectWorkaround(viewRectFromImagePixels(rc));
+    UpdateInformation info = getUpdateInformation(rawViewRect, rc);
 
     QRect viewportRect = toAlignedRectWorkaround(info.viewportRect);
 
@@ -362,13 +363,14 @@
 QRect KisPrescaledProjection::preScale(const QRect & rc)
 {
     if (!rc.isEmpty() && m_d->image) {
-        /**
-         * FIXME: Too many conversions view<->image
-         */
-        QRect imageRect = imageRectFromViewPortPixels(toFloatRectWorkaround(rc));
-        UpdateInformation info = getUpdateInformation(imageRect);
-        updateScaledImage(info);
-        return toAlignedRectWorkaround(info.viewportRect);
+        UpdateInformation info = getUpdateInformation(rc, QRect());
+
+        QPainter gc(&m_d->prescaledQImage);
+        gc.setCompositionMode(QPainter::CompositionMode_Source);
+        gc.fillRect(rc, QColor(0, 0, 0, 0));
+        drawUsingBackend(gc, info);
+        //FIXME: leave one of those rects, probably, first.
+        return rc | toAlignedRectWorkaround(info.viewportRect);
     }
     return QRect();
 }
@@ -415,7 +417,7 @@
 }
 
 UpdateInformation
-KisPrescaledProjection::getUpdateInformation(const QRect &dirtyImageRect)
+KisPrescaledProjection::getUpdateInformation(const QRect &viewportRect, const QRect \
&dirtyImageRect)  {
     Q_ASSERT(m_d->viewConverter);
 
@@ -433,15 +435,15 @@
     info.scaleX = zoomX / resX;
     info.scaleY = zoomY / resY;
 
+    // save it for future
     info.dirtyImageRect = dirtyImageRect;
 
-    // first, crop the part of image rect that is outside of the canvas
-    QRect rawViewRect = \
                toAlignedRectWorkaround(viewRectFromImagePixels(info.dirtyImageRect));
                
-    rawViewRect = rawViewRect.intersected(QRect(QPoint(0, 0), m_d->canvasSize));
+    // first, crop the part of the view rect that is outside of the canvas
+    QRect croppedViewRect = viewportRect.intersected(QRect(QPoint(0, 0), \
m_d->canvasSize));  
     // second, align this rect to the KisImage's pixels and pixels
     // of projection backend
-    info.imageRect = \
imageRectFromViewPortPixels(toFloatRectWorkaround(rawViewRect)); +    info.imageRect \
= imageRectFromViewPortPixels(toFloatRectWorkaround(croppedViewRect));  \
m_d->projectionBackend->alignSourceRect(info.imageRect, info.scaleX);  
     // finally, compute the dirty rect of the canvas
@@ -468,7 +470,7 @@
     dbgRender << ppVar(info.borderWidth) << ppVar(info.renderHints);
     dbgRender << ppVar(info.transfer);
     dbgRender << ppVar(dirtyImageRect);
-    dbgRender << "Not aligned rect of the canvas (raw):\t" << rawViewRect;
+    dbgRender << "Not aligned rect of the canvas (raw):\t" << croppedViewRect;
     dbgRender << "Update rect in KisImage's pixels:\t" << info.imageRect;
     dbgRender << "Update rect in canvas' pixels:\t" << info.viewportRect;
     dbgRender << "#####################################";
@@ -480,7 +482,7 @@
 {
     QPainter gc(&m_d->prescaledQImage);
     gc.setCompositionMode(QPainter::CompositionMode_Source);
-    gc.fillRect(info.viewportRect, QColor(255, 0, 0, 255));
+//    gc.fillRect(toAlignedRectWorkaround(viewRectFromImagePixels(info.dirtyImageRect)), \
QColor(255, 0, 0, 255));  drawUsingBackend(gc, info);
 }
 
--- trunk/koffice/krita/ui/canvas/kis_prescaled_projection.h #1129567:1129568
@@ -219,7 +219,8 @@
      *
      * @param dirtyImageRect the part of the KisImage that is dirty
      */
-    UpdateInformation getUpdateInformation(const QRect &dirtyImageRect);
+    UpdateInformation getUpdateInformation(const QRect &viewportRect,
+                                           const QRect &dirtyImageRect);
 
 
     void retrieveImageData(const QRect &dirtyRect, UpdateInformation &info);


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

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