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

List:       kde-commits
Subject:    KDE/kdegraphics/kviewshell/plugins/dvi
From:       Wilfried Huss <Wilfried.Huss () gmx ! at>
Date:       2006-03-01 21:12:54
Message-ID: 1141247574.859155.8599.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 514902 by whuss:

Add threading to the DVI plugin. Postscript is disabled for now, because
starting a QProcess in a QThread crashes the program. It works in Qt3.

 M  +1 -1      TeXFont.h  
 M  +9 -9      TeXFont_PFB.cpp  
 M  +1 -4      TeXFont_PK.cpp  
 M  +2 -2      TeXFont_TFM.cpp  
 M  +20 -5     dviRenderer.cpp  
 M  +1 -3      dviRenderer.h  
 M  +2 -3      dviRenderer_draw.cpp  
 M  +3 -1      fontpool.cpp  
 M  +2 -2      glyph.h  
 M  +10 -4     psgs.cpp  
 M  +3 -0      psgs.h  


--- trunk/KDE/kdegraphics/kviewshell/plugins/dvi/TeXFont.h #514901:514902
@@ -26,7 +26,7 @@
   void setDisplayResolution()
     {
       for(unsigned int i=0; i<TeXFontDefinition::max_num_of_chars_in_font; i++)
-        glyphtable[i].shrunkenCharacter.resize(0, 0);
+        glyphtable[i].shrunkenCharacter = QImage();
     };
 
   virtual glyph* getGlyph(quint16 character, bool generateCharacterPixmap=false, \
                const QColor& color=Qt::black) = 0;
--- trunk/KDE/kdegraphics/kviewshell/plugins/dvi/TeXFont_PFB.cpp #514901:514902
@@ -170,8 +170,8 @@
       if (errorMessage.isEmpty())
         errorMessage = msg;
       kError(kvs::dvi) << msg << endl;
-      g->shrunkenCharacter.resize(1,1);
-      g->shrunkenCharacter.fill(QColor(255, 255, 255));
+      g->shrunkenCharacter = QImage(1, 1, QImage::Format_RGB32);
+      g->shrunkenCharacter.fill(qRgb(255, 255, 255));
       return g;
     }
 
@@ -186,8 +186,8 @@
       if (errorMessage.isEmpty())
         errorMessage = msg;
       kError(kvs::dvi) << msg << endl;
-      g->shrunkenCharacter.resize(1,1);
-      g->shrunkenCharacter.fill(QColor(255, 255, 255));
+      g->shrunkenCharacter = QImage(1, 1, QImage::Format_RGB32);
+      g->shrunkenCharacter.fill(qRgb(255, 255, 255));
       return g;
     }
 
@@ -198,8 +198,8 @@
       if (errorMessage.isEmpty())
         errorMessage = msg;
       kError(kvs::dvi) << msg << endl;
-      g->shrunkenCharacter.resize(1,1);
-      g->shrunkenCharacter.fill(QColor(255, 255, 255));
+      g->shrunkenCharacter = QImage(1, 1, QImage::Format_RGB32);
+      g->shrunkenCharacter.fill(qRgb(255, 255, 255));
       return g;
     }
 
@@ -209,8 +209,8 @@
       if (errorMessage.isEmpty())
         errorMessage = i18n("Glyph #%1 is empty.").arg(ch);
       kError(kvs::dvi) << i18n("Glyph #%1 from font file %2 is \
                empty.").arg(ch).arg(parent->filename) << endl;
-      g->shrunkenCharacter.resize( 15, 15 );
-      g->shrunkenCharacter.fill(QColor(255, 0, 0));
+      g->shrunkenCharacter = QImage(15, 15 , QImage::Format_RGB32);
+      g->shrunkenCharacter.fill(qRgb(255, 0, 0));
       g->x2 = 0;
       g->y2 = 15;
     } else {
@@ -267,7 +267,7 @@
         }
       }
 
-      g->shrunkenCharacter.convertFromImage (imgi, 0);
+      g->shrunkenCharacter = imgi;
       g->x2 = -slot->bitmap_left;
       g->y2 = slot->bitmap_top;
     }
--- trunk/KDE/kdegraphics/kviewshell/plugins/dvi/TeXFont_PK.cpp #514901:514902
@@ -61,7 +61,6 @@
 
 #include <QFile>
 #include <QImage>
-#include <QPixmap>
 
 #include <cmath>
 
@@ -308,9 +307,7 @@
       }
     }
 
-    g->shrunkenCharacter.convertFromImage(im32,0);
-    //FIXME: KDE4 porting
-    //g->shrunkenCharacter.setOptimization(QPixmap::BestOptim);
+    g->shrunkenCharacter = im32;
   }
   return g;
 }
--- trunk/KDE/kdegraphics/kviewshell/plugins/dvi/TeXFont_TFM.cpp #514901:514902
@@ -149,8 +149,8 @@
     if (pixelHeight > 50)
       pixelHeight = 50;
 
-    g->shrunkenCharacter.resize( pixelWidth, pixelHeight );
-    g->shrunkenCharacter.fill(color);
+    g->shrunkenCharacter = QImage(pixelWidth, pixelHeight, QImage::Format_RGB32);
+    g->shrunkenCharacter.fill(color.rgba());
     g->x2 = 0;
     g->y2 = pixelHeight;
   }
--- trunk/KDE/kdegraphics/kviewshell/plugins/dvi/dviRenderer.cpp #514901:514902
@@ -163,14 +163,28 @@
   colorStack.clear();
   globalColor = Qt::black;
 
-  QApplication::setOverrideCursor( Qt::WaitCursor );
-  foreGroundPainter = page->getPainter();
+  SimplePageSize ps = sizeOfPage(page->getPageNumber());
+  if (!ps.isValid())
+  {
+    ps = sizeOfPage(1);
+  }
+  int pageHeight = ps.sizeInPixel(resolution).height();
+  int pageWidth = ps.sizeInPixel(resolution).width();
+ 
+  QImage img(pageWidth, pageHeight, QImage::Format_RGB32);
+  foreGroundPainter = new QPainter(&img); 
   if (foreGroundPainter != 0) {
     errorMsg = QString::null;
     draw_page();
-    page->returnPainter(foreGroundPainter);
+    delete foreGroundPainter;
+    foreGroundPainter = 0;
   }
-  QApplication::restoreOverrideCursor();
+  else
+  {
+    kDebug(kvs::dvi) << "painter creation failed." << endl;
+  }
+  page->setImage(img);
+  
   page->isEmpty = false;
   if (errorMsg.isEmpty() != true) {
     KMessageBox::detailedError(parentWidget,
@@ -192,7 +206,8 @@
       dviFile->sourceSpecialMarker = false;
       // Show the dialog as soon as event processing is finished, and
       // the program is idle
-      QTimer::singleShot( 0, this, SLOT(showThatSourceInformationIsPresent()) );
+      //FIXME
+      //QTimer::singleShot( 0, this, SLOT(showThatSourceInformationIsPresent()) );
     }
   }
 
--- trunk/KDE/kdegraphics/kviewshell/plugins/dvi/dviRenderer.h #514901:514902
@@ -100,9 +100,7 @@
 
   virtual bool  supportsTextSearch() const {return true;}
 
-  /** The DVI plugin is not multithreaded because it uses
-      the QPainter API. */
-  virtual bool isMultiThreaded() const { return false; }
+  virtual bool isMultiThreaded() const { return true; }
 
   bool          showPS() { return _postscript; }
   int           curr_page() { return current_page+1; }
--- trunk/KDE/kdegraphics/kviewshell/plugins/dvi/dviRenderer_draw.cpp #514901:514902
@@ -68,7 +68,6 @@
 #include <klocale.h>
 
 #include <QPainter>
-#include <QPixmap>
 
 extern QPainter *foreGroundPainter;
 
@@ -91,12 +90,12 @@
 
   long dvi_h_sav = currinf.data.dvi_h;
 
-  QPixmap pix = g->shrunkenCharacter;
+  QImage pix = g->shrunkenCharacter;
   int x = ((int) ((currinf.data.dvi_h) / (shrinkfactor * 65536))) - g->x2;
   int y = currinf.data.pxl_v - g->y2;
 
   // Draw the character.
-  foreGroundPainter->drawPixmap(x, y, pix);
+  foreGroundPainter->drawImage(x, y, pix);
 
   // Are we drawing text for a hyperlink? And are hyperlinks
   // enabled?
--- trunk/KDE/kdegraphics/kviewshell/plugins/dvi/fontpool.cpp #514901:514902
@@ -70,6 +70,7 @@
   connect(&kpsewhich_, SIGNAL(readyReadStandardError()),
           this, SLOT(mf_output_receiver()));
 
+  /*
   // Check if the QT library supports the alpha channel of
   // pixmaps. Experiments show that --depending of the configuration
   // of QT at compile and runtime or the availability of the XFt
@@ -98,7 +99,8 @@
     kDebug(kvs::dvi) << "fontPool::fontPool(): QPixmap supports the alpha channel" \
<< endl;  #endif
     QPixmapSupportsAlpha = true;
-  }
+  }*/
+  QPixmapSupportsAlpha = true;
 }
 
 
--- trunk/KDE/kdegraphics/kviewshell/plugins/dvi/glyph.h #514901:514902
@@ -4,7 +4,7 @@
 #define _GLYPH_H
 
 #include <QColor>
-#include <QPixmap>
+#include <QImage>
 
 
 struct bitmap {
@@ -32,7 +32,7 @@
   // x and y offset in pixels
   short   x, y;
 
-  QPixmap shrunkenCharacter;
+  QImage shrunkenCharacter;
 
   // x and y offset in pixels (shrunken bitmap)
   short   x2, y2;
--- trunk/KDE/kdegraphics/kviewshell/plugins/dvi/psgs.cpp #514901:514902
@@ -25,6 +25,7 @@
 #include <QProcess>
 #include <QTemporaryFile>
 #include <QTextStream>
+#include <QTimer>
 
 //#define DEBUG_PSGS
 
@@ -235,11 +236,15 @@
 #ifdef DEBUG_PSGS
   kDebug(kvs::dvi) << gs_exe + " " + gs_args.join(" ") << endl;
 #endif
-
+  
   QProcess gs;
   gs.setReadChannelMode(QProcess::MergedChannels);
+
+  // FIXME Investigate why the QProcess can not be started in a Thread.
+  // This works in Qt3, and according the Qt4 Documentation should still work.
+  return;
   gs.start(gs_exe, gs_args);
-
+  
   if (!gs.waitForStarted()) {
     // Starting ghostscript did not work.
     // TODO: Issue error message, switch PS support off.
@@ -336,8 +341,9 @@
 
   gs_generate_graphics_file(page, gfxFileName, magnification);
 
-  QPixmap MemoryCopy(gfxFileName);
-  paint->drawPixmap(0, 0, MemoryCopy);
+  //FIXME
+  //QPixmap MemoryCopy(gfxFileName);
+  //paint->drawPixmap(0, 0, MemoryCopy);
   return;
 }
 
--- trunk/KDE/kdegraphics/kviewshell/plugins/dvi/psgs.h #514901:514902
@@ -11,9 +11,12 @@
 #define _PSGS_H_
 
 #include <Q3IntDict>
+#include <QApplication>
 #include <QColor>
+#include <QCustomEvent>
 #include <QObject>
 #include <QString>
+#include <QThread>
 
 class KUrl;
 class PageNumber;


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

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