Ignore:
Timestamp:
May 5, 2011, 5:36:53 AM (14 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/opengl/qpaintengine_opengl.cpp

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    6161#include <private/qbezier_p.h>
    6262#include <qglframebufferobject.h>
     63#include <private/qstatictext_p.h>
    6364
    6465#include "private/qtessellator_p.h"
     
    7273#endif
    7374
    74 #ifdef QT_OPENGL_ES_1_CL
    75 #include "qgl_cl_p.h"
    76 #endif
    77 
    7875#define QGL_FUNC_CONTEXT QGLContext *ctx = const_cast<QGLContext *>(device->context());
    7976
     
    8380QT_BEGIN_NAMESPACE
    8481
    85 extern QImage qt_imageForBrush(int brushStyle, bool invert); //in qbrush.cpp
     82Q_DECL_IMPORT extern QImage qt_imageForBrush(int brushStyle, bool invert); //in qbrush.cpp
    8683#ifdef QT_MAC_USE_COCOA
    8784extern void *qt_current_nsopengl_context(); // qgl_mac.mm
     
    510507////////// GL program cache: start
    511508
    512 typedef struct {
     509struct GLProgram {
    513510    int brush; // brush index or mask index
    514511    int mode;  // composition mode index
    515512    bool mask;
    516513    GLuint program;
    517 } GLProgram;
     514};
    518515
    519516typedef QMultiHash<const QGLContext *, GLProgram> QGLProgramHash;
     
    672669        , shader_ctx(0)
    673670        , grad_palette(0)
     671        , tess_points(0)
    674672        , drawable_texture(0)
    675673        , ref_cleaner(this)
     
    781779
    782780    void composite(const QRectF &rect, const QPoint &maskOffset = QPoint());
    783     void composite(GLuint primitive, const q_vertexType *vertexArray, int vertexCount, const QPoint &maskOffset = QPoint());
     781    void composite(GLuint primitive, const GLfloat *vertexArray, int vertexCount, const QPoint &maskOffset = QPoint());
    784782
    785783    bool createFragmentPrograms();
     
    924922    stroker.setJoinStyle(cpen.joinStyle());
    925923    stroker.setMiterLimit(cpen.miterLimit());
     924    stroker.setDashOffset(cpen.dashOffset());
    926925
    927926    qreal width = cpen.widthF();
     
    17931792    QOpenGLTrapezoidToArrayTessellator() : vertices(0), allocated(0), size(0) {}
    17941793    ~QOpenGLTrapezoidToArrayTessellator() { free(vertices); }
    1795     q_vertexType *vertices;
     1794    GLfloat *vertices;
    17961795    int allocated;
    17971796    int size;
     
    18141813#endif
    18151814        allocated = qMax(2*allocated, 512);
    1816         vertices = (q_vertexType *)realloc(vertices, allocated * sizeof(q_vertexType));
     1815        vertices = (GLfloat *)realloc(vertices, allocated * sizeof(GLfloat));
    18171816    }
    18181817
     
    18201819
    18211820#ifndef QT_OPENGL_ES
    1822     vertices[size++] = f2vt(t.topLeftX);
    1823     vertices[size++] = f2vt(t.top);
    1824     vertices[size++] = f2vt(t.topRightX);
    1825     vertices[size++] = f2vt(t.top);
    1826     vertices[size++] = f2vt(t.bottomRightX);
    1827     vertices[size++] = f2vt(t.bottom);
    1828     vertices[size++] = f2vt(t.bottomLeftX);
    1829     vertices[size++] = f2vt(t.bottom);
     1821    vertices[size++] = t.topLeftX;
     1822    vertices[size++] = t.top;
     1823    vertices[size++] = t.topRightX;
     1824    vertices[size++] = t.top;
     1825    vertices[size++] = t.bottomRightX;
     1826    vertices[size++] = t.bottom;
     1827    vertices[size++] = t.bottomLeftX;
     1828    vertices[size++] = t.bottom;
    18301829#else
    18311830    // First triangle
    1832     vertices[size++] = f2vt(t.topLeftX);
    1833     vertices[size++] = f2vt(t.top);
    1834     vertices[size++] = f2vt(t.topRightX);
    1835     vertices[size++] = f2vt(t.top);
    1836     vertices[size++] = f2vt(t.bottomRightX);
    1837     vertices[size++] = f2vt(t.bottom);
     1831    vertices[size++] = t.topLeftX;
     1832    vertices[size++] = t.top;
     1833    vertices[size++] = t.topRightX;
     1834    vertices[size++] = t.top;
     1835    vertices[size++] = t.bottomRightX;
     1836    vertices[size++] = t.bottom;
    18381837
    18391838    // Second triangle
    1840     vertices[size++] = f2vt(t.bottomLeftX);
    1841     vertices[size++] = f2vt(t.bottom);
    1842     vertices[size++] = f2vt(t.topLeftX);
    1843     vertices[size++] = f2vt(t.top);
    1844     vertices[size++] = f2vt(t.bottomRightX);
    1845     vertices[size++] = f2vt(t.bottom);
     1839    vertices[size++] = t.bottomLeftX;
     1840    vertices[size++] = t.bottom;
     1841    vertices[size++] = t.topLeftX;
     1842    vertices[size++] = t.top;
     1843    vertices[size++] = t.bottomRightX;
     1844    vertices[size++] = t.bottom;
    18461845#endif
    18471846}
     
    18701869        composite(geometry_mode, tessellator.vertices, tessellator.size / 2);
    18711870    } else {
    1872         glVertexPointer(2, q_vertexTypeEnum, 0, tessellator.vertices);
     1871        glVertexPointer(2, GL_FLOAT, 0, tessellator.vertices);
    18731872        glEnableClientState(GL_VERTEX_ARRAY);
    18741873        glDrawArrays(geometry_mode, 0, tessellator.size/2);
     
    19591958void QOpenGLPaintEnginePrivate::drawVertexArrays()
    19601959{
     1960    if (tess_points_stops.count() == 0)
     1961        return;
    19611962    glEnableClientState(GL_VERTEX_ARRAY);
    19621963    glVertexPointer(2, GL_DOUBLE, 0, tess_points.data());
     
    22712272    }
    22722273
    2273 #if defined(QT_OPENGL_ES_1) || defined(QT_OPENGL_ES_2) || defined(QT_OPENGL_ES_1_CL)
     2274#if defined(QT_OPENGL_ES_1) || defined(QT_OPENGL_ES_2)
    22742275    glClearDepthf(0.0f);
    22752276#else
     
    22872288
    22882289    // rectangle count * 2 (triangles) * vertex count * component count (Z omitted)
    2289     QDataBuffer<q_vertexType> clipVertex(rects.size()*2*3*2);
     2290    QDataBuffer<GLfloat> clipVertex(rects.size()*2*3*2);
    22902291    for (int i = 0; i < rects.size(); ++i) {
    2291         q_vertexType x = i2vt(rects.at(i).left());
    2292         q_vertexType w = i2vt(rects.at(i).width());
    2293         q_vertexType h = i2vt(rects.at(i).height());
    2294         q_vertexType y = i2vt(rects.at(i).top());
     2292        GLfloat x = GLfloat(rects.at(i).left());
     2293        GLfloat w = GLfloat(rects.at(i).width());
     2294        GLfloat h = GLfloat(rects.at(i).height());
     2295        GLfloat y = GLfloat(rects.at(i).top());
    22952296
    22962297        // First triangle
     
    23202321
    23212322        glEnableClientState(GL_VERTEX_ARRAY);
    2322         glVertexPointer(2, q_vertexTypeEnum, 0, clipVertex.data());
     2323        glVertexPointer(2, GL_FLOAT, 0, clipVertex.data());
    23232324
    23242325        glDrawArrays(GL_TRIANGLES, 0, rects.size()*2*3);
     
    31123113}
    31133114
    3114 extern void qt_add_rect_to_array(const QRectF &r, q_vertexType *array);
    3115 extern void qt_add_texcoords_to_array(qreal x1, qreal y1, qreal x2, qreal y2, q_vertexType *array);
     3115extern void qt_add_rect_to_array(const QRectF &r, GLfloat *array);
     3116extern void qt_add_texcoords_to_array(qreal x1, qreal y1, qreal x2, qreal y2, GLfloat *array);
    31163117
    31173118void QGLTrapezoidMaskGenerator::drawMask(const QRect &rect)
     
    31443145    // clear mask
    31453146    glBlendFunc(GL_ZERO, GL_ZERO); // clear
    3146     glVertexPointer(2, q_vertexTypeEnum, 0, vertexArray);
     3147    glVertexPointer(2, GL_FLOAT, 0, vertexArray);
    31473148    glEnableClientState(GL_VERTEX_ARRAY);
    31483149    glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
     
    33513352    QTransform inv_matrix = gl_to_qt * matrix().inverted() * translate;
    33523353
    3353     float m[3][4] = { { inv_matrix.m11(), inv_matrix.m12(), inv_matrix.m13() },
    3354                       { inv_matrix.m21(), inv_matrix.m22(), inv_matrix.m23() },
    3355                       { inv_matrix.m31(), inv_matrix.m32(), inv_matrix.m33() } };
     3354    float m[3][4] = { { float(inv_matrix.m11()), float(inv_matrix.m12()), float(inv_matrix.m13()) },
     3355                      { float(inv_matrix.m21()), float(inv_matrix.m22()), float(inv_matrix.m23()) },
     3356                      { float(inv_matrix.m31()), float(inv_matrix.m32()), float(inv_matrix.m33()) } };
    33563357
    33573358    QPoint offs(screen_rect.left() - rect.left(), (offscreen->drawableSize().height() - screen_rect.top())
     
    33593360
    33603361    // last component needs to be 1.0f to avoid Nvidia bug on linux
    3361     float ellipse_offset[4] = { offs.x(), offs.y(), 0.0f, 1.0f };
     3362    float ellipse_offset[4] = { float(offs.x()), float(offs.y()), 0.0f, 1.0f };
    33623363
    33633364    GLfloat vertexArray[4 * 2];
     
    33753376
    33763377    glEnableClientState(GL_VERTEX_ARRAY);
    3377     glVertexPointer(2, q_vertexTypeEnum, 0, vertexArray);
     3378    glVertexPointer(2, GL_FLOAT, 0, vertexArray);
    33783379    glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
    33793380    glDisableClientState(GL_VERTEX_ARRAY);
     
    34053406    DEBUG_ONCE_STR("QOpenGLPaintEngine::drawRects(): drawing fast rect");
    34063407
    3407     q_vertexType vertexArray[10];
     3408    GLfloat vertexArray[10];
    34083409    qt_add_rect_to_array(r, vertexArray);
    34093410
     
    34263427        if (fast_style && has_fast_composition_mode) {
    34273428            glEnableClientState(GL_VERTEX_ARRAY);
    3428             glVertexPointer(2, q_vertexTypeEnum, 0, vertexArray);
     3429            glVertexPointer(2, GL_FLOAT, 0, vertexArray);
    34293430            glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
    34303431            glDisableClientState(GL_VERTEX_ARRAY);
     
    34453446            vertexArray[9] = vertexArray[1];
    34463447
    3447             glVertexPointer(2, q_vertexTypeEnum, 0, vertexArray);
     3448            glVertexPointer(2, GL_FLOAT, 0, vertexArray);
    34483449            glEnableClientState(GL_VERTEX_ARRAY);
    34493450            glDrawArrays(GL_LINE_STRIP, 0, 5);
     
    35523553}
    35533554
    3554 static void addQuadAsTriangle(q_vertexType *quad, q_vertexType *triangle)
     3555static void addQuadAsTriangle(GLfloat *quad, GLfloat *triangle)
    35553556{
    35563557    triangle[0] = quad[0];
     
    36133614
    36143615    if (d->has_fast_pen) {
    3615         QVarLengthArray<q_vertexType> vertexArray(6 * pointCount);
     3616        QVarLengthArray<GLfloat> vertexArray(6 * pointCount);
    36163617
    36173618        glMatrixMode(GL_MODELVIEW);
     
    36233624            QPointF mapped = d->matrix.map(points[i]);
    36243625
    3625             qreal xf = qRound(mapped.x());
    3626             qreal yf = qRound(mapped.y());
    3627 
    3628             q_vertexType x = f2vt(xf);
    3629             q_vertexType y = f2vt(yf);
     3626            GLfloat x = GLfloat(qRound(mapped.x()));
     3627            GLfloat y = GLfloat(qRound(mapped.y()));
    36303628
    36313629            vertexArray[j++] = x;
    3632             vertexArray[j++] = y - f2vt(0.5);
    3633 
    3634             vertexArray[j++] = x + f2vt(1.5);
    3635             vertexArray[j++] = y + f2vt(1.0);
     3630            vertexArray[j++] = y - 0.5f;
     3631
     3632            vertexArray[j++] = x + 1.5f;
     3633            vertexArray[j++] = y + 1.0f;
    36363634
    36373635            vertexArray[j++] = x;
    3638             vertexArray[j++] = y + f2vt(1.0);
     3636            vertexArray[j++] = y + 1.0f;
    36393637        }
    36403638
    36413639        glEnableClientState(GL_VERTEX_ARRAY);
    36423640
    3643         glVertexPointer(2, q_vertexTypeEnum, 0, vertexArray.constData());
     3641        glVertexPointer(2, GL_FLOAT, 0, vertexArray.constData());
    36443642        glDrawArrays(GL_TRIANGLES, 0, pointCount*3);
    36453643
     
    36583656    else {
    36593657        Q_ASSERT(sizeof(QPointF) == 8);
    3660         glVertexPointer(2, q_vertexTypeEnum, 0, vertexArray);
     3658        glVertexPointer(2, GL_FLOAT, 0, vertexArray);
    36613659    }
    36623660
     
    37263724            }
    37273725
    3728             q_vertexType endCap = f2vt(d->cpen.capStyle() == Qt::FlatCap ? 0 : 0.5);
     3726            GLfloat endCap = d->cpen.capStyle() == Qt::FlatCap ? 0.0f : 0.5f;
    37293727            if (useRects) {
    3730                 QVarLengthArray<q_vertexType> vertexArray(12 * lineCount);
    3731 
    3732                 q_vertexType quad[8];
     3728                QVarLengthArray<GLfloat> vertexArray(12 * lineCount);
     3729
     3730                GLfloat quad[8];
    37333731                for (int i = 0; i < lineCount; ++i) {
    3734                     q_vertexType x1 = f2vt(lines[i].x1());
    3735                     q_vertexType x2 = f2vt(lines[i].x2());
    3736                     q_vertexType y1 = f2vt(lines[i].y1());
    3737                     q_vertexType y2 = f2vt(lines[i].y2());
     3732                    GLfloat x1 = lines[i].x1();
     3733                    GLfloat x2 = lines[i].x2();
     3734                    GLfloat y1 = lines[i].y1();
     3735                    GLfloat y2 = lines[i].y2();
    37383736
    37393737                    if (x1 == x2) {
     
    37413739                            qSwap(y1, y2);
    37423740
    3743                         quad[0] = x1 - f2vt(0.5);
     3741                        quad[0] = x1 - 0.5f;
    37443742                        quad[1] = y1 - endCap;
    37453743
    3746                         quad[2] = x1 + f2vt(0.5);
     3744                        quad[2] = x1 + 0.5f;
    37473745                        quad[3] = y1 - endCap;
    37483746
    3749                         quad[4] = x1 + f2vt(0.5);
     3747                        quad[4] = x1 + 0.5f;
    37503748                        quad[5] = y2 + endCap;
    37513749
    3752                         quad[6] = x1 - f2vt(0.5);
     3750                        quad[6] = x1 - 0.5f;
    37533751                        quad[7] = y2 + endCap;
    37543752                    } else {
     
    37573755
    37583756                        quad[0] = x1 - endCap;
    3759                         quad[1] = y1 + f2vt(0.5);
     3757                        quad[1] = y1 + 0.5f;
    37603758
    37613759                        quad[2] = x1 - endCap;
    3762                         quad[3] = y1 - f2vt(0.5);
     3760                        quad[3] = y1 - 0.5f;
    37633761
    37643762                        quad[4] = x2 + endCap;
    3765                         quad[5] = y1 - f2vt(0.5);
     3763                        quad[5] = y1 - 0.5f;
    37663764
    37673765                        quad[6] = x2 + endCap;
    3768                         quad[7] = y1 + f2vt(0.5);
     3766                        quad[7] = y1 + 0.5f;
    37693767                    }
    37703768
     
    37743772                glEnableClientState(GL_VERTEX_ARRAY);
    37753773
    3776                 glVertexPointer(2, q_vertexTypeEnum, 0, vertexArray.constData());
     3774                glVertexPointer(2, GL_FLOAT, 0, vertexArray.constData());
    37773775                glDrawArrays(GL_TRIANGLES, 0, lineCount*6);
    37783776
    37793777                glDisableClientState(GL_VERTEX_ARRAY);
    37803778            } else {
    3781                 QVarLengthArray<q_vertexType> vertexArray(4 * lineCount);
     3779                QVarLengthArray<GLfloat> vertexArray(4 * lineCount);
    37823780                for (int i = 0; i < lineCount; ++i) {
    37833781                    const QPointF a = lines[i].p1();
    3784                     vertexArray[4*i]   = f2vt(lines[i].x1());
    3785                     vertexArray[4*i+1] = f2vt(lines[i].y1());
    3786                     vertexArray[4*i+2] = f2vt(lines[i].x2());
    3787                     vertexArray[4*i+3] = f2vt(lines[i].y2());
     3782                    vertexArray[4*i]   = lines[i].x1();
     3783                    vertexArray[4*i+1] = lines[i].y1();
     3784                    vertexArray[4*i+2] = lines[i].x2();
     3785                    vertexArray[4*i+3] = lines[i].y2();
    37883786                }
    37893787
    37903788                glEnableClientState(GL_VERTEX_ARRAY);
    37913789
    3792                 glVertexPointer(2, q_vertexTypeEnum, 0, vertexArray.constData());
     3790                glVertexPointer(2, GL_FLOAT, 0, vertexArray.constData());
    37933791                glDrawArrays(GL_LINES, 0, lineCount*2);
    37943792
    3795                 glVertexPointer(2, q_vertexTypeEnum, 4*sizeof(q_vertexType), vertexArray.constData() + 2);
     3793                glVertexPointer(2, GL_FLOAT, 4*sizeof(GLfloat), vertexArray.constData() + 2);
    37963794                glDrawArrays(GL_POINTS, 0, lineCount);
    37973795
     
    38803878            else {
    38813879                Q_ASSERT(sizeof(QPointF) == 8);
    3882                 glVertexPointer(2, q_vertexTypeEnum, 0, vertexArray);
     3880                glVertexPointer(2, GL_FLOAT, 0, vertexArray);
    38833881            }
    38843882
     
    38993897        if (d->has_fast_pen && !d->high_quality_antialiasing) {
    39003898            d->setGradientOps(d->cpen.brush(), bounds);
    3901             QVarLengthArray<q_vertexType> vertexArray(pointCount*2 + 2);
    3902             glVertexPointer(2, q_vertexTypeEnum, 0, vertexArray.constData());
     3899            QVarLengthArray<GLfloat> vertexArray(pointCount*2 + 2);
     3900            glVertexPointer(2, GL_FLOAT, 0, vertexArray.constData());
    39033901            int i;
    39043902            for (i=0; i<pointCount; ++i) {
    3905                 vertexArray[i*2] = f2vt(points[i].x());
    3906                 vertexArray[i*2+1] = f2vt(points[i].y());
     3903                vertexArray[i*2] = points[i].x();
     3904                vertexArray[i*2+1] = points[i].y();
    39073905            }
    39083906
     
    39593957}
    39603958
    3961 extern bool qt_scaleForTransform(const QTransform &transform, qreal *scale); // qtransform.cpp
     3959Q_GUI_EXPORT bool qt_scaleForTransform(const QTransform &transform, qreal *scale); // qtransform.cpp
    39623960
    39633961void QOpenGLPaintEnginePrivate::strokePath(const QPainterPath &path, bool use_cache)
     
    40804078        case QPainterPath::MoveToElement:
    40814079            if (i != 0) {
    4082                 glVertexPointer(2, q_vertexTypeEnum, 0, tess_points.data());
     4080                glVertexPointer(2, GL_FLOAT, 0, tess_points.data());
    40834081                glDrawArrays(GL_LINE_STRIP, 0, tess_points.size());
    40844082                tess_points.reset();
     
    41304128        } // end of switch
    41314129    }
    4132     glVertexPointer(2, q_vertexTypeEnum, 0, tess_points.data());
     4130    glVertexPointer(2, GL_FLOAT, 0, tess_points.data());
    41334131    glDrawArrays(GL_LINE_STRIP, 0, tess_points.size());
    41344132    glDisableClientState(GL_VERTEX_ARRAY);
     
    43974395        }
    43984396
    4399         q_vertexType vertexArray[4*2];
    4400         q_vertexType texCoordArray[4*2];
     4397        GLfloat vertexArray[4*2];
     4398        GLfloat texCoordArray[4*2];
    44014399
    44024400        double offset_x = offset.x() / pm.width();
     
    44074405                                  tc_w + offset_x, tc_h + offset_y, texCoordArray);
    44084406
    4409         glVertexPointer(2, q_vertexTypeEnum, 0, vertexArray);
    4410         glTexCoordPointer(2, q_vertexTypeEnum, 0, texCoordArray);
     4407        glVertexPointer(2, GL_FLOAT, 0, vertexArray);
     4408        glTexCoordPointer(2, GL_FLOAT, 0, texCoordArray);
    44114409
    44124410        glEnableClientState(GL_VERTEX_ARRAY);
     
    44894487    }
    44904488
    4491     q_vertexType vertexArray[4*2];
    4492     q_vertexType texCoordArray[4*2];
     4489    GLfloat vertexArray[4*2];
     4490    GLfloat texCoordArray[4*2];
    44934491
    44944492    qt_add_rect_to_array(r, vertexArray);
    44954493    qt_add_texcoords_to_array(x1, y2, x2, y1, texCoordArray);
    44964494
    4497     glVertexPointer(2, q_vertexTypeEnum, 0, vertexArray);
    4498     glTexCoordPointer(2, q_vertexTypeEnum, 0, texCoordArray);
     4495    glVertexPointer(2, GL_FLOAT, 0, vertexArray);
     4496    glTexCoordPointer(2, GL_FLOAT, 0, texCoordArray);
    44994497
    45004498    glEnableClientState(GL_VERTEX_ARRAY);
     
    45614559    ~QGLGlyphCache();
    45624560    QGLGlyphCoord *lookup(QFontEngine *, glyph_t);
    4563     void cacheGlyphs(QGLContext *, const QTextItemInt &, const QVarLengthArray<glyph_t> &);
     4561    void cacheGlyphs(QGLContext *, QFontEngine *, glyph_t *glyphs, int numGlyphs);
    45644562    void cleanCache();
    45654563    void allocTexture(int width, int height, GLuint texture);
     
    47134711#endif
    47144712
    4715 void QGLGlyphCache::cacheGlyphs(QGLContext *context, const QTextItemInt &ti,
    4716                                 const QVarLengthArray<glyph_t> &glyphs)
     4713void QGLGlyphCache::cacheGlyphs(QGLContext *context, QFontEngine *fontEngine,
     4714                                glyph_t *glyphs, int numGlyphs)
    47174715{
    47184716    QGLContextHash::const_iterator dev_it = qt_context_cache.constFind(context);
     
    47384736//         qDebug() << "new context" << context << font_cache;
    47394737        qt_context_cache.insert(context, font_cache);
    4740         if (context->isValid() && context->device()->devType() == QInternal::Widget) {
    4741             QWidget *widget = static_cast<QWidget *>(context->device());
    4742             connect(widget, SIGNAL(destroyed(QObject*)), SLOT(widgetDestroyed(QObject*)));
     4738        if (context->isValid()) {
     4739            if (context->device()->devType() == QInternal::Widget) {
     4740                QWidget *widget = static_cast<QWidget *>(context->device());
     4741                connect(widget, SIGNAL(destroyed(QObject*)), SLOT(widgetDestroyed(QObject*)));
     4742            }
    47434743            connect(QGLSignalProxy::instance(),
    47444744                    SIGNAL(aboutToDestroyContext(const QGLContext*)),
     
    47504750    Q_ASSERT(font_cache != 0);
    47514751
    4752     QGLFontGlyphHash::const_iterator cache_it = font_cache->constFind(ti.fontEngine);
     4752    QGLFontGlyphHash::const_iterator cache_it = font_cache->constFind(fontEngine);
    47534753    QGLGlyphHash *cache = 0;
    47544754    if (cache_it == font_cache->constEnd()) {
    47554755        cache = new QGLGlyphHash;
    4756         font_cache->insert(ti.fontEngine, cache);
    4757         connect(ti.fontEngine, SIGNAL(destroyed(QObject*)), SLOT(fontEngineDestroyed(QObject*)));
     4756        font_cache->insert(fontEngine, cache);
     4757        connect(fontEngine, SIGNAL(destroyed(QObject*)), SLOT(fontEngineDestroyed(QObject*)));
    47584758    } else {
    47594759        cache = cache_it.value();
     
    47624762
    47634763    quint64 font_key = (reinterpret_cast<quint64>(context_key ? context_key : context) << 32)
    4764                        | reinterpret_cast<quint64>(ti.fontEngine);
     4764                       | reinterpret_cast<quint64>(fontEngine);
    47654765    QGLFontTexHash::const_iterator it = qt_font_textures.constFind(font_key);
    47664766    QGLFontTexture *font_tex;
     
    47684768        GLuint font_texture;
    47694769        glGenTextures(1, &font_texture);
    4770         GLint tex_height = qt_next_power_of_two(qRound(ti.ascent.toReal() + ti.descent.toReal())+2);
     4770        GLint tex_height = qt_next_power_of_two(qRound(fontEngine->ascent().toReal() + fontEngine->descent().toReal())+2);
    47714771        GLint tex_width = qt_next_power_of_two(tex_height*30); // ###
    47724772        GLint max_tex_size;
     
    47904790    }
    47914791
    4792     for (int i=0; i< glyphs.size(); ++i) {
     4792    for (int i=0; i< numGlyphs; ++i) {
    47934793        QGLGlyphHash::const_iterator it = cache->constFind(glyphs[i]);
    47944794        if (it == cache->constEnd()) {
    47954795            // render new glyph and put it in the cache
    4796             glyph_metrics_t metrics = ti.fontEngine->boundingBox(glyphs[i]);
     4796            glyph_metrics_t metrics = fontEngine->boundingBox(glyphs[i]);
    47974797            int glyph_width = qRound(metrics.width.toReal())+2;
    4798             int glyph_height = qRound(ti.ascent.toReal() + ti.descent.toReal())+2;
     4798            int glyph_height = qRound(fontEngine->ascent().toReal() + fontEngine->descent().toReal())+2;
    47994799
    48004800            if (font_tex->x_offset + glyph_width + x_margin > font_tex->width) {
    4801                 int strip_height = qt_next_power_of_two(qRound(ti.ascent.toReal() + ti.descent.toReal())+2);
     4801                int strip_height = qt_next_power_of_two(qRound(fontEngine->ascent().toReal() + fontEngine->descent().toReal())+2);
    48024802                font_tex->x_offset = x_margin;
    48034803                font_tex->y_offset += strip_height;
     
    48324832            }
    48334833
    4834             QImage glyph_im(ti.fontEngine->alphaMapForGlyph(glyphs[i]));
     4834            QImage glyph_im(fontEngine->alphaMapForGlyph(glyphs[i]));
    48354835            glyph_im = glyph_im.convertToFormat(QImage::Format_Indexed8);
    48364836            glyph_width = glyph_im.width();
     
    49124912}
    49134913
     4914void QOpenGLPaintEngine::drawStaticTextItem(QStaticTextItem *textItem)
     4915{
     4916    Q_D(QOpenGLPaintEngine);
     4917
     4918    d->flushDrawQueue();
     4919
     4920    // make sure the glyphs we want to draw are in the cache
     4921    qt_glyph_cache()->cacheGlyphs(d->device->context(), textItem->fontEngine(), textItem->glyphs,
     4922                                  textItem->numGlyphs);
     4923
     4924    d->setGradientOps(Qt::SolidPattern, QRectF()); // turns off gradient ops
     4925    qt_glColor4ubv(d->pen_color);
     4926    glEnable(GL_TEXTURE_2D);
     4927
     4928#ifdef Q_WS_QWS
     4929    // XXX: it is necessary to disable alpha writes on GLES/embedded because we don't want
     4930    // text rendering to update the alpha in the window surface.
     4931    // XXX: This may not be needed as this behavior does seem to be caused by driver bug
     4932    glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_FALSE);
     4933#endif
     4934
     4935    // do the actual drawing
     4936    GLfloat vertexArray[4*2];
     4937    GLfloat texCoordArray[4*2];
     4938
     4939    glVertexPointer(2, GL_FLOAT, 0, vertexArray);
     4940    glTexCoordPointer(2, GL_FLOAT, 0, texCoordArray);
     4941
     4942    glEnableClientState(GL_VERTEX_ARRAY);
     4943    glEnableClientState(GL_TEXTURE_COORD_ARRAY);
     4944    bool antialias = !(textItem->fontEngine()->fontDef.styleStrategy & QFont::NoAntialias)
     4945                                   && (d->matrix.type() > QTransform::TxTranslate);
     4946    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, antialias ? GL_LINEAR : GL_NEAREST);
     4947    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, antialias ? GL_LINEAR : GL_NEAREST);
     4948
     4949    for (int i=0; i< textItem->numGlyphs; ++i) {
     4950        QGLGlyphCoord *g = qt_glyph_cache()->lookup(textItem->fontEngine(), textItem->glyphs[i]);
     4951
     4952        // we don't cache glyphs with no width/height
     4953        if (!g)
     4954            continue;
     4955
     4956        qreal x1, x2, y1, y2;
     4957        x1 = g->x;
     4958        y1 = g->y;
     4959        x2 = x1 + g->width;
     4960        y2 = y1 + g->height;
     4961
     4962        QPointF logical_pos((textItem->glyphPositions[i].x - g->x_offset).toReal(),
     4963                            (textItem->glyphPositions[i].y + g->y_offset).toReal());
     4964
     4965        qt_add_rect_to_array(QRectF(logical_pos, QSizeF(g->log_width, g->log_height)), vertexArray);
     4966        qt_add_texcoords_to_array(x1, y1, x2, y2, texCoordArray);
     4967
     4968        glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
     4969    }
     4970
     4971    glDisableClientState(GL_TEXTURE_COORD_ARRAY);
     4972    glDisableClientState(GL_VERTEX_ARRAY);
     4973
     4974    glDisable(GL_TEXTURE_2D);
     4975
     4976#ifdef Q_WS_QWS
     4977    // XXX: This may not be needed as this behavior does seem to be caused by driver bug
     4978    glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
     4979#endif
     4980
     4981}
     4982
    49144983void QOpenGLPaintEngine::drawTextItem(const QPointF &p, const QTextItem &textItem)
    49154984{
     
    49264995    }
    49274996
    4928     d->flushDrawQueue();
    4929 
    49304997    // add the glyphs used to the glyph texture cache
    49314998    QVarLengthArray<QFixedPoint> positions;
     
    49345001    ti.fontEngine->getGlyphPositions(ti.glyphs, matrix, ti.flags, glyphs, positions);
    49355002
    4936     // make sure the glyphs we want to draw are in the cache
    4937     qt_glyph_cache()->cacheGlyphs(d->device->context(), ti, glyphs);
    4938 
    4939     d->setGradientOps(Qt::SolidPattern, QRectF()); // turns off gradient ops
    4940     qt_glColor4ubv(d->pen_color);
    4941     glEnable(GL_TEXTURE_2D);
    4942 
    4943 #ifdef Q_WS_QWS
    4944     // XXX: it is necessary to disable alpha writes on GLES/embedded because we don't want
    4945     // text rendering to update the alpha in the window surface.
    4946     // XXX: This may not be needed as this behavior does seem to be caused by driver bug
    4947     glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_FALSE);
    4948 #endif
    4949 
    4950     // do the actual drawing
    4951     q_vertexType vertexArray[4*2];
    4952     q_vertexType texCoordArray[4*2];
    4953 
    4954     glVertexPointer(2, q_vertexTypeEnum, 0, vertexArray);
    4955     glTexCoordPointer(2, q_vertexTypeEnum, 0, texCoordArray);
    4956 
    4957     glEnableClientState(GL_VERTEX_ARRAY);
    4958     glEnableClientState(GL_TEXTURE_COORD_ARRAY);
    4959     bool antialias = !(ti.fontEngine->fontDef.styleStrategy & QFont::NoAntialias)
    4960                    && (d->matrix.type() > QTransform::TxTranslate);
    4961     glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, antialias ? GL_LINEAR : GL_NEAREST);
    4962     glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, antialias ? GL_LINEAR : GL_NEAREST);
    4963 
    4964     for (int i=0; i< glyphs.size(); ++i) {
    4965         QGLGlyphCoord *g = qt_glyph_cache()->lookup(ti.fontEngine, glyphs[i]);
    4966 
    4967         // we don't cache glyphs with no width/height
    4968         if (!g)
    4969             continue;
    4970 
    4971         qreal x1, x2, y1, y2;
    4972         x1 = g->x;
    4973         y1 = g->y;
    4974         x2 = x1 + g->width;
    4975         y2 = y1 + g->height;
    4976 
    4977         QPointF logical_pos((positions[i].x - g->x_offset).toReal(),
    4978                             (positions[i].y + g->y_offset).toReal());
    4979 
    4980         qt_add_rect_to_array(QRectF(logical_pos, QSizeF(g->log_width, g->log_height)), vertexArray);
    4981         qt_add_texcoords_to_array(x1, y1, x2, y2, texCoordArray);
    4982 
    4983         glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
    4984     }
    4985 
    4986     glDisableClientState(GL_TEXTURE_COORD_ARRAY);
    4987     glDisableClientState(GL_VERTEX_ARRAY);
    4988 
    4989     glDisable(GL_TEXTURE_2D);
    4990 
    4991 #ifdef Q_WS_QWS
    4992     // XXX: This may not be needed as this behavior does seem to be caused by driver bug
    4993     glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
    4994 #endif
     5003    {
     5004        QStaticTextItem staticTextItem;
     5005        staticTextItem.chars = const_cast<QChar *>(ti.chars);
     5006        staticTextItem.setFontEngine(ti.fontEngine);
     5007        staticTextItem.glyphs = glyphs.data();
     5008        staticTextItem.numChars = ti.num_chars;
     5009        staticTextItem.numGlyphs = glyphs.size();
     5010        staticTextItem.glyphPositions = positions.data();
     5011        drawStaticTextItem(&staticTextItem);
     5012    }
     5013
    49955014}
    49965015
     
    51665185    Q_UNUSED(maskOffset);
    51675186#else
    5168     q_vertexType vertexArray[8];
     5187    GLfloat vertexArray[8];
    51695188    qt_add_rect_to_array(rect, vertexArray);
    51705189
     
    51745193
    51755194
    5176 void QOpenGLPaintEnginePrivate::composite(GLuint primitive, const q_vertexType *vertexArray, int vertexCount, const QPoint &maskOffset)
     5195void QOpenGLPaintEnginePrivate::composite(GLuint primitive, const GLfloat *vertexArray, int vertexCount, const QPoint &maskOffset)
    51775196{
    51785197#ifdef QT_OPENGL_ES
     
    51975216
    51985217        for (int i = 0; i < vertexCount; ++i) {
    5199             qreal x = vt2f(vertexArray[2 * i]);
    5200             qreal y = vt2f(vertexArray[2 * i + 1]);
     5218            qreal x = vertexArray[2 * i];
     5219            qreal y = vertexArray[2 * i + 1];
    52015220
    52025221            qreal tx, ty;
     
    52575276
    52585277    glEnableClientState(GL_VERTEX_ARRAY);
    5259     glVertexPointer(2, q_vertexTypeEnum, 0, vertexArray);
     5278    glVertexPointer(2, GL_FLOAT, 0, vertexArray);
    52605279    glEnable(GL_FRAGMENT_PROGRAM_ARB);
    52615280    GLuint program = qt_gl_program_cache()->getProgram(device->context(),
Note: See TracChangeset for help on using the changeset viewer.