\value TextureOwnsGLTexture The texture object owns the texture id and
will delete the GL texture when the texture object is deleted.
+
+ \value TextureCanUseAtlas The image can be uploaded into a texture atlas.
*/
/*!
return d->clearBeforeRendering;
}
+/*!
+ \overload
+ */
+
+QSGTexture *QQuickWindow::createTextureFromImage(const QImage &image) const
+{
+ return createTextureFromImage(image, 0);
+}
/*!
The caller of the function is responsible for deleting the returned texture.
The actual GL texture will be deleted when the texture object is deleted.
- Depending on the underlying implementation of the scene graph, the returned
- texture may be part of an atlas. For code to be portable across implementations
- one should always use the texture coordinates returned from
- QSGTexture::normalizedTextureSubRect() when building geometry.
+ When \a options contains TextureCanUseAtlas the engine may put the image
+ into a texture atlas. Textures in an atlas need to rely on
+ QSGTexture::normalizedTextureSubRect() for their geometry and will not
+ support QSGTexture::Repeat. Other values from CreateTextureOption are
+ ignored.
\warning This function will return 0 if the scene graph has not yet been
initialized.
\sa sceneGraphInitialized()
*/
-QSGTexture *QQuickWindow::createTextureFromImage(const QImage &image) const
+QSGTexture *QQuickWindow::createTextureFromImage(const QImage &image, CreateTextureOptions options) const
{
Q_D(const QQuickWindow);
- if (d->context && d->context->isReady())
- return d->context->createTexture(image);
+ if (d->context && d->context->isReady()) {
+ if (options & TextureCanUseAtlas)
+ return d->context->createTexture(image);
+ else
+ return d->context->createTextureNoAtlas(image);
+ }
else
return 0;
}
The caller of the function is responsible for deleting the returned texture.
- Use \a options to customize the texture attributes.
+ Use \a options to customize the texture attributes. The TextureUsesAtlas
+ option is ignored.
\warning This function will return 0 if the scenegraph has not yet been
initialized.
enum CreateTextureOption {
TextureHasAlphaChannel = 0x0001,
TextureHasMipmaps = 0x0002,
- TextureOwnsGLTexture = 0x0004
+ TextureOwnsGLTexture = 0x0004,
+ TextureCanUseAtlas = 0x0008
};
Q_DECLARE_FLAGS(CreateTextureOptions, CreateTextureOption)
// Scene graph specific functions
QSGTexture *createTextureFromImage(const QImage &image) const;
+ QSGTexture *createTextureFromImage(const QImage &image, CreateTextureOptions options) const;
QSGTexture *createTextureFromId(uint id, const QSize &size, CreateTextureOptions options = CreateTextureOption(0)) const;
void setClearBeforeRendering(bool enabled);
virtual QSGGlyphNode *createNativeGlyphNode();
virtual QSGRenderer *createRenderer();
- virtual QSGTexture *createTexture(const QImage &image = QImage()) const;
+ virtual QSGTexture *createTexture(const QImage &image) const;
+ virtual QSGTexture *createTextureNoAtlas(const QImage &image) const;
virtual QSize minimumFBOSize() const;
virtual QSharedPointer<QSGDepthStencilBuffer> depthStencilBufferForFbo(QOpenGLFramebufferObject *fbo);
QSGDepthStencilBufferManager *depthStencilBufferManager();