QSGNode *CustomItem::updatePaintNode(QSGNode *node, QQuickItem::UpdatePaintNodeData *updateData) { Q_UNUSED(updateData); QSGSimpleTextureNode *textureNode = static_cast<QSGSimpleTextureNode *>(node); if (!textureNode) { textureNode = new QSGSimpleTextureNode(); QImage image(":/images/lady.png"); m_texture = window()->createTextureFromImage(image); textureNode->setTexture(m_texture);} textureNode->setRect(0, 0, width(), height()); textureNode->setFiltering(QSGTexture::Linear); return textureNode; }
static PyObject *meth_QSGSimpleTextureNode_setFiltering(PyObject *sipSelf, PyObject *sipArgs) { PyObject *sipParseErr = NULL; { QSGTexture::Filtering a0; QSGSimpleTextureNode *sipCpp; if (sipParseArgs(&sipParseErr, sipArgs, "BE", &sipSelf, sipType_QSGSimpleTextureNode, &sipCpp, sipType_QSGTexture_Filtering, &a0)) { sipCpp->setFiltering(a0); Py_INCREF(Py_None); return Py_None; } } /* Raise an exception if the arguments couldn't be parsed. */ sipNoMethod(sipParseErr, sipName_QSGSimpleTextureNode, sipName_setFiltering, doc_QSGSimpleTextureNode_setFiltering); return NULL; }
QSGNode *Renderer::paintNode(const QRectF& viewport) const { if (m_tiles.isEmpty()) { return 0; } QSGNode *parentNode = new QSGNode; for (const Tile& tile : m_tiles) { if (tile.visible) { QRectF rect = m_view->tileRect(tile); QSGSimpleTextureNode *node = new SimpleTextureNode; node->setFlag(QSGNode::OwnedByParent, true); node->setTexture(m_view->window()->createTextureFromImage(tile.image)); node->setRect(rect); node->setFiltering(QSGTexture::Nearest); // node->setOwnsTexture(true); // TODO: Qt 5.4 qreal dx1 = rect.left() < viewport.left() ? viewport.left() - rect.left() : 0.0f; qreal dy1 = 0.0f; qreal dx2 = rect.right() > viewport.right() ? viewport.right() - rect.right() : 0.0f; qreal dy2 = rect.bottom() > viewport.bottom() ? viewport.bottom() - rect.bottom() : 0.0f; if (dx1 != 0.0f || dx2 != 0.0f || dy2 != 0.0f) { QSGClipNode *clip = new QSGClipNode; clip->setIsRectangular(true); clip->setClipRect(rect.adjusted(dx1, dy1, dx2, dy2)); parentNode->appendChildNode(clip); clip->appendChildNode(node); // qDebug() << "Clipping"; } else { parentNode->appendChildNode(node); } } } return parentNode; }
QSGNode* QuickSubtitleItem::updatePaintNode(QSGNode *node, UpdatePaintNodeData *data) { Q_UNUSED(data); if (m_w_sub == 0 || m_h_sub == 0) { return node; } QSGSimpleTextureNode *stn = static_cast<QSGSimpleTextureNode*>(node); if (!node) { node = new QSGSimpleTextureNode(); stn = static_cast<QSGSimpleTextureNode*>(node); stn->setFiltering(QSGTexture::Linear); } stn->setRect(mapSubRect(m_rect, m_w_sub, m_h_sub)); if (m_texture) delete m_texture; { QMutexLocker lock(&m_mutex); Q_UNUSED(lock); m_texture = window()->createTextureFromImage(m_image); } stn->setTexture(m_texture); node->markDirty(QSGNode::DirtyGeometry); return node; }