Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
QPlatformGraphicsBufferHelper Namespace Reference

\inmodule QtGui More...

Functions

Q_GUI_EXPORT bool lockAndBindToTexture (QPlatformGraphicsBuffer *graphicsBuffer, bool *swizzleRandB, bool *premultipliedB, const QRect &rect=QRect())
 Convenience function to both lock and bind the graphicsBuffer to a texture.
 
bool bindSWToTexture (const QPlatformGraphicsBuffer *graphicsBuffer, bool *swizzleRandB=nullptr, bool *premultipliedB=nullptr, const QRect &rect=QRect())
 Convenience function that uploads the current raster content to the currently bound texture.
 

Detailed Description

\inmodule QtGui

Function Documentation

◆ bindSWToTexture()

bool QPlatformGraphicsBufferHelper::bindSWToTexture ( const QPlatformGraphicsBuffer * graphicsBuffer,
bool * swizzleRandB = nullptr,
bool * premultipliedB = nullptr,
const QRect & subRect = QRect() )

Convenience function that uploads the current raster content to the currently bound texture.

swizzleRandB is meant to be used by the caller to decide if the Red and Blue color channels need to be swizzled when rendering. This is an optimization. Qt often renders to software buffers interpreting pixels as unsigned ints. When these buffers are uploaded to textures and each color channel per pixel is interpreted as a byte (read sequentially), then the Red and Blue channels are swapped. Conveniently, the Alpha buffer will be correct, since Qt historically has had the alpha channel as the first channel, while OpenGL typically expects the alpha channel to be the last channel.

subRect is the region to be bound to the texture. This argument has a not less than semantic, meaning more (if not all) of the buffer can be bound to the texture. An empty QRect is interpreted as meaning the entire buffer should be bound.

This function fails if the graphicsBuffer is not locked to SWAccess.

Returns true on success, otherwise false. If premultipliedB is provided, it is set according to what happens, if the function returns true.

Definition at line 108 of file qplatformgraphicsbufferhelper.cpp.

References QPlatformGraphicsBuffer::bytesPerLine(), contains(), QOpenGLContext::currentContext(), QPlatformGraphicsBuffer::data(), QPlatformGraphicsBuffer::format(), QImage::Format_A2BGR30_Premultiplied, QImage::Format_A2RGB30_Premultiplied, QImage::Format_ARGB32, QImage::Format_ARGB32_Premultiplied, QImage::Format_BGR30, QImage::Format_RGB30, QImage::Format_RGB32, QImage::Format_RGBA8888, QImage::Format_RGBA8888_Premultiplied, QImage::Format_RGBX8888, funcs, GL_RGB10_A2, GL_RGBA, GL_UNPACK_ROW_LENGTH, GL_UNSIGNED_BYTE, GL_UNSIGNED_INT_2_10_10_10_REV, GLenum(), GLint(), GLuint, QPlatformGraphicsBuffer::isLocked(), Q_ASSERT, Q_FALLTHROUGH, Q_UNUSED, rect, QPlatformGraphicsBuffer::size(), QPlatformGraphicsBuffer::SWReadAccess, and QImage::toImageFormat().

Referenced by lockAndBindToTexture().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ lockAndBindToTexture()

bool QPlatformGraphicsBufferHelper::lockAndBindToTexture ( QPlatformGraphicsBuffer * graphicsBuffer,
bool * swizzle,
bool * premultiplied,
const QRect & rect = QRect() )

Convenience function to both lock and bind the graphicsBuffer to a texture.

This function will first try to lock with texture read and texture write access. If this succeeds it will use the bindToTexture function to bind the content to the currently bound texture, and if premultiplied is provided, it is set to false.

If it fails, it will try to lock with SWReadAccess and then use the bindSWToTexture convenience function. If premultiplied is provided, it is passed to the bindSWToTexture() function.

swizzle is meant to be used by the caller to figure out if the Red and Blue color channels need to be swizzled when rendering.

rect is the subrect which is desired to be bounded to the texture. This argument has a not less than semantic, meaning more (if not all) of the buffer can be bounded to the texture. An empty QRect is interpreted as entire buffer should be bound.

The user should use the AccessTypes returned by isLocked to figure out what lock has been obtained.

Returns true if the buffer has successfully been bound to the currently bound texture, otherwise returns false.

Definition at line 58 of file qplatformgraphicsbufferhelper.cpp.

References bindSWToTexture(), QPlatformGraphicsBuffer::bindToTexture(), QPlatformGraphicsBuffer::lock(), qWarning, rect, QPlatformGraphicsBuffer::SWReadAccess, and QPlatformGraphicsBuffer::TextureAccess.

+ Here is the call graph for this function: