Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package kquickcharts for openSUSE:Factory checked in at 2022-10-11 18:00:18 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/kquickcharts (Old) and /work/SRC/openSUSE:Factory/.kquickcharts.new.2275 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "kquickcharts" Tue Oct 11 18:00:18 2022 rev:35 rq:1009020 version:5.99.0 Changes: -------- --- /work/SRC/openSUSE:Factory/kquickcharts/kquickcharts.changes 2022-09-13 15:10:35.168844809 +0200 +++ /work/SRC/openSUSE:Factory/.kquickcharts.new.2275/kquickcharts.changes 2022-10-11 18:02:16.973767937 +0200 @@ -1,0 +2,13 @@ +Sat Oct 1 15:56:03 UTC 2022 - Christophe Giboudeaux <christo...@krop.fr> + +- Update to 5.99.0 + * New feature release + * For more details please see: + * https://kde.org/announcements/frameworks/5/5.99.0 +- Changes since 5.98.0: + * Unpack points in the fragment shader of a line chart (kde#449005) + * Adapt shaders to use Qt shader tools for Qt 6 + * Adapt to QSGMaterialShader API changes in Qt 6 + * Adapt to variant comparison changes in Qt 6 + +------------------------------------------------------------------- Old: ---- kquickcharts-5.98.0.tar.xz kquickcharts-5.98.0.tar.xz.sig New: ---- kquickcharts-5.99.0.tar.xz kquickcharts-5.99.0.tar.xz.sig ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ kquickcharts.spec ++++++ --- /var/tmp/diff_new_pack.pqMLQV/_old 2022-10-11 18:02:17.481768758 +0200 +++ /var/tmp/diff_new_pack.pqMLQV/_new 2022-10-11 18:02:17.485768765 +0200 @@ -16,14 +16,14 @@ # -%define _tar_path 5.98 +%define _tar_path 5.99 # Full KF5 version (e.g. 5.33.0) %{!?_kf5_version: %global _kf5_version %{version}} # Last major and minor KF5 version (e.g. 5.33) %{!?_kf5_bugfix_version: %define _kf5_bugfix_version %(echo %{_kf5_version} | awk -F. '{print $1"."$2}')} %bcond_without released Name: kquickcharts -Version: 5.98.0 +Version: 5.99.0 Release: 0 Summary: Set of charts for QtQuick applications License: LGPL-2.1-or-later ++++++ kquickcharts-5.98.0.tar.xz -> kquickcharts-5.99.0.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kquickcharts-5.98.0/.gitlab-ci.yml new/kquickcharts-5.99.0/.gitlab-ci.yml --- old/kquickcharts-5.98.0/.gitlab-ci.yml 2022-09-05 11:30:04.000000000 +0200 +++ new/kquickcharts-5.99.0/.gitlab-ci.yml 2022-10-01 15:20:32.000000000 +0200 @@ -6,3 +6,6 @@ - https://invent.kde.org/sysadmin/ci-utilities/raw/master/gitlab-templates/android.yml - https://invent.kde.org/sysadmin/ci-utilities/raw/master/gitlab-templates/freebsd.yml - https://invent.kde.org/sysadmin/ci-utilities/raw/master/gitlab-templates/windows.yml + - https://invent.kde.org/sysadmin/ci-utilities/raw/master/gitlab-templates/linux-qt6.yml + - https://invent.kde.org/sysadmin/ci-utilities/raw/master/gitlab-templates/android-qt6.yml + - https://invent.kde.org/sysadmin/ci-utilities/raw/master/gitlab-templates/freebsd-qt6.yml diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kquickcharts-5.98.0/CMakeLists.txt new/kquickcharts-5.99.0/CMakeLists.txt --- old/kquickcharts-5.98.0/CMakeLists.txt 2022-09-05 11:30:04.000000000 +0200 +++ new/kquickcharts-5.99.0/CMakeLists.txt 2022-10-01 15:20:32.000000000 +0200 @@ -1,12 +1,12 @@ cmake_minimum_required(VERSION 3.16) -set(KF_VERSION "5.98.0") # handled by release scripts -set(KF_DEP_VERSION "5.98.0") # handled by release scripts +set(KF_VERSION "5.99.0") # handled by release scripts +set(KF_DEP_VERSION "5.99.0") # handled by release scripts project(KQuickCharts VERSION ${KF_VERSION}) include(FeatureSummary) -find_package(ECM 5.98.0 NO_MODULE) +find_package(ECM 5.99.0 NO_MODULE) set_package_properties(ECM PROPERTIES TYPE REQUIRED DESCRIPTION "Extra CMake Modules." URL "https://commits.kde.org/extra-cmake-modules") feature_summary(WHAT REQUIRED_PACKAGES_NOT_FOUND FATAL_ON_MISSING_REQUIRED_PACKAGES) @@ -28,6 +28,9 @@ set(REQUIRED_QT_VERSION 5.15.2) find_package(Qt${QT_MAJOR_VERSION} ${REQUIRED_QT_VERSION} CONFIG REQUIRED Qml Quick QuickControls2) +if (QT_MAJOR_VERSION EQUAL "6") + find_package(Qt6 ${REQUIRED_QT_VERSION} CONFIG REQUIRED ShaderTools) +endif() set(EXCLUDE_DEPRECATED_BEFORE_AND_AT 0 CACHE STRING "Control the range of deprecated API excluded from the build [default=0].") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kquickcharts-5.98.0/autotests/MapProxySourceTest.cpp new/kquickcharts-5.99.0/autotests/MapProxySourceTest.cpp --- old/kquickcharts-5.98.0/autotests/MapProxySourceTest.cpp 2022-09-05 11:30:04.000000000 +0200 +++ new/kquickcharts-5.99.0/autotests/MapProxySourceTest.cpp 2022-10-01 15:20:32.000000000 +0200 @@ -47,10 +47,10 @@ QTest::newRow("colors") << QVariantList{qs("red"), qs("green"), qs("blue"), qs("red"), qs("green"), qs("blue")} - << QVariantMap{{qs("red"), QColor{Qt::red}}, {qs("green"), QColor{Qt::green}}, {qs("blue"), QColor{Qt::blue}}} - << QVariantList{QColor{Qt::red}, QColor{Qt::green}, QColor{Qt::blue}, QColor{Qt::red}, QColor{Qt::green}, QColor{Qt::blue}} - << QVariant{QColor{Qt::blue}} - << QVariant{QColor{Qt::red}}; + << QVariantMap{{qs("red"), QColor{Qt::red}.rgba()}, {qs("green"), QColor{Qt::green}.rgba()}, {qs("blue"), QColor{Qt::blue}.rgba()}} + << QVariantList{QColor{Qt::red}.rgba(), QColor{Qt::green}.rgba(), QColor{Qt::blue}.rgba(), QColor{Qt::red}.rgba(), QColor{Qt::green}.rgba(), QColor{Qt::blue}.rgba()} + << QVariant{QColor{Qt::blue}.rgba()} + << QVariant{QColor{Qt::red}.rgba()}; // clang-format on } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kquickcharts-5.98.0/examples/charts/CMakeLists.txt new/kquickcharts-5.99.0/examples/charts/CMakeLists.txt --- old/kquickcharts-5.98.0/examples/charts/CMakeLists.txt 2022-09-05 11:30:04.000000000 +0200 +++ new/kquickcharts-5.99.0/examples/charts/CMakeLists.txt 2022-10-01 15:20:32.000000000 +0200 @@ -1,6 +1,6 @@ -find_package(Qt5Widgets REQUIRED) -set_package_properties(Qt5Widgets PROPERTIES TYPE REQUIRED PURPOSE "The charts example needs Qt Widgets so the Plasma desktop style works properly.") +find_package(Qt${QT_MAJOR_VERSION}Widgets REQUIRED) +set_package_properties(Qt${QT_MAJOR_VERSION}Widgets PROPERTIES TYPE REQUIRED PURPOSE "The charts example needs Qt Widgets so the Plasma desktop style works properly.") find_package(KF5Kirigami2 REQUIRED) set_package_properties(KF5Kirigami2 PROPERTIES TYPE REQUIRED PURPOSE "The charts example uses Kirigami for its UI.") find_package(KF5Declarative REQUIRED) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kquickcharts-5.98.0/src/BarChart.cpp new/kquickcharts-5.99.0/src/BarChart.cpp --- old/kquickcharts-5.98.0/src/BarChart.cpp 2022-09-05 11:30:04.000000000 +0200 +++ new/kquickcharts-5.99.0/src/BarChart.cpp 2022-10-01 15:20:32.000000000 +0200 @@ -222,7 +222,7 @@ auto x = float(m_spacing / 2); const auto itemSpacing = w + m_spacing; - for (const auto &items : qAsConst(m_barDataItems)) { + for (const auto &items : std::as_const(m_barDataItems)) { result.reserve(result.size() + items.size()); if (stacked()) { std::transform(items.crbegin(), items.crend(), std::back_inserter(result), [x, w](const BarData &entry) { @@ -242,7 +242,7 @@ if (stacked()) { auto x = float(itemSpacing / 2 - m_barWidth / 2); - for (const auto &items : qAsConst(m_barDataItems)) { + for (const auto &items : std::as_const(m_barDataItems)) { result.reserve(result.size() + items.size()); std::transform(items.crbegin(), items.crend(), std::back_inserter(result), [x, w](const BarData &entry) { return Bar{x, w, float(entry.value), entry.color}; @@ -255,7 +255,7 @@ auto x = float(itemSpacing / 2 - totalWidth / 2); - for (const auto &items : qAsConst(m_barDataItems)) { + for (const auto &items : std::as_const(m_barDataItems)) { result.reserve(result.size() + items.size()); for (int i = 0; i < items.count(); ++i) { auto entry = items.at(i); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kquickcharts-5.98.0/src/CMakeLists.txt new/kquickcharts-5.99.0/src/CMakeLists.txt --- old/kquickcharts-5.98.0/src/CMakeLists.txt 2022-09-05 11:30:04.000000000 +0200 +++ new/kquickcharts-5.99.0/src/CMakeLists.txt 2022-10-01 15:20:32.000000000 +0200 @@ -1,5 +1,6 @@ add_library(QuickChartsStatic STATIC) +set_target_properties(QuickChartsStatic PROPERTIES POSITION_INDEPENDENT_CODE ON) target_sources(QuickChartsStatic PRIVATE BarChart.cpp @@ -105,6 +106,9 @@ target_sources(QuickCharts PRIVATE ChartsPlugin.cpp ChartsPlugin.h) target_link_libraries(QuickCharts PRIVATE QuickChartsStatic) +if (QT_MAJOR_VERSION EQUAL "6") + add_subdirectory(shaders6) +endif() ecm_generate_export_header(QuickCharts BASE_NAME QuickCharts diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kquickcharts-5.98.0/src/LineChart.cpp new/kquickcharts-5.99.0/src/LineChart.cpp --- old/kquickcharts-5.98.0/src/LineChart.cpp 2022-09-05 11:30:04.000000000 +0200 +++ new/kquickcharts-5.99.0/src/LineChart.cpp 2022-10-01 15:20:32.000000000 +0200 @@ -184,7 +184,7 @@ } m_pointDelegate = newPointDelegate; - for (auto entry : qAsConst(m_pointDelegates)) { + for (auto entry : std::as_const(m_pointDelegates)) { qDeleteAll(entry); } m_pointDelegates.clear(); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kquickcharts-5.98.0/src/datasource/ArraySource.cpp new/kquickcharts-5.99.0/src/datasource/ArraySource.cpp --- old/kquickcharts-5.98.0/src/datasource/ArraySource.cpp 2022-09-05 11:30:04.000000000 +0200 +++ new/kquickcharts-5.99.0/src/datasource/ArraySource.cpp 2022-10-01 15:20:32.000000000 +0200 @@ -28,7 +28,7 @@ QVariant ArraySource::minimum() const { - auto itr = std::min_element(m_array.cbegin(), m_array.cend()); + auto itr = std::min_element(m_array.cbegin(), m_array.cend(), variantCompare); if (itr != m_array.cend()) { return *itr; } @@ -37,7 +37,7 @@ QVariant ArraySource::maximum() const { - auto itr = std::max_element(m_array.cbegin(), m_array.cend()); + auto itr = std::max_element(m_array.cbegin(), m_array.cend(), variantCompare); if (itr != m_array.cend()) { return *itr; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kquickcharts-5.98.0/src/datasource/ChartDataSource.cpp new/kquickcharts-5.99.0/src/datasource/ChartDataSource.cpp --- old/kquickcharts-5.98.0/src/datasource/ChartDataSource.cpp 2022-09-05 11:30:04.000000000 +0200 +++ new/kquickcharts-5.99.0/src/datasource/ChartDataSource.cpp 2022-10-01 15:20:32.000000000 +0200 @@ -7,6 +7,7 @@ #include "ChartDataSource.h" +#include <QColor> #include <QVariant> ChartDataSource::ChartDataSource(QObject *parent) @@ -18,3 +19,12 @@ { return item(0); } + +bool ChartDataSource::variantCompare(const QVariant &lhs, const QVariant &rhs) +{ +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) + return lhs < rhs; +#else + return QVariant::compare(lhs, rhs) == QPartialOrdering::Less; +#endif +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kquickcharts-5.98.0/src/datasource/ChartDataSource.h new/kquickcharts-5.99.0/src/datasource/ChartDataSource.h --- old/kquickcharts-5.98.0/src/datasource/ChartDataSource.h 2022-09-05 11:30:04.000000000 +0200 +++ new/kquickcharts-5.99.0/src/datasource/ChartDataSource.h 2022-10-01 15:20:32.000000000 +0200 @@ -29,6 +29,9 @@ virtual QVariant first() const; Q_SIGNAL void dataChanged(); + +protected: + static bool variantCompare(const QVariant &lhs, const QVariant &rhs); }; #endif // DATASOURCE_H diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kquickcharts-5.98.0/src/datasource/ColorGradientSource.cpp new/kquickcharts-5.99.0/src/datasource/ColorGradientSource.cpp --- old/kquickcharts-5.98.0/src/datasource/ColorGradientSource.cpp 2022-09-05 11:30:04.000000000 +0200 +++ new/kquickcharts-5.99.0/src/datasource/ColorGradientSource.cpp 2022-10-01 15:20:32.000000000 +0200 @@ -73,7 +73,7 @@ { QVariantList colorsVariant; colorsVariant.reserve(m_colors.count()); - for (const QColor &color : qAsConst(m_colors)) { + for (const QColor &color : std::as_const(m_colors)) { colorsVariant.append(color); } return colorsVariant; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kquickcharts-5.98.0/src/datasource/HistoryProxySource.cpp new/kquickcharts-5.99.0/src/datasource/HistoryProxySource.cpp --- old/kquickcharts-5.98.0/src/datasource/HistoryProxySource.cpp 2022-09-05 11:30:04.000000000 +0200 +++ new/kquickcharts-5.99.0/src/datasource/HistoryProxySource.cpp 2022-10-01 15:20:32.000000000 +0200 @@ -70,7 +70,7 @@ } } - return *std::min_element(m_history.begin(), m_history.end()); + return *std::min_element(m_history.begin(), m_history.end(), variantCompare); } QVariant HistoryProxySource::maximum() const @@ -88,7 +88,7 @@ } } - return *std::max_element(m_history.begin(), m_history.end()); + return *std::max_element(m_history.begin(), m_history.end(), variantCompare); } QVariant HistoryProxySource::first() const diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kquickcharts-5.98.0/src/datasource/MapProxySource.cpp new/kquickcharts-5.99.0/src/datasource/MapProxySource.cpp --- old/kquickcharts-5.98.0/src/datasource/MapProxySource.cpp 2022-09-05 11:30:04.000000000 +0200 +++ new/kquickcharts-5.99.0/src/datasource/MapProxySource.cpp 2022-10-01 15:20:32.000000000 +0200 @@ -24,7 +24,7 @@ QVariant MapProxySource::minimum() const { - auto itr = std::min_element(m_map.cbegin(), m_map.cend()); + auto itr = std::min_element(m_map.cbegin(), m_map.cend(), variantCompare); if (itr != m_map.cend()) { return *itr; } @@ -33,7 +33,7 @@ QVariant MapProxySource::maximum() const { - auto itr = std::max_element(m_map.cbegin(), m_map.cend()); + auto itr = std::max_element(m_map.cbegin(), m_map.cend(), variantCompare); if (itr != m_map.cend()) { return *itr; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kquickcharts-5.98.0/src/datasource/ModelSource.cpp new/kquickcharts-5.99.0/src/datasource/ModelSource.cpp --- old/kquickcharts-5.98.0/src/datasource/ModelSource.cpp 2022-09-05 11:30:04.000000000 +0200 +++ new/kquickcharts-5.99.0/src/datasource/ModelSource.cpp 2022-10-01 15:20:32.000000000 +0200 @@ -114,7 +114,7 @@ QVariant result = std::numeric_limits<float>::max(); for (int i = 0; i < itemCount(); ++i) { - result = qMin(result, item(i)); + result = std::min(result, item(i), variantCompare); } return result; } @@ -137,7 +137,7 @@ QVariant result = std::numeric_limits<float>::min(); for (int i = 0; i < itemCount(); ++i) { - result = qMax(result, item(i)); + result = std::max(result, item(i), variantCompare); } return result; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kquickcharts-5.98.0/src/decorations/LegendModel.cpp new/kquickcharts-5.99.0/src/decorations/LegendModel.cpp --- old/kquickcharts-5.98.0/src/decorations/LegendModel.cpp 2022-09-05 11:30:04.000000000 +0200 +++ new/kquickcharts-5.99.0/src/decorations/LegendModel.cpp 2022-10-01 15:20:32.000000000 +0200 @@ -68,7 +68,7 @@ } if (m_chart) { - for (const auto &connection : qAsConst(m_connections)) { + for (const auto &connection : std::as_const(m_connections)) { disconnect(connection); } m_connections.clear(); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kquickcharts-5.98.0/src/scenegraph/BarChartMaterial.cpp new/kquickcharts-5.99.0/src/scenegraph/BarChartMaterial.cpp --- old/kquickcharts-5.98.0/src/scenegraph/BarChartMaterial.cpp 2022-09-05 11:30:04.000000000 +0200 +++ new/kquickcharts-5.99.0/src/scenegraph/BarChartMaterial.cpp 2022-10-01 15:20:32.000000000 +0200 @@ -21,7 +21,11 @@ return &type; } +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) QSGMaterialShader *BarChartMaterial::createShader() const +#else +QSGMaterialShader *BarChartMaterial::createShader(QSGRendererInterface::RenderMode) const +#endif { return new BarChartShader(); } @@ -49,6 +53,7 @@ { } +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) const char *const *BarChartShader::attributeNames() const { static const char *const names[] = {"in_vertex", "in_uv", "in_color", "in_value", nullptr}; @@ -81,3 +86,35 @@ program()->setUniformValue(m_radiusLocation, material->radius); } } +#else +bool BarChartShader::updateUniformData(QSGMaterialShader::RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) +{ + bool changed = false; + QByteArray *buf = state.uniformData(); + Q_ASSERT(buf->size() >= 96); + + if (state.isMatrixDirty()) { + const QMatrix4x4 m = state.combinedMatrix(); + memcpy(buf->data(), m.constData(), 64); + changed = true; + } + + if (state.isOpacityDirty()) { + const float opacity = state.opacity(); + memcpy(buf->data() + 72, &opacity, 4); + changed = true; + } + + if (!oldMaterial || newMaterial->compare(oldMaterial) != 0) { + const auto material = static_cast<BarChartMaterial *>(newMaterial); + memcpy(buf->data() + 64, &material->aspect, 8); + memcpy(buf->data() + 76, &material->radius, 4); + float c[4]; + material->backgroundColor.getRgbF(&c[0], &c[1], &c[2], &c[3]); + memcpy(buf->data() + 80, c, 16); + changed = true; + } + + return changed; +} +#endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kquickcharts-5.98.0/src/scenegraph/BarChartMaterial.h new/kquickcharts-5.99.0/src/scenegraph/BarChartMaterial.h --- old/kquickcharts-5.98.0/src/scenegraph/BarChartMaterial.h 2022-09-05 11:30:04.000000000 +0200 +++ new/kquickcharts-5.99.0/src/scenegraph/BarChartMaterial.h 2022-10-01 15:20:32.000000000 +0200 @@ -20,7 +20,11 @@ ~BarChartMaterial(); QSGMaterialType *type() const override; +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) QSGMaterialShader *createShader() const override; +#else + QSGMaterialShader *createShader(QSGRendererInterface::RenderMode) const override; +#endif int compare(const QSGMaterial *other) const override; QVector2D aspect = QVector2D{1.0, 1.0}; @@ -34,6 +38,7 @@ BarChartShader(); ~BarChartShader(); +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) char const *const *attributeNames() const override; void initialize() override; @@ -45,6 +50,9 @@ int m_aspectLocation = 0; int m_backgroundColorLocation = 0; int m_radiusLocation = 0; +#else + bool updateUniformData(QSGMaterialShader::RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override; +#endif }; #endif // PIECHARTMATERIAL_H diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kquickcharts-5.98.0/src/scenegraph/LineChartMaterial.cpp new/kquickcharts-5.99.0/src/scenegraph/LineChartMaterial.cpp --- old/kquickcharts-5.98.0/src/scenegraph/LineChartMaterial.cpp 2022-09-05 11:30:04.000000000 +0200 +++ new/kquickcharts-5.99.0/src/scenegraph/LineChartMaterial.cpp 2022-10-01 15:20:32.000000000 +0200 @@ -22,7 +22,11 @@ return &type; } +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) QSGMaterialShader *LineChartMaterial::createShader() const +#else +QSGMaterialShader *LineChartMaterial::createShader(QSGRendererInterface::RenderMode) const +#endif { return new LineChartShader(); } @@ -50,6 +54,7 @@ { } +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) const char *const *LineChartShader::attributeNames() const { /* clang-format off */ @@ -100,3 +105,33 @@ program()->setUniformValue(m_smoothingLocation, material->smoothing); } } +#else +bool LineChartShader::updateUniformData(QSGMaterialShader::RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) +{ + bool changed = false; + QByteArray *buf = state.uniformData(); + Q_ASSERT(buf->size() >= 80); + + if (state.isMatrixDirty()) { + const QMatrix4x4 m = state.combinedMatrix(); + memcpy(buf->data(), m.constData(), 64); + changed = true; + } + + if (state.isOpacityDirty()) { + const float opacity = state.opacity(); + memcpy(buf->data() + 72, &opacity, 4); + changed = true; + } + + if (!oldMaterial || newMaterial->compare(oldMaterial) != 0) { + const auto material = static_cast<LineChartMaterial *>(newMaterial); + memcpy(buf->data() + 64, &material->lineWidth, 4); + memcpy(buf->data() + 68, &material->aspect, 4); + memcpy(buf->data() + 76, &material->smoothing, 4); + changed = true; + } + + return changed; +} +#endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kquickcharts-5.98.0/src/scenegraph/LineChartMaterial.h new/kquickcharts-5.99.0/src/scenegraph/LineChartMaterial.h --- old/kquickcharts-5.98.0/src/scenegraph/LineChartMaterial.h 2022-09-05 11:30:04.000000000 +0200 +++ new/kquickcharts-5.99.0/src/scenegraph/LineChartMaterial.h 2022-10-01 15:20:32.000000000 +0200 @@ -21,7 +21,11 @@ ~LineChartMaterial(); QSGMaterialType *type() const override; +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) QSGMaterialShader *createShader() const override; +#else + QSGMaterialShader *createShader(QSGRendererInterface::RenderMode) const override; +#endif int compare(const QSGMaterial *other) const override; float aspect = 1.0; @@ -35,6 +39,7 @@ LineChartShader(); ~LineChartShader(); +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) char const *const *attributeNames() const override; void initialize() override; @@ -46,6 +51,9 @@ int m_lineWidthLocation = 0; int m_aspectLocation = 0; int m_smoothingLocation = 0; +#else + bool updateUniformData(QSGMaterialShader::RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override; +#endif }; #endif // LINECHARTMATERIAL_H diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kquickcharts-5.98.0/src/scenegraph/LineChartNode.cpp new/kquickcharts-5.99.0/src/scenegraph/LineChartNode.cpp --- old/kquickcharts-5.98.0/src/scenegraph/LineChartNode.cpp 2022-09-05 11:30:04.000000000 +0200 +++ new/kquickcharts-5.99.0/src/scenegraph/LineChartNode.cpp 2022-10-01 15:20:32.000000000 +0200 @@ -111,7 +111,7 @@ segment->setFillColor(m_fillColor); segment->setValues(segmentPoints); segment->setFarLeft(m_values.at(std::max(0, pointStart - pointsPerSegment - 1))); - segment->setFarRight(m_values.at(std::min(m_values.count() - 1, pointStart + 1))); + segment->setFarRight(m_values.at(std::min<int>(m_values.count() - 1, pointStart + 1))); segment->update(); currentX += segmentWidth; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kquickcharts-5.98.0/src/scenegraph/LineSegmentNode.cpp new/kquickcharts-5.99.0/src/scenegraph/LineSegmentNode.cpp --- old/kquickcharts-5.98.0/src/scenegraph/LineSegmentNode.cpp 2022-09-05 11:30:04.000000000 +0200 +++ new/kquickcharts-5.99.0/src/scenegraph/LineSegmentNode.cpp 2022-10-01 15:20:32.000000000 +0200 @@ -229,7 +229,7 @@ points << QVector2D(-0.5, m_values[0].y() * m_yAspect); } - for (auto value : qAsConst(m_values)) { + for (auto value : std::as_const(m_values)) { auto x = ((value.x() - m_rect.left()) / m_rect.width()) * m_xAspect; points << QVector2D(x, value.y() * m_yAspect); min = std::min(value.y() * m_yAspect, min); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kquickcharts-5.98.0/src/scenegraph/PieChartMaterial.cpp new/kquickcharts-5.99.0/src/scenegraph/PieChartMaterial.cpp --- old/kquickcharts-5.98.0/src/scenegraph/PieChartMaterial.cpp 2022-09-05 11:30:04.000000000 +0200 +++ new/kquickcharts-5.99.0/src/scenegraph/PieChartMaterial.cpp 2022-10-01 15:20:32.000000000 +0200 @@ -22,7 +22,11 @@ return &type; } +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) QSGMaterialShader *PieChartMaterial::createShader() const +#else +QSGMaterialShader *PieChartMaterial::createShader(QSGRendererInterface::RenderMode) const +#endif { return new PieChartShader(); } @@ -126,6 +130,7 @@ { } +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) const char *const *PieChartShader::attributeNames() const { static char const *const names[] = {"in_vertex", "in_uv", nullptr}; @@ -172,3 +177,52 @@ program()->setUniformValue(m_toAngleLocation, material->toAngle()); } } +#else +bool PieChartShader::updateUniformData(QSGMaterialShader::RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) +{ + bool changed = false; + QByteArray *buf = state.uniformData(); + Q_ASSERT(buf->size() >= 3332); + + if (state.isMatrixDirty()) { + const QMatrix4x4 m = state.combinedMatrix(); + memcpy(buf->data(), m.constData(), 64); + changed = true; + } + + if (state.isOpacityDirty()) { + const float opacity = state.opacity(); + memcpy(buf->data() + 72, &opacity, 4); + changed = true; + } + + if (!oldMaterial || newMaterial->compare(oldMaterial) != 0) { + const auto material = static_cast<PieChartMaterial *>(newMaterial); + const QVector2D aspect = material->aspectRatio(); + memcpy(buf->data() + 64, &aspect, 8); + float f = material->innerRadius(); + memcpy(buf->data() + 76, &f, 4); + f = material->outerRadius(); + memcpy(buf->data() + 80, &f, 4); + float c[4]; + material->backgroundColor().getRgbF(&c[0], &c[1], &c[2], &c[3]); + memcpy(buf->data() + 96, c, 16); + bool b = material->smoothEnds(); + memcpy(buf->data() + 112, &b, 1); + f = material->fromAngle(); + memcpy(buf->data() + 116, &f, 4); + f = material->toAngle(); + memcpy(buf->data() + 120, &f, 4); + const int segmentCount = material->segments().size(); + for (int i = 0; i < segmentCount; ++i) { + const QVector2D v = material->segments().at(i); + memcpy(buf->data() + 128 + (i * 16), &v, 8); + } + memcpy(buf->data() + 1728, material->colors().constData(), segmentCount * 16); + memcpy(buf->data() + 3328, &segmentCount, 4); + changed = true; + } + + return changed; +} +#endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kquickcharts-5.98.0/src/scenegraph/PieChartMaterial.h new/kquickcharts-5.99.0/src/scenegraph/PieChartMaterial.h --- old/kquickcharts-5.98.0/src/scenegraph/PieChartMaterial.h 2022-09-05 11:30:04.000000000 +0200 +++ new/kquickcharts-5.99.0/src/scenegraph/PieChartMaterial.h 2022-10-01 15:20:32.000000000 +0200 @@ -21,7 +21,11 @@ ~PieChartMaterial(); QSGMaterialType *type() const override; +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) QSGMaterialShader *createShader() const override; +#else + QSGMaterialShader *createShader(QSGRendererInterface::RenderMode) const override; +#endif QVector2D aspectRatio() const; float innerRadius() const; @@ -64,6 +68,7 @@ PieChartShader(); ~PieChartShader(); +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) char const *const *attributeNames() const override; void initialize() override; @@ -82,6 +87,9 @@ int m_smoothEndsLocation = 0; int m_fromAngleLocation = 0; int m_toAngleLocation = 0; +#else + bool updateUniformData(QSGMaterialShader::RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override; +#endif }; #endif // PIECHARTMATERIAL_H diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kquickcharts-5.98.0/src/scenegraph/SDFShader.cpp new/kquickcharts-5.99.0/src/scenegraph/SDFShader.cpp --- old/kquickcharts-5.98.0/src/scenegraph/SDFShader.cpp 2022-09-05 11:30:04.000000000 +0200 +++ new/kquickcharts-5.99.0/src/scenegraph/SDFShader.cpp 2022-10-01 15:20:32.000000000 +0200 @@ -22,6 +22,7 @@ void SDFShader::setShaders(const QString &vertex, const QString &fragment) { +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) auto header = QStringLiteral("header_desktop.glsl"); auto format = QOpenGLContext::currentContext()->format(); if (format.renderableType() == QSurfaceFormat::OpenGLES) { @@ -34,4 +35,8 @@ {QString::fromLatin1(shaderRoot) + header, // QString::fromLatin1(shaderRoot) + QStringLiteral("sdf.glsl"), // QString::fromLatin1(shaderRoot) + fragment}); +#else + setShaderFileName(QSGMaterialShader::VertexStage, QLatin1String(shaderRoot) + vertex + QLatin1String(".qsb")); + setShaderFileName(QSGMaterialShader::FragmentStage, QLatin1String(shaderRoot) + fragment + QLatin1String(".qsb")); +#endif } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kquickcharts-5.98.0/src/shaders/linechart.frag new/kquickcharts-5.99.0/src/shaders/linechart.frag --- old/kquickcharts-5.98.0/src/shaders/linechart.frag 2022-09-05 11:30:04.000000000 +0200 +++ new/kquickcharts-5.99.0/src/shaders/linechart.frag 2022-10-01 15:20:32.000000000 +0200 @@ -1,6 +1,7 @@ /* * This file is part of KQuickCharts * SPDX-FileCopyrightText: 2019 Arjen Hiemstra <ahiems...@heimr.nl> + * SPDX-FileCopyrightText: 2022 ??ukasz Wojni??owicz <lukasz.wojnilow...@gmail.com> * * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ @@ -15,7 +16,7 @@ #ifdef LEGACY_STAGE_INOUT varying mediump vec2 uv; -varying mediump vec2 points[18]; +varying mediump vec4 pointTuples[MAXIMUM_POINT_COUNT / 2]; varying highp float pointCount; varying mediump vec2 bounds; varying mediump vec4 lineColor; @@ -23,7 +24,7 @@ #define out_color gl_FragColor #else in mediump vec2 uv; -in mediump vec2 points[MAXIMUM_POINT_COUNT]; +in mediump vec4 pointTuples[MAXIMUM_POINT_COUNT / 2]; in highp float pointCount; in mediump vec2 bounds; in mediump vec4 lineColor; @@ -37,6 +38,26 @@ // For simplicity, we use the same function also for other APIs. lowp float sdf_polygon(in lowp vec2 point, in int count) { + mediump vec2 points[MAXIMUM_POINT_COUNT]; + points[0] = pointTuples[0].xy; + points[1] = pointTuples[0].zw; + points[2] = pointTuples[1].xy; + points[3] = pointTuples[1].zw; + points[4] = pointTuples[2].xy; + points[5] = pointTuples[2].zw; + points[6] = pointTuples[3].xy; + points[7] = pointTuples[3].zw; + points[8] = pointTuples[4].xy; + points[9] = pointTuples[4].zw; + points[10] = pointTuples[5].xy; + points[11] = pointTuples[5].zw; + points[12] = pointTuples[6].xy; + points[13] = pointTuples[6].zw; + points[14] = pointTuples[7].xy; + points[15] = pointTuples[7].zw; + points[16] = pointTuples[8].xy; + points[17] = pointTuples[8].zw; + lowp float d = dot(point - points[0], point - points[0]); lowp float s = 1.0; for (int i = 0, j = count - 1; i < count && i < MAXIMUM_POINT_COUNT; j = i, i++) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kquickcharts-5.98.0/src/shaders/linechart.vert new/kquickcharts-5.99.0/src/shaders/linechart.vert --- old/kquickcharts-5.98.0/src/shaders/linechart.vert 2022-09-05 11:30:04.000000000 +0200 +++ new/kquickcharts-5.99.0/src/shaders/linechart.vert 2022-10-01 15:20:32.000000000 +0200 @@ -1,6 +1,7 @@ /* * This file is part of KQuickCharts * SPDX-FileCopyrightText: 2019 Arjen Hiemstra <ahiems...@heimr.nl> + * SPDX-FileCopyrightText: 2022 ??ukasz Wojni??owicz <lukasz.wojnilow...@gmail.com> * * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ @@ -28,10 +29,9 @@ in highp float in_count; // Input points. Since OpenGL 2.1/GLSL 1.10 does not support array vertex -// attributes, we have to manually declare a number of attributes. In addition, -// while we use vec2 as point data format, we can store either a vec2 or a vec4 -// as a vertex attribute. Therefore, we define these as vec4 and manually unpack -// to make use of as much storage as possible. +// attributes, we have to manually declare a number of attributes. We use +// array of vec4 point tuples instead of vec2 to not cross the OpenGL limits +// like e.g. GL_MAX_VERTEX_ATTRIBS for some drivers. in mediump vec4 in_points_0; in mediump vec4 in_points_1; in mediump vec4 in_points_2; @@ -43,7 +43,7 @@ in mediump vec4 in_points_8; out mediump vec2 uv; -out mediump vec2 points[MAXIMUM_POINT_COUNT]; +out mediump vec4 pointTuples[MAXIMUM_POINT_COUNT / 2]; out highp float pointCount; out mediump vec2 bounds; out mediump vec4 lineColor; @@ -53,24 +53,15 @@ uv = in_uv; uv.y = (1.0 + -1.0 * uv.y) * aspect; - points[0] = in_points_0.xy; - points[1] = in_points_0.zw; - points[2] = in_points_1.xy; - points[3] = in_points_1.zw; - points[4] = in_points_2.xy; - points[5] = in_points_2.zw; - points[6] = in_points_3.xy; - points[7] = in_points_3.zw; - points[8] = in_points_4.xy; - points[9] = in_points_4.zw; - points[10] = in_points_5.xy; - points[11] = in_points_5.zw; - points[12] = in_points_6.xy; - points[13] = in_points_6.zw; - points[14] = in_points_7.xy; - points[15] = in_points_7.zw; - points[16] = in_points_8.xy; - points[17] = in_points_8.zw; + pointTuples[0] = in_points_0; + pointTuples[1] = in_points_1; + pointTuples[2] = in_points_2; + pointTuples[3] = in_points_3; + pointTuples[4] = in_points_4; + pointTuples[5] = in_points_5; + pointTuples[6] = in_points_6; + pointTuples[7] = in_points_7; + pointTuples[8] = in_points_8; pointCount = in_count; bounds = in_bounds; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kquickcharts-5.98.0/src/shaders6/CMakeLists.txt new/kquickcharts-5.99.0/src/shaders6/CMakeLists.txt --- old/kquickcharts-5.98.0/src/shaders6/CMakeLists.txt 1970-01-01 01:00:00.000000000 +0100 +++ new/kquickcharts-5.99.0/src/shaders6/CMakeLists.txt 2022-10-01 15:20:32.000000000 +0200 @@ -0,0 +1,17 @@ +# SPDX-FileCopyrightText: 2022 Volker Krause <vkra...@kde.org> +# SPDX-License-Identifier: BSD-2-Clause + +qt6_add_shaders(QuickCharts "shaders6" + BATCHABLE + PRECOMPILE + OPTIMIZED + PREFIX "/org.kde.quickcharts/" + GLSL "300es,130" + FILES + barchart.vert + barchart.frag + linechart.vert + linechart.frag + piechart.vert + piechart.frag +) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kquickcharts-5.98.0/src/shaders6/barchart.frag new/kquickcharts-5.99.0/src/shaders6/barchart.frag --- old/kquickcharts-5.98.0/src/shaders6/barchart.frag 1970-01-01 01:00:00.000000000 +0100 +++ new/kquickcharts-5.99.0/src/shaders6/barchart.frag 2022-10-01 15:20:32.000000000 +0200 @@ -0,0 +1,39 @@ +/* + * SPDX-FileCopyrightText: 2021 Arjen Hiemstra <ahiems...@heimr.nl> + * + * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL + */ + +#version 440 + +#extension GL_GOOGLE_include_directive: enable +#include "sdf.glsl" + +layout(std140, binding = 0) uniform buf { + highp mat4 matrix; + lowp vec2 aspect; // offset 64 + lowp float opacity; // offset 72 + lowp float radius; // offset 76 + lowp vec4 backgroundColor; // offset 80 +} ubuf; // size 96 + +layout (location = 0) in lowp vec2 uv; +layout (location = 1) in mediump vec4 foregroundColor; +layout (location = 2) in mediump float value; + +layout (location = 0) out lowp vec4 out_color; + +void main() +{ + lowp vec4 color = vec4(0.0); + + lowp float background = sdf_round(sdf_rectangle(uv, vec2(1.0, ubuf.aspect.y) - ubuf.radius), ubuf.radius); + + color = sdf_render(background, color, ubuf.backgroundColor); + + lowp float foreground = sdf_round(sdf_rectangle(vec2(uv.x, -ubuf.aspect.y + uv.y + value), vec2(1.0, value) - ubuf.radius), ubuf.radius); + + color = sdf_render(foreground, color, foregroundColor); + + out_color = color * ubuf.opacity; +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kquickcharts-5.98.0/src/shaders6/barchart.vert new/kquickcharts-5.99.0/src/shaders6/barchart.vert --- old/kquickcharts-5.98.0/src/shaders6/barchart.vert 1970-01-01 01:00:00.000000000 +0100 +++ new/kquickcharts-5.99.0/src/shaders6/barchart.vert 2022-10-01 15:20:32.000000000 +0200 @@ -0,0 +1,31 @@ +/* + * SPDX-FileCopyrightText: 2021 Arjen Hiemstra <ahiems...@heimr.nl> + * + * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL + */ + +#version 440 + +layout(std140, binding = 0) uniform buf { + highp mat4 matrix; + lowp vec2 aspect; + lowp float opacity; + lowp float radius; + lowp vec4 backgroundColor; +} ubuf; + +layout (location = 0) in highp vec4 in_vertex; +layout (location = 1) in mediump vec2 in_uv; +layout (location = 2) in mediump vec4 in_color; +layout (location = 3) in mediump float in_value; + +layout (location = 0) out mediump vec2 uv; +layout (location = 1) out mediump vec4 foregroundColor; +layout (location = 2) out mediump float value; + +void main() { + uv = (-1.0 + 2.0 * in_uv) * ubuf.aspect; + value = in_value; + foregroundColor = in_color; + gl_Position = ubuf.matrix * in_vertex; +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kquickcharts-5.98.0/src/shaders6/linechart.frag new/kquickcharts-5.99.0/src/shaders6/linechart.frag --- old/kquickcharts-5.98.0/src/shaders6/linechart.frag 1970-01-01 01:00:00.000000000 +0100 +++ new/kquickcharts-5.99.0/src/shaders6/linechart.frag 2022-10-01 15:20:32.000000000 +0200 @@ -0,0 +1,105 @@ +/* + * This file is part of KQuickCharts + * SPDX-FileCopyrightText: 2019 Arjen Hiemstra <ahiems...@heimr.nl> + * SPDX-FileCopyrightText: 2022 ??ukasz Wojni??owicz <lukasz.wojnilow...@gmail.com> + * + * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL + */ + +#version 440 + +#extension GL_GOOGLE_include_directive: enable +#include "sdf.glsl" + +layout(std140, binding = 0) uniform buf { + highp mat4 matrix; + lowp float lineWidth; // offset 64 + lowp float aspect; // offset 68 + lowp float opacity; // inherited opacity of this item - offset 72 + lowp float smoothing; // offset 76 +} ubuf; // size 80 + +#define MAXIMUM_POINT_COUNT 18 + +layout (location = 0) in mediump vec2 uv; +layout (location = 1) in mediump vec4 pointTuples[MAXIMUM_POINT_COUNT / 2]; +layout (location = 19) in highp float pointCount; +layout (location = 20) in mediump vec2 bounds; +layout (location = 21) in mediump vec4 lineColor; +layout (location = 22) in mediump vec4 fillColor; +layout (location = 0) out lowp vec4 out_color; + +// ES2 does not support array function arguments. So instead we need to +// reference the uniform array directly. So this copies the implementation of +// sdf_polygon from sdf.glsl, changing it to refer to the points array directly. +// For simplicity, we use the same function also for other APIs. +lowp float sdf_polygon(in lowp vec2 point, in int count) +{ + mediump vec2 points[MAXIMUM_POINT_COUNT]; + points[0] = pointTuples[0].xy; + points[1] = pointTuples[0].zw; + points[2] = pointTuples[1].xy; + points[3] = pointTuples[1].zw; + points[4] = pointTuples[2].xy; + points[5] = pointTuples[2].zw; + points[6] = pointTuples[3].xy; + points[7] = pointTuples[3].zw; + points[8] = pointTuples[4].xy; + points[9] = pointTuples[4].zw; + points[10] = pointTuples[5].xy; + points[11] = pointTuples[5].zw; + points[12] = pointTuples[6].xy; + points[13] = pointTuples[6].zw; + points[14] = pointTuples[7].xy; + points[15] = pointTuples[7].zw; + points[16] = pointTuples[8].xy; + points[17] = pointTuples[8].zw; + + lowp float d = dot(point - points[0], point - points[0]); + lowp float s = 1.0; + for (int i = 0, j = count - 1; i < count && i < MAXIMUM_POINT_COUNT; j = i, i++) + { + lowp vec2 e = points[j] - points[i]; + lowp vec2 w = point - points[i]; + lowp float h = clamp( dot(w, e) / dot(e, e), 0.0, 1.0 ); + lowp vec2 b = w - e * h; + d = min(d, dot(b, b)); + + bvec3 c = bvec3(point.y >= points[i].y, point.y < points[j].y, e.x * w.y > e.y * w.x); + if(all(c) || all(not(c))) s *= -1.0; + } + return s * sqrt(d); +} + +void main() +{ + lowp vec2 point = uv; + + lowp vec4 color = vec4(0.0, 0.0, 0.0, 0.0); + + lowp float bounds_range = max(0.01, ubuf.lineWidth); + + // bounds.y contains the line segment's maximum value. If we are a bit above + // that, we will never render anything, so just discard the pixel. + if (point.y > bounds.y + bounds_range) { + discard; + } + + // bounds.x contains the line segment's minimum value. If we are a bit below + // that, we know we will always be inside the polygon described by points. + // So just return a pixel with fillColor. + if (point.y < bounds.x - bounds_range) { + out_color = fillColor * ubuf.opacity; + return; + } + + lowp float polygon = sdf_polygon(point, int(pointCount)); + + color = sdf_render(polygon, color, fillColor); + + if (ubuf.lineWidth > 0.0) { + color = mix(color, lineColor, 1.0 - smoothstep(-ubuf.smoothing, ubuf.smoothing, sdf_annular(polygon, ubuf.lineWidth))); + } + + out_color = color * ubuf.opacity; +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kquickcharts-5.98.0/src/shaders6/linechart.vert new/kquickcharts-5.99.0/src/shaders6/linechart.vert --- old/kquickcharts-5.98.0/src/shaders6/linechart.vert 1970-01-01 01:00:00.000000000 +0100 +++ new/kquickcharts-5.99.0/src/shaders6/linechart.vert 2022-10-01 15:20:32.000000000 +0200 @@ -0,0 +1,72 @@ +/* + * This file is part of KQuickCharts + * SPDX-FileCopyrightText: 2019 Arjen Hiemstra <ahiems...@heimr.nl> + * SPDX-FileCopyrightText: 2022 ??ukasz Wojni??owicz <lukasz.wojnilow...@gmail.com> + * + * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL + */ +#version 440 +#line 8 + +layout(std140, binding = 0) uniform buf { + highp mat4 matrix; + lowp float lineWidth; + lowp float aspect; + lowp float opacity; + lowp float smoothing; +} ubuf; + +#define MAXIMUM_POINT_COUNT 18 + +layout (location = 0) in highp vec4 in_vertex; +layout (location = 1) in mediump vec2 in_uv; + +layout (location = 2) in mediump vec4 in_lineColor; +layout (location = 3) in mediump vec4 in_fillColor; +layout (location = 4) in mediump vec2 in_bounds; + +layout (location = 5) in highp float in_count; + +// Input points. Since OpenGL 2.1/GLSL 1.10 does not support array vertex +// attributes, we have to manually declare a number of attributes. We use +// array of vec4 point tuples instead of vec2 to not cross the OpenGL limits +// like e.g. GL_MAX_VERTEX_ATTRIBS for some drivers. +layout (location = 6) in mediump vec4 in_points_0; +layout (location = 8) in mediump vec4 in_points_1; +layout (location = 9) in mediump vec4 in_points_2; +layout (location = 10) in mediump vec4 in_points_3; +layout (location = 11) in mediump vec4 in_points_4; +layout (location = 12) in mediump vec4 in_points_5; +layout (location = 13) in mediump vec4 in_points_6; +layout (location = 14) in mediump vec4 in_points_7; +layout (location = 15) in mediump vec4 in_points_8; + +layout (location = 0) out mediump vec2 uv; +layout (location = 1) out mediump vec4 pointTuples[MAXIMUM_POINT_COUNT / 2]; +layout (location = 19) out highp float pointCount; +layout (location = 20) out mediump vec2 bounds; +layout (location = 21) out mediump vec4 lineColor; +layout (location = 22) out mediump vec4 fillColor; + +void main() { + uv = in_uv; + uv.y = (1.0 + -1.0 * uv.y) * ubuf.aspect; + + pointTuples[0] = in_points_0; + pointTuples[1] = in_points_1; + pointTuples[2] = in_points_2; + pointTuples[3] = in_points_3; + pointTuples[4] = in_points_4; + pointTuples[5] = in_points_5; + pointTuples[6] = in_points_6; + pointTuples[7] = in_points_7; + pointTuples[8] = in_points_8; + + pointCount = in_count; + bounds = in_bounds; + + lineColor = in_lineColor; + fillColor = in_fillColor; + + gl_Position = ubuf.matrix * in_vertex; +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kquickcharts-5.98.0/src/shaders6/piechart.frag new/kquickcharts-5.99.0/src/shaders6/piechart.frag --- old/kquickcharts-5.98.0/src/shaders6/piechart.frag 1970-01-01 01:00:00.000000000 +0100 +++ new/kquickcharts-5.99.0/src/shaders6/piechart.frag 2022-10-01 15:20:32.000000000 +0200 @@ -0,0 +1,68 @@ +/* + * This file is part of KQuickCharts + * SPDX-FileCopyrightText: 2019 Arjen Hiemstra <ahiems...@heimr.nl> + * + * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL + */ + +#version 440 + +#extension GL_GOOGLE_include_directive: enable +#include "sdf.glsl" + +// The maximum number of segments we can support for a single pie. +// This is based on OpenGL's MAX_FRAGMENT_UNIFORM_COMPONENTS. +// MAX_FRAGMENT_UNIFORM_COMPONENTS is required to be at least 1024. +// Assuming a segment of size 1, each segment needs +// 2 (size of a vec2) * 2 (number of points) + 4 (size of vec4) + 1 (segment size) +// components. We also need to leave some room for the other uniforms. +#define MAX_SEGMENTS 100 + +layout(std140, binding = 0) uniform buf { + highp mat4 matrix; + lowp vec2 aspect; // offset 64 + lowp float opacity; // offset 72 + lowp float innerRadius; // offset 76 + lowp float outerRadius; // offset 80 + lowp vec4 backgroundColor; // offset 96 + bool smoothEnds; // offset 112 + lowp float fromAngle; // offset 116 + lowp float toAngle; // offset 120 + + lowp vec2 segments[MAX_SEGMENTS]; // offset 128 with vec4 alignment! + lowp vec4 colors[MAX_SEGMENTS]; // offset 1728 + int segmentCount; // offset 3328 +} ubuf; // size 3332 + +layout (location = 0) in lowp vec2 uv; +layout (location = 0) out lowp vec4 out_color; + +const lowp vec2 origin = vec2(0.0, 0.0); +const lowp float lineSmooth = 0.001; + +lowp float rounded_segment(lowp float from, lowp float to, lowp float inner, lowp float outer, lowp float rounding) +{ + return sdf_torus_segment(uv, from + rounding, to - rounding, inner + rounding, outer - rounding) - rounding; +} + +void main() +{ + lowp vec4 color = vec4(0.0); + + lowp float thickness = (ubuf.outerRadius - ubuf.innerRadius) / 2.0; + lowp float rounding = ubuf.smoothEnds ? thickness : 0.0; + + // Background first, slightly smaller than the actual pie to avoid antialiasing artifacts. + lowp float background_rounding = (ubuf.toAngle - ubuf.fromAngle) >= 2.0 * pi ? 0.001 : rounding + 0.001; + lowp float background = rounded_segment(ubuf.fromAngle, ubuf.toAngle, ubuf.innerRadius, ubuf.outerRadius, background_rounding); + color = sdf_render(background, color, ubuf.backgroundColor); + + for (int i = 0; i < ubuf.segmentCount && i < MAX_SEGMENTS; ++i) { + lowp vec2 segment = ubuf.segments[i]; + + lowp float segment_sdf = rounded_segment(segment.x, segment.y, ubuf.innerRadius, ubuf.outerRadius, rounding); + color = sdf_render(segment_sdf, color, ubuf.colors[i]); + } + + out_color = color * ubuf.opacity; +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kquickcharts-5.98.0/src/shaders6/piechart.vert new/kquickcharts-5.99.0/src/shaders6/piechart.vert --- old/kquickcharts-5.98.0/src/shaders6/piechart.vert 1970-01-01 01:00:00.000000000 +0100 +++ new/kquickcharts-5.99.0/src/shaders6/piechart.vert 2022-10-01 15:20:32.000000000 +0200 @@ -0,0 +1,35 @@ +/* + * This file is part of KQuickCharts + * SPDX-FileCopyrightText: 2019 Arjen Hiemstra <ahiems...@heimr.nl> + * + * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL + */ + +#version 440 + +#define MAX_SEGMENTS 100 +layout(std140, binding = 0) uniform buf { + highp mat4 matrix; + lowp vec2 aspect; + lowp float opacity; + lowp float innerRadius; + lowp float outerRadius; + lowp vec4 backgroundColor; + bool smoothEnds; + lowp float fromAngle; + lowp float toAngle; + + lowp vec2 segments[MAX_SEGMENTS]; + lowp vec4 colors[MAX_SEGMENTS]; + int segmentCount; +} ubuf; + +layout (location = 0) in highp vec4 in_vertex; +layout (location = 1) in mediump vec2 in_uv; +layout (location = 0) out mediump vec2 uv; + +void main() { + uv = (-1.0 + 2.0 * in_uv) * ubuf.aspect; + uv.y *= -1.0; + gl_Position = ubuf.matrix * in_vertex; +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kquickcharts-5.98.0/src/shaders6/sdf.glsl new/kquickcharts-5.99.0/src/shaders6/sdf.glsl --- old/kquickcharts-5.98.0/src/shaders6/sdf.glsl 1970-01-01 01:00:00.000000000 +0100 +++ new/kquickcharts-5.99.0/src/shaders6/sdf.glsl 2022-10-01 15:20:32.000000000 +0200 @@ -0,0 +1,282 @@ +// SPDX-FileCopyrightText: 2019 Arjen Hiemstra <ahiems...@heimr.nl> +// SPDX-FileCopyrightText: 2017 Inigo Quilez +// +// SPDX-License-Identifier: MIT +// +// This file is based on +// https://iquilezles.org/www/articles/distfunctions2d/distfunctions2d.htm + +// A maximum point count to be used for sdf_polygon input arrays. +// Unfortunately even function inputs require a fixed size at declaration time +// for arrays, unless we were to use OpenGL 4.5. +// Since the polygon is most likely to be defined in a uniform, this should be +// at least less than MAX_FRAGMENT_UNIFORM_COMPONENTS / 2 (since we need vec2). +#define SDF_POLYGON_MAX_POINT_COUNT 400 + +// A constant for pi +const lowp float pi = 3.1415926535897932384626433832795; + +/********************************* + Shapes +*********************************/ + +// Distance field for a circle. +// +// \param point A point on the distance field. +// \param radius The radius of the circle. +// +// \return The signed distance from point to the circle. If negative, point is +// inside the circle. +lowp float sdf_circle(in lowp vec2 point, in lowp float radius) +{ + return length(point) - radius; +} + +// Distance field for a triangle. +// +// \param point A point on the distance field. +// \param p0 The first vertex of the triangle. +// \param p0 The second vertex of the triangle. +// \param p0 The third vertex of the triangle. +// +// \note The ordering of the three vertices does not matter. +// +// \return The signed distance from point to triangle. If negative, point is +// inside the triangle. +lowp float sdf_triangle(in lowp vec2 point, in lowp vec2 p0, in lowp vec2 p1, in lowp vec2 p2) +{ + lowp vec2 e0 = p1 - p0; + lowp vec2 e1 = p2 - p1; + lowp vec2 e2 = p0 - p2; + + lowp vec2 v0 = point - p0; + lowp vec2 v1 = point - p1; + lowp vec2 v2 = point - p2; + + lowp vec2 pq0 = v0 - e0 * clamp( dot(v0, e0) / dot(e0, e0), 0.0, 1.0 ); + lowp vec2 pq1 = v1 - e1 * clamp( dot(v1, e1) / dot(e1, e1), 0.0, 1.0 ); + lowp vec2 pq2 = v2 - e2 * clamp( dot(v2, e2) / dot(e2, e2), 0.0, 1.0 ); + + lowp float s = sign( e0.x*e2.y - e0.y*e2.x ); + lowp vec2 d = min(min(vec2(dot(pq0,pq0), s*(v0.x*e0.y-v0.y*e0.x)), + vec2(dot(pq1,pq1), s*(v1.x*e1.y-v1.y*e1.x))), + vec2(dot(pq2,pq2), s*(v2.x*e2.y-v2.y*e2.x))); + + return -sqrt(d.x)*sign(d.y); +} + +#ifndef API_ES2 +// Distance field for an arbitrary polygon. +// +// \param point A point on the distance field. +// \param vertices An array of points that make up the polygon. +// \param count The amount of points to use for the polygon. +// +// \note points should be an array of vec2 of size SDF_POLYGON_MAX_POINT_COUNT. +// Use count to indicate how many items of that array should be used. +// +// \return The signed distance from point to triangle. If negative, point is +// inside the triangle. +lowp float sdf_polygon(in lowp vec2 point, in lowp vec2[SDF_POLYGON_MAX_POINT_COUNT] vertices, in lowp int count) +{ + lowp float d = dot(point - vertices[0], point - vertices[0]); + lowp float s = 1.0; + for (int i = 0, j = count - 1; i < count && i < SDF_POLYGON_MAX_POINT_COUNT; j = i, i++) + { + lowp vec2 e = vertices[j] - vertices[i]; + lowp vec2 w = point - vertices[i]; + lowp float h = clamp( dot(w, e) / dot(e, e), 0.0, 1.0 ); + lowp vec2 b = w - e * h; + d = min(d, dot(b, b)); + + bvec3 c = bvec3(point.y >= vertices[i].y, point.y < vertices[j].y, e.x * w.y > e.y * w.x); + if(all(c) || all(not(c))) s *= -1.0; + } + return s * sqrt(d); +} +#endif + +// Distance field for a rectangle. +// +// \param point A point on the distance field. +// \param rect A vec2 with the size of the rectangle. +// +// \return The signed distance from point to rectangle. If negative, point is +// inside the rectangle. +lowp float sdf_rectangle(in lowp vec2 point, in lowp vec2 rect) +{ + lowp vec2 d = abs(point) - rect; + return length(max(d, 0.0)) + min(max(d.x, d.y), 0.0); +} + +// Distance field for a torus segment. +// +// \param point A point on the distance field. +// \param start The start angle in radians of the segment. +// \param end The end angle in radians of the segment. +// \param inner_radius The inner radius of the torus. +// \param outer_radius The outer radius of the torus. +// +// \return The signed distance from point to the torus segment. If negative, +// point is inside the segment. +lowp float sdf_torus_segment(in lowp vec2 point, in lowp float start, in lowp float end, in lowp float inner_radius, in lowp float outer_radius) +{ + start = clamp(start, end - 2.0 * pi, end); + end = clamp(end, start, start + 2.0 * pi); + + lowp float angle = (end - start) / 2.0; + lowp float rotation = (start + end) / 2.0; + + lowp vec2 rotated = point * mat2(cos(rotation), -sin(rotation), sin(rotation), cos(rotation)); + lowp vec2 c = vec2(sin(angle), cos(angle)); + + rotated.x = abs(rotated.x); + + lowp float t = (outer_radius - inner_radius) / 2.0; + lowp float l = abs(length(rotated) - (inner_radius + t)) - t; + + lowp float m = length(rotated - c * clamp(dot(rotated, c), inner_radius, outer_radius)); + return max(l, m * sign(c.y * rotated.x - c.x * rotated.y)); +} + +/********************* + Operators +*********************/ + +// Convert a distance field to an annular (hollow) distance field. +// +// \param sdf The result of an sdf shape to convert. +// \param thickness The thickness of the resulting shape. +// +// \return The value of sdf modified to an annular shape. +lowp float sdf_annular(in lowp float sdf, in lowp float thickness) +{ + return abs(sdf) - thickness; +} + +// Union two sdf shapes together. +// +// \param sdf1 The first sdf shape. +// \param sdf2 The second sdf shape. +// +// \return The union of sdf1 and sdf2, that is, the distance to both sdf1 and +// sdf2. +lowp float sdf_union(in lowp float sdf1, in lowp float sdf2) +{ + return min(sdf1, sdf2); +} + +// Subtract two sdf shapes. +// +// \param sdf1 The first sdf shape. +// \param sdf2 The second sdf shape. +// +// \return sdf1 with sdf2 subtracted from it. +lowp float sdf_subtract(in lowp float sdf1, in lowp float sdf2) +{ + return max(sdf1, -sdf2); +} + +// Intersect two sdf shapes. +// +// \param sdf1 The first sdf shape. +// \param sdf2 The second sdf shape. +// +// \return The intersection between sdf1 and sdf2, that is, the area where both +// sdf1 and sdf2 provide the same distance value. +lowp float sdf_intersect(in lowp float sdf1, in lowp float sdf2) +{ + return max(sdf1, sdf2); +} + +// Smoothly intersect two sdf shapes. +// +// \param sdf1 The first sdf shape. +// \param sdf2 The second sdf shape. +// \param smoothing The amount of smoothing to apply. +// +// \return A smoothed version of the intersect operation. +lowp float sdf_intersect_smooth(in lowp float sdf1, in lowp float sdf2, in lowp float smoothing) +{ + lowp float h = clamp(0.5 - 0.5 * (sdf1 - sdf2) / smoothing, 0.0, 1.0); + return mix(sdf1, sdf2, h) + smoothing * h * (1.0 - h); +} + +// Round an sdf shape. +// +// \param sdf The sdf shape to round. +// \param amount The amount of rounding to apply. +// +// \return The rounded shape of sdf. +// Note that rounding happens by basically selecting an isoline of sdf, +// therefore, the resulting shape may be larger than the input shape. +lowp float sdf_round(in lowp float sdf, in lowp float amount) +{ + return sdf - amount; +} + +// Convert an sdf shape to an outline of its shape. +// +// \param sdf The sdf shape to turn into an outline. +// +// \return The outline of sdf. +lowp float sdf_outline(in lowp float sdf) +{ + return abs(sdf); +} + +/******************** + Convenience +********************/ + +// A constant to represent a "null" value of an sdf. +// Since 0 is a point exactly on the outline of an sdf shape, and negative +// values are inside the shape, this uses a very large positive constant to +// indicate a value that is really far away from the actual sdf shape. +const lowp float sdf_null = 99999.0; + +// A constant for a default level of smoothing when rendering an sdf. +const lowp float sdf_default_smoothing = 0.625; + +// Render an sdf shape. +// +// This will render the sdf shape on top of whatever source color is input, +// making sure to apply smoothing if desired. +// +// \param sdf The sdf shape to render. +// \param sourceColor The source color to render on top of. +// \param sdfColor The color to use for rendering the sdf shape. +// +// \return sourceColor with the sdf shape rendered on top. +lowp vec4 sdf_render(in lowp float sdf, in lowp vec4 sourceColor, in lowp vec4 sdfColor) +{ + lowp float g = fwidth(sdf); + return mix(sourceColor, sdfColor, 1.0 - smoothstep(-sdf_default_smoothing * g, sdf_default_smoothing * g, sdf)); +} + +// Render an sdf shape. +// +// This is an overload of sdf_render(float, vec4, vec4) that allows specifying a +// smoothing amount. +// +// \param smoothing The amount of smoothing to apply to the sdf. +// +lowp vec4 sdf_render(in lowp float sdf, in lowp vec4 sourceColor, in lowp vec4 sdfColor, in lowp float smoothing) +{ + lowp float g = fwidth(sdf); + return mix(sourceColor, sdfColor, 1.0 - smoothstep(-smoothing * g, smoothing * g, sdf)); +} + +// Render an sdf shape alpha-blended onto an existing color. +// +// This is an overload of sdf_render(float, vec4, vec4) that allows specifying a +// blending amount and a smoothing amount. +// +// \param alpha The alpha to use for blending. +// \param smoothing The amount of smoothing to apply to the sdf. +// +lowp vec4 sdf_render(in lowp float sdf, in lowp vec4 sourceColor, in lowp vec4 sdfColor, in lowp float alpha, in lowp float smoothing) +{ + lowp float g = fwidth(sdf); + return mix(sourceColor, sdfColor, alpha * (1.0 - smoothstep(-smoothing * g, smoothing * g, sdf))); +}