diff options
Diffstat (limited to 'src/quickshapes')
27 files changed, 17 insertions, 2570 deletions
diff --git a/src/quickshapes/CMakeLists.txt b/src/quickshapes/CMakeLists.txt index b8a37288f0..0833d51e1b 100644 --- a/src/quickshapes/CMakeLists.txt +++ b/src/quickshapes/CMakeLists.txt @@ -22,22 +22,6 @@ qt_add_module(QuickShapes # Resources: set(qtquickshapes_resource_files - "shaders/blit.frag" - "shaders/blit.vert" - "shaders/blit_core.frag" - "shaders/blit_core.vert" - "shaders/conicalgradient.frag" - "shaders/conicalgradient.vert" - "shaders/conicalgradient_core.frag" - "shaders/conicalgradient_core.vert" - "shaders/lineargradient.frag" - "shaders/lineargradient.vert" - "shaders/lineargradient_core.frag" - "shaders/lineargradient_core.vert" - "shaders/radialgradient.frag" - "shaders/radialgradient.vert" - "shaders/radialgradient_core.frag" - "shaders/radialgradient_core.vert" "shaders_ng/conicalgradient.frag.qsb" "shaders_ng/conicalgradient.vert.qsb" "shaders_ng/lineargradient.frag.qsb" @@ -60,16 +44,6 @@ qt_add_resource(QuickShapes "qtquickshapes" # QML_IMPORT_NAME = "QtQuick.Shapes" # QML_IMPORT_VERSION = "$$QT_VERSION" -## Scopes: -##################################################################### - -qt_extend_target(QuickShapes CONDITION QT_FEATURE_opengl - SOURCES - qquicknvprfunctions.cpp qquicknvprfunctions_p.h - qquicknvprfunctions_p_p.h - qquickshapenvprrenderer.cpp qquickshapenvprrenderer_p.h -) - set_target_properties(QuickShapes PROPERTIES QT_QML_MODULE_INSTALL_QMLTYPES TRUE QT_QML_MODULE_VERSION ${CMAKE_PROJECT_VERSION} diff --git a/src/quickshapes/qquicknvprfunctions.cpp b/src/quickshapes/qquicknvprfunctions.cpp deleted file mode 100644 index 409a59be7f..0000000000 --- a/src/quickshapes/qquicknvprfunctions.cpp +++ /dev/null @@ -1,281 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtQuick module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qquicknvprfunctions_p.h" - -#if QT_CONFIG(opengl) - -#include <QOpenGLContext> -#include <QOffscreenSurface> -#include <QOpenGLExtraFunctions> -#include "qquicknvprfunctions_p_p.h" - -QT_BEGIN_NAMESPACE - -/*! - \class QQuickNvprFunctions - - \brief Function resolvers and other helpers for GL_NV_path_rendering - for both desktop (GL 4.3+) and mobile/embedded (GLES 3.1+) in a manner - that does not distract builds that do not have NVPR support either at - compile or run time. - - \internal - */ - -QQuickNvprFunctions::QQuickNvprFunctions() - : d(new QQuickNvprFunctionsPrivate(this)) -{ -} - -QQuickNvprFunctions::~QQuickNvprFunctions() -{ - delete d; -} - -/*! - \return a recommended QSurfaceFormat suitable for GL_NV_path_rendering on top - of OpenGL 4.3 or OpenGL ES 3.1. - */ -QSurfaceFormat QQuickNvprFunctions::format() -{ - QSurfaceFormat fmt; - fmt.setDepthBufferSize(24); - fmt.setStencilBufferSize(8); - if (QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGL) { - fmt.setVersion(4, 3); - fmt.setProfile(QSurfaceFormat::CompatibilityProfile); - } else if (QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGLES) { - fmt.setVersion(3, 1); - } - return fmt; -} - -#define PROC(type, name) reinterpret_cast<type>(ctx->getProcAddress(#name)) - -/*! - \return true if GL_NV_path_rendering is supported with the current OpenGL - context. - - When there is no current context, a temporary dummy one will be created and - made current. - */ -bool QQuickNvprFunctions::isSupported() -{ - QOpenGLContext *ctx = QOpenGLContext::currentContext(); - QScopedPointer<QOpenGLContext> tempContext; - QScopedPointer<QOffscreenSurface> tempSurface; - if (!ctx) { - tempContext.reset(new QOpenGLContext); - if (!tempContext->create()) - return false; - ctx = tempContext.data(); - tempSurface.reset(new QOffscreenSurface); - tempSurface->setFormat(ctx->format()); - tempSurface->create(); - if (!ctx->makeCurrent(tempSurface.data())) - return false; - } - - if (!ctx->hasExtension(QByteArrayLiteral("GL_NV_path_rendering"))) - return false; - - // Check that GL_NV_Path_rendering extension is at least API revision 1.3 - if (!PROC(PFNGLPROGRAMPATHFRAGMENTINPUTGENNVPROC, glProgramPathFragmentInputGenNV)) - return false; - - // Do not check for DSA as the string may not be exposed on ES - // drivers, yet the functions we need are resolvable. -#if 0 - if (!ctx->hasExtension(QByteArrayLiteral("GL_EXT_direct_state_access"))) { - qWarning("QtQuickPath/NVPR: GL_EXT_direct_state_access not supported"); - return false; - } -#endif - - return true; -} - -/*! - Initializes using the current OpenGL context. - - \return true when GL_NV_path_rendering is supported and initialization was - successful. - */ -bool QQuickNvprFunctions::create() -{ - return isSupported() && d->resolve(); -} - -/*! - Creates a program pipeline consisting of a separable fragment shader program. - - This is essential for using NVPR with OpenGL ES 3.1+ since normal, - GLES2-style programs would not work without a vertex shader. - - \note \a fragmentShaderSource should be a \c{version 310 es} shader since - this works both on desktop and embedded NVIDIA drivers, thus avoiding the - need to fight GLSL and GLSL ES differences. - - The pipeline object is stored into \a pipeline, the fragment shader program - into \a program. - - Use QOpenGLExtraFunctions to set uniforms, bind the pipeline, etc. - - \return \c false on failure in which case the error log is printed on the - debug output. \c true on success. - */ -bool QQuickNvprFunctions::createFragmentOnlyPipeline(const char *fragmentShaderSource, GLuint *pipeline, GLuint *program) -{ - QOpenGLContext *ctx = QOpenGLContext::currentContext(); - if (!ctx) - return false; - - QOpenGLExtraFunctions *f = ctx->extraFunctions(); - *program = f->glCreateShaderProgramv(GL_FRAGMENT_SHADER, 1, &fragmentShaderSource); - GLint status = 0; - f->glGetProgramiv(*program, GL_LINK_STATUS, &status); - if (!status) { - GLint len = 0; - f->glGetProgramiv(*program, GL_INFO_LOG_LENGTH, &len); - if (len) { - QByteArray s; - s.resize(len); - f->glGetProgramInfoLog(*program, s.count(), nullptr, s.data()); - qWarning("Failed to create separable shader program:\n%s", s.constData()); - } - return false; - } - - f->glGenProgramPipelines(1, pipeline); - f->glUseProgramStages(*pipeline, GL_FRAGMENT_SHADER_BIT, *program); - f->glActiveShaderProgram(*pipeline, *program); - - f->glValidateProgramPipeline(*pipeline); - status = 0; - f->glGetProgramPipelineiv(*pipeline, GL_VALIDATE_STATUS, &status); - if (!status) { - GLint len = 0; - f->glGetProgramPipelineiv(*pipeline, GL_INFO_LOG_LENGTH, &len); - if (len) { - QByteArray s; - s.resize(len); - f->glGetProgramPipelineInfoLog(*pipeline, s.count(), nullptr, s.data()); - qWarning("Program pipeline validation failed:\n%s", s.constData()); - } - return false; - } - - return true; -} - -bool QQuickNvprFunctionsPrivate::resolve() -{ - QOpenGLContext *ctx = QOpenGLContext::currentContext(); - - q->genPaths = PROC(PFNGLGENPATHSNVPROC, glGenPathsNV); - q->deletePaths = PROC(PFNGLDELETEPATHSNVPROC, glDeletePathsNV); - q->isPath = PROC(PFNGLISPATHNVPROC, glIsPathNV); - q->pathCommands = PROC(PFNGLPATHCOMMANDSNVPROC, glPathCommandsNV); - q->pathCoords = PROC(PFNGLPATHCOORDSNVPROC, glPathCoordsNV); - q->pathSubCommands = PROC(PFNGLPATHSUBCOMMANDSNVPROC, glPathSubCommandsNV); - q->pathSubCoords = PROC(PFNGLPATHSUBCOORDSNVPROC, glPathSubCoordsNV); - q->pathString = PROC(PFNGLPATHSTRINGNVPROC, glPathStringNV); - q->pathGlyphs = PROC(PFNGLPATHGLYPHSNVPROC, glPathGlyphsNV); - q->pathGlyphRange = PROC(PFNGLPATHGLYPHRANGENVPROC, glPathGlyphRangeNV); - q->weightPaths = PROC(PFNGLWEIGHTPATHSNVPROC, glWeightPathsNV); - q->copyPath = PROC(PFNGLCOPYPATHNVPROC, glCopyPathNV); - q->interpolatePaths = PROC(PFNGLINTERPOLATEPATHSNVPROC, glInterpolatePathsNV); - q->transformPath = PROC(PFNGLTRANSFORMPATHNVPROC, glTransformPathNV); - q->pathParameteriv = PROC(PFNGLPATHPARAMETERIVNVPROC, glPathParameterivNV); - q->pathParameteri = PROC(PFNGLPATHPARAMETERINVPROC, glPathParameteriNV); - q->pathParameterfv = PROC(PFNGLPATHPARAMETERFVNVPROC, glPathParameterfvNV); - q->pathParameterf = PROC(PFNGLPATHPARAMETERFNVPROC, glPathParameterfNV); - q->pathDashArray = PROC(PFNGLPATHDASHARRAYNVPROC, glPathDashArrayNV); - q->pathStencilFunc = PROC(PFNGLPATHSTENCILFUNCNVPROC, glPathStencilFuncNV); - q->pathStencilDepthOffset = PROC(PFNGLPATHSTENCILDEPTHOFFSETNVPROC, glPathStencilDepthOffsetNV); - q->stencilFillPath = PROC(PFNGLSTENCILFILLPATHNVPROC, glStencilFillPathNV); - q->stencilStrokePath = PROC(PFNGLSTENCILSTROKEPATHNVPROC, glStencilStrokePathNV); - q->stencilFillPathInstanced = PROC(PFNGLSTENCILFILLPATHINSTANCEDNVPROC, glStencilFillPathInstancedNV); - q->stencilStrokePathInstanced = PROC(PFNGLSTENCILSTROKEPATHINSTANCEDNVPROC, glStencilStrokePathInstancedNV); - q->pathCoverDepthFunc = PROC(PFNGLPATHCOVERDEPTHFUNCNVPROC, glPathCoverDepthFuncNV); - q->coverFillPath = PROC(PFNGLCOVERFILLPATHNVPROC, glCoverFillPathNV); - q->coverStrokePath = PROC(PFNGLCOVERSTROKEPATHNVPROC, glCoverStrokePathNV); - q->coverFillPathInstanced = PROC(PFNGLCOVERFILLPATHINSTANCEDNVPROC, glCoverFillPathInstancedNV); - q->coverStrokePathInstanced = PROC(PFNGLCOVERSTROKEPATHINSTANCEDNVPROC, glCoverStrokePathInstancedNV); - q->getPathParameteriv = PROC(PFNGLGETPATHPARAMETERIVNVPROC, glGetPathParameterivNV); - q->getPathParameterfv = PROC(PFNGLGETPATHPARAMETERFVNVPROC, glGetPathParameterfvNV); - q->getPathCommands = PROC(PFNGLGETPATHCOMMANDSNVPROC, glGetPathCommandsNV); - q->getPathCoords = PROC(PFNGLGETPATHCOORDSNVPROC, glGetPathCoordsNV); - q->getPathDashArray = PROC(PFNGLGETPATHDASHARRAYNVPROC, glGetPathDashArrayNV); - q->getPathMetrics = PROC(PFNGLGETPATHMETRICSNVPROC, glGetPathMetricsNV); - q->getPathMetricRange = PROC(PFNGLGETPATHMETRICRANGENVPROC, glGetPathMetricRangeNV); - q->getPathSpacing = PROC(PFNGLGETPATHSPACINGNVPROC, glGetPathSpacingNV); - q->isPointInFillPath = PROC(PFNGLISPOINTINFILLPATHNVPROC, glIsPointInFillPathNV); - q->isPointInStrokePath = PROC(PFNGLISPOINTINSTROKEPATHNVPROC, glIsPointInStrokePathNV); - q->getPathLength = PROC(PFNGLGETPATHLENGTHNVPROC, glGetPathLengthNV); - q->getPointAlongPath = PROC(PFNGLPOINTALONGPATHNVPROC, glPointAlongPathNV); - q->matrixLoad3x2f = PROC(PFNGLMATRIXLOAD3X2FNVPROC, glMatrixLoad3x2fNV); - q->matrixLoad3x3f = PROC(PFNGLMATRIXLOAD3X3FNVPROC, glMatrixLoad3x3fNV); - q->matrixLoadTranspose3x3f = PROC(PFNGLMATRIXLOADTRANSPOSE3X3FNVPROC, glMatrixLoadTranspose3x3fNV); - q->matrixMult3x2f = PROC(PFNGLMATRIXMULT3X2FNVPROC, glMatrixMult3x2fNV); - q->matrixMult3x3f = PROC(PFNGLMATRIXMULT3X3FNVPROC, glMatrixMult3x3fNV); - q->matrixMultTranspose3x3f = PROC(PFNGLMATRIXMULTTRANSPOSE3X3FNVPROC, glMatrixMultTranspose3x3fNV); - q->stencilThenCoverFillPath = PROC(PFNGLSTENCILTHENCOVERFILLPATHNVPROC, glStencilThenCoverFillPathNV); - q->stencilThenCoverStrokePath = PROC(PFNGLSTENCILTHENCOVERSTROKEPATHNVPROC, glStencilThenCoverStrokePathNV); - q->stencilThenCoverFillPathInstanced = PROC(PFNGLSTENCILTHENCOVERFILLPATHINSTANCEDNVPROC, glStencilThenCoverFillPathInstancedNV); - q->stencilThenCoverStrokePathInstanced = PROC(PFNGLSTENCILTHENCOVERSTROKEPATHINSTANCEDNVPROC, glStencilThenCoverStrokePathInstancedNV); - q->pathGlyphIndexRange = PROC(PFNGLPATHGLYPHINDEXRANGENVPROC, glPathGlyphIndexRangeNV); - q->pathGlyphIndexArray = PROC(PFNGLPATHGLYPHINDEXARRAYNVPROC, glPathGlyphIndexArrayNV); - q->pathMemoryGlyphIndexArray = PROC(PFNGLPATHMEMORYGLYPHINDEXARRAYNVPROC, glPathMemoryGlyphIndexArrayNV); - q->programPathFragmentInputGen = PROC(PFNGLPROGRAMPATHFRAGMENTINPUTGENNVPROC, glProgramPathFragmentInputGenNV); - q->getProgramResourcefv = PROC(PFNGLGETPROGRAMRESOURCEFVNVPROC, glGetProgramResourcefvNV); - - q->matrixLoadf = PROC(PFNGLMATRIXLOADFEXTPROC, glMatrixLoadfEXT); - q->matrixLoadIdentity = PROC(PFNGLMATRIXLOADIDENTITYEXTPROC, glMatrixLoadIdentityEXT); - - return q->genPaths != nullptr // base path rendering ext - && q->programPathFragmentInputGen != nullptr // updated path rendering ext - && q->matrixLoadf != nullptr // direct state access ext - && q->matrixLoadIdentity != nullptr; -} - -QT_END_NAMESPACE - -#endif // QT_CONFIG(opengl) diff --git a/src/quickshapes/qquicknvprfunctions_p.h b/src/quickshapes/qquicknvprfunctions_p.h deleted file mode 100644 index 92246cf4c8..0000000000 --- a/src/quickshapes/qquicknvprfunctions_p.h +++ /dev/null @@ -1,401 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtQuick module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QQUICKNVPRFUNCTIONS_P_H -#define QQUICKNVPRFUNCTIONS_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of a number of Qt sources files. This header file may change from -// version to version without notice, or even be removed. -// -// We mean it. -// - -#include <QtQuickShapes/private/qquickshapesglobal_p.h> -#include <qopengl.h> -#include <QtGui/qsurfaceformat.h> - -#if QT_CONFIG(opengl) - -QT_BEGIN_NAMESPACE - -// note: fixed pipeline specific functions are removed - modern ES ext -// headers have all this, but not the fixed stuff - -#ifndef GL_NV_path_rendering -#define GL_PATH_FORMAT_SVG_NV 0x9070 -#define GL_PATH_FORMAT_PS_NV 0x9071 -#define GL_STANDARD_FONT_NAME_NV 0x9072 -#define GL_SYSTEM_FONT_NAME_NV 0x9073 -#define GL_FILE_NAME_NV 0x9074 -#define GL_PATH_STROKE_WIDTH_NV 0x9075 -#define GL_PATH_END_CAPS_NV 0x9076 -#define GL_PATH_INITIAL_END_CAP_NV 0x9077 -#define GL_PATH_TERMINAL_END_CAP_NV 0x9078 -#define GL_PATH_JOIN_STYLE_NV 0x9079 -#define GL_PATH_MITER_LIMIT_NV 0x907A -#define GL_PATH_DASH_CAPS_NV 0x907B -#define GL_PATH_INITIAL_DASH_CAP_NV 0x907C -#define GL_PATH_TERMINAL_DASH_CAP_NV 0x907D -#define GL_PATH_DASH_OFFSET_NV 0x907E -#define GL_PATH_CLIENT_LENGTH_NV 0x907F -#define GL_PATH_FILL_MODE_NV 0x9080 -#define GL_PATH_FILL_MASK_NV 0x9081 -#define GL_PATH_FILL_COVER_MODE_NV 0x9082 -#define GL_PATH_STROKE_COVER_MODE_NV 0x9083 -#define GL_PATH_STROKE_MASK_NV 0x9084 -#define GL_COUNT_UP_NV 0x9088 -#define GL_COUNT_DOWN_NV 0x9089 -#define GL_PATH_OBJECT_BOUNDING_BOX_NV 0x908A -#define GL_CONVEX_HULL_NV 0x908B -#define GL_BOUNDING_BOX_NV 0x908D -#define GL_TRANSLATE_X_NV 0x908E -#define GL_TRANSLATE_Y_NV 0x908F -#define GL_TRANSLATE_2D_NV 0x9090 -#define GL_TRANSLATE_3D_NV 0x9091 -#define GL_AFFINE_2D_NV 0x9092 -#define GL_AFFINE_3D_NV 0x9094 -#define GL_TRANSPOSE_AFFINE_2D_NV 0x9096 -#define GL_TRANSPOSE_AFFINE_3D_NV 0x9098 -#define GL_UTF8_NV 0x909A -#define GL_UTF16_NV 0x909B -#define GL_BOUNDING_BOX_OF_BOUNDING_BOXES_NV 0x909C -#define GL_PATH_COMMAND_COUNT_NV 0x909D -#define GL_PATH_COORD_COUNT_NV 0x909E -#define GL_PATH_DASH_ARRAY_COUNT_NV 0x909F -#define GL_PATH_COMPUTED_LENGTH_NV 0x90A0 -#define GL_PATH_FILL_BOUNDING_BOX_NV 0x90A1 -#define GL_PATH_STROKE_BOUNDING_BOX_NV 0x90A2 -#define GL_SQUARE_NV 0x90A3 -#define GL_ROUND_NV 0x90A4 -#define GL_TRIANGULAR_NV 0x90A5 -#define GL_BEVEL_NV 0x90A6 -#define GL_MITER_REVERT_NV 0x90A7 -#define GL_MITER_TRUNCATE_NV 0x90A8 -#define GL_SKIP_MISSING_GLYPH_NV 0x90A9 -#define GL_USE_MISSING_GLYPH_NV 0x90AA -#define GL_PATH_ERROR_POSITION_NV 0x90AB -#define GL_PATH_FOG_GEN_MODE_NV 0x90AC -#define GL_ACCUM_ADJACENT_PAIRS_NV 0x90AD -#define GL_ADJACENT_PAIRS_NV 0x90AE -#define GL_FIRST_TO_REST_NV 0x90AF -#define GL_PATH_GEN_MODE_NV 0x90B0 -#define GL_PATH_GEN_COEFF_NV 0x90B1 -#define GL_PATH_GEN_COLOR_FORMAT_NV 0x90B2 -#define GL_PATH_GEN_COMPONENTS_NV 0x90B3 -#define GL_PATH_STENCIL_FUNC_NV 0x90B7 -#define GL_PATH_STENCIL_REF_NV 0x90B8 -#define GL_PATH_STENCIL_VALUE_MASK_NV 0x90B9 -#define GL_PATH_STENCIL_DEPTH_OFFSET_FACTOR_NV 0x90BD -#define GL_PATH_STENCIL_DEPTH_OFFSET_UNITS_NV 0x90BE -#define GL_PATH_COVER_DEPTH_FUNC_NV 0x90BF -#define GL_PATH_DASH_OFFSET_RESET_NV 0x90B4 -#define GL_MOVE_TO_RESETS_NV 0x90B5 -#define GL_MOVE_TO_CONTINUES_NV 0x90B6 -#define GL_CLOSE_PATH_NV 0x00 -#define GL_MOVE_TO_NV 0x02 -#define GL_RELATIVE_MOVE_TO_NV 0x03 -#define GL_LINE_TO_NV 0x04 -#define GL_RELATIVE_LINE_TO_NV 0x05 -#define GL_HORIZONTAL_LINE_TO_NV 0x06 -#define GL_RELATIVE_HORIZONTAL_LINE_TO_NV 0x07 -#define GL_VERTICAL_LINE_TO_NV 0x08 -#define GL_RELATIVE_VERTICAL_LINE_TO_NV 0x09 -#define GL_QUADRATIC_CURVE_TO_NV 0x0A -#define GL_RELATIVE_QUADRATIC_CURVE_TO_NV 0x0B -#define GL_CUBIC_CURVE_TO_NV 0x0C -#define GL_RELATIVE_CUBIC_CURVE_TO_NV 0x0D -#define GL_SMOOTH_QUADRATIC_CURVE_TO_NV 0x0E -#define GL_RELATIVE_SMOOTH_QUADRATIC_CURVE_TO_NV 0x0F -#define GL_SMOOTH_CUBIC_CURVE_TO_NV 0x10 -#define GL_RELATIVE_SMOOTH_CUBIC_CURVE_TO_NV 0x11 -#define GL_SMALL_CCW_ARC_TO_NV 0x12 -#define GL_RELATIVE_SMALL_CCW_ARC_TO_NV 0x13 -#define GL_SMALL_CW_ARC_TO_NV 0x14 -#define GL_RELATIVE_SMALL_CW_ARC_TO_NV 0x15 -#define GL_LARGE_CCW_ARC_TO_NV 0x16 -#define GL_RELATIVE_LARGE_CCW_ARC_TO_NV 0x17 -#define GL_LARGE_CW_ARC_TO_NV 0x18 -#define GL_RELATIVE_LARGE_CW_ARC_TO_NV 0x19 -#define GL_RESTART_PATH_NV 0xF0 -#define GL_DUP_FIRST_CUBIC_CURVE_TO_NV 0xF2 -#define GL_DUP_LAST_CUBIC_CURVE_TO_NV 0xF4 -#define GL_RECT_NV 0xF6 -#define GL_CIRCULAR_CCW_ARC_TO_NV 0xF8 -#define GL_CIRCULAR_CW_ARC_TO_NV 0xFA -#define GL_CIRCULAR_TANGENT_ARC_TO_NV 0xFC -#define GL_ARC_TO_NV 0xFE -#define GL_RELATIVE_ARC_TO_NV 0xFF -#define GL_BOLD_BIT_NV 0x01 -#define GL_ITALIC_BIT_NV 0x02 -#define GL_GLYPH_WIDTH_BIT_NV 0x01 -#define GL_GLYPH_HEIGHT_BIT_NV 0x02 -#define GL_GLYPH_HORIZONTAL_BEARING_X_BIT_NV 0x04 -#define GL_GLYPH_HORIZONTAL_BEARING_Y_BIT_NV 0x08 -#define GL_GLYPH_HORIZONTAL_BEARING_ADVANCE_BIT_NV 0x10 -#define GL_GLYPH_VERTICAL_BEARING_X_BIT_NV 0x20 -#define GL_GLYPH_VERTICAL_BEARING_Y_BIT_NV 0x40 -#define GL_GLYPH_VERTICAL_BEARING_ADVANCE_BIT_NV 0x80 -#define GL_GLYPH_HAS_KERNING_BIT_NV 0x100 -#define GL_FONT_X_MIN_BOUNDS_BIT_NV 0x00010000 -#define GL_FONT_Y_MIN_BOUNDS_BIT_NV 0x00020000 -#define GL_FONT_X_MAX_BOUNDS_BIT_NV 0x00040000 -#define GL_FONT_Y_MAX_BOUNDS_BIT_NV 0x00080000 -#define GL_FONT_UNITS_PER_EM_BIT_NV 0x00100000 -#define GL_FONT_ASCENDER_BIT_NV 0x00200000 -#define GL_FONT_DESCENDER_BIT_NV 0x00400000 -#define GL_FONT_HEIGHT_BIT_NV 0x00800000 -#define GL_FONT_MAX_ADVANCE_WIDTH_BIT_NV 0x01000000 -#define GL_FONT_MAX_ADVANCE_HEIGHT_BIT_NV 0x02000000 -#define GL_FONT_UNDERLINE_POSITION_BIT_NV 0x04000000 -#define GL_FONT_UNDERLINE_THICKNESS_BIT_NV 0x08000000 -#define GL_FONT_HAS_KERNING_BIT_NV 0x10000000 -#define GL_PRIMARY_COLOR_NV 0x852C -#define GL_SECONDARY_COLOR_NV 0x852D -#define GL_ROUNDED_RECT_NV 0xE8 -#define GL_RELATIVE_ROUNDED_RECT_NV 0xE9 -#define GL_ROUNDED_RECT2_NV 0xEA -#define GL_RELATIVE_ROUNDED_RECT2_NV 0xEB -#define GL_ROUNDED_RECT4_NV 0xEC -#define GL_RELATIVE_ROUNDED_RECT4_NV 0xED -#define GL_ROUNDED_RECT8_NV 0xEE -#define GL_RELATIVE_ROUNDED_RECT8_NV 0xEF -#define GL_RELATIVE_RECT_NV 0xF7 -#define GL_FONT_GLYPHS_AVAILABLE_NV 0x9368 -#define GL_FONT_TARGET_UNAVAILABLE_NV 0x9369 -#define GL_FONT_UNAVAILABLE_NV 0x936A -#define GL_FONT_UNINTELLIGIBLE_NV 0x936B -#define GL_CONIC_CURVE_TO_NV 0x1A -#define GL_RELATIVE_CONIC_CURVE_TO_NV 0x1B -#define GL_FONT_NUM_GLYPH_INDICES_BIT_NV 0x20000000 -#define GL_STANDARD_FONT_FORMAT_NV 0x936C -#define GL_2_BYTES_NV 0x1407 -#define GL_3_BYTES_NV 0x1408 -#define GL_4_BYTES_NV 0x1409 -#define GL_EYE_LINEAR_NV 0x2400 -#define GL_OBJECT_LINEAR_NV 0x2401 -#define GL_CONSTANT_NV 0x8576 -#define GL_PATH_PROJECTION_NV 0x1701 -#define GL_PATH_MODELVIEW_NV 0x1700 -#define GL_PATH_MODELVIEW_STACK_DEPTH_NV 0x0BA3 -#define GL_PATH_MODELVIEW_MATRIX_NV 0x0BA6 -#define GL_PATH_MAX_MODELVIEW_STACK_DEPTH_NV 0x0D36 -#define GL_PATH_TRANSPOSE_MODELVIEW_MATRIX_NV 0x84E3 -#define GL_PATH_PROJECTION_STACK_DEPTH_NV 0x0BA4 -#define GL_PATH_PROJECTION_MATRIX_NV 0x0BA7 -#define GL_PATH_MAX_PROJECTION_STACK_DEPTH_NV 0x0D38 -#define GL_PATH_TRANSPOSE_PROJECTION_MATRIX_NV 0x84E4 -#define GL_FRAGMENT_INPUT_NV 0x936D - -typedef GLuint (QOPENGLF_APIENTRYP PFNGLGENPATHSNVPROC) (GLsizei range); -typedef void (QOPENGLF_APIENTRYP PFNGLDELETEPATHSNVPROC) (GLuint path, GLsizei range); -typedef GLboolean (QOPENGLF_APIENTRYP PFNGLISPATHNVPROC) (GLuint path); -typedef void (QOPENGLF_APIENTRYP PFNGLPATHCOMMANDSNVPROC) (GLuint path, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords); -typedef void (QOPENGLF_APIENTRYP PFNGLPATHCOORDSNVPROC) (GLuint path, GLsizei numCoords, GLenum coordType, const void *coords); -typedef void (QOPENGLF_APIENTRYP PFNGLPATHSUBCOMMANDSNVPROC) (GLuint path, GLsizei commandStart, GLsizei commandsToDelete, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords); -typedef void (QOPENGLF_APIENTRYP PFNGLPATHSUBCOORDSNVPROC) (GLuint path, GLsizei coordStart, GLsizei numCoords, GLenum coordType, const void *coords); -typedef void (QOPENGLF_APIENTRYP PFNGLPATHSTRINGNVPROC) (GLuint path, GLenum format, GLsizei length, const void *pathString); -typedef void (QOPENGLF_APIENTRYP PFNGLPATHGLYPHSNVPROC) (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLsizei numGlyphs, GLenum type, const void *charcodes, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); -typedef void (QOPENGLF_APIENTRYP PFNGLPATHGLYPHRANGENVPROC) (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyph, GLsizei numGlyphs, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); -typedef void (QOPENGLF_APIENTRYP PFNGLWEIGHTPATHSNVPROC) (GLuint resultPath, GLsizei numPaths, const GLuint *paths, const GLfloat *weights); -typedef void (QOPENGLF_APIENTRYP PFNGLCOPYPATHNVPROC) (GLuint resultPath, GLuint srcPath); -typedef void (QOPENGLF_APIENTRYP PFNGLINTERPOLATEPATHSNVPROC) (GLuint resultPath, GLuint pathA, GLuint pathB, GLfloat weight); -typedef void (QOPENGLF_APIENTRYP PFNGLTRANSFORMPATHNVPROC) (GLuint resultPath, GLuint srcPath, GLenum transformType, const GLfloat *transformValues); -typedef void (QOPENGLF_APIENTRYP PFNGLPATHPARAMETERIVNVPROC) (GLuint path, GLenum pname, const GLint *value); -typedef void (QOPENGLF_APIENTRYP PFNGLPATHPARAMETERINVPROC) (GLuint path, GLenum pname, GLint value); -typedef void (QOPENGLF_APIENTRYP PFNGLPATHPARAMETERFVNVPROC) (GLuint path, GLenum pname, const GLfloat *value); -typedef void (QOPENGLF_APIENTRYP PFNGLPATHPARAMETERFNVPROC) (GLuint path, GLenum pname, GLfloat value); -typedef void (QOPENGLF_APIENTRYP PFNGLPATHDASHARRAYNVPROC) (GLuint path, GLsizei dashCount, const GLfloat *dashArray); -typedef void (QOPENGLF_APIENTRYP PFNGLPATHSTENCILFUNCNVPROC) (GLenum func, GLint ref, GLuint mask); -typedef void (QOPENGLF_APIENTRYP PFNGLPATHSTENCILDEPTHOFFSETNVPROC) (GLfloat factor, GLfloat units); -typedef void (QOPENGLF_APIENTRYP PFNGLSTENCILFILLPATHNVPROC) (GLuint path, GLenum fillMode, GLuint mask); -typedef void (QOPENGLF_APIENTRYP PFNGLSTENCILSTROKEPATHNVPROC) (GLuint path, GLint reference, GLuint mask); -typedef void (QOPENGLF_APIENTRYP PFNGLSTENCILFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum transformType, const GLfloat *transformValues); -typedef void (QOPENGLF_APIENTRYP PFNGLSTENCILSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum transformType, const GLfloat *transformValues); -typedef void (QOPENGLF_APIENTRYP PFNGLPATHCOVERDEPTHFUNCNVPROC) (GLenum func); -typedef void (QOPENGLF_APIENTRYP PFNGLCOVERFILLPATHNVPROC) (GLuint path, GLenum coverMode); -typedef void (QOPENGLF_APIENTRYP PFNGLCOVERSTROKEPATHNVPROC) (GLuint path, GLenum coverMode); -typedef void (QOPENGLF_APIENTRYP PFNGLCOVERFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); -typedef void (QOPENGLF_APIENTRYP PFNGLCOVERSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); -typedef void (QOPENGLF_APIENTRYP PFNGLGETPATHPARAMETERIVNVPROC) (GLuint path, GLenum pname, GLint *value); -typedef void (QOPENGLF_APIENTRYP PFNGLGETPATHPARAMETERFVNVPROC) (GLuint path, GLenum pname, GLfloat *value); -typedef void (QOPENGLF_APIENTRYP PFNGLGETPATHCOMMANDSNVPROC) (GLuint path, GLubyte *commands); -typedef void (QOPENGLF_APIENTRYP PFNGLGETPATHCOORDSNVPROC) (GLuint path, GLfloat *coords); -typedef void (QOPENGLF_APIENTRYP PFNGLGETPATHDASHARRAYNVPROC) (GLuint path, GLfloat *dashArray); -typedef void (QOPENGLF_APIENTRYP PFNGLGETPATHMETRICSNVPROC) (GLbitfield metricQueryMask, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLsizei stride, GLfloat *metrics); -typedef void (QOPENGLF_APIENTRYP PFNGLGETPATHMETRICRANGENVPROC) (GLbitfield metricQueryMask, GLuint firstPathName, GLsizei numPaths, GLsizei stride, GLfloat *metrics); -typedef void (QOPENGLF_APIENTRYP PFNGLGETPATHSPACINGNVPROC) (GLenum pathListMode, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLfloat advanceScale, GLfloat kerningScale, GLenum transformType, GLfloat *returnedSpacing); -typedef GLboolean (QOPENGLF_APIENTRYP PFNGLISPOINTINFILLPATHNVPROC) (GLuint path, GLuint mask, GLfloat x, GLfloat y); -typedef GLboolean (QOPENGLF_APIENTRYP PFNGLISPOINTINSTROKEPATHNVPROC) (GLuint path, GLfloat x, GLfloat y); -typedef GLfloat (QOPENGLF_APIENTRYP PFNGLGETPATHLENGTHNVPROC) (GLuint path, GLsizei startSegment, GLsizei numSegments); -typedef GLboolean (QOPENGLF_APIENTRYP PFNGLPOINTALONGPATHNVPROC) (GLuint path, GLsizei startSegment, GLsizei numSegments, GLfloat distance, GLfloat *x, GLfloat *y, GLfloat *tangentX, GLfloat *tangentY); -typedef void (QOPENGLF_APIENTRYP PFNGLMATRIXLOAD3X2FNVPROC) (GLenum matrixMode, const GLfloat *m); -typedef void (QOPENGLF_APIENTRYP PFNGLMATRIXLOAD3X3FNVPROC) (GLenum matrixMode, const GLfloat *m); -typedef void (QOPENGLF_APIENTRYP PFNGLMATRIXLOADTRANSPOSE3X3FNVPROC) (GLenum matrixMode, const GLfloat *m); -typedef void (QOPENGLF_APIENTRYP PFNGLMATRIXMULT3X2FNVPROC) (GLenum matrixMode, const GLfloat *m); -typedef void (QOPENGLF_APIENTRYP PFNGLMATRIXMULT3X3FNVPROC) (GLenum matrixMode, const GLfloat *m); -typedef void (QOPENGLF_APIENTRYP PFNGLMATRIXMULTTRANSPOSE3X3FNVPROC) (GLenum matrixMode, const GLfloat *m); -typedef void (QOPENGLF_APIENTRYP PFNGLSTENCILTHENCOVERFILLPATHNVPROC) (GLuint path, GLenum fillMode, GLuint mask, GLenum coverMode); -typedef void (QOPENGLF_APIENTRYP PFNGLSTENCILTHENCOVERSTROKEPATHNVPROC) (GLuint path, GLint reference, GLuint mask, GLenum coverMode); -typedef void (QOPENGLF_APIENTRYP PFNGLSTENCILTHENCOVERFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); -typedef void (QOPENGLF_APIENTRYP PFNGLSTENCILTHENCOVERSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); -typedef GLenum (QOPENGLF_APIENTRYP PFNGLPATHGLYPHINDEXRANGENVPROC) (GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint pathParameterTemplate, GLfloat emScale, GLuint baseAndCount[2]); -typedef GLenum (QOPENGLF_APIENTRYP PFNGLPATHGLYPHINDEXARRAYNVPROC) (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyphIndex, GLsizei numGlyphs, GLuint pathParameterTemplate, GLfloat emScale); -typedef GLenum (QOPENGLF_APIENTRYP PFNGLPATHMEMORYGLYPHINDEXARRAYNVPROC) (GLuint firstPathName, GLenum fontTarget, GLsizeiptr fontSize, const void *fontData, GLsizei faceIndex, GLuint firstGlyphIndex, GLsizei numGlyphs, GLuint pathParameterTemplate, GLfloat emScale); -typedef void (QOPENGLF_APIENTRYP PFNGLPROGRAMPATHFRAGMENTINPUTGENNVPROC) (GLuint program, GLint location, GLenum genMode, GLint components, const GLfloat *coeffs); -typedef void (QOPENGLF_APIENTRYP PFNGLGETPROGRAMRESOURCEFVNVPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei bufSize, GLsizei *length, GLfloat *params); -#endif - -#ifndef GL_FLAT -#define GL_FLAT 0x1D00 -#endif - -#ifndef GL_INVERT -#define GL_INVERT 0x150A -#endif - -// this one originates from fixed pipeline so may not be in GLES ext headers, but we need it still -#ifndef GL_OBJECT_LINEAR_NV -#define GL_OBJECT_LINEAR_NV 0x2401 -#endif - -#ifndef GL_EXT_direct_state_access -typedef void (QOPENGLF_APIENTRYP PFNGLMATRIXLOADFEXTPROC) (GLenum mode, const GLfloat *m); -typedef void (QOPENGLF_APIENTRYP PFNGLMATRIXLOADIDENTITYEXTPROC) (GLenum mode); -#endif - -// When building on a system with GLES 2.0 or 3.0, we may still compile the NVPR -// code path even though it's never used. Keep it compiling by defining the -// necessary ES 3.1 separable program constants. -#ifndef GL_FRAGMENT_SHADER_BIT -#define GL_FRAGMENT_SHADER_BIT 0x00000002 -#endif -#ifndef GL_UNIFORM -#define GL_UNIFORM 0x92E1 -#endif - -class QQuickNvprFunctionsPrivate; - -class QQuickNvprFunctions -{ -public: - QQuickNvprFunctions(); - ~QQuickNvprFunctions(); - - static QSurfaceFormat format(); - static bool isSupported(); - - bool create(); - - bool createFragmentOnlyPipeline(const char *fragmentShaderSource, GLuint *pipeline, GLuint *program); - - PFNGLGENPATHSNVPROC genPaths = nullptr; - PFNGLDELETEPATHSNVPROC deletePaths = nullptr; - PFNGLISPATHNVPROC isPath = nullptr; - PFNGLPATHCOMMANDSNVPROC pathCommands = nullptr; - PFNGLPATHCOORDSNVPROC pathCoords = nullptr; - PFNGLPATHSUBCOMMANDSNVPROC pathSubCommands = nullptr; - PFNGLPATHSUBCOORDSNVPROC pathSubCoords = nullptr; - PFNGLPATHSTRINGNVPROC pathString = nullptr; - PFNGLPATHGLYPHSNVPROC pathGlyphs = nullptr; - PFNGLPATHGLYPHRANGENVPROC pathGlyphRange = nullptr; - PFNGLWEIGHTPATHSNVPROC weightPaths = nullptr; - PFNGLCOPYPATHNVPROC copyPath = nullptr; - PFNGLINTERPOLATEPATHSNVPROC interpolatePaths = nullptr; - PFNGLTRANSFORMPATHNVPROC transformPath = nullptr; - PFNGLPATHPARAMETERIVNVPROC pathParameteriv = nullptr; - PFNGLPATHPARAMETERINVPROC pathParameteri = nullptr; - PFNGLPATHPARAMETERFVNVPROC pathParameterfv = nullptr; - PFNGLPATHPARAMETERFNVPROC pathParameterf = nullptr; - PFNGLPATHDASHARRAYNVPROC pathDashArray = nullptr; - PFNGLPATHSTENCILFUNCNVPROC pathStencilFunc = nullptr; - PFNGLPATHSTENCILDEPTHOFFSETNVPROC pathStencilDepthOffset = nullptr; - PFNGLSTENCILFILLPATHNVPROC stencilFillPath = nullptr; - PFNGLSTENCILSTROKEPATHNVPROC stencilStrokePath = nullptr; - PFNGLSTENCILFILLPATHINSTANCEDNVPROC stencilFillPathInstanced = nullptr; - PFNGLSTENCILSTROKEPATHINSTANCEDNVPROC stencilStrokePathInstanced = nullptr; - PFNGLPATHCOVERDEPTHFUNCNVPROC pathCoverDepthFunc = nullptr; - PFNGLCOVERFILLPATHNVPROC coverFillPath = nullptr; - PFNGLCOVERSTROKEPATHNVPROC coverStrokePath = nullptr; - PFNGLCOVERFILLPATHINSTANCEDNVPROC coverFillPathInstanced = nullptr; - PFNGLCOVERSTROKEPATHINSTANCEDNVPROC coverStrokePathInstanced = nullptr; - PFNGLGETPATHPARAMETERIVNVPROC getPathParameteriv = nullptr; - PFNGLGETPATHPARAMETERFVNVPROC getPathParameterfv = nullptr; - PFNGLGETPATHCOMMANDSNVPROC getPathCommands = nullptr; - PFNGLGETPATHCOORDSNVPROC getPathCoords = nullptr; - PFNGLGETPATHDASHARRAYNVPROC getPathDashArray = nullptr; - PFNGLGETPATHMETRICSNVPROC getPathMetrics = nullptr; - PFNGLGETPATHMETRICRANGENVPROC getPathMetricRange = nullptr; - PFNGLGETPATHSPACINGNVPROC getPathSpacing = nullptr; - PFNGLISPOINTINFILLPATHNVPROC isPointInFillPath = nullptr; - PFNGLISPOINTINSTROKEPATHNVPROC isPointInStrokePath = nullptr; - PFNGLGETPATHLENGTHNVPROC getPathLength = nullptr; - PFNGLPOINTALONGPATHNVPROC getPointAlongPath = nullptr; - PFNGLMATRIXLOAD3X2FNVPROC matrixLoad3x2f = nullptr; - PFNGLMATRIXLOAD3X3FNVPROC matrixLoad3x3f = nullptr; - PFNGLMATRIXLOADTRANSPOSE3X3FNVPROC matrixLoadTranspose3x3f = nullptr; - PFNGLMATRIXMULT3X2FNVPROC matrixMult3x2f = nullptr; - PFNGLMATRIXMULT3X3FNVPROC matrixMult3x3f = nullptr; - PFNGLMATRIXMULTTRANSPOSE3X3FNVPROC matrixMultTranspose3x3f = nullptr; - PFNGLSTENCILTHENCOVERFILLPATHNVPROC stencilThenCoverFillPath = nullptr; - PFNGLSTENCILTHENCOVERSTROKEPATHNVPROC stencilThenCoverStrokePath = nullptr; - PFNGLSTENCILTHENCOVERFILLPATHINSTANCEDNVPROC stencilThenCoverFillPathInstanced = nullptr; - PFNGLSTENCILTHENCOVERSTROKEPATHINSTANCEDNVPROC stencilThenCoverStrokePathInstanced = nullptr; - PFNGLPATHGLYPHINDEXRANGENVPROC pathGlyphIndexRange = nullptr; - PFNGLPATHGLYPHINDEXARRAYNVPROC pathGlyphIndexArray = nullptr; - PFNGLPATHMEMORYGLYPHINDEXARRAYNVPROC pathMemoryGlyphIndexArray = nullptr; - PFNGLPROGRAMPATHFRAGMENTINPUTGENNVPROC programPathFragmentInputGen = nullptr; - PFNGLGETPROGRAMRESOURCEFVNVPROC getProgramResourcefv = nullptr; - - PFNGLMATRIXLOADFEXTPROC matrixLoadf = nullptr; - PFNGLMATRIXLOADIDENTITYEXTPROC matrixLoadIdentity = nullptr; - -private: - QQuickNvprFunctionsPrivate *d; -}; - -QT_END_NAMESPACE - -#endif // QT_CONFIG(opengl) - -#endif // QQUICKNVPRFUNCTIONS_P_H diff --git a/src/quickshapes/qquicknvprfunctions_p_p.h b/src/quickshapes/qquicknvprfunctions_p_p.h deleted file mode 100644 index 3d9ca0de9f..0000000000 --- a/src/quickshapes/qquicknvprfunctions_p_p.h +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtQuick module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QQUICKNVPRFUNCTIONS_P_P_H -#define QQUICKNVPRFUNCTIONS_P_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of a number of Qt sources files. This header file may change from -// version to version without notice, or even be removed. -// -// We mean it. -// - -#include <QtQuickShapes/private/qquickshapesglobal_p.h> -#include <QtQuickShapes/private/qquicknvprfunctions_p.h> - -QT_BEGIN_NAMESPACE - -class QQuickNvprFunctionsPrivate -{ -public: - QQuickNvprFunctionsPrivate(QQuickNvprFunctions *q_ptr) : q(q_ptr) { } - - bool resolve(); - - QQuickNvprFunctions *q; -}; - -QT_END_NAMESPACE - -#endif // QQUICKNVPRFUNCTIONS_P_P_H diff --git a/src/quickshapes/qquickshape.cpp b/src/quickshapes/qquickshape.cpp index 563303b84a..5e2cfc6622 100644 --- a/src/quickshapes/qquickshape.cpp +++ b/src/quickshapes/qquickshape.cpp @@ -40,7 +40,6 @@ #include "qquickshape_p.h" #include "qquickshape_p_p.h" #include "qquickshapegenericrenderer_p.h" -#include "qquickshapenvprrenderer_p.h" #include "qquickshapesoftwarerenderer_p.h" #include <private/qsgplaintexture_p.h> #include <private/qquicksvgparser_p.h> @@ -694,12 +693,6 @@ QQuickShape::~QQuickShape() engine. This is the default on non-NVIDIA hardware when the default, OpenGL Qt Quick scenegraph backend is in use. - \value Shape.NvprRenderer - Path items are rendered by performing OpenGL calls using the - \c{GL_NV_path_rendering} extension. This is the default on NVIDIA - hardware when the default, OpenGL Qt Quick scenegraph backend is in - use. - \value Shape.SoftwareRenderer Pure QPainter drawing using the raster paint engine. This is the default, and only, option when the Qt Quick scenegraph is running @@ -755,12 +748,9 @@ void QQuickShape::setAsynchronous(bool async) As of Qt 5.12 Shape.NvprRenderer is disabled by default and a uniform behavior, based on triangulating the path and generating QSGGeometryNode - instances, is used regardless of the graphics card and drivers. To enable - using vendor-specific path rendering approaches set the value to \c true. - Depending on the platform and content, this can lead to improved - performance. Setting the value to \c true is safe in any case since - rendering falls back to the default method when the vendor-specific - approach, such as \c GL_NV_path_rendering, is not supported at run time. + instances, is used regardless of the graphics card and drivers. + + As of Qt 6.0 there are no vendor-specific rendering paths implemented. */ bool QQuickShape::vendorExtensionsEnabled() const @@ -993,13 +983,8 @@ void QQuickShapePrivate::createRenderer() switch (ri->graphicsApi()) { #if QT_CONFIG(opengl) case QSGRendererInterface::OpenGL: - if (enableVendorExts && QQuickShapeNvprRenderNode::isSupported()) { - rendererType = QQuickShape::NvprRenderer; - renderer = new QQuickShapeNvprRenderer; - } else { - rendererType = QQuickShape::GeometryRenderer; - renderer = new QQuickShapeGenericRenderer(q); - } + rendererType = QQuickShape::GeometryRenderer; + renderer = new QQuickShapeGenericRenderer(q); break; #endif case QSGRendererInterface::Software: @@ -1031,15 +1016,9 @@ QSGNode *QQuickShapePrivate::createNode() switch (ri->graphicsApi()) { #if QT_CONFIG(opengl) case QSGRendererInterface::OpenGL: - if (enableVendorExts && QQuickShapeNvprRenderNode::isSupported()) { - node = new QQuickShapeNvprRenderNode; - static_cast<QQuickShapeNvprRenderer *>(renderer)->setNode( - static_cast<QQuickShapeNvprRenderNode *>(node)); - } else { - node = new QQuickShapeGenericNode; - static_cast<QQuickShapeGenericRenderer *>(renderer)->setRootNode( - static_cast<QQuickShapeGenericNode *>(node)); - } + node = new QQuickShapeGenericNode; + static_cast<QQuickShapeGenericRenderer *>(renderer)->setRootNode( + static_cast<QQuickShapeGenericNode *>(node)); break; #endif case QSGRendererInterface::Software: diff --git a/src/quickshapes/qquickshapegenericrenderer.cpp b/src/quickshapes/qquickshapegenericrenderer.cpp index 9fbff8fdda..148cbca3d0 100644 --- a/src/quickshapes/qquickshapegenericrenderer.cpp +++ b/src/quickshapes/qquickshapegenericrenderer.cpp @@ -752,51 +752,6 @@ QSGMaterial *QQuickShapeGenericMaterialFactory::createConicalGradient(QQuickWind return nullptr; } -#if QT_CONFIG(opengl) - -QQuickShapeLinearGradientShader::QQuickShapeLinearGradientShader() -{ - setShaderSourceFile(QOpenGLShader::Vertex, - QStringLiteral(":/qt-project.org/shapes/shaders/lineargradient.vert")); - setShaderSourceFile(QOpenGLShader::Fragment, - QStringLiteral(":/qt-project.org/shapes/shaders/lineargradient.frag")); -} - -void QQuickShapeLinearGradientShader::initialize() -{ - m_opacityLoc = program()->uniformLocation("opacity"); - m_matrixLoc = program()->uniformLocation("matrix"); - m_gradStartLoc = program()->uniformLocation("gradStart"); - m_gradEndLoc = program()->uniformLocation("gradEnd"); -} - -void QQuickShapeLinearGradientShader::updateState(const RenderState &state, QSGMaterial *mat, QSGMaterial *) -{ - QQuickShapeLinearGradientMaterial *m = static_cast<QQuickShapeLinearGradientMaterial *>(mat); - - if (state.isOpacityDirty()) - program()->setUniformValue(m_opacityLoc, state.opacity()); - - if (state.isMatrixDirty()) - program()->setUniformValue(m_matrixLoc, state.combinedMatrix()); - - QQuickShapeGenericStrokeFillNode *node = m->node(); - program()->setUniformValue(m_gradStartLoc, QVector2D(node->m_fillGradient.a)); - program()->setUniformValue(m_gradEndLoc, QVector2D(node->m_fillGradient.b)); - - const QQuickShapeGradientCacheKey cacheKey(node->m_fillGradient.stops, node->m_fillGradient.spread); - QSGTexture *tx = QQuickShapeGradientOpenGLCache::currentCache()->get(cacheKey); - tx->bind(); -} - -char const *const *QQuickShapeLinearGradientShader::attributeNames() const -{ - static const char *const attr[] = { "vertexCoord", "vertexColor", nullptr }; - return attr; -} - -#endif // QT_CONFIG(opengl) - QQuickShapeLinearGradientRhiShader::QQuickShapeLinearGradientRhiShader() { setShaderFileName(VertexStage, QStringLiteral(":/qt-project.org/shapes/shaders_ng/lineargradient.vert.qsb")); @@ -903,73 +858,9 @@ int QQuickShapeLinearGradientMaterial::compare(const QSGMaterial *other) const QSGMaterialShader *QQuickShapeLinearGradientMaterial::createShader() const { - if (flags().testFlag(RhiShaderWanted)) - return new QQuickShapeLinearGradientRhiShader; -#if QT_CONFIG(opengl) - else - return new QQuickShapeLinearGradientShader; -#else - return nullptr; -#endif -} - -#if QT_CONFIG(opengl) - -QQuickShapeRadialGradientShader::QQuickShapeRadialGradientShader() -{ - setShaderSourceFile(QOpenGLShader::Vertex, - QStringLiteral(":/qt-project.org/shapes/shaders/radialgradient.vert")); - setShaderSourceFile(QOpenGLShader::Fragment, - QStringLiteral(":/qt-project.org/shapes/shaders/radialgradient.frag")); -} - -void QQuickShapeRadialGradientShader::initialize() -{ - QOpenGLShaderProgram *prog = program(); - m_opacityLoc = prog->uniformLocation("opacity"); - m_matrixLoc = prog->uniformLocation("matrix"); - m_translationPointLoc = prog->uniformLocation("translationPoint"); - m_focalToCenterLoc = prog->uniformLocation("focalToCenter"); - m_centerRadiusLoc = prog->uniformLocation("centerRadius"); - m_focalRadiusLoc = prog->uniformLocation("focalRadius"); -} - -void QQuickShapeRadialGradientShader::updateState(const RenderState &state, QSGMaterial *mat, QSGMaterial *) -{ - QQuickShapeRadialGradientMaterial *m = static_cast<QQuickShapeRadialGradientMaterial *>(mat); - - if (state.isOpacityDirty()) - program()->setUniformValue(m_opacityLoc, state.opacity()); - - if (state.isMatrixDirty()) - program()->setUniformValue(m_matrixLoc, state.combinedMatrix()); - - QQuickShapeGenericStrokeFillNode *node = m->node(); - - const QPointF centerPoint = node->m_fillGradient.a; - const QPointF focalPoint = node->m_fillGradient.b; - const QPointF focalToCenter = centerPoint - focalPoint; - const GLfloat centerRadius = node->m_fillGradient.v0; - const GLfloat focalRadius = node->m_fillGradient.v1; - - program()->setUniformValue(m_translationPointLoc, focalPoint); - program()->setUniformValue(m_centerRadiusLoc, centerRadius); - program()->setUniformValue(m_focalRadiusLoc, focalRadius); - program()->setUniformValue(m_focalToCenterLoc, focalToCenter); - - const QQuickShapeGradientCacheKey cacheKey(node->m_fillGradient.stops, node->m_fillGradient.spread); - QSGTexture *tx = QQuickShapeGradientOpenGLCache::currentCache()->get(cacheKey); - tx->bind(); -} - -char const *const *QQuickShapeRadialGradientShader::attributeNames() const -{ - static const char *const attr[] = { "vertexCoord", "vertexColor", nullptr }; - return attr; + return new QQuickShapeLinearGradientRhiShader; } -#endif // QT_CONFIG(opengl) - QQuickShapeRadialGradientRhiShader::QQuickShapeRadialGradientRhiShader() { setShaderFileName(VertexStage, QStringLiteral(":/qt-project.org/shapes/shaders_ng/radialgradient.vert.qsb")); @@ -1100,66 +991,9 @@ int QQuickShapeRadialGradientMaterial::compare(const QSGMaterial *other) const QSGMaterialShader *QQuickShapeRadialGradientMaterial::createShader() const { - if (flags().testFlag(RhiShaderWanted)) - return new QQuickShapeRadialGradientRhiShader; -#if QT_CONFIG(opengl) - else - return new QQuickShapeRadialGradientShader; -#else - return nullptr; -#endif -} - -#if QT_CONFIG(opengl) - -QQuickShapeConicalGradientShader::QQuickShapeConicalGradientShader() -{ - setShaderSourceFile(QOpenGLShader::Vertex, - QStringLiteral(":/qt-project.org/shapes/shaders/conicalgradient.vert")); - setShaderSourceFile(QOpenGLShader::Fragment, - QStringLiteral(":/qt-project.org/shapes/shaders/conicalgradient.frag")); + return new QQuickShapeRadialGradientRhiShader; } -void QQuickShapeConicalGradientShader::initialize() -{ - QOpenGLShaderProgram *prog = program(); - m_opacityLoc = prog->uniformLocation("opacity"); - m_matrixLoc = prog->uniformLocation("matrix"); - m_angleLoc = prog->uniformLocation("angle"); - m_translationPointLoc = prog->uniformLocation("translationPoint"); -} - -void QQuickShapeConicalGradientShader::updateState(const RenderState &state, QSGMaterial *mat, QSGMaterial *) -{ - QQuickShapeConicalGradientMaterial *m = static_cast<QQuickShapeConicalGradientMaterial *>(mat); - - if (state.isOpacityDirty()) - program()->setUniformValue(m_opacityLoc, state.opacity()); - - if (state.isMatrixDirty()) - program()->setUniformValue(m_matrixLoc, state.combinedMatrix()); - - QQuickShapeGenericStrokeFillNode *node = m->node(); - - const QPointF centerPoint = node->m_fillGradient.a; - const GLfloat angle = -qDegreesToRadians(node->m_fillGradient.v0); - - program()->setUniformValue(m_angleLoc, angle); - program()->setUniformValue(m_translationPointLoc, centerPoint); - - const QQuickShapeGradientCacheKey cacheKey(node->m_fillGradient.stops, QQuickShapeGradient::RepeatSpread); - QSGTexture *tx = QQuickShapeGradientOpenGLCache::currentCache()->get(cacheKey); - tx->bind(); -} - -char const *const *QQuickShapeConicalGradientShader::attributeNames() const -{ - static const char *const attr[] = { "vertexCoord", "vertexColor", nullptr }; - return attr; -} - -#endif // QT_CONFIG(opengl) - QQuickShapeConicalGradientRhiShader::QQuickShapeConicalGradientRhiShader() { setShaderFileName(VertexStage, QStringLiteral(":/qt-project.org/shapes/shaders_ng/conicalgradient.vert.qsb")); @@ -1265,14 +1099,7 @@ int QQuickShapeConicalGradientMaterial::compare(const QSGMaterial *other) const QSGMaterialShader *QQuickShapeConicalGradientMaterial::createShader() const { - if (flags().testFlag(RhiShaderWanted)) - return new QQuickShapeConicalGradientRhiShader; -#if QT_CONFIG(opengl) - else - return new QQuickShapeConicalGradientShader; -#else - return nullptr; -#endif + return new QQuickShapeConicalGradientRhiShader; } QT_END_NAMESPACE diff --git a/src/quickshapes/qquickshapegenericrenderer_p.h b/src/quickshapes/qquickshapegenericrenderer_p.h index 75c4277383..cb206cea87 100644 --- a/src/quickshapes/qquickshapegenericrenderer_p.h +++ b/src/quickshapes/qquickshapegenericrenderer_p.h @@ -243,27 +243,7 @@ public: static QSGMaterial *createConicalGradient(QQuickWindow *window, QQuickShapeGenericStrokeFillNode *node); }; -#if QT_CONFIG(opengl) - - class QQuickShapeLinearGradientShader : public QSGMaterialShader -{ -public: - QQuickShapeLinearGradientShader(); - - void initialize() override; - void updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect) override; - char const *const *attributeNames() const override; - -private: - int m_opacityLoc = -1; - int m_matrixLoc = -1; - int m_gradStartLoc = -1; - int m_gradEndLoc = -1; -}; - -#endif // QT_CONFIG(opengl) - -class QQuickShapeLinearGradientRhiShader : public QSGMaterialRhiShader +class QQuickShapeLinearGradientRhiShader : public QSGMaterialShader { public: QQuickShapeLinearGradientRhiShader(); @@ -289,7 +269,7 @@ public: // the vertex data. The shader will rely on the fact that // vertexCoord.xy is the Shape-space coordinate and so no modifications // are welcome. - setFlag(Blending | RequiresFullMatrix | SupportsRhiShader); + setFlag(Blending | RequiresFullMatrix); } QSGMaterialType *type() const override; @@ -302,29 +282,7 @@ private: QQuickShapeGenericStrokeFillNode *m_node; }; -#if QT_CONFIG(opengl) - -class QQuickShapeRadialGradientShader : public QSGMaterialShader -{ -public: - QQuickShapeRadialGradientShader(); - - void initialize() override; - void updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect) override; - char const *const *attributeNames() const override; - -private: - int m_opacityLoc = -1; - int m_matrixLoc = -1; - int m_translationPointLoc = -1; - int m_focalToCenterLoc = -1; - int m_centerRadiusLoc = -1; - int m_focalRadiusLoc = -1; -}; - -#endif // QT_CONFIG(opengl) - -class QQuickShapeRadialGradientRhiShader : public QSGMaterialRhiShader +class QQuickShapeRadialGradientRhiShader : public QSGMaterialShader { public: QQuickShapeRadialGradientRhiShader(); @@ -347,7 +305,7 @@ public: QQuickShapeRadialGradientMaterial(QQuickShapeGenericStrokeFillNode *node) : m_node(node) { - setFlag(Blending | RequiresFullMatrix | SupportsRhiShader); + setFlag(Blending | RequiresFullMatrix); } QSGMaterialType *type() const override; @@ -360,27 +318,7 @@ private: QQuickShapeGenericStrokeFillNode *m_node; }; -#if QT_CONFIG(opengl) - -class QQuickShapeConicalGradientShader : public QSGMaterialShader -{ -public: - QQuickShapeConicalGradientShader(); - - void initialize() override; - void updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect) override; - char const *const *attributeNames() const override; - -private: - int m_opacityLoc = -1; - int m_matrixLoc = -1; - int m_angleLoc = -1; - int m_translationPointLoc = -1; -}; - -#endif // QT_CONFIG(opengl) - -class QQuickShapeConicalGradientRhiShader : public QSGMaterialRhiShader +class QQuickShapeConicalGradientRhiShader : public QSGMaterialShader { public: QQuickShapeConicalGradientRhiShader(); @@ -401,7 +339,7 @@ public: QQuickShapeConicalGradientMaterial(QQuickShapeGenericStrokeFillNode *node) : m_node(node) { - setFlag(Blending | RequiresFullMatrix | SupportsRhiShader); + setFlag(Blending | RequiresFullMatrix); } QSGMaterialType *type() const override; diff --git a/src/quickshapes/qquickshapenvprrenderer.cpp b/src/quickshapes/qquickshapenvprrenderer.cpp deleted file mode 100644 index 721091b669..0000000000 --- a/src/quickshapes/qquickshapenvprrenderer.cpp +++ /dev/null @@ -1,1001 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtQuick module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qquickshapenvprrenderer_p.h" -#include <QOpenGLExtraFunctions> -#include <QOpenGLFramebufferObject> -#include <QOpenGLShaderProgram> -#include <QOpenGLBuffer> -#include <qmath.h> -#include <private/qpainterpath_p.h> -#include <private/qquickpath_p_p.h> - -QT_BEGIN_NAMESPACE - -void QQuickShapeNvprRenderer::beginSync(int totalCount) -{ - if (m_sp.count() != totalCount) { - m_sp.resize(totalCount); - m_accDirty |= DirtyList; - } -} - -void QQuickShapeNvprRenderer::setPath(int index, const QQuickPath *path) -{ - ShapePathGuiData &d(m_sp[index]); - convertPath(path, &d); - d.dirty |= DirtyPath; - m_accDirty |= DirtyPath; -} - -void QQuickShapeNvprRenderer::setStrokeColor(int index, const QColor &color) -{ - ShapePathGuiData &d(m_sp[index]); - d.strokeColor = color; - d.dirty |= DirtyStyle; - m_accDirty |= DirtyStyle; -} - -void QQuickShapeNvprRenderer::setStrokeWidth(int index, qreal w) -{ - ShapePathGuiData &d(m_sp[index]); - d.strokeWidth = w; - d.dirty |= DirtyStyle; - m_accDirty |= DirtyStyle; -} - -void QQuickShapeNvprRenderer::setFillColor(int index, const QColor &color) -{ - ShapePathGuiData &d(m_sp[index]); - d.fillColor = color; - d.dirty |= DirtyStyle; - m_accDirty |= DirtyStyle; -} - -void QQuickShapeNvprRenderer::setFillRule(int index, QQuickShapePath::FillRule fillRule) -{ - ShapePathGuiData &d(m_sp[index]); - d.fillRule = fillRule; - d.dirty |= DirtyFillRule; - m_accDirty |= DirtyFillRule; -} - -void QQuickShapeNvprRenderer::setJoinStyle(int index, QQuickShapePath::JoinStyle joinStyle, int miterLimit) -{ - ShapePathGuiData &d(m_sp[index]); - d.joinStyle = joinStyle; - d.miterLimit = miterLimit; - d.dirty |= DirtyStyle; - m_accDirty |= DirtyStyle; -} - -void QQuickShapeNvprRenderer::setCapStyle(int index, QQuickShapePath::CapStyle capStyle) -{ - ShapePathGuiData &d(m_sp[index]); - d.capStyle = capStyle; - d.dirty |= DirtyStyle; - m_accDirty |= DirtyStyle; -} - -void QQuickShapeNvprRenderer::setStrokeStyle(int index, QQuickShapePath::StrokeStyle strokeStyle, - qreal dashOffset, const QVector<qreal> &dashPattern) -{ - ShapePathGuiData &d(m_sp[index]); - d.dashActive = strokeStyle == QQuickShapePath::DashLine; - d.dashOffset = dashOffset; - d.dashPattern = dashPattern; - d.dirty |= DirtyDash; - m_accDirty |= DirtyDash; -} - -void QQuickShapeNvprRenderer::setFillGradient(int index, QQuickShapeGradient *gradient) -{ - ShapePathGuiData &d(m_sp[index]); - if (gradient) { - d.fillGradient.stops = gradient->gradientStops(); // sorted - d.fillGradient.spread = gradient->spread(); - if (QQuickShapeLinearGradient *g = qobject_cast<QQuickShapeLinearGradient *>(gradient)) { - d.fillGradientActive = LinearGradient; - d.fillGradient.a = QPointF(g->x1(), g->y1()); - d.fillGradient.b = QPointF(g->x2(), g->y2()); - } else if (QQuickShapeRadialGradient *g = qobject_cast<QQuickShapeRadialGradient *>(gradient)) { - d.fillGradientActive = RadialGradient; - d.fillGradient.a = QPointF(g->centerX(), g->centerY()); - d.fillGradient.b = QPointF(g->focalX(), g->focalY()); - d.fillGradient.v0 = g->centerRadius(); - d.fillGradient.v1 = g->focalRadius(); - } else if (QQuickShapeConicalGradient *g = qobject_cast<QQuickShapeConicalGradient *>(gradient)) { - d.fillGradientActive = ConicalGradient; - d.fillGradient.a = QPointF(g->centerX(), g->centerY()); - d.fillGradient.v0 = g->angle(); - } else { - Q_UNREACHABLE(); - } - } else { - d.fillGradientActive = NoGradient; - } - d.dirty |= DirtyFillGradient; - m_accDirty |= DirtyFillGradient; -} - -void QQuickShapeNvprRenderer::endSync(bool) -{ -} - -void QQuickShapeNvprRenderer::setNode(QQuickShapeNvprRenderNode *node) -{ - if (m_node != node) { - m_node = node; - m_accDirty |= DirtyList; - } -} - -QDebug operator<<(QDebug debug, const QQuickShapeNvprRenderer::NvprPath &path) -{ - QDebugStateSaver saver(debug); - debug.space().noquote(); - if (!path.str.isEmpty()) { - debug << "Path with SVG string" << path.str; - return debug; - } - debug << "Path with" << path.cmd.count() << "commands"; - int ci = 0; - for (GLubyte cmd : path.cmd) { - static struct { GLubyte cmd; const char *s; int coordCount; } nameTabs[] = { - { GL_MOVE_TO_NV, "moveTo", 2 }, - { GL_LINE_TO_NV, "lineTo", 2 }, - { GL_QUADRATIC_CURVE_TO_NV, "quadTo", 4 }, - { GL_CUBIC_CURVE_TO_NV, "cubicTo", 6 }, - { GL_LARGE_CW_ARC_TO_NV, "arcTo-large-CW", 5 }, - { GL_LARGE_CCW_ARC_TO_NV, "arcTo-large-CCW", 5 }, - { GL_SMALL_CW_ARC_TO_NV, "arcTo-small-CW", 5 }, - { GL_SMALL_CCW_ARC_TO_NV, "arcTo-small-CCW", 5 }, - { GL_CLOSE_PATH_NV, "closePath", 0 } }; - for (const auto &nameTab : nameTabs) { - if (nameTab.cmd == cmd) { - QByteArray cs; - for (int j = 0; j < nameTab.coordCount; ++j) { - cs.append(QByteArray::number(path.coord[ci++])); - cs.append(' '); - } - debug << "\n " << nameTab.s << " " << cs; - break; - } - } - } - return debug; -} - -static inline void appendCoords(QVector<GLfloat> *v, QQuickCurve *c, QPointF *pos) -{ - QPointF p(c->hasRelativeX() ? pos->x() + c->relativeX() : c->x(), - c->hasRelativeY() ? pos->y() + c->relativeY() : c->y()); - v->append(p.x()); - v->append(p.y()); - *pos = p; -} - -static inline void appendControlCoords(QVector<GLfloat> *v, QQuickPathQuad *c, const QPointF &pos) -{ - QPointF p(c->hasRelativeControlX() ? pos.x() + c->relativeControlX() : c->controlX(), - c->hasRelativeControlY() ? pos.y() + c->relativeControlY() : c->controlY()); - v->append(p.x()); - v->append(p.y()); -} - -static inline void appendControl1Coords(QVector<GLfloat> *v, QQuickPathCubic *c, const QPointF &pos) -{ - QPointF p(c->hasRelativeControl1X() ? pos.x() + c->relativeControl1X() : c->control1X(), - c->hasRelativeControl1Y() ? pos.y() + c->relativeControl1Y() : c->control1Y()); - v->append(p.x()); - v->append(p.y()); -} - -static inline void appendControl2Coords(QVector<GLfloat> *v, QQuickPathCubic *c, const QPointF &pos) -{ - QPointF p(c->hasRelativeControl2X() ? pos.x() + c->relativeControl2X() : c->control2X(), - c->hasRelativeControl2Y() ? pos.y() + c->relativeControl2Y() : c->control2Y()); - v->append(p.x()); - v->append(p.y()); -} - -void QQuickShapeNvprRenderer::convertPath(const QQuickPath *path, ShapePathGuiData *d) -{ - d->path = NvprPath(); - if (!path) - return; - - const QList<QQuickPathElement *> &pp(QQuickPathPrivate::get(path)->_pathElements); - if (pp.isEmpty()) - return; - - QPointF startPos(path->startX(), path->startY()); - QPointF pos(startPos); - if (!qFuzzyIsNull(pos.x()) || !qFuzzyIsNull(pos.y())) { - d->path.cmd.append(GL_MOVE_TO_NV); - d->path.coord.append(pos.x()); - d->path.coord.append(pos.y()); - } - - for (QQuickPathElement *e : pp) { - if (QQuickPathMove *o = qobject_cast<QQuickPathMove *>(e)) { - d->path.cmd.append(GL_MOVE_TO_NV); - appendCoords(&d->path.coord, o, &pos); - startPos = pos; - } else if (QQuickPathLine *o = qobject_cast<QQuickPathLine *>(e)) { - d->path.cmd.append(GL_LINE_TO_NV); - appendCoords(&d->path.coord, o, &pos); - } else if (QQuickPathQuad *o = qobject_cast<QQuickPathQuad *>(e)) { - d->path.cmd.append(GL_QUADRATIC_CURVE_TO_NV); - appendControlCoords(&d->path.coord, o, pos); - appendCoords(&d->path.coord, o, &pos); - } else if (QQuickPathCubic *o = qobject_cast<QQuickPathCubic *>(e)) { - d->path.cmd.append(GL_CUBIC_CURVE_TO_NV); - appendControl1Coords(&d->path.coord, o, pos); - appendControl2Coords(&d->path.coord, o, pos); - appendCoords(&d->path.coord, o, &pos); - } else if (QQuickPathArc *o = qobject_cast<QQuickPathArc *>(e)) { - const bool sweepFlag = o->direction() == QQuickPathArc::Clockwise; // maps to CCW, not a typo - GLenum cmd; - if (o->useLargeArc()) - cmd = sweepFlag ? GL_LARGE_CCW_ARC_TO_NV : GL_LARGE_CW_ARC_TO_NV; - else - cmd = sweepFlag ? GL_SMALL_CCW_ARC_TO_NV : GL_SMALL_CW_ARC_TO_NV; - d->path.cmd.append(cmd); - d->path.coord.append(o->radiusX()); - d->path.coord.append(o->radiusY()); - d->path.coord.append(o->xAxisRotation()); - appendCoords(&d->path.coord, o, &pos); - } else if (QQuickPathSvg *o = qobject_cast<QQuickPathSvg *>(e)) { - // PathSvg cannot be combined with other elements. But take at - // least startX and startY into account. - if (d->path.str.isEmpty()) - d->path.str = QString(QStringLiteral("M %1 %2 ")).arg(pos.x()).arg(pos.y()).toUtf8(); - d->path.str.append(o->path().toUtf8()); - } else if (QQuickPathAngleArc *o = qobject_cast<QQuickPathAngleArc *>(e)) { - QRectF rect(o->centerX() - o->radiusX(), o->centerY() - o->radiusY(), o->radiusX() * 2, o->radiusY() * 2); - QPointF startPoint; - QPointF endPoint; - qt_find_ellipse_coords(rect, o->startAngle(), -o->sweepAngle(), &startPoint, &endPoint); - - // get to our starting position - if (o->moveToStart()) - d->path.cmd.append(GL_MOVE_TO_NV); - else - d->path.cmd.append(GL_LINE_TO_NV); // ### should we check if startPoint == pos? - d->path.coord.append(startPoint.x()); - d->path.coord.append(startPoint.y()); - - const bool sweepFlag = o->sweepAngle() > 0; // maps to CCW, not a typo - d->path.cmd.append(qAbs(o->sweepAngle()) > 180.0 - ? (sweepFlag ? GL_LARGE_CCW_ARC_TO_NV : GL_LARGE_CW_ARC_TO_NV) - : (sweepFlag ? GL_SMALL_CCW_ARC_TO_NV : GL_SMALL_CW_ARC_TO_NV)); - d->path.coord.append(o->radiusX()); - d->path.coord.append(o->radiusY()); - d->path.coord.append(0); // xAxisRotation - d->path.coord.append(endPoint.x()); - d->path.coord.append(endPoint.y()); - pos = endPoint; - } else { - qWarning() << "Shape/NVPR: unsupported Path element" << e; - } - } - - // For compatibility with QTriangulatingStroker. SVG and others would not - // implicitly close the path when end_pos == start_pos (start_pos being the - // last moveTo pos); that would still need an explicit 'z' or similar. We - // don't have an explicit close command, so just fake a close when the - // positions match. - if (pos == startPos) - d->path.cmd.append(GL_CLOSE_PATH_NV); -} - -static inline QVector4D qsg_premultiply(const QColor &c, float globalOpacity) -{ - const float o = c.alphaF() * globalOpacity; - return QVector4D(c.redF() * o, c.greenF() * o, c.blueF() * o, o); -} - -void QQuickShapeNvprRenderer::updateNode() -{ - // Called on the render thread with gui blocked -> update the node with its - // own copy of all relevant data. - - if (!m_accDirty) - return; - - const int count = m_sp.count(); - const bool listChanged = m_accDirty & DirtyList; - if (listChanged) - m_node->m_sp.resize(count); - - for (int i = 0; i < count; ++i) { - ShapePathGuiData &src(m_sp[i]); - QQuickShapeNvprRenderNode::ShapePathRenderData &dst(m_node->m_sp[i]); - - int dirty = src.dirty; - src.dirty = 0; - if (listChanged) - dirty |= DirtyPath | DirtyStyle | DirtyFillRule | DirtyDash | DirtyFillGradient; - - // updateNode() can be called several times with different dirty - // states before render() gets invoked. So accumulate. - dst.dirty |= dirty; - - if (dirty & DirtyPath) - dst.source = src.path; - - if (dirty & DirtyStyle) { - dst.strokeWidth = src.strokeWidth; - dst.strokeColor = qsg_premultiply(src.strokeColor, 1.0f); - dst.fillColor = qsg_premultiply(src.fillColor, 1.0f); - switch (src.joinStyle) { - case QQuickShapePath::MiterJoin: - dst.joinStyle = GL_MITER_TRUNCATE_NV; - break; - case QQuickShapePath::BevelJoin: - dst.joinStyle = GL_BEVEL_NV; - break; - case QQuickShapePath::RoundJoin: - dst.joinStyle = GL_ROUND_NV; - break; - default: - Q_UNREACHABLE(); - } - dst.miterLimit = src.miterLimit; - switch (src.capStyle) { - case QQuickShapePath::FlatCap: - dst.capStyle = GL_FLAT; - break; - case QQuickShapePath::SquareCap: - dst.capStyle = GL_SQUARE_NV; - break; - case QQuickShapePath::RoundCap: - dst.capStyle = GL_ROUND_NV; - break; - default: - Q_UNREACHABLE(); - } - } - - if (dirty & DirtyFillRule) { - switch (src.fillRule) { - case QQuickShapePath::OddEvenFill: - dst.fillRule = GL_INVERT; - break; - case QQuickShapePath::WindingFill: - dst.fillRule = GL_COUNT_UP_NV; - break; - default: - Q_UNREACHABLE(); - } - } - - if (dirty & DirtyDash) { - // Multiply by strokeWidth because the Shape API follows QPen - // meaning the input dash pattern and dash offset here are in width units. - dst.dashOffset = src.dashOffset * src.strokeWidth; - if (src.dashActive) { - if (src.dashPattern.isEmpty()) { - // default values for DashLine as defined in qpen.cpp - dst.dashPattern.resize(2); - dst.dashPattern[0] = 4 * src.strokeWidth; // dash - dst.dashPattern[1] = 2 * src.strokeWidth; // space - } else { - dst.dashPattern.resize(src.dashPattern.count()); - for (int i = 0; i < src.dashPattern.count(); ++i) - dst.dashPattern[i] = GLfloat(src.dashPattern[i]) * src.strokeWidth; - - // QPen expects a dash pattern of even length and so should we - if (src.dashPattern.count() % 2 != 0) { - qWarning("QQuickShapeNvprRenderNode: dash pattern not of even length"); - dst.dashPattern << src.strokeWidth; - } - } - } else { - dst.dashPattern.clear(); - } - } - - if (dirty & DirtyFillGradient) { - dst.fillGradientActive = src.fillGradientActive; - if (src.fillGradientActive) - dst.fillGradient = src.fillGradient; - } - } - - m_node->markDirty(QSGNode::DirtyMaterial); - m_accDirty = 0; -} - -bool QQuickShapeNvprRenderNode::nvprInited = false; -QQuickNvprFunctions QQuickShapeNvprRenderNode::nvpr; -QQuickNvprMaterialManager QQuickShapeNvprRenderNode::mtlmgr; - -QQuickShapeNvprRenderNode::~QQuickShapeNvprRenderNode() -{ - releaseResources(); -} - -void QQuickShapeNvprRenderNode::releaseResources() -{ - for (ShapePathRenderData &d : m_sp) { - if (d.path) { - nvpr.deletePaths(d.path, 1); - d.path = 0; - } - if (d.fallbackFbo) { - delete d.fallbackFbo; - d.fallbackFbo = nullptr; - } - } - - m_fallbackBlitter.destroy(); -} - -void QQuickNvprMaterialManager::create(QQuickNvprFunctions *nvpr) -{ - m_nvpr = nvpr; -} - -void QQuickNvprMaterialManager::releaseResources() -{ - QOpenGLExtraFunctions *f = QOpenGLContext::currentContext()->extraFunctions(); - for (MaterialDesc &mtl : m_materials) { - if (mtl.ppl) { - f->glDeleteProgramPipelines(1, &mtl.ppl); - mtl = MaterialDesc(); - } - } -} - -QQuickNvprMaterialManager::MaterialDesc *QQuickNvprMaterialManager::activateMaterial(Material m) -{ - QOpenGLExtraFunctions *f = QOpenGLContext::currentContext()->extraFunctions(); - MaterialDesc &mtl(m_materials[m]); - - if (!mtl.ppl) { - if (m == MatSolid) { - static const char *fragSrc = - "#version 310 es\n" - "precision highp float;\n" - "out vec4 fragColor;\n" - "uniform vec4 color;\n" - "uniform float opacity;\n" - "void main() {\n" - " fragColor = color * opacity;\n" - "}\n"; - if (!m_nvpr->createFragmentOnlyPipeline(fragSrc, &mtl.ppl, &mtl.prg)) { - qWarning("NVPR: Failed to create shader pipeline for solid fill"); - return nullptr; - } - Q_ASSERT(mtl.ppl && mtl.prg); - mtl.uniLoc[0] = f->glGetProgramResourceLocation(mtl.prg, GL_UNIFORM, "color"); - Q_ASSERT(mtl.uniLoc[0] >= 0); - mtl.uniLoc[1] = f->glGetProgramResourceLocation(mtl.prg, GL_UNIFORM, "opacity"); - Q_ASSERT(mtl.uniLoc[1] >= 0); - } else if (m == MatLinearGradient) { - static const char *fragSrc = - "#version 310 es\n" - "precision highp float;\n" - "layout(location = 0) in vec2 uv;" - "uniform float opacity;\n" - "uniform sampler2D gradTab;\n" - "uniform vec2 gradStart;\n" - "uniform vec2 gradEnd;\n" - "out vec4 fragColor;\n" - "void main() {\n" - " vec2 gradVec = gradEnd - gradStart;\n" - " float gradTabIndex = dot(gradVec, uv - gradStart) / (gradVec.x * gradVec.x + gradVec.y * gradVec.y);\n" - " fragColor = texture(gradTab, vec2(gradTabIndex, 0.5)) * opacity;\n" - "}\n"; - if (!m_nvpr->createFragmentOnlyPipeline(fragSrc, &mtl.ppl, &mtl.prg)) { - qWarning("NVPR: Failed to create shader pipeline for linear gradient"); - return nullptr; - } - Q_ASSERT(mtl.ppl && mtl.prg); - mtl.uniLoc[1] = f->glGetProgramResourceLocation(mtl.prg, GL_UNIFORM, "opacity"); - Q_ASSERT(mtl.uniLoc[1] >= 0); - mtl.uniLoc[2] = f->glGetProgramResourceLocation(mtl.prg, GL_UNIFORM, "gradStart"); - Q_ASSERT(mtl.uniLoc[2] >= 0); - mtl.uniLoc[3] = f->glGetProgramResourceLocation(mtl.prg, GL_UNIFORM, "gradEnd"); - Q_ASSERT(mtl.uniLoc[3] >= 0); - } else if (m == MatRadialGradient) { - static const char *fragSrc = - "#version 310 es\n" - "precision highp float;\n" - "uniform sampler2D gradTab;\n" - "uniform float opacity;\n" - "uniform vec2 focalToCenter;\n" - "uniform float centerRadius;\n" - "uniform float focalRadius;\n" - "uniform vec2 translationPoint;\n" - "layout(location = 0) in vec2 uv;\n" - "out vec4 fragColor;\n" - "void main() {\n" - " vec2 coord = uv - translationPoint;\n" - " float rd = centerRadius - focalRadius;\n" - " float b = 2.0 * (rd * focalRadius + dot(coord, focalToCenter));\n" - " float fmp2_m_radius2 = -focalToCenter.x * focalToCenter.x - focalToCenter.y * focalToCenter.y + rd * rd;\n" - " float inverse_2_fmp2_m_radius2 = 1.0 / (2.0 * fmp2_m_radius2);\n" - " float det = b * b - 4.0 * fmp2_m_radius2 * ((focalRadius * focalRadius) - dot(coord, coord));\n" - " vec4 result = vec4(0.0);\n" - " if (det >= 0.0) {\n" - " float detSqrt = sqrt(det);\n" - " float w = max((-b - detSqrt) * inverse_2_fmp2_m_radius2, (-b + detSqrt) * inverse_2_fmp2_m_radius2);\n" - " if (focalRadius + w * (centerRadius - focalRadius) >= 0.0)\n" - " result = texture(gradTab, vec2(w, 0.5)) * opacity;\n" - " }\n" - " fragColor = result;\n" - "}\n"; - if (!m_nvpr->createFragmentOnlyPipeline(fragSrc, &mtl.ppl, &mtl.prg)) { - qWarning("NVPR: Failed to create shader pipeline for radial gradient"); - return nullptr; - } - Q_ASSERT(mtl.ppl && mtl.prg); - mtl.uniLoc[1] = f->glGetProgramResourceLocation(mtl.prg, GL_UNIFORM, "opacity"); - Q_ASSERT(mtl.uniLoc[1] >= 0); - mtl.uniLoc[2] = f->glGetProgramResourceLocation(mtl.prg, GL_UNIFORM, "focalToCenter"); - Q_ASSERT(mtl.uniLoc[2] >= 0); - mtl.uniLoc[3] = f->glGetProgramResourceLocation(mtl.prg, GL_UNIFORM, "centerRadius"); - Q_ASSERT(mtl.uniLoc[3] >= 0); - mtl.uniLoc[4] = f->glGetProgramResourceLocation(mtl.prg, GL_UNIFORM, "focalRadius"); - Q_ASSERT(mtl.uniLoc[4] >= 0); - mtl.uniLoc[5] = f->glGetProgramResourceLocation(mtl.prg, GL_UNIFORM, "translationPoint"); - Q_ASSERT(mtl.uniLoc[5] >= 0); - } else if (m == MatConicalGradient) { - static const char *fragSrc = - "#version 310 es\n" - "precision highp float;\n" - "#define INVERSE_2PI 0.1591549430918953358\n" - "uniform sampler2D gradTab;\n" - "uniform float opacity;\n" - "uniform float angle;\n" - "uniform vec2 translationPoint;\n" - "layout(location = 0) in vec2 uv;\n" - "out vec4 fragColor;\n" - "void main() {\n" - " vec2 coord = uv - translationPoint;\n" - " float t;\n" - " if (abs(coord.y) == abs(coord.x))\n" - " t = (atan(-coord.y + 0.002, coord.x) + angle) * INVERSE_2PI;\n" - " else\n" - " t = (atan(-coord.y, coord.x) + angle) * INVERSE_2PI;\n" - " fragColor = texture(gradTab, vec2(t - floor(t), 0.5)) * opacity;\n" - "}\n"; - if (!m_nvpr->createFragmentOnlyPipeline(fragSrc, &mtl.ppl, &mtl.prg)) { - qWarning("NVPR: Failed to create shader pipeline for conical gradient"); - return nullptr; - } - Q_ASSERT(mtl.ppl && mtl.prg); - mtl.uniLoc[1] = f->glGetProgramResourceLocation(mtl.prg, GL_UNIFORM, "opacity"); - Q_ASSERT(mtl.uniLoc[1] >= 0); - mtl.uniLoc[2] = f->glGetProgramResourceLocation(mtl.prg, GL_UNIFORM, "angle"); - Q_ASSERT(mtl.uniLoc[2] >= 0); - mtl.uniLoc[3] = f->glGetProgramResourceLocation(mtl.prg, GL_UNIFORM, "translationPoint"); - Q_ASSERT(mtl.uniLoc[3] >= 0); - } else { - Q_UNREACHABLE(); - } - } - - f->glBindProgramPipeline(mtl.ppl); - - return &mtl; -} - -void QQuickShapeNvprRenderNode::updatePath(ShapePathRenderData *d) -{ - if (d->dirty & QQuickShapeNvprRenderer::DirtyPath) { - if (!d->path) { - d->path = nvpr.genPaths(1); - Q_ASSERT(d->path != 0); - } - if (d->source.str.isEmpty()) { - nvpr.pathCommands(d->path, d->source.cmd.count(), d->source.cmd.constData(), - d->source.coord.count(), GL_FLOAT, d->source.coord.constData()); - } else { - nvpr.pathString(d->path, GL_PATH_FORMAT_SVG_NV, d->source.str.count(), d->source.str.constData()); - } - } - - if (d->dirty & QQuickShapeNvprRenderer::DirtyStyle) { - nvpr.pathParameterf(d->path, GL_PATH_STROKE_WIDTH_NV, d->strokeWidth); - nvpr.pathParameteri(d->path, GL_PATH_JOIN_STYLE_NV, d->joinStyle); - nvpr.pathParameteri(d->path, GL_PATH_MITER_LIMIT_NV, d->miterLimit); - nvpr.pathParameteri(d->path, GL_PATH_END_CAPS_NV, d->capStyle); - nvpr.pathParameteri(d->path, GL_PATH_DASH_CAPS_NV, d->capStyle); - } - - if (d->dirty & QQuickShapeNvprRenderer::DirtyDash) { - nvpr.pathParameterf(d->path, GL_PATH_DASH_OFFSET_NV, d->dashOffset); - // count == 0 -> no dash - nvpr.pathDashArray(d->path, d->dashPattern.count(), d->dashPattern.constData()); - } - - if (d->dirty) - d->fallbackValid = false; -} - -void QQuickShapeNvprRenderNode::renderStroke(ShapePathRenderData *d, int strokeStencilValue, int writeMask) -{ - QQuickNvprMaterialManager::MaterialDesc *mtl = mtlmgr.activateMaterial(QQuickNvprMaterialManager::MatSolid); - f->glProgramUniform4f(mtl->prg, mtl->uniLoc[0], - d->strokeColor.x(), d->strokeColor.y(), d->strokeColor.z(), d->strokeColor.w()); - f->glProgramUniform1f(mtl->prg, mtl->uniLoc[1], inheritedOpacity()); - - nvpr.stencilThenCoverStrokePath(d->path, strokeStencilValue, writeMask, GL_CONVEX_HULL_NV); -} - -void QQuickShapeNvprRenderNode::renderFill(ShapePathRenderData *d) -{ - QQuickNvprMaterialManager::MaterialDesc *mtl = nullptr; - if (d->fillGradientActive) { - QQuickShapeGradient::SpreadMode spread = d->fillGradient.spread; - if (d->fillGradientActive == QQuickAbstractPathRenderer::LinearGradient) { - mtl = mtlmgr.activateMaterial(QQuickNvprMaterialManager::MatLinearGradient); - // uv = vec2(coeff[0] * x + coeff[1] * y + coeff[2], coeff[3] * x + coeff[4] * y + coeff[5]) - // where x and y are in path coordinate space, which is just what - // we need since the gradient's start and stop are in that space too. - GLfloat coeff[6] = { 1, 0, 0, - 0, 1, 0 }; - nvpr.programPathFragmentInputGen(mtl->prg, 0, GL_OBJECT_LINEAR_NV, 2, coeff); - f->glProgramUniform2f(mtl->prg, mtl->uniLoc[2], d->fillGradient.a.x(), d->fillGradient.a.y()); - f->glProgramUniform2f(mtl->prg, mtl->uniLoc[3], d->fillGradient.b.x(), d->fillGradient.b.y()); - } else if (d->fillGradientActive == QQuickAbstractPathRenderer::RadialGradient) { - mtl = mtlmgr.activateMaterial(QQuickNvprMaterialManager::MatRadialGradient); - // simply drive uv (location 0) with x and y, just like for the linear gradient - GLfloat coeff[6] = { 1, 0, 0, - 0, 1, 0 }; - nvpr.programPathFragmentInputGen(mtl->prg, 0, GL_OBJECT_LINEAR_NV, 2, coeff); - - const QPointF centerPoint = d->fillGradient.a; - const QPointF focalPoint = d->fillGradient.b; - const QPointF focalToCenter = centerPoint - focalPoint; - const GLfloat centerRadius = d->fillGradient.v0; - const GLfloat focalRadius = d->fillGradient.v1; - - f->glProgramUniform2f(mtl->prg, mtl->uniLoc[2], focalToCenter.x(), focalToCenter.y()); - f->glProgramUniform1f(mtl->prg, mtl->uniLoc[3], centerRadius); - f->glProgramUniform1f(mtl->prg, mtl->uniLoc[4], focalRadius); - f->glProgramUniform2f(mtl->prg, mtl->uniLoc[5], focalPoint.x(), focalPoint.y()); - } else if (d->fillGradientActive == QQuickAbstractPathRenderer::ConicalGradient) { - mtl = mtlmgr.activateMaterial(QQuickNvprMaterialManager::MatConicalGradient); - // same old - GLfloat coeff[6] = { 1, 0, 0, - 0, 1, 0 }; - nvpr.programPathFragmentInputGen(mtl->prg, 0, GL_OBJECT_LINEAR_NV, 2, coeff); - - const QPointF centerPoint = d->fillGradient.a; - const GLfloat angle = -qDegreesToRadians(d->fillGradient.v0); - - f->glProgramUniform1f(mtl->prg, mtl->uniLoc[2], angle); - f->glProgramUniform2f(mtl->prg, mtl->uniLoc[3], centerPoint.x(), centerPoint.y()); - - spread = QQuickShapeGradient::RepeatSpread; - } else { - Q_UNREACHABLE(); - } - const QQuickShapeGradientCacheKey cacheKey(d->fillGradient.stops, spread); - QSGTexture *tx = QQuickShapeGradientOpenGLCache::currentCache()->get(cacheKey); - tx->bind(); - } else { - mtl = mtlmgr.activateMaterial(QQuickNvprMaterialManager::MatSolid); - f->glProgramUniform4f(mtl->prg, mtl->uniLoc[0], - d->fillColor.x(), d->fillColor.y(), d->fillColor.z(), d->fillColor.w()); - } - f->glProgramUniform1f(mtl->prg, mtl->uniLoc[1], inheritedOpacity()); - - const int writeMask = 0xFF; - nvpr.stencilThenCoverFillPath(d->path, d->fillRule, writeMask, GL_BOUNDING_BOX_NV); -} - -void QQuickShapeNvprRenderNode::renderOffscreenFill(ShapePathRenderData *d) -{ - if (d->fallbackValid && d->fallbackFbo) - return; - - GLfloat bb[4]; - nvpr.getPathParameterfv(d->path, GL_PATH_STROKE_BOUNDING_BOX_NV, bb); - QSize sz = QSizeF(bb[2] - bb[0] + 1, bb[3] - bb[1] + 1).toSize(); - d->fallbackSize = QSize(qMax(32, sz.width()), qMax(32, sz.height())); - d->fallbackTopLeft = QPointF(bb[0], bb[1]); - - if (d->fallbackFbo && d->fallbackFbo->size() != d->fallbackSize) { - delete d->fallbackFbo; - d->fallbackFbo = nullptr; - } - if (!d->fallbackFbo) - d->fallbackFbo = new QOpenGLFramebufferObject(d->fallbackSize, QOpenGLFramebufferObject::CombinedDepthStencil); - if (!d->fallbackFbo->bind()) - return; - - GLint prevViewport[4]; - f->glGetIntegerv(GL_VIEWPORT, prevViewport); - - f->glViewport(0, 0, d->fallbackSize.width(), d->fallbackSize.height()); - f->glDisable(GL_DEPTH_TEST); - f->glClearColor(0, 0, 0, 0); - f->glClearStencil(0); - f->glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); - f->glStencilFunc(GL_NOTEQUAL, 0, 0xFF); - f->glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); - - QMatrix4x4 mv; - mv.translate(-d->fallbackTopLeft.x(), -d->fallbackTopLeft.y()); - nvpr.matrixLoadf(GL_PATH_MODELVIEW_NV, mv.constData()); - QMatrix4x4 proj; - proj.ortho(0, d->fallbackSize.width(), d->fallbackSize.height(), 0, 1, -1); - nvpr.matrixLoadf(GL_PATH_PROJECTION_NV, proj.constData()); - - renderFill(d); - - d->fallbackFbo->release(); - f->glEnable(GL_DEPTH_TEST); - f->glViewport(prevViewport[0], prevViewport[1], prevViewport[2], prevViewport[3]); - - d->fallbackValid = true; -} - -void QQuickShapeNvprRenderNode::setupStencilForCover(bool stencilClip, int sv) -{ - if (!stencilClip) { - // Assume stencil buffer is cleared to 0 for each frame. - // Within the frame dppass=GL_ZERO for glStencilOp ensures stencil is reset and so no need to clear. - f->glStencilFunc(GL_NOTEQUAL, 0, 0xFF); - f->glStencilOp(GL_KEEP, GL_KEEP, GL_ZERO); - } else { - f->glStencilFunc(GL_LESS, sv, 0xFF); // pass if (sv & 0xFF) < (stencil_value & 0xFF) - f->glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE); // dppass: replace with the original value (clip's stencil ref value) - } -} - -void QQuickShapeNvprRenderNode::render(const RenderState *state) -{ - f = QOpenGLContext::currentContext()->extraFunctions(); - - if (!nvprInited) { - if (!nvpr.create()) { - qWarning("NVPR init failed"); - return; - } - mtlmgr.create(&nvpr); - nvprInited = true; - } - - f->glUseProgram(0); - f->glStencilMask(~0); - f->glEnable(GL_STENCIL_TEST); - - const bool stencilClip = state->stencilEnabled(); - // when true, the stencil buffer already has a clip path with a ref value of sv - const int sv = state->stencilValue(); - const bool hasScissor = state->scissorEnabled(); - - if (hasScissor) { - // scissor rect is already set, just enable scissoring - f->glEnable(GL_SCISSOR_TEST); - } - - // Depth test against the opaque batches rendered before. - f->glEnable(GL_DEPTH_TEST); - f->glDepthFunc(GL_LESS); - nvpr.pathCoverDepthFunc(GL_LESS); - nvpr.pathStencilDepthOffset(-0.05f, -1); - - bool reloadMatrices = true; - - for (ShapePathRenderData &d : m_sp) { - updatePath(&d); - - const bool hasFill = d.hasFill(); - const bool hasStroke = d.hasStroke(); - - if (hasFill && stencilClip) { - // Fall back to a texture when complex clipping is in use and we have - // to fill. Reconciling glStencilFillPath's and the scenegraph's clip - // stencil semantics has not succeeded so far... - if (hasScissor) - f->glDisable(GL_SCISSOR_TEST); - renderOffscreenFill(&d); - reloadMatrices = true; - if (hasScissor) - f->glEnable(GL_SCISSOR_TEST); - } - - if (reloadMatrices) { - reloadMatrices = false; - nvpr.matrixLoadf(GL_PATH_MODELVIEW_NV, matrix()->constData()); - nvpr.matrixLoadf(GL_PATH_PROJECTION_NV, state->projectionMatrix()->constData()); - } - - // Fill! - if (hasFill) { - if (!stencilClip) { - setupStencilForCover(false, 0); - renderFill(&d); - } else { - if (!m_fallbackBlitter.isCreated()) - m_fallbackBlitter.create(); - f->glStencilFunc(GL_EQUAL, sv, 0xFF); - f->glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); - QMatrix4x4 mv = *matrix(); - mv.translate(d.fallbackTopLeft.x(), d.fallbackTopLeft.y()); - m_fallbackBlitter.texturedQuad(d.fallbackFbo->texture(), d.fallbackFbo->size(), - *state->projectionMatrix(), mv, - inheritedOpacity()); - } - } - - // Stroke! - if (hasStroke) { - const int strokeStencilValue = 0x80; - const int writeMask = 0x80; - - setupStencilForCover(stencilClip, sv); - if (stencilClip) { - // for the stencil step (eff. read mask == 0xFF & ~writeMask) - nvpr.pathStencilFunc(GL_EQUAL, sv, 0xFF); - // With stencilCLip == true the read mask for the stencil test before the stencil step is 0x7F. - // This assumes the clip stencil value is <= 127. - if (sv >= strokeStencilValue) - qWarning("Shape/NVPR: stencil clip ref value %d too large; expect rendering errors", sv); - } - - renderStroke(&d, strokeStencilValue, writeMask); - } - - if (stencilClip) - nvpr.pathStencilFunc(GL_ALWAYS, 0, ~0); - - d.dirty = 0; - } - - f->glBindProgramPipeline(0); -} - -QSGRenderNode::StateFlags QQuickShapeNvprRenderNode::changedStates() const -{ - return BlendState | StencilState | DepthState | ScissorState; -} - -QSGRenderNode::RenderingFlags QQuickShapeNvprRenderNode::flags() const -{ - return DepthAwareRendering; // avoid hitting the less optimal no-opaque-batch path in the renderer -} - -bool QQuickShapeNvprRenderNode::isSupported() -{ - static const bool nvprDisabled = qEnvironmentVariableIntValue("QT_NO_NVPR") != 0; - return !nvprDisabled && QQuickNvprFunctions::isSupported(); -} - -bool QQuickNvprBlitter::create() -{ - if (isCreated()) - destroy(); - - m_program = new QOpenGLShaderProgram; - if (QOpenGLContext::currentContext()->format().profile() == QSurfaceFormat::CoreProfile) { - m_program->addCacheableShaderFromSourceFile(QOpenGLShader::Vertex, QStringLiteral(":/qt-project.org/shapes/shaders/blit_core.vert")); - m_program->addCacheableShaderFromSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/qt-project.org/shapes/shaders/blit_core.frag")); - } else { - m_program->addCacheableShaderFromSourceFile(QOpenGLShader::Vertex, QStringLiteral(":/qt-project.org/shapes/shaders/blit.vert")); - m_program->addCacheableShaderFromSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/qt-project.org/shapes/shaders/blit.frag")); - } - m_program->bindAttributeLocation("qt_Vertex", 0); - m_program->bindAttributeLocation("qt_MultiTexCoord0", 1); - if (!m_program->link()) - return false; - - m_matrixLoc = m_program->uniformLocation("qt_Matrix"); - m_opacityLoc = m_program->uniformLocation("qt_Opacity"); - - m_buffer = new QOpenGLBuffer; - if (!m_buffer->create()) - return false; - m_buffer->bind(); - m_buffer->allocate(4 * sizeof(GLfloat) * 6); - m_buffer->release(); - - return true; -} - -void QQuickNvprBlitter::destroy() -{ - if (m_program) { - delete m_program; - m_program = nullptr; - } - if (m_buffer) { - delete m_buffer; - m_buffer = nullptr; - } -} - -void QQuickNvprBlitter::texturedQuad(GLuint textureId, const QSize &size, - const QMatrix4x4 &proj, const QMatrix4x4 &modelview, - float opacity) -{ - QOpenGLExtraFunctions *f = QOpenGLContext::currentContext()->extraFunctions(); - - m_program->bind(); - - QMatrix4x4 m = proj * modelview; - m_program->setUniformValue(m_matrixLoc, m); - m_program->setUniformValue(m_opacityLoc, opacity); - - m_buffer->bind(); - - if (size != m_prevSize) { - m_prevSize = size; - - QPointF p0(size.width() - 1, size.height() - 1); - QPointF p1(0, 0); - QPointF p2(0, size.height() - 1); - QPointF p3(size.width() - 1, 0); - - GLfloat vertices[6 * 4] = { - GLfloat(p0.x()), GLfloat(p0.y()), 1, 0, - GLfloat(p1.x()), GLfloat(p1.y()), 0, 1, - GLfloat(p2.x()), GLfloat(p2.y()), 0, 0, - - GLfloat(p0.x()), GLfloat(p0.y()), 1, 0, - GLfloat(p3.x()), GLfloat(p3.y()), 1, 1, - GLfloat(p1.x()), GLfloat(p1.y()), 0, 1, - }; - - m_buffer->write(0, vertices, sizeof(vertices)); - } - - m_program->enableAttributeArray(0); - m_program->enableAttributeArray(1); - f->glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(GLfloat), nullptr); - f->glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(GLfloat), (const void *) (2 * sizeof(GLfloat))); - - f->glBindTexture(GL_TEXTURE_2D, textureId); - - f->glDrawArrays(GL_TRIANGLES, 0, 6); - - f->glBindTexture(GL_TEXTURE_2D, 0); - m_buffer->release(); - m_program->release(); -} - -QT_END_NAMESPACE diff --git a/src/quickshapes/qquickshapenvprrenderer_p.h b/src/quickshapes/qquickshapenvprrenderer_p.h deleted file mode 100644 index d40eb1bce9..0000000000 --- a/src/quickshapes/qquickshapenvprrenderer_p.h +++ /dev/null @@ -1,238 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtQuick module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QQUICKSHAPENVPRRENDERER_P_H -#define QQUICKSHAPENVPRRENDERER_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of a number of Qt sources files. This header file may change from -// version to version without notice, or even be removed. -// -// We mean it. -// - -#include <QtQuickShapes/private/qquickshapesglobal_p.h> -#include <QtQuickShapes/private/qquickshape_p_p.h> -#include <QtQuickShapes/private/qquicknvprfunctions_p.h> -#include <qsgrendernode.h> -#include <QColor> -#include <QVector4D> -#include <QDebug> - -#if QT_CONFIG(opengl) - -QT_BEGIN_NAMESPACE - -class QQuickShapeNvprRenderNode; -class QOpenGLFramebufferObject; -class QOpenGLBuffer; -class QOpenGLExtraFunctions; - -class QQuickShapeNvprRenderer : public QQuickAbstractPathRenderer -{ -public: - enum Dirty { - DirtyPath = 0x01, - DirtyStyle = 0x02, - DirtyFillRule = 0x04, - DirtyDash = 0x08, - DirtyFillGradient = 0x10, - DirtyList = 0x20 - }; - - void beginSync(int totalCount) override; - void setPath(int index, const QQuickPath *path) override; - void setStrokeColor(int index, const QColor &color) override; - void setStrokeWidth(int index, qreal w) override; - void setFillColor(int index, const QColor &color) override; - void setFillRule(int index, QQuickShapePath::FillRule fillRule) override; - void setJoinStyle(int index, QQuickShapePath::JoinStyle joinStyle, int miterLimit) override; - void setCapStyle(int index, QQuickShapePath::CapStyle capStyle) override; - void setStrokeStyle(int index, QQuickShapePath::StrokeStyle strokeStyle, - qreal dashOffset, const QVector<qreal> &dashPattern) override; - void setFillGradient(int index, QQuickShapeGradient *gradient) override; - void endSync(bool async) override; - - void updateNode() override; - - void setNode(QQuickShapeNvprRenderNode *node); - - struct NvprPath { - QVector<GLubyte> cmd; - QVector<GLfloat> coord; - QByteArray str; - }; - -private: - struct ShapePathGuiData { - int dirty = 0; - NvprPath path; - qreal strokeWidth; - QColor strokeColor; - QColor fillColor; - QQuickShapePath::JoinStyle joinStyle; - int miterLimit; - QQuickShapePath::CapStyle capStyle; - QQuickShapePath::FillRule fillRule; - bool dashActive; - qreal dashOffset; - QVector<qreal> dashPattern; - FillGradientType fillGradientActive; - GradientDesc fillGradient; - }; - - void convertPath(const QQuickPath *path, ShapePathGuiData *d); - - QQuickShapeNvprRenderNode *m_node = nullptr; - int m_accDirty = 0; - - QVector<ShapePathGuiData> m_sp; -}; - -QDebug operator<<(QDebug debug, const QQuickShapeNvprRenderer::NvprPath &path); - -class QQuickNvprMaterialManager -{ -public: - enum Material { - MatSolid, - MatLinearGradient, - MatRadialGradient, - MatConicalGradient, - - NMaterials - }; - - struct MaterialDesc { - GLuint ppl = 0; - GLuint prg = 0; - int uniLoc[8]; - }; - - void create(QQuickNvprFunctions *nvpr); - MaterialDesc *activateMaterial(Material m); - void releaseResources(); - -private: - QQuickNvprFunctions *m_nvpr = nullptr; - MaterialDesc m_materials[NMaterials]; -}; - -class QQuickNvprBlitter -{ -public: - bool create(); - void destroy(); - bool isCreated() const { return m_program != nullptr; } - void texturedQuad(GLuint textureId, const QSize &size, - const QMatrix4x4 &proj, const QMatrix4x4 &modelview, - float opacity); - -private: - QOpenGLShaderProgram *m_program = nullptr; - QOpenGLBuffer *m_buffer = nullptr; - int m_matrixLoc = -1; - int m_opacityLoc = -1; - QSize m_prevSize; -}; - -class QQuickShapeNvprRenderNode : public QSGRenderNode -{ -public: - ~QQuickShapeNvprRenderNode(); - - void render(const RenderState *state) override; - void releaseResources() override; - StateFlags changedStates() const override; - RenderingFlags flags() const override; - - static bool isSupported(); - -private: - struct ShapePathRenderData { - GLuint path = 0; - int dirty = 0; - QQuickShapeNvprRenderer::NvprPath source; - GLfloat strokeWidth; - QVector4D strokeColor; - QVector4D fillColor; - GLenum joinStyle; - GLint miterLimit; - GLenum capStyle; - GLenum fillRule; - GLfloat dashOffset; - QVector<GLfloat> dashPattern; - QQuickAbstractPathRenderer::FillGradientType fillGradientActive; - QQuickAbstractPathRenderer::GradientDesc fillGradient; - QOpenGLFramebufferObject *fallbackFbo = nullptr; - bool fallbackValid = false; - QSize fallbackSize; - QPointF fallbackTopLeft; - - bool hasFill() const { return !qFuzzyIsNull(fillColor.w()) || fillGradientActive; } - bool hasStroke() const { return strokeWidth >= 0.0f && !qFuzzyIsNull(strokeColor.w()); } - }; - - void updatePath(ShapePathRenderData *d); - void renderStroke(ShapePathRenderData *d, int strokeStencilValue, int writeMask); - void renderFill(ShapePathRenderData *d); - void renderOffscreenFill(ShapePathRenderData *d); - void setupStencilForCover(bool stencilClip, int sv); - - static bool nvprInited; - static QQuickNvprFunctions nvpr; - static QQuickNvprMaterialManager mtlmgr; - - QQuickNvprBlitter m_fallbackBlitter; - QOpenGLExtraFunctions *f = nullptr; - - QVector<ShapePathRenderData> m_sp; - - friend class QQuickShapeNvprRenderer; -}; - -QT_END_NAMESPACE - -#endif // QT_CONFIG(opengl) - -#endif // QQUICKSHAPENVPRRENDERER_P_H diff --git a/src/quickshapes/qtquickshapes.qrc b/src/quickshapes/qtquickshapes.qrc index 1e3dcdef4e..2484d62d22 100644 --- a/src/quickshapes/qtquickshapes.qrc +++ b/src/quickshapes/qtquickshapes.qrc @@ -1,25 +1,9 @@ <RCC> <qresource prefix="/qt-project.org/shapes"> - <file>shaders/blit.vert</file> - <file>shaders/blit.frag</file> - <file>shaders/blit_core.frag</file> - <file>shaders/blit_core.vert</file> - <file>shaders/lineargradient.vert</file> - <file>shaders/lineargradient.frag</file> - <file>shaders/lineargradient_core.vert</file> - <file>shaders/lineargradient_core.frag</file> <file>shaders_ng/lineargradient.vert.qsb</file> <file>shaders_ng/lineargradient.frag.qsb</file> - <file>shaders/radialgradient.vert</file> - <file>shaders/radialgradient.frag</file> - <file>shaders/radialgradient_core.vert</file> - <file>shaders/radialgradient_core.frag</file> <file>shaders_ng/radialgradient.vert.qsb</file> <file>shaders_ng/radialgradient.frag.qsb</file> - <file>shaders/conicalgradient.vert</file> - <file>shaders/conicalgradient.frag</file> - <file>shaders/conicalgradient_core.vert</file> - <file>shaders/conicalgradient_core.frag</file> <file>shaders_ng/conicalgradient.vert.qsb</file> <file>shaders_ng/conicalgradient.frag.qsb</file> </qresource> diff --git a/src/quickshapes/quickshapes.pro b/src/quickshapes/quickshapes.pro index 7b77391d92..c53d267df6 100644 --- a/src/quickshapes/quickshapes.pro +++ b/src/quickshapes/quickshapes.pro @@ -17,17 +17,6 @@ SOURCES += \ qquickshapegenericrenderer.cpp \ qquickshapesoftwarerenderer.cpp -qtConfig(opengl) { - HEADERS += \ - qquicknvprfunctions_p.h \ - qquicknvprfunctions_p_p.h \ - qquickshapenvprrenderer_p.h - - SOURCES += \ - qquicknvprfunctions.cpp \ - qquickshapenvprrenderer.cpp -} - RESOURCES += qtquickshapes.qrc load(qt_module) diff --git a/src/quickshapes/shaders/blit.frag b/src/quickshapes/shaders/blit.frag deleted file mode 100644 index 505f0db179..0000000000 --- a/src/quickshapes/shaders/blit.frag +++ /dev/null @@ -1,9 +0,0 @@ -varying highp vec2 qt_TexCoord0; - -uniform sampler2D source; -uniform lowp float qt_Opacity; - -void main() -{ - gl_FragColor = texture2D(source, qt_TexCoord0) * qt_Opacity; -} diff --git a/src/quickshapes/shaders/blit.vert b/src/quickshapes/shaders/blit.vert deleted file mode 100644 index f8306bd945..0000000000 --- a/src/quickshapes/shaders/blit.vert +++ /dev/null @@ -1,12 +0,0 @@ -uniform highp mat4 qt_Matrix; - -attribute highp vec4 qt_Vertex; -attribute highp vec2 qt_MultiTexCoord0; - -varying highp vec2 qt_TexCoord0; - -void main() -{ - qt_TexCoord0 = qt_MultiTexCoord0; - gl_Position = qt_Matrix * qt_Vertex; -} diff --git a/src/quickshapes/shaders/blit_core.frag b/src/quickshapes/shaders/blit_core.frag deleted file mode 100644 index 7073808fba..0000000000 --- a/src/quickshapes/shaders/blit_core.frag +++ /dev/null @@ -1,13 +0,0 @@ -#version 150 core - -in vec2 qt_TexCoord0; - -out vec4 fragColor; - -uniform sampler2D source; -uniform float qt_Opacity; - -void main() -{ - fragColor = texture(source, qt_TexCoord0) * qt_Opacity; -} diff --git a/src/quickshapes/shaders/blit_core.vert b/src/quickshapes/shaders/blit_core.vert deleted file mode 100644 index 5246441da3..0000000000 --- a/src/quickshapes/shaders/blit_core.vert +++ /dev/null @@ -1,14 +0,0 @@ -#version 150 core - -in vec4 qt_Vertex; -in vec2 qt_MultiTexCoord0; - -out vec2 qt_TexCoord0; - -uniform mat4 qt_Matrix; - -void main() -{ - qt_TexCoord0 = qt_MultiTexCoord0; - gl_Position = qt_Matrix * qt_Vertex; -} diff --git a/src/quickshapes/shaders/conicalgradient.frag b/src/quickshapes/shaders/conicalgradient.frag deleted file mode 100644 index af5fdd5ee0..0000000000 --- a/src/quickshapes/shaders/conicalgradient.frag +++ /dev/null @@ -1,19 +0,0 @@ -#define INVERSE_2PI 0.1591549430918953358 - -uniform sampler2D gradTabTexture; -uniform lowp float opacity; - -uniform highp float angle; - -varying highp vec2 coord; - -void main() -{ - highp float t; - if (abs(coord.y) == abs(coord.x)) - t = (atan(-coord.y + 0.002, coord.x) + angle) * INVERSE_2PI; - else - t = (atan(-coord.y, coord.x) + angle) * INVERSE_2PI; - gl_FragColor = texture2D(gradTabTexture, vec2(t - floor(t), 0.5)) * opacity; - -} diff --git a/src/quickshapes/shaders/conicalgradient.vert b/src/quickshapes/shaders/conicalgradient.vert deleted file mode 100644 index 3350b0675a..0000000000 --- a/src/quickshapes/shaders/conicalgradient.vert +++ /dev/null @@ -1,13 +0,0 @@ -attribute vec4 vertexCoord; -attribute vec4 vertexColor; - -uniform mat4 matrix; -uniform vec2 translationPoint; - -varying vec2 coord; - -void main() -{ - coord = vertexCoord.xy - translationPoint; - gl_Position = matrix * vertexCoord; -} diff --git a/src/quickshapes/shaders/conicalgradient_core.frag b/src/quickshapes/shaders/conicalgradient_core.frag deleted file mode 100644 index e18b80159a..0000000000 --- a/src/quickshapes/shaders/conicalgradient_core.frag +++ /dev/null @@ -1,22 +0,0 @@ -#version 150 core - -#define INVERSE_2PI 0.1591549430918953358 - -uniform sampler2D gradTabTexture; -uniform float opacity; - -uniform float angle; - -in vec2 coord; - -out vec4 fragColor; - -void main() -{ - float t; - if (abs(coord.y) == abs(coord.x)) - t = (atan(-coord.y + 0.002, coord.x) + angle) * INVERSE_2PI; - else - t = (atan(-coord.y, coord.x) + angle) * INVERSE_2PI; - fragColor = texture(gradTabTexture, vec2(t - floor(t), 0.5)) * opacity; -} diff --git a/src/quickshapes/shaders/conicalgradient_core.vert b/src/quickshapes/shaders/conicalgradient_core.vert deleted file mode 100644 index f94a56401b..0000000000 --- a/src/quickshapes/shaders/conicalgradient_core.vert +++ /dev/null @@ -1,15 +0,0 @@ -#version 150 core - -in vec4 vertexCoord; -in vec4 vertexColor; - -uniform mat4 matrix; -uniform vec2 translationPoint; - -out vec2 coord; - -void main() -{ - coord = vertexCoord.xy - translationPoint; - gl_Position = matrix * vertexCoord; -} diff --git a/src/quickshapes/shaders/lineargradient.frag b/src/quickshapes/shaders/lineargradient.frag deleted file mode 100644 index 7f4a739109..0000000000 --- a/src/quickshapes/shaders/lineargradient.frag +++ /dev/null @@ -1,9 +0,0 @@ -uniform sampler2D gradTabTexture; -uniform highp float opacity; - -varying highp float gradTabIndex; - -void main() -{ - gl_FragColor = texture2D(gradTabTexture, vec2(gradTabIndex, 0.5)) * opacity; -} diff --git a/src/quickshapes/shaders/lineargradient.vert b/src/quickshapes/shaders/lineargradient.vert deleted file mode 100644 index eb21b8886b..0000000000 --- a/src/quickshapes/shaders/lineargradient.vert +++ /dev/null @@ -1,15 +0,0 @@ -attribute vec4 vertexCoord; -attribute vec4 vertexColor; - -uniform mat4 matrix; -uniform vec2 gradStart; -uniform vec2 gradEnd; - -varying float gradTabIndex; - -void main() -{ - vec2 gradVec = gradEnd - gradStart; - gradTabIndex = dot(gradVec, vertexCoord.xy - gradStart) / (gradVec.x * gradVec.x + gradVec.y * gradVec.y); - gl_Position = matrix * vertexCoord; -} diff --git a/src/quickshapes/shaders/lineargradient_core.frag b/src/quickshapes/shaders/lineargradient_core.frag deleted file mode 100644 index 5908acfa67..0000000000 --- a/src/quickshapes/shaders/lineargradient_core.frag +++ /dev/null @@ -1,12 +0,0 @@ -#version 150 core - -uniform sampler2D gradTabTexture; -uniform float opacity; - -in float gradTabIndex; -out vec4 fragColor; - -void main() -{ - fragColor = texture(gradTabTexture, vec2(gradTabIndex, 0.5)) * opacity; -} diff --git a/src/quickshapes/shaders/lineargradient_core.vert b/src/quickshapes/shaders/lineargradient_core.vert deleted file mode 100644 index 60b56f38e3..0000000000 --- a/src/quickshapes/shaders/lineargradient_core.vert +++ /dev/null @@ -1,17 +0,0 @@ -#version 150 core - -in vec4 vertexCoord; -in vec4 vertexColor; - -uniform mat4 matrix; -uniform vec2 gradStart; -uniform vec2 gradEnd; - -out float gradTabIndex; - -void main() -{ - vec2 gradVec = gradEnd - gradStart; - gradTabIndex = dot(gradVec, vertexCoord.xy - gradStart) / (gradVec.x * gradVec.x + gradVec.y * gradVec.y); - gl_Position = matrix * vertexCoord; -} diff --git a/src/quickshapes/shaders/radialgradient.frag b/src/quickshapes/shaders/radialgradient.frag deleted file mode 100644 index 0f503bc0f7..0000000000 --- a/src/quickshapes/shaders/radialgradient.frag +++ /dev/null @@ -1,25 +0,0 @@ -uniform sampler2D gradTabTexture; -uniform lowp float opacity; - -uniform highp vec2 focalToCenter; -uniform highp float centerRadius; -uniform highp float focalRadius; - -varying highp vec2 coord; - -void main() -{ - highp float rd = centerRadius - focalRadius; - highp float b = 2.0 * (rd * focalRadius + dot(coord, focalToCenter)); - highp float fmp2_m_radius2 = -focalToCenter.x * focalToCenter.x - focalToCenter.y * focalToCenter.y + rd * rd; - highp float inverse_2_fmp2_m_radius2 = 1.0 / (2.0 * fmp2_m_radius2); - highp float det = b * b - 4.0 * fmp2_m_radius2 * ((focalRadius * focalRadius) - dot(coord, coord)); - lowp vec4 result = vec4(0.0); - if (det >= 0.0) { - highp float detSqrt = sqrt(det); - highp float w = max((-b - detSqrt) * inverse_2_fmp2_m_radius2, (-b + detSqrt) * inverse_2_fmp2_m_radius2); - if (focalRadius + w * (centerRadius - focalRadius) >= 0.0) - result = texture2D(gradTabTexture, vec2(w, 0.5)) * opacity; - } - gl_FragColor = result; -} diff --git a/src/quickshapes/shaders/radialgradient.vert b/src/quickshapes/shaders/radialgradient.vert deleted file mode 100644 index 3350b0675a..0000000000 --- a/src/quickshapes/shaders/radialgradient.vert +++ /dev/null @@ -1,13 +0,0 @@ -attribute vec4 vertexCoord; -attribute vec4 vertexColor; - -uniform mat4 matrix; -uniform vec2 translationPoint; - -varying vec2 coord; - -void main() -{ - coord = vertexCoord.xy - translationPoint; - gl_Position = matrix * vertexCoord; -} diff --git a/src/quickshapes/shaders/radialgradient_core.frag b/src/quickshapes/shaders/radialgradient_core.frag deleted file mode 100644 index 706ce53e4d..0000000000 --- a/src/quickshapes/shaders/radialgradient_core.frag +++ /dev/null @@ -1,29 +0,0 @@ -#version 150 core - -uniform sampler2D gradTabTexture; -uniform float opacity; - -uniform vec2 focalToCenter; -uniform float centerRadius; -uniform float focalRadius; - -in vec2 coord; - -out vec4 fragColor; - -void main() -{ - float rd = centerRadius - focalRadius; - float b = 2.0 * (rd * focalRadius + dot(coord, focalToCenter)); - float fmp2_m_radius2 = -focalToCenter.x * focalToCenter.x - focalToCenter.y * focalToCenter.y + rd * rd; - float inverse_2_fmp2_m_radius2 = 1.0 / (2.0 * fmp2_m_radius2); - float det = b * b - 4.0 * fmp2_m_radius2 * ((focalRadius * focalRadius) - dot(coord, coord)); - vec4 result = vec4(0.0); - if (det >= 0.0) { - float detSqrt = sqrt(det); - float w = max((-b - detSqrt) * inverse_2_fmp2_m_radius2, (-b + detSqrt) * inverse_2_fmp2_m_radius2); - if (focalRadius + w * (centerRadius - focalRadius) >= 0.0) - result = texture(gradTabTexture, vec2(w, 0.5)) * opacity; - } - fragColor = result; -} diff --git a/src/quickshapes/shaders/radialgradient_core.vert b/src/quickshapes/shaders/radialgradient_core.vert deleted file mode 100644 index f94a56401b..0000000000 --- a/src/quickshapes/shaders/radialgradient_core.vert +++ /dev/null @@ -1,15 +0,0 @@ -#version 150 core - -in vec4 vertexCoord; -in vec4 vertexColor; - -uniform mat4 matrix; -uniform vec2 translationPoint; - -out vec2 coord; - -void main() -{ - coord = vertexCoord.xy - translationPoint; - gl_Position = matrix * vertexCoord; -} |