Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.
C++
Rename KisRandomGenerator->KisRandomGenerator2D
Dmitry Kazakov3d9d85820055
diff --git a/libs/image/CMakeLists.txt b/libs/image/CMakeLists.txtindex 004e32b641..6420f4a1e9 100644--- a/libs/image/CMakeLists.txt+++ b/libs/image/CMakeLists.txt@@ -276,7 +276,7 @@ set(kritaimage_LIB_SRCSkis_processing_information.cppkis_properties_configuration.cckis_random_accessor_ng.cpp- kis_random_generator.cc+ KisRandomGenerator2D.cppkis_random_sub_accessor.cppkis_wrapped_random_accessor.cppkis_selection.ccdiff --git a/libs/image/kis_random_generator.cc b/libs/image/KisRandomGenerator2D.cppsimilarity index 82%rename from libs/image/kis_random_generator.ccrename to libs/image/KisRandomGenerator2D.cppindex 78ee7b7d26..3df50931af 100644--- a/libs/image/kis_random_generator.cc+++ b/libs/image/KisRandomGenerator2D.cpp@@ -7,7 +7,7 @@* SPDX-License-Identifier: GPL-2.0-or-later*/-#include "kis_random_generator.h"+#include "KisRandomGenerator2D.h"/* Mac OS X doesn't define a number of UINT* macros without this before stdlib.h */#define __STDC_LIMIT_MACROS@@ -31,21 +31,21 @@ inline quint64 part(quint64 n1, quint64 n2, int p)return quint64(salt[i][j]) << b;}-struct Q_DECL_HIDDEN KisRandomGenerator::Private {+struct Q_DECL_HIDDEN KisRandomGenerator2D::Private {quint64 seed;};-KisRandomGenerator::KisRandomGenerator(quint64 seed) : d(new Private)+KisRandomGenerator2D::KisRandomGenerator2D(quint64 seed) : d(new Private){d->seed = seed;}-KisRandomGenerator::~KisRandomGenerator()+KisRandomGenerator2D::~KisRandomGenerator2D(){delete d;}-quint64 KisRandomGenerator::randomAt(qint64 x, qint64 y)+quint64 KisRandomGenerator2D::randomAt(qint64 x, qint64 y){const quint64 kxa = 427140578808118991LL;const quint64 kya = 166552399647317237LL;@@ -69,7 +69,7 @@ quint64 KisRandomGenerator::randomAt(qint64 x, qint64 y)return v;}-double KisRandomGenerator::doubleRandomAt(qint64 x, qint64 y)+double KisRandomGenerator2D::doubleRandomAt(qint64 x, qint64 y){return randomAt(x, y) / (double)UINT64_MAX;}diff --git a/libs/image/kis_random_generator.h b/libs/image/KisRandomGenerator2D.hsimilarity index 85%rename from libs/image/kis_random_generator.hrename to libs/image/KisRandomGenerator2D.hindex 181ca09a7f..1d443c1ca7 100644--- a/libs/image/kis_random_generator.h+++ b/libs/image/KisRandomGenerator2D.h@@ -6,8 +6,8 @@* SPDX-License-Identifier: GPL-2.0-or-later*/-#ifndef _KIS_RANDOM_GENERATOR_H_-#define _KIS_RANDOM_GENERATOR_H_+#ifndef _KIS_RANDOM_GENERATOR_2D_H_+#define _KIS_RANDOM_GENERATOR_2D_H_#include <kritaimage_export.h>@@ -20,14 +20,14 @@* needs to always get the same random value at each run, or else the result will constantly* changes when used as an adjustment layer.*/-class KRITAIMAGE_EXPORT KisRandomGenerator+class KRITAIMAGE_EXPORT KisRandomGenerator2D{public:/*** Creates a new instance of a random generator with the given seed.*/- KisRandomGenerator(quint64 seed);- ~KisRandomGenerator();+ KisRandomGenerator2D(quint64 seed);+ ~KisRandomGenerator2D();/*** @return the constant random value corresponding to a given pixel, the value is between 0* and RAND_MAXdiff --git a/libs/image/tests/CMakeLists.txt b/libs/image/tests/CMakeLists.txtindex 9850d4db9d..eb662b8640 100644--- a/libs/image/tests/CMakeLists.txt+++ b/libs/image/tests/CMakeLists.txt@@ -13,11 +13,11 @@ endif()include(KritaAddBrokenUnitTest)-set(KisRandomGeneratorDemoSources kis_random_generator_demo.cpp kimageframe.cpp)-ki18n_wrap_ui(KisRandomGeneratorDemoSources kis_random_generator_demo.ui)-add_executable(KisRandomGeneratorDemo ${KisRandomGeneratorDemoSources})-target_link_libraries(KisRandomGeneratorDemo kritaimage)-ecm_mark_as_test(KisRandomGeneratorDemo)+set(KisRandomGenerator2DDemoSources KisRandomGenerator2DDemo.cpp kimageframe.cpp)+ki18n_wrap_ui(KisRandomGenerator2DDemoSources KisRandomGenerator2DDemo.ui)+add_executable(KisRandomGenerator2DDemo ${KisRandomGenerator2DDemoSources})+target_link_libraries(KisRandomGenerator2DDemo kritaimage)+ecm_mark_as_test(KisRandomGenerator2DDemo)kis_add_tests(@@ -112,7 +112,7 @@ kis_add_tests(kis_image_animation_interface_test.cppkis_walkers_test.cppkis_cage_transform_worker_test.cpp- kis_random_generator_test.cpp+ KisRandomGenerator2DTest.cppkis_keyframing_test.cppkis_time_span_test.cppkis_filter_mask_test.cpp@@ -161,5 +161,5 @@ if(APPLE)set_property(TARGET kis_image_animation_interface_test PROPERTY MACOSX_BUNDLE ON)set_property(TARGET kis_cage_transform_worker_test PROPERTY MACOSX_BUNDLE ON)- macos_test_fixrpath(KisRandomGeneratorDemo)+ macos_test_fixrpath(KisRandomGenerator2DDemo)endif()diff --git a/libs/image/tests/kis_random_generator_demo.cpp b/libs/image/tests/KisRandomGenerator2DDemo.cppsimilarity index 89%rename from libs/image/tests/kis_random_generator_demo.cpprename to libs/image/tests/KisRandomGenerator2DDemo.cppindex 6ff1ebc3e6..beff2f12cf 100644--- a/libs/image/tests/kis_random_generator_demo.cpp+++ b/libs/image/tests/KisRandomGenerator2DDemo.cpp@@ -2,8 +2,8 @@* SPDX-License-Identifier: GPL-3.0-or-later*/-#include "kis_random_generator_demo.h"-#include "../kis_random_generator.h"+#include "KisRandomGenerator2DDemo.h"+#include "KisRandomGenerator2D.h"#include <ctime>#include <cstdlib>@@ -24,7 +24,7 @@ Noise::~Noise()void Noise::update(quint64 seed, int shift, int cutoff, bool chR, bool chG, bool chB){- KisRandomGenerator rand(seed);+ KisRandomGenerator2D rand(seed);int h[256][256] = { { 0 } };int m = 0;@@ -93,7 +93,7 @@ const int WIDTH = 1024;const int HEIGHT = 1024;Noise noise(WIDTH, HEIGHT);-KisRandomGeneratorDemo::KisRandomGeneratorDemo(QWidget* parent) : QWidget(parent)+KisRandomGenerator2DDemo::KisRandomGenerator2DDemo(QWidget* parent) : QWidget(parent){_noUpdate = true;setupUi(this);@@ -108,11 +108,11 @@ KisRandomGeneratorDemo::KisRandomGeneratorDemo(QWidget* parent) : QWidget(parentupdateNoise();}-KisRandomGeneratorDemo::~KisRandomGeneratorDemo()+KisRandomGenerator2DDemo::~KisRandomGenerator2DDemo(){}-void KisRandomGeneratorDemo::updateNoise()+void KisRandomGenerator2DDemo::updateNoise(){if (_noUpdate)return;@@ -142,7 +142,7 @@ void KisRandomGeneratorDemo::updateNoise()int main(int argc, char **argv){QApplication app(argc, argv);- KisRandomGeneratorDemo *demo = new KisRandomGeneratorDemo;+ KisRandomGenerator2DDemo *demo = new KisRandomGenerator2DDemo;demo->show();return app.exec();}diff --git a/libs/image/tests/kis_random_generator_demo.h b/libs/image/tests/KisRandomGenerator2DDemo.hsimilarity index 70%rename from libs/image/tests/kis_random_generator_demo.hrename to libs/image/tests/KisRandomGenerator2DDemo.hindex 0f2724220a..9dfc681f9c 100644--- a/libs/image/tests/kis_random_generator_demo.h+++ b/libs/image/tests/KisRandomGenerator2DDemo.h@@ -4,10 +4,10 @@* SPDX-License-Identifier: GPL-2.0-or-later*/-#ifndef KIS_RANDOM_GENERATOR_DEMO_H-#define KIS_RANDOM_GENERATOR_DEMO_H+#ifndef KIS_RANDOM_GENERATOR_2D_DEMO_H+#define KIS_RANDOM_GENERATOR_2D_DEMO_H-#include "ui_kis_random_generator_demo.h"+#include "ui_KisRandomGenerator2DDemo.h"class Noise {public:@@ -27,12 +27,12 @@ private:quint64 _min, _max, _sum;};-class KisRandomGeneratorDemo: public QWidget, Ui::NoiseDemoUi+class KisRandomGenerator2DDemo: public QWidget, Ui::NoiseDemoUi{Q_OBJECTpublic:- KisRandomGeneratorDemo(QWidget* parent = 0);- ~KisRandomGeneratorDemo() override;+ KisRandomGenerator2DDemo(QWidget* parent = 0);+ ~KisRandomGenerator2DDemo() override;public Q_SLOTS:void updateNoise();diff --git a/libs/image/tests/kis_random_generator_demo.ui b/libs/image/tests/KisRandomGenerator2DDemo.uisimilarity index 100%rename from libs/image/tests/kis_random_generator_demo.uirename to libs/image/tests/KisRandomGenerator2DDemo.uidiff --git a/libs/image/tests/kis_random_generator_test.cpp b/libs/image/tests/KisRandomGenerator2DTest.cppsimilarity index 75%rename from libs/image/tests/kis_random_generator_test.cpprename to libs/image/tests/KisRandomGenerator2DTest.cppindex 566510e3db..c6da4e7494 100644--- a/libs/image/tests/kis_random_generator_test.cpp+++ b/libs/image/tests/KisRandomGenerator2DTest.cpp@@ -4,19 +4,19 @@* SPDX-License-Identifier: GPL-2.0-or-later*/-#include "kis_random_generator_test.h"+#include "KisRandomGenerator2DTest.h"#include <simpletest.h>-#include "kis_random_generator.h"+#include "KisRandomGenerator2D.h"#include <math.h>#include "kis_debug.h"-void KisRandomGeneratorTest::twoSeeds(quint64 seed1, quint64 seed2)+void KisRandomGenerator2DTest::twoSeeds(quint64 seed1, quint64 seed2){- KisRandomGenerator rand1(seed1);- KisRandomGenerator rand2(seed2);+ KisRandomGenerator2D rand1(seed1);+ KisRandomGenerator2D rand2(seed2);for (int y = 0; y < 100; y++) {for (int x = 0; x < 100; x++) {QVERIFY(rand1.randomAt(x, y) != rand2.randomAt(x, y));@@ -24,7 +24,7 @@ void KisRandomGeneratorTest::twoSeeds(quint64 seed1, quint64 seed2)}}-void KisRandomGeneratorTest::twoSeeds()+void KisRandomGenerator2DTest::twoSeeds(){twoSeeds(140, 1405);twoSeeds(140515215, 232351521LL);@@ -35,9 +35,9 @@ void KisRandomGeneratorTest::twoSeeds()}-void KisRandomGeneratorTest::twoCalls(quint64 seed)+void KisRandomGenerator2DTest::twoCalls(quint64 seed){- KisRandomGenerator rand1(seed);+ KisRandomGenerator2D rand1(seed);for (int y = 0; y < 100; y++) {for (int x = 0; x < 100; x++) {dbgKrita << rand1.randomAt(x, y) << rand1.randomAt(x, y);@@ -47,7 +47,7 @@ void KisRandomGeneratorTest::twoCalls(quint64 seed)}}-void KisRandomGeneratorTest::twoCalls()+void KisRandomGenerator2DTest::twoCalls(){twoCalls(5023325165LL);twoCalls(751461346LL);@@ -57,10 +57,10 @@ void KisRandomGeneratorTest::twoCalls()twoCalls(6013413451550LL);}-void KisRandomGeneratorTest::testConstantness(quint64 seed)+void KisRandomGenerator2DTest::testConstantness(quint64 seed){- KisRandomGenerator rand1(seed);- KisRandomGenerator rand2(seed);+ KisRandomGenerator2D rand1(seed);+ KisRandomGenerator2D rand2(seed);for (int y = 0; y < 100; y++) {for (int x = 0; x < 100; x++) {QCOMPARE(rand1.randomAt(x, y), rand2.randomAt(x, y));@@ -70,7 +70,7 @@ void KisRandomGeneratorTest::testConstantness(quint64 seed)}-void KisRandomGeneratorTest::testConstantness()+void KisRandomGenerator2DTest::testConstantness(){testConstantness(50);testConstantness(75);@@ -82,11 +82,11 @@ void KisRandomGeneratorTest::testConstantness()#include <iostream>-void KisRandomGeneratorTest::testEvolution()+void KisRandomGenerator2DTest::testEvolution(){int counter = 0;- KisRandomGenerator randg(10000);+ KisRandomGenerator2D randg(10000);for (int y = 0; y < 1024; y++) {for (int x = 0; x < 1024; x++) {quint64 number = randg.randomAt(x, y);@@ -107,4 +107,4 @@ void KisRandomGeneratorTest::testEvolution()QVERIFY(counter == 0);}-SIMPLE_TEST_MAIN(KisRandomGeneratorTest)+SIMPLE_TEST_MAIN(KisRandomGenerator2DTest)diff --git a/libs/image/tests/kis_random_generator_test.h b/libs/image/tests/KisRandomGenerator2DTest.hsimilarity index 77%rename from libs/image/tests/kis_random_generator_test.hrename to libs/image/tests/KisRandomGenerator2DTest.hindex f165a196c5..33bb74a4b5 100644--- a/libs/image/tests/kis_random_generator_test.h+++ b/libs/image/tests/KisRandomGenerator2DTest.h@@ -4,12 +4,12 @@* SPDX-License-Identifier: GPL-2.0-or-later*/-#ifndef KIS_RANDOM_GENERATOR_TEST_H-#define KIS_RANDOM_GENERATOR_TEST_H+#ifndef KIS_RANDOM_GENERATOR_2D_TEST_H+#define KIS_RANDOM_GENERATOR_2D_TEST_H#include <simpletest.h>-class KisRandomGeneratorTest : public QObject+class KisRandomGenerator2DTest : public QObject{Q_OBJECTdiff --git a/libs/ui/utils/KisDitherUtil.cpp b/libs/ui/utils/KisDitherUtil.cppindex 31ac93c556..4b6aa4f53c 100644--- a/libs/ui/utils/KisDitherUtil.cpp+++ b/libs/ui/utils/KisDitherUtil.cpp@@ -9,7 +9,7 @@#include "KisDitherUtil.h"#include <kis_filter_configuration.h>-#include <kis_random_generator.h>+#include <KisRandomGenerator2D.h>#include <KisResourcesInterface.h>KisDitherUtil::KisDitherUtil()@@ -70,7 +70,7 @@ qreal KisDitherUtil::threshold(const QPoint &pos)threshold = (m_patternUseAlpha ? color.alphaF() : color.lightnessF());}else if (m_thresholdMode == ThresholdMode::Noise) {- KisRandomGenerator random(m_noiseSeed);+ KisRandomGenerator2D random(m_noiseSeed);threshold = random.doubleRandomAt(pos.x(), pos.y());}else threshold = 0.5;diff --git a/plugins/filters/noisefilter/noisefilter.cpp b/plugins/filters/noisefilter/noisefilter.cppindex 8981ffafb3..5f42f2edf7 100644--- a/plugins/filters/noisefilter/noisefilter.cpp+++ b/plugins/filters/noisefilter/noisefilter.cpp@@ -25,7 +25,7 @@#include <kis_layer.h>#include <filter/kis_filter_registry.h>#include <kis_global.h>-#include <kis_random_generator.h>+#include <KisRandomGenerator2D.h>#include <kis_selection.h>#include <kis_types.h>#include <filter/kis_filter_category_ids.h>@@ -111,10 +111,10 @@ void KisFilterNoise::processImpl(KisPaintDeviceSP device,seedBlue = config->getInt("seedBlue", seedBlue);}- KisRandomGenerator randt(seedThreshold);- KisRandomGenerator randr(seedRed);- KisRandomGenerator randg(seedGreen);- KisRandomGenerator randb(seedBlue);+ KisRandomGenerator2D randt(seedThreshold);+ KisRandomGenerator2D randr(seedRed);+ KisRandomGenerator2D randg(seedGreen);+ KisRandomGenerator2D randb(seedBlue);KisSequentialIteratorProgress it(device, applyRect, progressUpdater);diff --git a/plugins/filters/palettize/palettize.cpp b/plugins/filters/palettize/palettize.cppindex ca61685430..37d7bbe0b0 100644--- a/plugins/filters/palettize/palettize.cpp+++ b/plugins/filters/palettize/palettize.cpp@@ -19,7 +19,7 @@#include <KisResourceItemChooser.h>#include <KoColorSet.h>#include <KoPattern.h>-#include <kis_random_generator.h>+#include <KisRandomGenerator2D.h>#include <KisDitherUtil.h>#include <KisGlobalResourcesInterface.h>#include <KoResourceLoadResult.h>diff --git a/plugins/filters/randompickfilter/randompickfilter.cpp b/plugins/filters/randompickfilter/randompickfilter.cppindex f424ab9396..812c2f34e1 100644--- a/plugins/filters/randompickfilter/randompickfilter.cpp+++ b/plugins/filters/randompickfilter/randompickfilter.cpp@@ -27,7 +27,7 @@#include <kis_layer.h>#include <kis_paint_device.h>#include <kis_random_accessor_ng.h>-#include <kis_random_generator.h>+#include <KisRandomGenerator2D.h>#include <kis_selection.h>#include <kis_types.h>#include <filter/kis_filter_category_ids.h>@@ -83,9 +83,9 @@ void KisFilterRandomPick::processImpl(KisPaintDeviceSP device,seedH = config->getInt("seedH", seedH);seedV = config->getInt("seedV", seedV);}- KisRandomGenerator randT(seedThreshold);- KisRandomGenerator randH(seedH);- KisRandomGenerator randV(seedV);+ KisRandomGenerator2D randT(seedThreshold);+ KisRandomGenerator2D randH(seedH);+ KisRandomGenerator2D randV(seedV);KisSequentialIteratorProgress dstIt(device, applyRect, progressUpdater);KisRandomConstAccessorSP srcRA = device->createRandomConstAccessorNG();