koffice/krita [POSSIBLY UNSAFE]

Bart Coppens kde at bartcoppens.be
Tue Jan 29 22:06:41 CET 2008


SVN commit 768355 by coppens:

*Lightning Flash* *KABOOM!*

Bet you didn't see this one coming, eh? ;-)

This commit adds an experimental new tile backend, which features actual shared tiles and so. It's also supposed to be more robust for threading. Emphasis on the 'supposed'.

It's still very experimental, a lot of things probably are just plain wrong and bad code, and it might crash your Krita. It seems almost all regression tests pass (including some new ones written specifically for it), but sometimes there is a random SIGSEGV, I haven't figured out yet what's causing those (but you can be absolutely sure that the amount of crashes is significantly lower than while I was coding this all). It also doesn't do a lot of things yet, like clean up its tempfiles at exit and all that dull stuff about deleting unused data and so ;-)

Cyrille will be (not very) pleased to find out it is also significantly slower, at least when just timing the make tests. I'm suspecting either bad coding (possibly memory leakage, or just badly written), or too much time being spent in locking.

This codepath is disabled by default (Duh!). To try it out, edit the krita/image/CMakeLists.txt, and comment out the 'set(USE_OLD_TILESYSTEM 1)'.

Have fun with it! (Or not... :P)

CCMAIL:kimageshop at kde.org




 M  +22 -0     image/CMakeLists.txt  
 A             image/config-tiles.h.cmake  
 M  +9 -0      image/kis_datamanager.h  
 M  +6 -1      image/kis_iterator.cc  
 M  +2 -0      image/kis_paint_device.cc  
 M  +12 -8     image/kis_random_accessor.h  
 M  +4 -0      image/tiles/kis_tilediterator.cc  
 A             image/tiles_new (directory)  
 A             image/tiles_new/CMakeLists.txt  
 A             image/tiles_new/kis_memento.cc   [License: GPL (v2+)]
 A             image/tiles_new/kis_memento.h   [License: GPL (v2+)]
 A             image/tiles_new/kis_tile.cc   [License: GPL (v2+)]
 A             image/tiles_new/kis_tile.h   [License: GPL (v2+)]
 A             image/tiles_new/kis_tile_compressor.cc   [License: GPL (v2+)]
 A             image/tiles_new/kis_tile_compressor.h   [License: GPL (v2+)]
 A             image/tiles_new/kis_tile_global.h   [License: GPL (v2+)]
 A             image/tiles_new/kis_tiled_random_accessor.cc   [License: UNKNOWN]
 A             image/tiles_new/kis_tiled_random_accessor.h   [License: UNKNOWN]
 A             image/tiles_new/kis_tileddatamanager.cc   [POSSIBLY UNSAFE: scanf] [License: GPL (v2+)]
 A             image/tiles_new/kis_tileddatamanager.h   [License: GPL (v2+)]
 A             image/tiles_new/kis_tiledhlineiterator.cc   [License: GPL (v2+)]
 A             image/tiles_new/kis_tilediterator.cc   [License: GPL (v2+)]
 A             image/tiles_new/kis_tilediterator.h   [License: GPL (v2+)]
 A             image/tiles_new/kis_tiledrectiterator.cc   [License: GPL (v2+)]
 A             image/tiles_new/kis_tiledvlineiterator.cc   [License: GPL (v2+)]
 A             image/tiles_new/kis_tilestore.cc   [License: GPL (v2+)]
 A             image/tiles_new/kis_tilestore.h   [License: GPL (v2+)]
 A             image/tiles_new/kis_tilestorememory.cc   [License: GPL (v2+)]
 A             image/tiles_new/kis_tilestorememory.h   [License: GPL (v2+)]
 A             image/tiles_new/kis_tileswapper.cc   [License: GPL (v2+)]
 A             image/tiles_new/kis_tileswapper.h   [License: GPL (v2+)]
 A             image/tiles_new/tests (directory)  
 A             image/tiles_new/tests/CMakeLists.txt  
 A             image/tiles_new/tests/kis_tile_sharing_tester.cpp   [License: GPL (v2+)]
 A             image/tiles_new/tests/kis_tile_sharing_tester.h   [License: GPL (v2+)]
 A             image/tiles_new/tests/kis_tiled_data_tester.cpp   [License: GPL (v2+)]
 A             image/tiles_new/tests/kis_tiled_data_tester.h   [License: GPL (v2+)]
 A             image/tiles_new/tests/kis_tiles_regression_tester.cpp   [License: GPL (v2+)]
 A             image/tiles_new/tests/kis_tiles_regression_tester.h   [License: GPL (v2+)]
 A             image/tiles_new/tests/kis_tileswapper_tester.cpp   [License: GPL (v2+)]
 A             image/tiles_new/tests/kis_tileswapper_tester.h   [License: GPL (v2+)]
 M  +1 -1      ui/kis_dlg_preferences.cc  


--- trunk/koffice/krita/image/CMakeLists.txt #768354:768355
@@ -5,6 +5,11 @@
 
 add_definitions(${KDE4_ENABLE_EXCEPTIONS})
 
+# Chose a tiles backend (comment out the next line to enable the new system):
+set(USE_OLD_TILESYSTEM 1)
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config-tiles.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/../config-tiles.h) ### WRONG PLACE???
+
+if(USE_OLD_TILESYSTEM)
 set(libkritatile_SRCS
 	${CMAKE_SOURCE_DIR}/krita/image/tiles/kis_tiled_random_accessor.cc
 	${CMAKE_SOURCE_DIR}/krita/image/tiles/kis_tiledvlineiterator.cc
@@ -17,6 +22,23 @@
 	${CMAKE_SOURCE_DIR}/krita/image/tiles/kis_tilemanager.cc
 	${CMAKE_SOURCE_DIR}/krita/image/tiles/kis_tile_compressor.cc
 )
+else(USE_OLD_TILESYSTEM)
+set(libkritatile_SRCS
+	${CMAKE_SOURCE_DIR}/krita/image/tiles_new/kis_tiled_random_accessor.cc
+	${CMAKE_SOURCE_DIR}/krita/image/tiles_new/kis_tiledvlineiterator.cc
+	${CMAKE_SOURCE_DIR}/krita/image/tiles_new/kis_tiledhlineiterator.cc
+	${CMAKE_SOURCE_DIR}/krita/image/tiles_new/kis_tileddatamanager.cc
+	${CMAKE_SOURCE_DIR}/krita/image/tiles_new/kis_tile.cc
+	${CMAKE_SOURCE_DIR}/krita/image/tiles_new/kis_tilediterator.cc
+	${CMAKE_SOURCE_DIR}/krita/image/tiles_new/kis_tiledrectiterator.cc
+	${CMAKE_SOURCE_DIR}/krita/image/tiles_new/kis_memento.cc
+	${CMAKE_SOURCE_DIR}/krita/image/tiles_new/kis_tile_compressor.cc
+	${CMAKE_SOURCE_DIR}/krita/image/tiles_new/kis_tilestore.cc
+	${CMAKE_SOURCE_DIR}/krita/image/tiles_new/kis_tilestorememory.cc
+	${CMAKE_SOURCE_DIR}/krita/image/tiles_new/kis_tileswapper.cc
+)
+add_subdirectory( tiles_new )
+endif(USE_OLD_TILESYSTEM)
 
 include_directories( ${KDE4_INCLUDE_DIR}/threadweaver/
                      ${CMAKE_SOURCE_DIR}/krita/image/metadata
--- trunk/koffice/krita/image/kis_datamanager.h #768354:768355
@@ -26,7 +26,16 @@
 
 
 // Change the following two lines to switch (at compiletime) to another datamanager
+//#define USE_OLD_TILESYSTEM
+#include "config-tiles.h" // For the next define
+
+
+#ifdef USE_OLD_TILESYSTEM
 #include "tiles/kis_tileddatamanager.h"
+#else
+#include "tiles_new/kis_tileddatamanager.h"
+#endif
+
 #define ACTUAL_DATAMGR KisTiledDataManager
 
 /**
--- trunk/koffice/krita/image/kis_iterator.cc #768354:768355
@@ -23,7 +23,12 @@
 
 #include "kis_iterator.h"
 #include "kis_datamanager.h"
-#include "kis_tilediterator.h"
+#include "config-tiles.h" // For the next define
+#ifdef USE_OLD_TILESYSTEM
+#include "tiles/kis_tilediterator.h"
+#else
+#include "tiles_new/kis_tilediterator.h"
+#endif
 
 KisRectConstIterator::KisRectConstIterator ( KisDataManager *dm, qint32  x, qint32  y, qint32  w, qint32  h)
 {
--- trunk/koffice/krita/image/kis_paint_device.cc #768354:768355
@@ -112,6 +112,8 @@
 
     m_d->colorSpace = colorSpace->clone();
 
+    Q_ASSERT(m_d->colorSpace);
+
     m_d->pixelSize = m_d->colorSpace->pixelSize();
     m_d->nChannels = m_d->colorSpace->channelCount();
 
--- trunk/koffice/krita/image/kis_random_accessor.h #768354:768355
@@ -24,12 +24,16 @@
 #include <kis_shared_ptr.h>
 #include <krita_export.h>
 #include <kis_global.h>
-#include "kis_tiled_random_accessor.h"
 
+#include "config-tiles.h" // For the next define
+#ifdef USE_OLD_TILESYSTEM
+#include "tiles/kis_tiled_random_accessor.h"
+#else
+#include "tiles_new/kis_tiled_random_accessor.h"
+#endif
+
 typedef KisSharedPtr<KisTiledRandomAccessor> KisTiledRandomAccessorSP;
 
-class KisTiledDataManager;
-
 /**
  * Gives a random access to the pixels of an image. Use the moveTo
  * function to select the pixel. And then rawData to access the value
@@ -40,11 +44,11 @@
 
     friend class KisRandomAccessor;
 
-    KisRandomConstAccessor(KisTiledDataManager *ktm, qint32 x, qint32 y, qint32 offsetx, qint32 offsety, bool writable);
+    KisRandomConstAccessor(KisDataManager *ktm, qint32 x, qint32 y, qint32 offsetx, qint32 offsety, bool writable);
 
 public:
 
-    KisRandomConstAccessor(KisTiledDataManager *ktm, qint32 x, qint32 y, qint32 offsetx, qint32 offsety);
+    KisRandomConstAccessor(KisDataManager *ktm, qint32 x, qint32 y, qint32 offsetx, qint32 offsety);
 
     KisRandomConstAccessor(const KisRandomConstAccessor& rhs);
 
@@ -77,7 +81,7 @@
 
 public:
 
-    KisRandomAccessor(KisTiledDataManager *ktm, qint32 x, qint32 y, qint32 offsetx, qint32 offsety)
+    KisRandomAccessor(KisDataManager *ktm, qint32 x, qint32 y, qint32 offsetx, qint32 offsety)
         : KisRandomConstAccessor(ktm,x,y,offsetx, offsety, true)
         {
         }
@@ -163,8 +167,8 @@
 
 public:
 
-    KisRandomAccessorPixelBase(KisTiledDataManager *ktm,
-                               KisTiledDataManager *ktmSelect,
+    KisRandomAccessorPixelBase(KisDataManager *ktm,
+                               KisDataManager *ktmSelect,
                                qint32 x, qint32 y, qint32 offsetx, qint32 offsety)
         : T( ktm, x, y, offsetx, offsety)
         , KisRandomAccessorPixelTrait<T, TSelect>( this,
--- trunk/koffice/krita/image/tiles/kis_tilediterator.cc #768354:768355
@@ -61,6 +61,8 @@
         m_writable = rhs.m_writable;
         if (m_tile)
             m_tile->addReader();
+        if (m_oldTile)
+            m_oldTile->addReader();
     }
 }
 
@@ -85,6 +87,8 @@
         m_writable = rhs.m_writable;
         if (m_tile)
             m_tile->addReader();
+        if (m_oldTile)
+            m_oldTile->addReader();
     }
     return *this;
 }
--- trunk/koffice/krita/ui/kis_dlg_preferences.cc #768354:768355
@@ -897,7 +897,7 @@
         cfg.setUpdateAllOfQpainterCanvas( dialog->m_performanceSettings->chkUpdateAllOfQPainterCanvas->isChecked() );
         cfg.setUseNearestNeighbour( dialog->m_performanceSettings->chkUseNearestNeighbour->isChecked() );
         // let the tile manager know
-        KisTileManager::instance()->configChanged();
+        //KisTileManager::instance()->configChanged();
 
         dialog->m_tabletSettings->applySettings();
 


More information about the kimageshop mailing list