------------------------------------------------------------------------------ | OMX_ImageElement::updatePaintNode +-----------------------------------------------------------------------------*/
| 60 | | OMX_ImageElement::updatePaintNode |
| 61 | +-----------------------------------------------------------------------------*/ |
| 62 | QSGNode* OMX_ImageElement::updatePaintNode(QSGNode* oldNode, UpdatePaintNodeData*) |
| 63 | { |
| 64 | QSGGeometryNode* node = 0; |
| 65 | QSGGeometry* geometry = 0; |
| 66 | |
| 67 | if (!oldNode) { |
| 68 | // Create the node. |
| 69 | node = new QSGGeometryNode; |
| 70 | geometry = new QSGGeometry(QSGGeometry::defaultAttributes_TexturedPoint2D(), 4); |
| 71 | geometry->setDrawingMode(GL_TRIANGLE_STRIP); |
| 72 | node->setGeometry(geometry); |
| 73 | node->setFlag(QSGNode::OwnsGeometry); |
| 74 | |
| 75 | // Load and set the texture. The first time it is always needed to do this. |
| 76 | updateTexture(); |
| 77 | |
| 78 | // TODO: Who is freeing this? |
| 79 | QSGOpaqueTextureMaterial* material = new QSGOpaqueTextureMaterial; |
| 80 | material->setTexture(new OMX_SGTexture(m_texture, QSize(1920, 1080))); |
| 81 | node->setMaterial(material); |
| 82 | node->setFlag(QSGNode::OwnsMaterial); |
| 83 | } |
| 84 | else { |
| 85 | node = static_cast<QSGGeometryNode *>(oldNode); |
| 86 | geometry = node->geometry(); |
| 87 | geometry->allocate(4); |
| 88 | |
| 89 | // Update texture in the node if needed. |
| 90 | QSGOpaqueTextureMaterial* material = (QSGOpaqueTextureMaterial*)node->material(); |
| 91 | if (m_texture != (GLuint)material->texture()->textureId()) { |
| 92 | updateTexture(); |
| 93 | |
| 94 | // TODO: Does setTextureId frees the prev texture? |
| 95 | OMX_SGTexture* mySGTexture = (OMX_SGTexture*)material->texture(); |
| 96 | mySGTexture->setTexture(m_texture, QSize(1920, 1080)); |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | // Create the vertices and map to texture. |
| 101 | QRectF bounds = boundingRect(); |
| 102 | QSGGeometry::TexturedPoint2D* vertices = geometry->vertexDataAsTexturedPoint2D(); |
| 103 | vertices[0].set(bounds.x(), bounds.y() + bounds.height(), 0.0f, 1.0f); |
| 104 | vertices[1].set(bounds.x() + bounds.width(), bounds.y() + bounds.height(), 1.0f, 1.0f); |
| 105 | vertices[2].set(bounds.x(), bounds.y(), 0.0f, 0.0f); |
| 106 | vertices[3].set(bounds.x() + bounds.width(), bounds.y(), 1.0f, 0.0f); |
| 107 | return node; |
| 108 | } |
| 109 | |
| 110 | /*------------------------------------------------------------------------------ |
| 111 | | OMX_ImageElement::updateTexture |
nothing calls this directly
no test coverage detected