File indexing completed on 2024-11-10 04:00:28
0001 /* 0002 * SPDX-FileCopyrightText: 2010 Cyrille Berger <cberger@cberger.net> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #include <simpletest.h> 0008 0009 #include "kis_mask_generator_benchmark.h" 0010 0011 #include "kis_circle_mask_generator.h" 0012 #include "kis_rect_mask_generator.h" 0013 0014 void KisMaskGeneratorBenchmark::benchmarkCircle() 0015 { 0016 KisCircleMaskGenerator gen(1000, 0.5, 0.5, 0.5, 3, true); 0017 QBENCHMARK{ 0018 for(int i = -600; i < 600; ++i) 0019 { 0020 for(int j = -600; j < 600; ++j) 0021 { 0022 gen.valueAt(i, j); 0023 } 0024 } 0025 } 0026 } 0027 0028 #include <KoColorSpace.h> 0029 #include <KoColorSpaceRegistry.h> 0030 #include "kis_fixed_paint_device.h" 0031 #include "kis_types.h" 0032 #include "kis_brush_mask_applicator_base.h" 0033 #include "krita_utils.h" 0034 0035 0036 void benchmarkSIMD(qreal fade) { 0037 const KoColorSpace * cs = KoColorSpaceRegistry::instance()->rgb8(); 0038 KisFixedPaintDeviceSP dev = new KisFixedPaintDevice(cs); 0039 dev->setRect(QRect(0, 0, 1000, 1000)); 0040 dev->initialize(); 0041 0042 MaskProcessingData data(dev, cs, nullptr, 0043 0.0, 1.0, 0044 500, 500, 0); 0045 0046 KisCircleMaskGenerator gen(1000, 1.0, fade, fade, 2, false); 0047 0048 KisBrushMaskApplicatorBase *applicator = gen.applicator(); 0049 applicator->initializeData(&data); 0050 0051 QVector<QRect> rects = KritaUtils::splitRectIntoPatches(dev->bounds(), QSize(63, 63)); 0052 0053 QBENCHMARK{ 0054 Q_FOREACH (const QRect &rc, rects) { 0055 applicator->process(rc); 0056 } 0057 } 0058 } 0059 0060 void KisMaskGeneratorBenchmark::benchmarkSIMD_SharpBrush() 0061 { 0062 benchmarkSIMD(1.0); 0063 } 0064 0065 void KisMaskGeneratorBenchmark::benchmarkSIMD_FadedBrush() 0066 { 0067 benchmarkSIMD(0.5); 0068 } 0069 0070 void KisMaskGeneratorBenchmark::benchmarkSquare() 0071 { 0072 KisRectangleMaskGenerator gen(1000, 0.5, 0.5, 0.5, 3, true); 0073 QBENCHMARK{ 0074 for(int i = -600; i < 600; ++i) 0075 { 0076 for(int j = -600; j < 600; ++j) 0077 { 0078 gen.valueAt(i, j); 0079 } 0080 } 0081 } 0082 } 0083 0084 SIMPLE_TEST_MAIN(KisMaskGeneratorBenchmark)