Commit 83b8995c authored by Dmitry Kazakov's avatar Dmitry Kazakov

Activated fastBitBlt in KisPainter

This is an optimization of a special case when colorspaces of two
devices coincide, no selection is present and the devices are not
shifted. This case became 3.5 times faster.

svn path=/trunk/koffice/; revision=1148332
parent 6ec74861
......@@ -32,6 +32,7 @@
#include <KoColorSpace.h>
#include <KoColorSpaceRegistry.h>
#include <KoCompositeOp.h>
#include <KoColor.h>
#include <kis_image.h>
......@@ -53,7 +54,6 @@ void KisPainterBenchmark::cleanupTestCase()
{
}
void KisPainterBenchmark::benchmarkBitBlt()
{
KisPaintDeviceSP src = new KisPaintDevice(m_colorSpace);
......@@ -64,7 +64,7 @@ void KisPainterBenchmark::benchmarkBitBlt()
KisPainter gc(dst);
QPoint pos(0,0);
QRect rc(0,0,TEST_IMAGE_WIDTH, TEST_IMAGE_WIDTH);
QRect rc(0,0,TEST_IMAGE_WIDTH, TEST_IMAGE_HEIGHT);
QBENCHMARK{
for (int i = 0; i < CYCLES ; i++){
......@@ -74,6 +74,26 @@ void KisPainterBenchmark::benchmarkBitBlt()
}
void KisPainterBenchmark::benchmarkFastBitBlt()
{
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());
KisPainter gc(dst);
gc.setCompositeOp(m_colorSpace->compositeOp(COMPOSITE_COPY));
QPoint pos(0,0);
QRect rc(0,0,TEST_IMAGE_WIDTH, TEST_IMAGE_HEIGHT);
QBENCHMARK{
for (int i = 0; i < CYCLES ; i++){
gc.bitBlt(pos,src,rc);
}
}
}
void KisPainterBenchmark::benchmarkBitBltSelection()
{
......@@ -91,7 +111,7 @@ void KisPainterBenchmark::benchmarkBitBltSelection()
gc.setSelection(selection);
QPoint pos(0,0);
QRect rc(0,0,TEST_IMAGE_WIDTH, TEST_IMAGE_WIDTH);
QRect rc(0,0,TEST_IMAGE_WIDTH, TEST_IMAGE_HEIGHT);
QBENCHMARK{
for (int i = 0; i < CYCLES ; i++){
......
......@@ -41,6 +41,7 @@ private slots:
void cleanupTestCase();
void benchmarkBitBlt();
void benchmarkFastBitBlt();
void benchmarkBitBltSelection();
void benchmarkFixedBitBlt();
void benchmarkFixedBitBltSelection();
......
......@@ -345,15 +345,20 @@ void KisPainter::bitBlt(qint32 dx, qint32 dy,
QRect srcRect = QRect(sx, sy, sw, sh);
// In case of COMPOSITE_COPY restricting bitblt to extent can
// have unexpected behavior since it would reduce the area that
// is copied.
if (d->compositeOp->id() != COMPOSITE_COPY) {
srcRect &= srcdev->extent();
if (d->compositeOp->id() == COMPOSITE_COPY) {
if(!d->selection && d->device->fastBitBltPossible(srcdev)) {
d->device->fastBitBlt(srcdev, srcRect);
return;
}
}
else {
// In case of COMPOSITE_COPY restricting bitblt to extent can
// have unexpected behavior since it would reduce the area that
// is copied.
srcRect &= srcdev->extent();
if (srcRect.isEmpty()) {
return;
if(srcRect.isEmpty())
return;
}
dx += srcRect.x() - sx;
......
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