@@ -512,14 +512,16 QSGNode *DeclarativeChart::updatePaintNode(QSGNode *oldNode, QQuickItem::UpdateP | |||||
512 |
|
512 | |||
513 | if (!node) { |
|
513 | if (!node) { | |
514 | node = new DeclarativeChartNode(window()); |
|
514 | node = new DeclarativeChartNode(window()); | |
|
515 | if (node->glRenderNode()) { | |||
515 | connect(window(), &QQuickWindow::beforeRendering, |
|
516 | connect(window(), &QQuickWindow::beforeRendering, | |
516 | node->glRenderNode(), &DeclarativeRenderNode::render); |
|
517 | node->glRenderNode(), &DeclarativeRenderNode::render); | |
517 | } |
|
518 | } | |
|
519 | } | |||
518 |
|
520 | |||
519 | const QRectF &bRect = boundingRect(); |
|
521 | const QRectF &bRect = boundingRect(); | |
520 |
|
522 | |||
521 | // Update GL data |
|
523 | // Update GL data | |
522 | if (m_glXYDataManager->dataMap().size() || m_glXYDataManager->mapDirty()) { |
|
524 | if (node->glRenderNode() && (m_glXYDataManager->dataMap().size() || m_glXYDataManager->mapDirty())) { | |
523 | const QRectF &plotArea = m_chart->plotArea(); |
|
525 | const QRectF &plotArea = m_chart->plotArea(); | |
524 | const QSizeF &chartAreaSize = m_chart->size(); |
|
526 | const QSizeF &chartAreaSize = m_chart->size(); | |
525 |
|
527 |
@@ -39,28 +39,28 DeclarativeChartNode::DeclarativeChartNode(QQuickWindow *window) : | |||||
39 | m_textureSize(1, 1), |
|
39 | m_textureSize(1, 1), | |
40 | m_glRenderNode(0) |
|
40 | m_glRenderNode(0) | |
41 | { |
|
41 | { | |
42 | initializeOpenGLFunctions(); |
|
|||
43 |
|
||||
44 | // Our texture node must have a texture, so use a default one pixel texture |
|
42 | // Our texture node must have a texture, so use a default one pixel texture | |
45 | GLuint defaultTexture = 0; |
|
43 | QImage dummyImage(QSize(1, 1), QImage::Format_ARGB32); | |
46 | glGenTextures(1, &defaultTexture); |
|
44 | uchar *imageData = dummyImage.bits(); | |
47 | glBindTexture(GL_TEXTURE_2D, defaultTexture); |
|
45 | imageData[0] = 0; | |
48 | uchar buf[4] = { 0, 0, 0, 0 }; |
|
46 | imageData[1] = 0; | |
49 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, &buf); |
|
47 | imageData[2] = 0; | |
50 |
|
48 | imageData[3] = 0; | ||
51 | QQuickWindow::CreateTextureOptions defaultTextureOptions = QQuickWindow::CreateTextureOptions( |
|
49 | QQuickWindow::CreateTextureOptions defaultTextureOptions = QQuickWindow::CreateTextureOptions( | |
52 | QQuickWindow::TextureHasAlphaChannel | QQuickWindow::TextureOwnsGLTexture); |
|
50 | QQuickWindow::TextureHasAlphaChannel | QQuickWindow::TextureOwnsGLTexture); | |
53 |
m_texture = m_window->createTextureFromI |
|
51 | m_texture = m_window->createTextureFromImage(dummyImage, defaultTextureOptions); | |
54 |
|
52 | |||
55 | setTexture(m_texture); |
|
53 | setTexture(m_texture); | |
56 | setFiltering(QSGTexture::Linear); |
|
54 | setFiltering(QSGTexture::Linear); | |
57 |
|
55 | |||
|
56 | if (QOpenGLContext::currentContext()) { | |||
58 | // Create child node for rendering GL graphics |
|
57 | // Create child node for rendering GL graphics | |
59 | m_glRenderNode = new DeclarativeRenderNode(m_window); |
|
58 | m_glRenderNode = new DeclarativeRenderNode(m_window); | |
60 | m_glRenderNode->setFlag(OwnedByParent); |
|
59 | m_glRenderNode->setFlag(OwnedByParent); | |
61 | appendChildNode(m_glRenderNode); |
|
60 | appendChildNode(m_glRenderNode); | |
62 | m_glRenderNode->setRect(0, 0, 0, 0); // Hide child node by default |
|
61 | m_glRenderNode->setRect(0, 0, 0, 0); // Hide child node by default | |
63 | } |
|
62 | } | |
|
63 | } | |||
64 |
|
64 | |||
65 | DeclarativeChartNode::~DeclarativeChartNode() |
|
65 | DeclarativeChartNode::~DeclarativeChartNode() | |
66 | { |
|
66 | { |
General Comments 0
You need to be logged in to leave comments.
Login now