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++
Force SVG gradients to work in premultiplied alpha mode
Dmitry Kazakov753107e08aa0
diff --git a/libs/flake/svg/SvgParser.cpp b/libs/flake/svg/SvgParser.cppindex 62addad05c..2aec0a38a3 100644--- a/libs/flake/svg/SvgParser.cpp+++ b/libs/flake/svg/SvgParser.cpp@@ -1085,9 +1085,11 @@ QGradient* prepareGradientForShape(const SvgGradientHelper *gradient,}}- // NOTE: this is an internal API in Qt. SVG specs specify that we- // shouldn't interpolate in pre-multiplied space.- resultGradient->setInterpolationMode(QGradient::ComponentInterpolation);+ // TODO: all gradients in Krita are rendered in a premultiplied-alpha+ // mode, which is against SVG standard. We need to fix that. Though+ // it requires deepeer changes, than just mere setting of the+ // QGradient's interpolation mode on loading.+ // resultGradient->setInterpolationMode(QGradient::ComponentInterpolation);return resultGradient;}diff --git a/libs/flake/tests/TestSvgParser.cpp b/libs/flake/tests/TestSvgParser.cppindex 463ad4e224..cdac06c368 100644--- a/libs/flake/tests/TestSvgParser.cpp+++ b/libs/flake/tests/TestSvgParser.cpp@@ -1417,6 +1417,7 @@ void TestSvgParser::testRenderFillLinearGradientTransparent()SvgRenderTester t(data);t.setCheckQImagePremultiplied(true);+ QEXPECT_FAIL("", "TODO: Krita forces all gradients to work in premultiplied space, which is against SVG spec", Abort);t.test_standard_30px_72ppi("fill_gradient_transparent", false);}@@ -1484,6 +1485,7 @@ void TestSvgParser::testRenderFillRadialGradientTransparent()SvgRenderTester t(data);t.setFuzzyThreshold(1);t.setCheckQImagePremultiplied(true);+ QEXPECT_FAIL("", "TODO: Krita forces all gradients to work in premultiplied space, which is against SVG spec", Abort);t.test_standard_30px_72ppi("fill_gradient_radial_transparent", false);}