5#include <private/qopenglpaintengine_p.h> 
    6#include "private/qopenglengineshadersource_p.h" 
    7#include <private/qopenglextensions_p.h> 
    9#include <private/qdrawhelper_p.h> 
   17    return 1 + serial.fetchAndAddRelaxed(1);
 
   29#ifdef QT_GL_TEXTURE_GLYPH_CACHE_DEBUG 
   32    m_vertexCoordinateArray[0] = -1.0f;
 
   33    m_vertexCoordinateArray[1] = -1.0f;
 
   34    m_vertexCoordinateArray[2] =  1.0f;
 
   35    m_vertexCoordinateArray[3] = -1.0f;
 
   36    m_vertexCoordinateArray[4] =  1.0f;
 
   37    m_vertexCoordinateArray[5] =  1.0f;
 
   38    m_vertexCoordinateArray[6] = -1.0f;
 
   39    m_vertexCoordinateArray[7] =  1.0f;
 
   41    m_textureCoordinateArray[0] = 0.0f;
 
   42    m_textureCoordinateArray[1] = 0.0f;
 
   43    m_textureCoordinateArray[2] = 1.0f;
 
   44    m_textureCoordinateArray[3] = 0.0f;
 
   45    m_textureCoordinateArray[4] = 1.0f;
 
   46    m_textureCoordinateArray[5] = 1.0f;
 
   47    m_textureCoordinateArray[6] = 0.0f;
 
   48    m_textureCoordinateArray[7] = 1.0f;
 
   53#ifdef QT_GL_TEXTURE_GLYPH_CACHE_DEBUG 
   54    qDebug(
" -> ~QOpenGLTextureGlyphCache() %p.", 
this);
 
   59#if !QT_CONFIG(opengles2) 
   70        qWarning(
"QOpenGLTextureGlyphCache::createTextureData: Called with no context");
 
   77    if (
ctx->d_func()->workaround_brokenFBOReadBack && 
image().
isNull())
 
   86    if (m_textureResource && !m_textureResource->
m_texture) {
 
   87        delete m_textureResource;
 
   88        m_textureResource = 
nullptr;
 
   91    if (!m_textureResource)
 
  103        for (
int i = 0; 
i < 
data.size(); ++
i)
 
  108        for (
int i = 0; 
i < 
data.size(); ++
i)
 
  110#if !QT_CONFIG(opengles2) 
  120    funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
 
  121    funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
 
  129        static GLfloat buf[
sizeof(m_vertexCoordinateArray) + 
sizeof(m_textureCoordinateArray)];
 
  130        memcpy(
buf, m_vertexCoordinateArray, 
sizeof(m_vertexCoordinateArray));
 
  131        memcpy(
buf + (
sizeof(m_vertexCoordinateArray) / 
sizeof(
GLfloat)),
 
  132               m_textureCoordinateArray,
 
  133               sizeof(m_textureCoordinateArray));
 
  142void QOpenGLTextureGlyphCache::setupVertexAttribs()
 
  159    const int imgWidth = 
img.width();
 
  160    const int imgHeight = 
img.height();
 
  164    } 
else if (
img.depth() == 32) {
 
  172                && 
ctx->isOpenGLES())
 
  175            for (
int y = 0; 
y < imgHeight; ++
y) {
 
  177                for (
int x = 0; 
x < imgWidth; ++
x) {
 
  183                        avg = (
r + 
g + 
b + 1) / 3; 
 
  189#if Q_BYTE_ORDER != Q_BIG_ENDIAN 
  190                    if (
ctx->isOpenGLES())
 
  199    if (
img.depth() == 32) {
 
  200#if QT_CONFIG(opengles2) 
  206#if Q_BYTE_ORDER == Q_BIG_ENDIAN 
  213#if !QT_CONFIG(opengles2) 
  243    if (
ctx == 
nullptr) {
 
  244        qWarning(
"QOpenGLTextureGlyphCache::resizeTextureData: Called with no context");
 
  252    int oldWidth = m_textureResource->
m_width;
 
  253    int oldHeight = m_textureResource->
m_height;
 
  264    if (
ctx->d_func()->workaround_brokenFBOReadBack) {
 
  277    funcs->glGenTextures(1, &tmp_texture);
 
  278    funcs->glBindTexture(GL_TEXTURE_2D, tmp_texture);
 
  279    funcs->glTexImage2D(GL_TEXTURE_2D, 0, 
GL_RGBA, oldWidth, oldHeight, 0,
 
  281    funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
 
  282    funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
 
  286    funcs->glBindTexture(GL_TEXTURE_2D, 0);
 
  288                                  GL_TEXTURE_2D, tmp_texture, 0);
 
  291    funcs->glBindTexture(GL_TEXTURE_2D, oldTexture);
 
  296    funcs->glDisable(GL_STENCIL_TEST);
 
  297    funcs->glDisable(GL_DEPTH_TEST);
 
  298    funcs->glDisable(GL_SCISSOR_TEST);
 
  299    funcs->glDisable(GL_BLEND);
 
  301    funcs->glViewport(0, 0, oldWidth, oldHeight);
 
  304    if (pex == 
nullptr) {
 
  305        if (m_blitProgram == 
nullptr) {
 
  336            m_blitProgram->
link();
 
  340                setupVertexAttribs();
 
  347            setupVertexAttribs();
 
  349        m_blitProgram->
bind();
 
  350        blitProgram = m_blitProgram;
 
  362    funcs->glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
 
  364    funcs->glBindTexture(GL_TEXTURE_2D, m_textureResource->
m_texture);
 
  366    funcs->glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, oldWidth, oldHeight);
 
  370    funcs->glDeleteTextures(1, &tmp_texture);
 
  371    funcs->glDeleteTextures(1, &oldTexture);
 
  375    if (pex != 
nullptr) {
 
  393    if (
ctx == 
nullptr) {
 
  394        qWarning(
"QOpenGLTextureGlyphCache::fillTexture: Called with no context");
 
  398    if (
ctx->d_func()->workaround_brokenFBOReadBack) {
 
  422        return ctx->d_func()->maxTextureSize();
 
  431    if (
ctx->d_func()->workaround_brokenTexSubImage)
 
  432        return qMin(1024, 
ctx->d_func()->maxTextureSize());
 
  434        return ctx->d_func()->maxTextureSize();
 
  439    if (m_textureResource)
 
  440        m_textureResource->
free();
 
  441    m_textureResource = 
nullptr;
 
  443    delete m_blitProgram;
 
  444    m_blitProgram = 
nullptr;
 
The QColor class provides colors based on RGB, HSV or CMYK values.
QFontEngine::GlyphFormat m_format
virtual void createTextureData(int width, int height) override
virtual void resizeTextureData(int width, int height) override
const QImage & image() const
virtual void fillTexture(const Coord &c, glyph_t glyph, const QFixedPoint &subPixelPosition) override
QImage copy(const QRect &rect=QRect()) const
Returns a sub-area of the image as a new image.
int width() const
Returns the width of the image.
int height() const
Returns the height of the image.
@ Format_ARGB32_Premultiplied
QOpenGLEngineShaderManager * shaderManager
void transferMode(EngineMode newMode)
void uploadData(unsigned int arrayIndex, const GLfloat *data, GLuint count)
void updateClipScissorTest()
The QOpenGLBuffer class provides functions for creating and managing OpenGL buffer objects.
bool bind()
Binds the buffer associated with this object to the current OpenGL context.
bool create()
Creates the buffer object in the OpenGL server.
bool isCreated() const
Returns true if this buffer has been created; false otherwise.
void allocate(const void *data, int count)
Allocates count bytes of space to the buffer, initialized to the contents of data.
void release()
Releases the buffer associated with this object from the current OpenGL context.
QSurfaceFormat format() const
Returns the format of the underlying platform context, if create() has been called.
static QOpenGLContext * currentContext()
Returns the last context which called makeCurrent in the current thread, or \nullptr,...
QOpenGLShaderProgram * blitProgram()
The QOpenGLFunctions class provides cross-platform access to the OpenGL ES 2.0 API.
The QOpenGLShaderProgram class allows OpenGL shader programs to be linked and used.
void bindAttributeLocation(const char *name, int location)
Binds the attribute name to the specified location.
void enableAttributeArray(int location)
Enables the vertex array at location in this shader program so that the value set by setAttributeArra...
virtual bool link()
Links together the shaders that were added to this program with addShader().
void setUniformValue(int location, GLfloat value)
Sets the uniform variable at location in the current context to value.
void disableAttributeArray(int location)
Disables the vertex array at location in this shader program that was enabled by a previous call to e...
bool addCacheableShaderFromSourceCode(QOpenGLShader::ShaderType type, const char *source)
Registers the shader of the specified type and source to this program.
bool bind()
Binds this shader program to the active QOpenGLContext and makes it the current shader program.
void setAttributeBuffer(int location, GLenum type, int offset, int tupleSize, int stride=0)
Sets an array of vertex values on the attribute at location in this shader program,...
virtual int glyphPadding() const override
~QOpenGLTextureGlyphCache()
virtual int maxTextureWidth() const override
virtual void createTextureData(int width, int height) override
virtual int maxTextureHeight() const override
virtual void resizeTextureData(int width, int height) override
virtual void fillTexture(const Coord &c, glyph_t glyph, const QFixedPoint &subPixelPosition) override
QOpenGLTextureGlyphCache(QFontEngine::GlyphFormat glyphFormat, const QTransform &matrix, const QColor &color=QColor())
void release()
Unbinds this vertex array object by binding the default vertex array object (id = 0).
bool create()
Creates the underlying OpenGL vertex array object.
bool isCreated() const
Returns true is the underlying OpenGL vertex array object has been created.
void bind()
Binds this vertex array object to the OpenGL binding point.
\macro QT_RESTRICTED_CAST_FROM_ASCII
virtual int maxTextureHeight() const
QImage textureMapForGlyph(glyph_t g, const QFixedPoint &subPixelPosition) const
virtual int maxTextureWidth() const
static VulkanServerBufferGlFunctions * funcs
Combined button and popup list for selecting options.
#define Q_BASIC_ATOMIC_INITIALIZER(a)
constexpr const T & qMin(const T &a, const T &b)
static const GLuint QT_TEXTURE_COORDS_ATTR
static QT_BEGIN_NAMESPACE const GLuint QT_VERTEX_COORDS_ATTR
static const char *const qopenglslImageSrcFragmentShader
static const char *const qopenglslUntransformedPositionVertexShader
static const char *const qopenglslMainFragmentShader
static const char *const qopenglslMainWithTexCoordsVertexShader
GLboolean GLboolean GLboolean b
typedef GLint(GL_APIENTRYP PFNGLGETPROGRAMRESOURCELOCATIONINDEXEXTPROC)(GLuint program
GLint GLint GLint GLint GLint x
[0]
typedef GLfloat(GL_APIENTRYP PFNGLGETPATHLENGTHNVPROC)(GLuint path
GLfloat GLfloat GLfloat w
[0]
GLint GLsizei GLsizei height
GLsizei const GLubyte GLsizei GLenum const void * coords
typedef GLenum(GL_APIENTRYP PFNGLGETGRAPHICSRESETSTATUSKHRPROC)(void)
GLenum GLuint GLenum GLsizei const GLchar * buf
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLint GLint GLint GLint GLint GLint GLint GLbitfield mask
GLint GLsizei GLsizei GLenum format
GLsizei GLenum internalFormat
GLfloat GLfloat GLfloat GLfloat h
GLsizei GLsizei GLchar * source
#define GL_COLOR_ATTACHMENT0
#define GL_FRAMEBUFFER_BINDING
#define QT_IMAGE_TEXTURE_UNIT
static void load_glyph_image_region_to_texture(QOpenGLContext *ctx, const QImage &srcImg, int x, int y, int w, int h, GLuint texture, int tx, int ty)
static bool isCoreProfile()
static void load_glyph_image_to_texture(QOpenGLContext *ctx, QImage &img, GLuint texture, int tx, int ty)
static QT_BEGIN_NAMESPACE int next_qopengltextureglyphcache_serial_number()
static quint32 ARGB2RGBA(quint32 x)
QT_BEGIN_NAMESPACE typedef unsigned int QRgb
constexpr int qRed(QRgb rgb)
constexpr int qGreen(QRgb rgb)
constexpr QRgb qRgba(int r, int g, int b, int a)
constexpr int qBlue(QRgb rgb)
constexpr int qAlpha(QRgb rgb)
QVideoFrameFormat::PixelFormat fmt