From b2259e94e953bb982bd65439c90a25717c9ca562 2016-03-17 15:04:44 From: Frederik Gladhorn Date: 2016-03-17 15:04:44 Subject: [PATCH] Merge remote-tracking branch 'origin/5.6.0' into 5.6 Change-Id: I69de781a63b4492ed7802e1d60b319d56a7bdd01 --- diff --git a/src/chartsqml2/declarativechart.cpp b/src/chartsqml2/declarativechart.cpp index ab0a612..abff683 100644 --- a/src/chartsqml2/declarativechart.cpp +++ b/src/chartsqml2/declarativechart.cpp @@ -512,14 +512,16 @@ QSGNode *DeclarativeChart::updatePaintNode(QSGNode *oldNode, QQuickItem::UpdateP if (!node) { node = new DeclarativeChartNode(window()); - connect(window(), &QQuickWindow::beforeRendering, - node->glRenderNode(), &DeclarativeRenderNode::render); + if (node->glRenderNode()) { + connect(window(), &QQuickWindow::beforeRendering, + node->glRenderNode(), &DeclarativeRenderNode::render); + } } const QRectF &bRect = boundingRect(); // Update GL data - if (m_glXYDataManager->dataMap().size() || m_glXYDataManager->mapDirty()) { + if (node->glRenderNode() && (m_glXYDataManager->dataMap().size() || m_glXYDataManager->mapDirty())) { const QRectF &plotArea = m_chart->plotArea(); const QSizeF &chartAreaSize = m_chart->size(); diff --git a/src/chartsqml2/declarativechartnode.cpp b/src/chartsqml2/declarativechartnode.cpp index 7b89c03..7d423b2 100644 --- a/src/chartsqml2/declarativechartnode.cpp +++ b/src/chartsqml2/declarativechartnode.cpp @@ -39,27 +39,27 @@ DeclarativeChartNode::DeclarativeChartNode(QQuickWindow *window) : m_textureSize(1, 1), m_glRenderNode(0) { - initializeOpenGLFunctions(); - // Our texture node must have a texture, so use a default one pixel texture - GLuint defaultTexture = 0; - glGenTextures(1, &defaultTexture); - glBindTexture(GL_TEXTURE_2D, defaultTexture); - uchar buf[4] = { 0, 0, 0, 0 }; - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, &buf); - + QImage dummyImage(QSize(1, 1), QImage::Format_ARGB32); + uchar *imageData = dummyImage.bits(); + imageData[0] = 0; + imageData[1] = 0; + imageData[2] = 0; + imageData[3] = 0; QQuickWindow::CreateTextureOptions defaultTextureOptions = QQuickWindow::CreateTextureOptions( QQuickWindow::TextureHasAlphaChannel | QQuickWindow::TextureOwnsGLTexture); - m_texture = m_window->createTextureFromId(defaultTexture, QSize(1, 1), defaultTextureOptions); + m_texture = m_window->createTextureFromImage(dummyImage, defaultTextureOptions); setTexture(m_texture); setFiltering(QSGTexture::Linear); - // Create child node for rendering GL graphics - m_glRenderNode = new DeclarativeRenderNode(m_window); - m_glRenderNode->setFlag(OwnedByParent); - appendChildNode(m_glRenderNode); - m_glRenderNode->setRect(0, 0, 0, 0); // Hide child node by default + if (QOpenGLContext::currentContext()) { + // Create child node for rendering GL graphics + m_glRenderNode = new DeclarativeRenderNode(m_window); + m_glRenderNode->setFlag(OwnedByParent); + appendChildNode(m_glRenderNode); + m_glRenderNode->setRect(0, 0, 0, 0); // Hide child node by default + } } DeclarativeChartNode::~DeclarativeChartNode()