1// qsgmaterial.sip generated by MetaSIP 2// 3// This file is part of the QtQuick Python extension module. 4// 5// Copyright (c) 2021 Riverbank Computing Limited <info@riverbankcomputing.com> 6// 7// This file is part of PyQt5. 8// 9// This file may be used under the terms of the GNU General Public License 10// version 3.0 as published by the Free Software Foundation and appearing in 11// the file LICENSE included in the packaging of this file. Please review the 12// following information to ensure the GNU General Public License version 3.0 13// requirements will be met: http://www.gnu.org/copyleft/gpl.html. 14// 15// If you do not wish to use this file under the terms of the GPL version 3.0 16// then you may purchase a commercial license. For more information contact 17// info@riverbankcomputing.com. 18// 19// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 20// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 21 22 23class QSGMaterialShader /Supertype=sip.wrapper/ 24{ 25%TypeHeaderCode 26#include <qsgmaterial.h> 27%End 28 29public: 30 class RenderState 31 { 32%TypeHeaderCode 33#include <qsgmaterial.h> 34%End 35 36 public: 37 enum DirtyState 38 { 39 DirtyMatrix, 40 DirtyOpacity, 41%If (Qt_5_8_0 -) 42 DirtyCachedMaterialData, 43%End 44%If (Qt_5_8_0 -) 45 DirtyAll, 46%End 47 }; 48 49 typedef QFlags<QSGMaterialShader::RenderState::DirtyState> DirtyStates; 50 QSGMaterialShader::RenderState::DirtyStates dirtyStates() const; 51 bool isMatrixDirty() const; 52 bool isOpacityDirty() const; 53 float opacity() const; 54 QMatrix4x4 combinedMatrix() const; 55 QMatrix4x4 modelViewMatrix() const; 56 QRect viewportRect() const; 57 QRect deviceRect() const; 58 float determinant() const; 59%If (PyQt_OpenGL) 60 QOpenGLContext *context() const; 61%End 62%If (Qt_5_1_0 -) 63 QMatrix4x4 projectionMatrix() const; 64%End 65%If (Qt_5_1_0 -) 66 float devicePixelRatio() const; 67%End 68%If (Qt_5_8_0 -) 69 bool isCachedMaterialDataDirty() const; 70%End 71 }; 72 73 QSGMaterialShader(); 74 virtual ~QSGMaterialShader(); 75 virtual void activate(); 76 virtual void deactivate(); 77 virtual void updateState(const QSGMaterialShader::RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial); 78 virtual SIP_PYOBJECT attributeNames() const = 0 /TypeHint="List[str]"/ [const char * const * ()]; 79%MethodCode 80 const char * const *names = sipCpp->attributeNames(); 81 82 Py_ssize_t nr_names = 0; 83 84 if (names) 85 while (names[nr_names]) 86 ++nr_names; 87 88 sipRes = PyList_New(nr_names); 89 90 if (!sipRes) 91 sipIsErr = 1; 92 else 93 for (Py_ssize_t i = 0; i < nr_names; ++i) 94 { 95 const char *name = names[i]; 96 PyObject *el; 97 98 #if PY_MAJOR_VERSION >= 3 99 el = PyUnicode_DecodeASCII(name, strlen(name), 0); 100 #else 101 el = PyString_FromString(name); 102 #endif 103 104 if (!el) 105 { 106 Py_DECREF(sipRes); 107 sipIsErr = 1; 108 break; 109 } 110 111 PyList_SetItem(sipRes, i, el); 112 } 113%End 114 115%VirtualCatcherCode 116 PyObject *names = sipCallMethod(&sipIsErr, sipMethod, ""); 117 118 if (names) 119 { 120 sipRes = qtquick_anc_get_attr_names(sipPySelf, sipMethod, names); 121 122 if (!sipRes) 123 sipIsErr = 1; 124 125 Py_DECREF(names); 126 } 127%End 128 129%If (PyQt_OpenGL) 130 QOpenGLShaderProgram *program(); 131%End 132 133protected: 134%If (PyQt_OpenGL) 135 virtual void compile(); 136%End 137 virtual void initialize(); 138%If (Qt_5_2_0 -) 139%If (PyQt_OpenGL) 140 virtual const char *vertexShader() const; 141%End 142%End 143%If (- Qt_5_2_0) 144%If (PyQt_OpenGL) 145 virtual const char *vertexShader() const = 0; 146%End 147%End 148%If (Qt_5_2_0 -) 149%If (PyQt_OpenGL) 150 virtual const char *fragmentShader() const; 151%End 152%End 153%If (- Qt_5_2_0) 154%If (PyQt_OpenGL) 155 virtual const char *fragmentShader() const = 0; 156%End 157%End 158%If (Qt_5_2_0 -) 159%If (PyQt_OpenGL) 160 void setShaderSourceFile(QOpenGLShader::ShaderType type, const QString &sourceFile); 161%End 162%End 163%If (Qt_5_2_0 -) 164%If (PyQt_OpenGL) 165 void setShaderSourceFiles(QOpenGLShader::ShaderType type, const QStringList &sourceFiles); 166%End 167%End 168 169private: 170 QSGMaterialShader(const QSGMaterialShader &); 171}; 172 173struct QSGMaterialType 174{ 175%TypeHeaderCode 176#include <qsgmaterial.h> 177%End 178}; 179 180class QSGMaterial /Supertype=sip.wrapper/ 181{ 182%TypeHeaderCode 183#include <qsgmaterial.h> 184%End 185 186public: 187 enum Flag 188 { 189 Blending, 190 RequiresDeterminant, 191 RequiresFullMatrixExceptTranslate, 192 RequiresFullMatrix, 193%If (Qt_5_2_0 -) 194 CustomCompileStep, 195%End 196%If (Qt_5_14_0 -) 197 SupportsRhiShader, 198%End 199%If (Qt_5_14_0 -) 200 RhiShaderWanted, 201%End 202 }; 203 204 typedef QFlags<QSGMaterial::Flag> Flags; 205 QSGMaterial(); 206 virtual ~QSGMaterial(); 207 virtual QSGMaterialType *type() const = 0; 208 virtual QSGMaterialShader *createShader() const = 0 /Factory/; 209 virtual int compare(const QSGMaterial *other) const; 210 QSGMaterial::Flags flags() const; 211 void setFlag(QSGMaterial::Flags flags, bool enabled = true); 212 213private: 214 QSGMaterial(const QSGMaterial &); 215}; 216 217QFlags<QSGMaterial::Flag> operator|(QSGMaterial::Flag f1, QFlags<QSGMaterial::Flag> f2); 218QFlags<QSGMaterialShader::RenderState::DirtyState> operator|(QSGMaterialShader::RenderState::DirtyState f1, QFlags<QSGMaterialShader::RenderState::DirtyState> f2); 219 220%ModuleCode 221// Release any attribute names to the heap. 222static void qtquick_anc_release(char **attr_names) 223{ 224 if (attr_names) 225 { 226 for (int i = 0; attr_names[i]; ++i) 227 delete[] attr_names[i]; 228 229 delete[] attr_names; 230 } 231} 232 233 234// The destructor for the attribute names PyCapsule. 235static void qtquick_anc_destructor(PyObject *cap) 236{ 237 qtquick_anc_release( 238 reinterpret_cast<char **>(PyCapsule_GetPointer(cap, NULL))); 239} 240 241 242// Get the attribute names or 0 if there was an error. 243static char **qtquick_anc_get_attr_names(sipSimpleWrapper *pySelf, PyObject *method, PyObject *attr_names_obj) 244{ 245 // Dispose of any existing names. 246 Py_XDECREF(sipGetUserObject(pySelf)); 247 sipSetUserObject(pySelf, NULL); 248 249 // Convert the new names. 250 if (!PyList_Check(attr_names_obj)) 251 { 252 sipBadCatcherResult(method); 253 return 0; 254 } 255 256 char **names = new char *[PyList_Size(attr_names_obj) + 1]; 257 258 for (Py_ssize_t i = 0; i < PyList_Size(attr_names_obj); ++i) 259 { 260 char *name; 261 PyObject *el = PyList_GetItem(attr_names_obj, i); 262 263#if PY_MAJOR_VERSION >= 3 264 PyObject *name_obj = PyUnicode_AsASCIIString(el); 265 266 name = (name_obj ? PyBytes_AsString(name_obj) : 0); 267#else 268 name = PyString_AsString(el); 269#endif 270 271 if (!name) 272 { 273 names[i] = 0; 274 qtquick_anc_release(names); 275 276 sipBadCatcherResult(method); 277 return 0; 278 } 279 280 char *name_copy = new char[strlen(name) + 1]; 281 strcpy(name_copy, name); 282 names[i] = name_copy; 283 284#if PY_MAJOR_VERSION >= 3 285 Py_DECREF(name_obj); 286#endif 287 } 288 289 names[PyList_Size(attr_names_obj)] = 0; 290 291 sipSetUserObject(pySelf, PyCapsule_New(names, NULL, qtquick_anc_destructor)); 292 293 if (!sipGetUserObject(pySelf)) 294 { 295 qtquick_anc_release(names); 296 return 0; 297 } 298 299 return names; 300} 301%End 302