Commit f6cb2056 authored by Lukáš Tvrdý's avatar Lukáš Tvrdý

Add KisFillPainter benchmark to benchmark Flood fill tool speed.

svn path=/trunk/koffice/; revision=1098274
parent 42acd6ed
...@@ -18,6 +18,7 @@ set(kis_blur_benchmark_SRCS kis_blur_benchmark.cpp) ...@@ -18,6 +18,7 @@ set(kis_blur_benchmark_SRCS kis_blur_benchmark.cpp)
set(kis_painter_benchmark_SRCS kis_painter_benchmark.cpp) set(kis_painter_benchmark_SRCS kis_painter_benchmark.cpp)
set(kis_stroke_benchmark_SRCS kis_stroke_benchmark.cpp) set(kis_stroke_benchmark_SRCS kis_stroke_benchmark.cpp)
set(kis_fast_math_benchmark_SRCS kis_fast_math_benchmark.cpp) set(kis_fast_math_benchmark_SRCS kis_fast_math_benchmark.cpp)
set(kis_floodfill_benchmark_SRCS kis_floodfill_benchmark.cpp)
kde4_add_unit_test(KisDatamanagerBenchmark TESTNAME krita-benchmarks-KisDataManager ${kis_datamanager_benchmark_SRCS}) kde4_add_unit_test(KisDatamanagerBenchmark TESTNAME krita-benchmarks-KisDataManager ${kis_datamanager_benchmark_SRCS})
kde4_add_unit_test(KisHLineIteratorBenchmark TESTNAME krita-benchmarks-KisHLineIterator ${kis_hiterator_benchmark_SRCS}) kde4_add_unit_test(KisHLineIteratorBenchmark TESTNAME krita-benchmarks-KisHLineIterator ${kis_hiterator_benchmark_SRCS})
...@@ -30,6 +31,7 @@ kde4_add_unit_test(KisBlurBenchmark TESTNAME krita-benchmarks-KisBlurBenchmark $ ...@@ -30,6 +31,7 @@ kde4_add_unit_test(KisBlurBenchmark TESTNAME krita-benchmarks-KisBlurBenchmark $
kde4_add_unit_test(KisPainterBenchmark TESTNAME krita-benchmarks-KisPainterBenchmark ${kis_painter_benchmark_SRCS}) kde4_add_unit_test(KisPainterBenchmark TESTNAME krita-benchmarks-KisPainterBenchmark ${kis_painter_benchmark_SRCS})
kde4_add_unit_test(KisStrokeBenchmark TESTNAME krita-benchmarks-KisStrokeBenchmark ${kis_stroke_benchmark_SRCS}) kde4_add_unit_test(KisStrokeBenchmark TESTNAME krita-benchmarks-KisStrokeBenchmark ${kis_stroke_benchmark_SRCS})
kde4_add_unit_test(KisFastMathBenchmark TESTNAME krita-benchmarks-KisFastMath ${kis_fast_math_benchmark_SRCS}) kde4_add_unit_test(KisFastMathBenchmark TESTNAME krita-benchmarks-KisFastMath ${kis_fast_math_benchmark_SRCS})
kde4_add_unit_test(KisFloodfillBenchmark TESTNAME krita-benchmarks-KisFloodFill ${kis_floodfill_benchmark_SRCS})
target_link_libraries(KisDatamanagerBenchmark ${KDE4_KDEUI_LIBS} kritaimage ${QT_QTTEST_LIBRARY}) target_link_libraries(KisDatamanagerBenchmark ${KDE4_KDEUI_LIBS} kritaimage ${QT_QTTEST_LIBRARY})
target_link_libraries(KisHLineIteratorBenchmark ${KDE4_KDEUI_LIBS} kritaimage ${QT_QTTEST_LIBRARY}) target_link_libraries(KisHLineIteratorBenchmark ${KDE4_KDEUI_LIBS} kritaimage ${QT_QTTEST_LIBRARY})
...@@ -41,4 +43,7 @@ target_link_libraries(KisBContrastBenchmark ${KDE4_KDEUI_LIBS} kritaimage ${QT_Q ...@@ -41,4 +43,7 @@ target_link_libraries(KisBContrastBenchmark ${KDE4_KDEUI_LIBS} kritaimage ${QT_Q
target_link_libraries(KisBlurBenchmark ${KDE4_KDEUI_LIBS} kritaimage ${QT_QTTEST_LIBRARY}) target_link_libraries(KisBlurBenchmark ${KDE4_KDEUI_LIBS} kritaimage ${QT_QTTEST_LIBRARY})
target_link_libraries(KisPainterBenchmark ${KDE4_KDEUI_LIBS} kritaimage ${QT_QTTEST_LIBRARY}) target_link_libraries(KisPainterBenchmark ${KDE4_KDEUI_LIBS} kritaimage ${QT_QTTEST_LIBRARY})
target_link_libraries(KisStrokeBenchmark ${KDE4_KDEUI_LIBS} kritaimage ${QT_QTTEST_LIBRARY}) target_link_libraries(KisStrokeBenchmark ${KDE4_KDEUI_LIBS} kritaimage ${QT_QTTEST_LIBRARY})
target_link_libraries(KisFastMathBenchmark ${KDE4_KDEUI_LIBS} kritaimage ${QT_QTTEST_LIBRARY}) target_link_libraries(KisFastMathBenchmark ${KDE4_KDEUI_LIBS} kritaimage ${QT_QTTEST_LIBRARY})
\ No newline at end of file target_link_libraries(KisFloodfillBenchmark ${KDE4_KDEUI_LIBS} kritaimage ${QT_QTTEST_LIBRARY})
/*
* Copyright (c) 2010 Lukáš Tvrdý <lukast.dev@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <qtest_kde.h>
#include "kis_benchmark_values.h"
#include "kis_paint_device.h"
#include "kis_random_accessor.h"
#include <KoColorSpace.h>
#include <KoColorSpaceRegistry.h>
#include <KoColor.h>
#include <kis_image.h>
#include "kis_floodfill_benchmark.h"
#include <kis_fill_painter.h>
#include <KoCompositeOps.h>
void KisFloodFillBenchmark::initTestCase()
{
m_colorSpace = KoColorSpaceRegistry::instance()->rgb8();
m_device = new KisPaintDevice(m_colorSpace);
m_color = KoColor(m_colorSpace);
QColor qcolor(Qt::red);
srand(31524744);
int tilew = 38;
int tileh = 56;
m_color.fromQColor(QColor(0,0,0,0)); // default pixel
m_device->fill( 0,0,GMP_IMAGE_WIDTH, GMP_IMAGE_HEIGHT,m_color.data() );
// fill the image with red ellipses (like some random dabs)
m_color.fromQColor(Qt::red);
KisPainter painter(m_device);
painter.setFillStyle(KisPainter::FillStyleForegroundColor);
painter.setPaintColor(m_color);
int x = 0;
int y = 0;
for (int i = 0; i < 100;i++){
x = rand() % GMP_IMAGE_WIDTH;
y = rand() % GMP_IMAGE_HEIGHT;
// plus 10 so that we don't fill the ellipse
painter.paintEllipse(x+ 10, y+ 10, tilew, tileh);
}
}
void KisFloodFillBenchmark::benchmarkFlood()
{
KoColor fg(m_colorSpace);
KoColor bg(m_colorSpace);
fg.fromQColor(Qt::blue);
bg.fromQColor(Qt::black);
QBENCHMARK
{
QRegion dirty;
KisFillPainter fillPainter(m_device);
//setupPainter(&fillPainter);
fillPainter.setBounds( QRect(0,0,GMP_IMAGE_WIDTH,GMP_IMAGE_HEIGHT) );
fillPainter.setPaintColor( fg );
fillPainter.setBackgroundColor( bg );
fillPainter.beginTransaction(i18n("Flood Fill"));
//fillPainter.setProgress(updater->startSubtask());
fillPainter.setOpacity(OPACITY_OPAQUE_U8);
// default
fillPainter.setFillThreshold(15);
fillPainter.setCompositeOp(COMPOSITE_OVER);
fillPainter.setSampleMerged(false);
fillPainter.setCareForSelection(true);
fillPainter.setWidth(GMP_IMAGE_WIDTH);
fillPainter.setHeight(GMP_IMAGE_HEIGHT);
// fill twice
fillPainter.fillColor(1, 1, false);
dirty = fillPainter.dirtyRegion();
fillPainter.endTransaction();
}
// uncomment this to see the output
//QImage out = m_device->convertToQImage(m_colorSpace->profile(),0,0,GMP_IMAGE_WIDTH,GMP_IMAGE_HEIGHT);
//out.save("fill_output.png");
}
void KisFloodFillBenchmark::cleanupTestCase()
{
}
QTEST_KDEMAIN(KisFloodFillBenchmark, NoGUI)
#include "kis_floodfill_benchmark.moc"
\ No newline at end of file
/*
* Copyright (c) 2010 Lukáš Tvrdý <lukast.dev@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef KIS_FLOODFILL_BENCHMARK_H
#define KIS_FLOODFILL_BENCHMARK_H
#include <KoColor.h>
#include <kis_types.h>
#include <QtTest/QtTest>
class KisPaintDevice;
class KoColorSpace;
class KoColor;
class KisFloodFillBenchmark : public QObject
{
Q_OBJECT
private:
const KoColorSpace * m_colorSpace;
KoColor m_color;
KisPaintDeviceSP m_device;
int m_startX;
int m_startY;
private slots:
void initTestCase();
void cleanupTestCase();
void benchmarkFlood();
};
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment