/*! Creates a texture object that wraps the GL texture \a id uploaded with \a size Valid \a options are TextureHasAlphaChannel and TextureOwnsGLTexture The caller takes ownership of the texture object and the texture should only be used with this engine. \sa createTextureFromImage(), QSGSimpleTextureNode::setOwnsTexture(), QQuickWindow::createTextureFromId() */ QSGTexture *QSGEngine::createTextureFromId(uint id, const QSize &size, CreateTextureOptions options) const { Q_D(const QSGEngine); if (d->sgRenderContext->isValid()) { QSGPlainTexture *texture = new QSGPlainTexture(); texture->setTextureId(id); texture->setHasAlphaChannel(options & TextureHasAlphaChannel); texture->setOwnsTexture(options & TextureOwnsGLTexture); texture->setTextureSize(size); return texture; } return 0; }
QSGTexture *QQuickContext2DFBOTexture::textureForNextFrame(QSGTexture *lastTexture, QQuickWindow *) { QSGPlainTexture *texture = static_cast<QSGPlainTexture *>(lastTexture); if (m_onCustomThread) m_mutex.lock(); if (m_fbo) { if (!texture) { texture = new QSGPlainTexture(); texture->setHasAlphaChannel(true); texture->setOwnsTexture(false); m_dirtyTexture = true; } if (m_dirtyTexture) { if (!m_gl) { // on a rendering thread, use the fbo directly... texture->setTextureId(m_fbo->texture()); } else { // on GUI or custom thread, use display textures... m_displayTexture = m_displayTexture == 0 ? 1 : 0; texture->setTextureId(m_displayTextures[m_displayTexture]); } texture->setTextureSize(m_fbo->size()); m_dirtyTexture = false; } } if (m_onCustomThread) { m_condition.wakeOne(); m_mutex.unlock(); } return texture; }