Krita Source Code Documentation
Loading...
Searching...
No Matches
KoCompositeOpsBenchmark.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2010 Lukáš Tvrdý <lukast.dev@gmail.com>
3 *
4 * SPDX-License-Identifier: LGPL-2.1-or-later
5 */
6
8
12
13#include <KoColorSpaceTraits.h>
15
16#include <QRandomGenerator>
17
18#include <simpletest.h>
19
20const int TILE_WIDTH = 64;
21const int TILE_HEIGHT = 64;
22
23const int IMG_WIDTH = 2048;
24const int IMG_HEIGHT = 2048;
25
26const qreal OPACITY_HALF = 0.5;
27
30
31
32#define COMPOSITE_BENCHMARK \
33 for (int y = 0; y < TILES_IN_HEIGHT; y++){ \
34 for (int x = 0; x < TILES_IN_WIDTH; x++) { \
35 const int rowStride = IMG_WIDTH * KoBgrU8Traits::pixelSize; \
36 const int bufOffset = y * rowStride + x * TILE_WIDTH * KoBgrU8Traits::pixelSize; \
37 compositeOp->composite(m_dstBuffer + bufOffset, rowStride, \
38 m_srcBuffer + bufOffset, rowStride, \
39 m_mskBuffer + bufOffset, rowStride, \
40 TILE_WIDTH, TILE_HEIGHT, \
41 OPACITY_HALF); \
42 } \
43 }
44
46{
47 const int bufLen = IMG_HEIGHT * IMG_WIDTH * KoBgrU8Traits::pixelSize;
48
49 m_dstBuffer = new quint8[bufLen];
50 m_srcBuffer = new quint8[bufLen];
51 m_mskBuffer = new quint8[bufLen];
52}
53
54// this is called before every benchmark
56{
57 QRandomGenerator rng(42);
58
59 for (int i = 0; i < int(IMG_WIDTH * IMG_HEIGHT * KoBgrU8Traits::pixelSize); i++) {
60 const int randVal = rng.bounded(RAND_MAX);
61
62 m_srcBuffer[i] = randVal & 0x0000FF;
63 m_dstBuffer[i] = (randVal & 0x00FF000) >> 8;
64 m_mskBuffer[i] = (randVal & 0xFF0000) >> 16;
65 }
66}
67
68
70{
71 delete [] m_dstBuffer;
72 delete [] m_srcBuffer;
73 delete [] m_mskBuffer;
74}
75
83
91
92
100
101
102QTEST_GUILESS_MAIN(KoCompositeOpsBenchmark)
const int TILES_IN_WIDTH
const qreal OPACITY_HALF
const int IMG_HEIGHT
const int TILE_HEIGHT
const int TILE_WIDTH
const int IMG_WIDTH
#define COMPOSITE_BENCHMARK
const int TILES_IN_HEIGHT
static KoCompositeOp * createOverOp32(const KoColorSpace *cs)
static KoCompositeOp * createAlphaDarkenOpCreamy32(const KoColorSpace *cs)
static KoCompositeOp * createAlphaDarkenOpHard32(const KoColorSpace *cs)
static KoColorSpaceRegistry * instance()
static const quint32 pixelSize