Commit 5c104d57 authored by Lukáš Tvrdý's avatar Lukáš Tvrdý

Add new benchmarks for KisPainter.

svn path=/trunk/koffice/; revision=1082003
parent aa521673
......@@ -18,10 +18,16 @@
#include <qtest_kde.h>
#include <QImage>
#include "kis_painter_benchmark.h"
#include "kis_benchmark_values.h"
#include "kis_paint_device.h"
#include "kis_fixed_paint_device.h"
#include "kis_selection.h"
#include "kis_pixel_selection.h"
#include "kis_iterators_pixel.h"
#include <KoColorSpace.h>
......@@ -32,20 +38,19 @@
#include <kis_painter.h>
#include <kis_types.h>
#define GMP_IMAGE_WIDTH 4096
#define GMP_IMAGE_HEIGHT 4096
#define CYCLES 20
void KisPainterBenchmark::initTestCase()
{
m_colorSpace = KoColorSpaceRegistry::instance()->rgb8();
m_color = new KoColor(m_colorSpace);
m_color->fromQColor(Qt::red);
m_color = KoColor(m_colorSpace);
m_color.fromQColor(Qt::red);
}
void KisPainterBenchmark::cleanupTestCase()
{
delete m_color;
}
......@@ -53,16 +58,96 @@ void KisPainterBenchmark::benchmarkBitBlt()
{
KisPaintDeviceSP src = new KisPaintDevice(m_colorSpace);
KisPaintDeviceSP dst = new KisPaintDevice(m_colorSpace);
src->fill(0,0,GMP_IMAGE_WIDTH, GMP_IMAGE_HEIGHT, m_color->data());
dst->fill(0,0,GMP_IMAGE_WIDTH, GMP_IMAGE_HEIGHT, m_color->data());
src->fill(0,0,TEST_IMAGE_WIDTH, TEST_IMAGE_HEIGHT, m_color.data());
dst->fill(0,0,TEST_IMAGE_WIDTH, TEST_IMAGE_HEIGHT, m_color.data());
KisPainter gc(dst);
QPoint pos(0,0);
QRect rc(0,0,TEST_IMAGE_WIDTH, TEST_IMAGE_WIDTH);
QBENCHMARK{
for (int i = 0; i < CYCLES ; i++){
gc.bitBlt(pos,src,rc);
}
}
}
void KisPainterBenchmark::benchmarkBitBltSelection()
{
KisPaintDeviceSP src = new KisPaintDevice(m_colorSpace);
KisPaintDeviceSP dst = new KisPaintDevice(m_colorSpace);
src->fill(0,0,TEST_IMAGE_WIDTH, TEST_IMAGE_HEIGHT, m_color.data());
dst->fill(0,0,TEST_IMAGE_WIDTH, TEST_IMAGE_HEIGHT, m_color.data());
KisSelectionSP selection = new KisSelection();
selection->getOrCreatePixelSelection()->select(QRect(0, 0, TEST_IMAGE_WIDTH, TEST_IMAGE_HEIGHT));
selection->updateProjection();
KisPainter painter(dst);
KisPainter gc(dst);
gc.setSelection(selection);
QPoint pos(0,0);
QRect rc(0,0,GMP_IMAGE_WIDTH, GMP_IMAGE_HEIGHT);
QRect rc(0,0,TEST_IMAGE_WIDTH, TEST_IMAGE_WIDTH);
QBENCHMARK{
for (int i = 0; i < CYCLES ; i++){
gc.bitBlt(pos,src,rc);
}
}
}
void KisPainterBenchmark::benchmarkFixedBitBlt()
{
QImage img(TEST_IMAGE_WIDTH,TEST_IMAGE_HEIGHT,QImage::Format_ARGB32);
img.fill(255);
KisFixedPaintDeviceSP fdev = new KisFixedPaintDevice(m_colorSpace);
fdev->convertFromQImage(img, "");
KisPaintDeviceSP dst = new KisPaintDevice(m_colorSpace);
KisPainter gc(dst);
QPoint pos(0, 0);
QRect rc = img.rect();
QBENCHMARK{
for (int i = 0; i < CYCLES ; i++){
gc.bltFixed(pos,fdev,rc);
}
}
}
void KisPainterBenchmark::benchmarkFixedBitBltSelection()
{
QImage img(TEST_IMAGE_WIDTH,TEST_IMAGE_HEIGHT,QImage::Format_ARGB32);
img.fill(128);
KisFixedPaintDeviceSP fdev = new KisFixedPaintDevice(m_colorSpace);
fdev->convertFromQImage(img, "");
KisPaintDeviceSP dst = new KisPaintDevice(m_colorSpace);
KisSelectionSP selection = new KisSelection();
selection->getOrCreatePixelSelection()->select(QRect(0, 0, TEST_IMAGE_WIDTH , TEST_IMAGE_HEIGHT));
selection->updateProjection();
KisPainter gc(dst);
gc.setSelection(selection);
QPoint pos(0, 0);
QRect rc = img.rect();
QBENCHMARK{
painter.bitBlt(pos,src,rc);
for (int i = 0; i < CYCLES ; i++){
gc.bltFixed(pos,fdev,rc);
}
}
}
......
......@@ -20,24 +20,31 @@
#define KIS_PAINTER_BENCHMARK_H
#include <QtTest/QtTest>
#include <KoColor.h>
#include <kis_types.h>
class KisPaintDevice;
class KoColorSpace;
class KoColor;
class KisPainterBenchmark : public QObject
{
Q_OBJECT
private:
const KoColorSpace * m_colorSpace;
KoColor * m_color;
KoColor m_color;
private slots:
void initTestCase();
void cleanupTestCase();
void benchmarkBitBlt();
void benchmarkBitBltSelection();
void benchmarkFixedBitBlt();
void benchmarkFixedBitBltSelection();
};
......
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