Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

kis_painter_benchmark.cpp 1.96 KB
Newer Older
Lukáš Tvrdý's avatar
Lukáš Tvrdý committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
/*
 *  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_painter_benchmark.h"
#include "kis_benchmark_values.h"

#include "kis_paint_device.h"
#include "kis_iterators_pixel.h"

#include <KoColorSpace.h>
#include <KoColorSpaceRegistry.h>
#include <KoColor.h>

#include <kis_image.h>
#include <kis_painter.h>
33
#include <kis_types.h>
Lukáš Tvrdý's avatar
Lukáš Tvrdý committed
34

35 36
#define GMP_IMAGE_WIDTH 4096
#define GMP_IMAGE_HEIGHT 4096
Lukáš Tvrdý's avatar
Lukáš Tvrdý committed
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58

void KisPainterBenchmark::initTestCase()
{
    m_colorSpace = KoColorSpaceRegistry::instance()->rgb8();    
    
    m_color = new KoColor(m_colorSpace);
    m_color->fromQColor(Qt::red);
}

void KisPainterBenchmark::cleanupTestCase()
{
    delete m_color;
}


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());
    
59
    KisPainter painter(dst);
Lukáš Tvrdý's avatar
Lukáš Tvrdý committed
60 61 62 63
    
    QPoint pos(0,0);
    QRect rc(0,0,GMP_IMAGE_WIDTH, GMP_IMAGE_HEIGHT);
    
64 65
    QBENCHMARK{
        painter.bitBlt(pos,src,rc);
Lukáš Tvrdý's avatar
Lukáš Tvrdý committed
66 67 68 69 70 71 72 73
    }

}



QTEST_KDEMAIN(KisPainterBenchmark, NoGUI)
#include "kis_painter_benchmark.moc"