diff options
author | Rhys Weatherley <rhys.weatherley@nokia.com> | 2010-01-29 00:48:15 (GMT) |
---|---|---|
committer | Rhys Weatherley <rhys.weatherley@nokia.com> | 2010-02-04 01:06:08 (GMT) |
commit | ad47f9cee2cd47ef566f86ca20f54e3f6da54070 (patch) | |
tree | 2c77b9ee200da679ffabea192395ec8fc4509b43 /src/opengl/qpaintengine_opengl.cpp | |
parent | 35988b6d5d14388004a4b51df1355d3d3a97d145 (diff) | |
download | Qt-ad47f9cee2cd47ef566f86ca20f54e3f6da54070.zip Qt-ad47f9cee2cd47ef566f86ca20f54e3f6da54070.tar.gz Qt-ad47f9cee2cd47ef566f86ca20f54e3f6da54070.tar.bz2 |
Remove obsolete OpenGL/ES CommonLite (fixed-point) support
Task-number: QTBUG-7683
Reviewed-by: Tom Cooksey
Diffstat (limited to 'src/opengl/qpaintengine_opengl.cpp')
-rw-r--r-- | src/opengl/qpaintengine_opengl.cpp | 197 |
1 files changed, 95 insertions, 102 deletions
diff --git a/src/opengl/qpaintengine_opengl.cpp b/src/opengl/qpaintengine_opengl.cpp index 57918d0..3845e43 100644 --- a/src/opengl/qpaintengine_opengl.cpp +++ b/src/opengl/qpaintengine_opengl.cpp @@ -71,10 +71,6 @@ #include "private/qwsmanager_p.h" #endif -#ifdef QT_OPENGL_ES_1_CL -#include "qgl_cl_p.h" -#endif - #define QGL_FUNC_CONTEXT QGLContext *ctx = const_cast<QGLContext *>(device->context()); #include <stdlib.h> @@ -780,7 +776,7 @@ public: void drawOffscreenPath(const QPainterPath &path); void composite(const QRectF &rect, const QPoint &maskOffset = QPoint()); - void composite(GLuint primitive, const q_vertexType *vertexArray, int vertexCount, const QPoint &maskOffset = QPoint()); + void composite(GLuint primitive, const GLfloat *vertexArray, int vertexCount, const QPoint &maskOffset = QPoint()); bool createFragmentPrograms(); void deleteFragmentPrograms(); @@ -1787,7 +1783,7 @@ class QOpenGLTrapezoidToArrayTessellator : public QOpenGLTessellator public: QOpenGLTrapezoidToArrayTessellator() : vertices(0), allocated(0), size(0) {} ~QOpenGLTrapezoidToArrayTessellator() { free(vertices); } - q_vertexType *vertices; + GLfloat *vertices; int allocated; int size; QRectF bounds; @@ -1808,36 +1804,36 @@ void QOpenGLTrapezoidToArrayTessellator::addTrap(const Trapezoid &trap) if (size > allocated - 12) { #endif allocated = qMax(2*allocated, 512); - vertices = (q_vertexType *)realloc(vertices, allocated * sizeof(q_vertexType)); + vertices = (GLfloat *)realloc(vertices, allocated * sizeof(GLfloat)); } QGLTrapezoid t = toGLTrapezoid(trap); #ifndef QT_OPENGL_ES - vertices[size++] = f2vt(t.topLeftX); - vertices[size++] = f2vt(t.top); - vertices[size++] = f2vt(t.topRightX); - vertices[size++] = f2vt(t.top); - vertices[size++] = f2vt(t.bottomRightX); - vertices[size++] = f2vt(t.bottom); - vertices[size++] = f2vt(t.bottomLeftX); - vertices[size++] = f2vt(t.bottom); + vertices[size++] = t.topLeftX; + vertices[size++] = t.top; + vertices[size++] = t.topRightX; + vertices[size++] = t.top; + vertices[size++] = t.bottomRightX; + vertices[size++] = t.bottom; + vertices[size++] = t.bottomLeftX; + vertices[size++] = t.bottom; #else // First triangle - vertices[size++] = f2vt(t.topLeftX); - vertices[size++] = f2vt(t.top); - vertices[size++] = f2vt(t.topRightX); - vertices[size++] = f2vt(t.top); - vertices[size++] = f2vt(t.bottomRightX); - vertices[size++] = f2vt(t.bottom); + vertices[size++] = t.topLeftX; + vertices[size++] = t.top; + vertices[size++] = t.topRightX; + vertices[size++] = t.top; + vertices[size++] = t.bottomRightX; + vertices[size++] = t.bottom; // Second triangle - vertices[size++] = f2vt(t.bottomLeftX); - vertices[size++] = f2vt(t.bottom); - vertices[size++] = f2vt(t.topLeftX); - vertices[size++] = f2vt(t.top); - vertices[size++] = f2vt(t.bottomRightX); - vertices[size++] = f2vt(t.bottom); + vertices[size++] = t.bottomLeftX; + vertices[size++] = t.bottom; + vertices[size++] = t.topLeftX; + vertices[size++] = t.top; + vertices[size++] = t.bottomRightX; + vertices[size++] = t.bottom; #endif } @@ -1864,7 +1860,7 @@ void QOpenGLPaintEnginePrivate::fillPolygon_dev(const QPointF *polygonPoints, in if (use_fragment_programs && !(fast_style && has_fast_composition_mode)) { composite(geometry_mode, tessellator.vertices, tessellator.size / 2); } else { - glVertexPointer(2, q_vertexTypeEnum, 0, tessellator.vertices); + glVertexPointer(2, GL_FLOAT, 0, tessellator.vertices); glEnableClientState(GL_VERTEX_ARRAY); glDrawArrays(geometry_mode, 0, tessellator.size/2); glDisableClientState(GL_VERTEX_ARRAY); @@ -2265,7 +2261,7 @@ void QOpenGLPaintEnginePrivate::updateDepthClip() return; } -#if defined(QT_OPENGL_ES_1) || defined(QT_OPENGL_ES_2) || defined(QT_OPENGL_ES_1_CL) +#if defined(QT_OPENGL_ES_1) || defined(QT_OPENGL_ES_2) glClearDepthf(0.0f); #else glClearDepth(0.0f); @@ -2281,12 +2277,12 @@ void QOpenGLPaintEnginePrivate::updateDepthClip() const QVector<QRect> rects = q->state()->clipEnabled ? q->state()->clipRegion.rects() : q->systemClip().rects(); // rectangle count * 2 (triangles) * vertex count * component count (Z omitted) - QDataBuffer<q_vertexType> clipVertex(rects.size()*2*3*2); + QDataBuffer<GLfloat> clipVertex(rects.size()*2*3*2); for (int i = 0; i < rects.size(); ++i) { - q_vertexType x = i2vt(rects.at(i).left()); - q_vertexType w = i2vt(rects.at(i).width()); - q_vertexType h = i2vt(rects.at(i).height()); - q_vertexType y = i2vt(rects.at(i).top()); + GLfloat x = GLfloat(rects.at(i).left()); + GLfloat w = GLfloat(rects.at(i).width()); + GLfloat h = GLfloat(rects.at(i).height()); + GLfloat y = GLfloat(rects.at(i).top()); // First triangle clipVertex.add(x); @@ -2314,7 +2310,7 @@ void QOpenGLPaintEnginePrivate::updateDepthClip() glLoadIdentity(); glEnableClientState(GL_VERTEX_ARRAY); - glVertexPointer(2, q_vertexTypeEnum, 0, clipVertex.data()); + glVertexPointer(2, GL_FLOAT, 0, clipVertex.data()); glDrawArrays(GL_TRIANGLES, 0, rects.size()*2*3); glDisableClientState(GL_VERTEX_ARRAY); @@ -3106,8 +3102,8 @@ QGLTrapezoidMaskGenerator::QGLTrapezoidMaskGenerator(const QPainterPath &path, c { } -extern void qt_add_rect_to_array(const QRectF &r, q_vertexType *array); -extern void qt_add_texcoords_to_array(qreal x1, qreal y1, qreal x2, qreal y2, q_vertexType *array); +extern void qt_add_rect_to_array(const QRectF &r, GLfloat *array); +extern void qt_add_texcoords_to_array(qreal x1, qreal y1, qreal x2, qreal y2, GLfloat *array); void QGLTrapezoidMaskGenerator::drawMask(const QRect &rect) { @@ -3138,7 +3134,7 @@ void QGLTrapezoidMaskGenerator::drawMask(const QRect &rect) // clear mask glBlendFunc(GL_ZERO, GL_ZERO); // clear - glVertexPointer(2, q_vertexTypeEnum, 0, vertexArray); + glVertexPointer(2, GL_FLOAT, 0, vertexArray); glEnableClientState(GL_VERTEX_ARRAY); glDrawArrays(GL_TRIANGLE_FAN, 0, 4); glDisableClientState(GL_VERTEX_ARRAY); @@ -3369,7 +3365,7 @@ void QGLEllipseMaskGenerator::drawMask(const QRect &rect) glProgramLocalParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, maskVariableLocations[VAR_ELLIPSE_OFFSET], ellipse_offset); glEnableClientState(GL_VERTEX_ARRAY); - glVertexPointer(2, q_vertexTypeEnum, 0, vertexArray); + glVertexPointer(2, GL_FLOAT, 0, vertexArray); glDrawArrays(GL_TRIANGLE_FAN, 0, 4); glDisableClientState(GL_VERTEX_ARRAY); glDisable(GL_FRAGMENT_PROGRAM_ARB); @@ -3399,7 +3395,7 @@ void QOpenGLPaintEnginePrivate::drawFastRect(const QRectF &r) Q_Q(QOpenGLPaintEngine); DEBUG_ONCE_STR("QOpenGLPaintEngine::drawRects(): drawing fast rect"); - q_vertexType vertexArray[10]; + GLfloat vertexArray[10]; qt_add_rect_to_array(r, vertexArray); if (has_pen) @@ -3420,7 +3416,7 @@ void QOpenGLPaintEnginePrivate::drawFastRect(const QRectF &r) if (fast_style && has_fast_composition_mode) { glEnableClientState(GL_VERTEX_ARRAY); - glVertexPointer(2, q_vertexTypeEnum, 0, vertexArray); + glVertexPointer(2, GL_FLOAT, 0, vertexArray); glDrawArrays(GL_TRIANGLE_FAN, 0, 4); glDisableClientState(GL_VERTEX_ARRAY); } else { @@ -3439,7 +3435,7 @@ void QOpenGLPaintEnginePrivate::drawFastRect(const QRectF &r) vertexArray[8] = vertexArray[0]; vertexArray[9] = vertexArray[1]; - glVertexPointer(2, q_vertexTypeEnum, 0, vertexArray); + glVertexPointer(2, GL_FLOAT, 0, vertexArray); glEnableClientState(GL_VERTEX_ARRAY); glDrawArrays(GL_LINE_STRIP, 0, 5); glDisableClientState(GL_VERTEX_ARRAY); @@ -3546,7 +3542,7 @@ void QOpenGLPaintEngine::drawRects(const QRectF *rects, int rectCount) } } -static void addQuadAsTriangle(q_vertexType *quad, q_vertexType *triangle) +static void addQuadAsTriangle(GLfloat *quad, GLfloat *triangle) { triangle[0] = quad[0]; triangle[1] = quad[1]; @@ -3607,7 +3603,7 @@ void QOpenGLPaintEngine::drawPoints(const QPointF *points, int pointCount) d->flushDrawQueue(); if (d->has_fast_pen) { - QVarLengthArray<q_vertexType> vertexArray(6 * pointCount); + QVarLengthArray<GLfloat> vertexArray(6 * pointCount); glMatrixMode(GL_MODELVIEW); glPushMatrix(); @@ -3617,25 +3613,22 @@ void QOpenGLPaintEngine::drawPoints(const QPointF *points, int pointCount) for (int i = 0; i < pointCount; ++i) { QPointF mapped = d->matrix.map(points[i]); - qreal xf = qRound(mapped.x()); - qreal yf = qRound(mapped.y()); - - q_vertexType x = f2vt(xf); - q_vertexType y = f2vt(yf); + GLfloat x = GLfloat(qRound(mapped.x())); + GLfloat y = GLfloat(qRound(mapped.y())); vertexArray[j++] = x; - vertexArray[j++] = y - f2vt(0.5); + vertexArray[j++] = y - 0.5f; - vertexArray[j++] = x + f2vt(1.5); - vertexArray[j++] = y + f2vt(1.0); + vertexArray[j++] = x + 1.5f; + vertexArray[j++] = y + 1.0f; vertexArray[j++] = x; - vertexArray[j++] = y + f2vt(1.0); + vertexArray[j++] = y + 1.0f; } glEnableClientState(GL_VERTEX_ARRAY); - glVertexPointer(2, q_vertexTypeEnum, 0, vertexArray.constData()); + glVertexPointer(2, GL_FLOAT, 0, vertexArray.constData()); glDrawArrays(GL_TRIANGLES, 0, pointCount*3); glDisableClientState(GL_VERTEX_ARRAY); @@ -3652,7 +3645,7 @@ void QOpenGLPaintEngine::drawPoints(const QPointF *points, int pointCount) } else { Q_ASSERT(sizeof(QPointF) == 8); - glVertexPointer(2, q_vertexTypeEnum, 0, vertexArray); + glVertexPointer(2, GL_FLOAT, 0, vertexArray); } glEnableClientState(GL_VERTEX_ARRAY); @@ -3720,47 +3713,47 @@ void QOpenGLPaintEngine::drawLines(const QLineF *lines, int lineCount) } } - q_vertexType endCap = f2vt(d->cpen.capStyle() == Qt::FlatCap ? 0 : 0.5); + GLfloat endCap = d->cpen.capStyle() == Qt::FlatCap ? 0.0f : 0.5f; if (useRects) { - QVarLengthArray<q_vertexType> vertexArray(12 * lineCount); + QVarLengthArray<GLfloat> vertexArray(12 * lineCount); - q_vertexType quad[8]; + GLfloat quad[8]; for (int i = 0; i < lineCount; ++i) { - q_vertexType x1 = f2vt(lines[i].x1()); - q_vertexType x2 = f2vt(lines[i].x2()); - q_vertexType y1 = f2vt(lines[i].y1()); - q_vertexType y2 = f2vt(lines[i].y2()); + GLfloat x1 = lines[i].x1(); + GLfloat x2 = lines[i].x2(); + GLfloat y1 = lines[i].y1(); + GLfloat y2 = lines[i].y2(); if (x1 == x2) { if (y1 > y2) qSwap(y1, y2); - quad[0] = x1 - f2vt(0.5); + quad[0] = x1 - 0.5f; quad[1] = y1 - endCap; - quad[2] = x1 + f2vt(0.5); + quad[2] = x1 + 0.5f; quad[3] = y1 - endCap; - quad[4] = x1 + f2vt(0.5); + quad[4] = x1 + 0.5f; quad[5] = y2 + endCap; - quad[6] = x1 - f2vt(0.5); + quad[6] = x1 - 0.5f; quad[7] = y2 + endCap; } else { if (x1 > x2) qSwap(x1, x2); quad[0] = x1 - endCap; - quad[1] = y1 + f2vt(0.5); + quad[1] = y1 + 0.5f; quad[2] = x1 - endCap; - quad[3] = y1 - f2vt(0.5); + quad[3] = y1 - 0.5f; quad[4] = x2 + endCap; - quad[5] = y1 - f2vt(0.5); + quad[5] = y1 - 0.5f; quad[6] = x2 + endCap; - quad[7] = y1 + f2vt(0.5); + quad[7] = y1 + 0.5f; } addQuadAsTriangle(quad, &vertexArray[12*i]); @@ -3768,26 +3761,26 @@ void QOpenGLPaintEngine::drawLines(const QLineF *lines, int lineCount) glEnableClientState(GL_VERTEX_ARRAY); - glVertexPointer(2, q_vertexTypeEnum, 0, vertexArray.constData()); + glVertexPointer(2, GL_FLOAT, 0, vertexArray.constData()); glDrawArrays(GL_TRIANGLES, 0, lineCount*6); glDisableClientState(GL_VERTEX_ARRAY); } else { - QVarLengthArray<q_vertexType> vertexArray(4 * lineCount); + QVarLengthArray<GLfloat> vertexArray(4 * lineCount); for (int i = 0; i < lineCount; ++i) { const QPointF a = lines[i].p1(); - vertexArray[4*i] = f2vt(lines[i].x1()); - vertexArray[4*i+1] = f2vt(lines[i].y1()); - vertexArray[4*i+2] = f2vt(lines[i].x2()); - vertexArray[4*i+3] = f2vt(lines[i].y2()); + vertexArray[4*i] = lines[i].x1(); + vertexArray[4*i+1] = lines[i].y1(); + vertexArray[4*i+2] = lines[i].x2(); + vertexArray[4*i+3] = lines[i].y2(); } glEnableClientState(GL_VERTEX_ARRAY); - glVertexPointer(2, q_vertexTypeEnum, 0, vertexArray.constData()); + glVertexPointer(2, GL_FLOAT, 0, vertexArray.constData()); glDrawArrays(GL_LINES, 0, lineCount*2); - glVertexPointer(2, q_vertexTypeEnum, 4*sizeof(q_vertexType), vertexArray.constData() + 2); + glVertexPointer(2, GL_FLOAT, 4*sizeof(GLfloat), vertexArray.constData() + 2); glDrawArrays(GL_POINTS, 0, lineCount); glDisableClientState(GL_VERTEX_ARRAY); @@ -3874,7 +3867,7 @@ void QOpenGLPaintEngine::drawPolygon(const QPointF *points, int pointCount, Poly } else { Q_ASSERT(sizeof(QPointF) == 8); - glVertexPointer(2, q_vertexTypeEnum, 0, vertexArray); + glVertexPointer(2, GL_FLOAT, 0, vertexArray); } glEnableClientState(GL_VERTEX_ARRAY); @@ -3893,12 +3886,12 @@ void QOpenGLPaintEngine::drawPolygon(const QPointF *points, int pointCount, Poly if (d->has_pen) { if (d->has_fast_pen && !d->high_quality_antialiasing) { d->setGradientOps(d->cpen.brush(), bounds); - QVarLengthArray<q_vertexType> vertexArray(pointCount*2 + 2); - glVertexPointer(2, q_vertexTypeEnum, 0, vertexArray.constData()); + QVarLengthArray<GLfloat> vertexArray(pointCount*2 + 2); + glVertexPointer(2, GL_FLOAT, 0, vertexArray.constData()); int i; for (i=0; i<pointCount; ++i) { - vertexArray[i*2] = f2vt(points[i].x()); - vertexArray[i*2+1] = f2vt(points[i].y()); + vertexArray[i*2] = points[i].x(); + vertexArray[i*2+1] = points[i].y(); } glEnableClientState(GL_VERTEX_ARRAY); @@ -4074,7 +4067,7 @@ void QOpenGLPaintEnginePrivate::strokePathFastPen(const QPainterPath &path, bool switch (e.type) { case QPainterPath::MoveToElement: if (i != 0) { - glVertexPointer(2, q_vertexTypeEnum, 0, tess_points.data()); + glVertexPointer(2, GL_FLOAT, 0, tess_points.data()); glDrawArrays(GL_LINE_STRIP, 0, tess_points.size()); tess_points.reset(); } @@ -4124,7 +4117,7 @@ void QOpenGLPaintEnginePrivate::strokePathFastPen(const QPainterPath &path, bool break; } // end of switch } - glVertexPointer(2, q_vertexTypeEnum, 0, tess_points.data()); + glVertexPointer(2, GL_FLOAT, 0, tess_points.data()); glDrawArrays(GL_LINE_STRIP, 0, tess_points.size()); glDisableClientState(GL_VERTEX_ARRAY); #endif @@ -4391,8 +4384,8 @@ void QOpenGLPaintEngine::drawTiledPixmap(const QRectF &r, const QPixmap &pm, con glRotatef(180.0, 0.0, 0.0, 1.0); } - q_vertexType vertexArray[4*2]; - q_vertexType texCoordArray[4*2]; + GLfloat vertexArray[4*2]; + GLfloat texCoordArray[4*2]; double offset_x = offset.x() / pm.width(); double offset_y = offset.y() / pm.height(); @@ -4401,8 +4394,8 @@ void QOpenGLPaintEngine::drawTiledPixmap(const QRectF &r, const QPixmap &pm, con qt_add_texcoords_to_array(offset_x, offset_y, tc_w + offset_x, tc_h + offset_y, texCoordArray); - glVertexPointer(2, q_vertexTypeEnum, 0, vertexArray); - glTexCoordPointer(2, q_vertexTypeEnum, 0, texCoordArray); + glVertexPointer(2, GL_FLOAT, 0, vertexArray); + glTexCoordPointer(2, GL_FLOAT, 0, texCoordArray); glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); @@ -4483,14 +4476,14 @@ void QOpenGLPaintEngine::drawTextureRect(int tx_width, int tx_height, const QRec y2 = sr.y(); } - q_vertexType vertexArray[4*2]; - q_vertexType texCoordArray[4*2]; + GLfloat vertexArray[4*2]; + GLfloat texCoordArray[4*2]; qt_add_rect_to_array(r, vertexArray); qt_add_texcoords_to_array(x1, y2, x2, y1, texCoordArray); - glVertexPointer(2, q_vertexTypeEnum, 0, vertexArray); - glTexCoordPointer(2, q_vertexTypeEnum, 0, texCoordArray); + glVertexPointer(2, GL_FLOAT, 0, vertexArray); + glTexCoordPointer(2, GL_FLOAT, 0, texCoordArray); glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); @@ -4943,11 +4936,11 @@ void QOpenGLPaintEngine::drawTextItem(const QPointF &p, const QTextItem &textIte #endif // do the actual drawing - q_vertexType vertexArray[4*2]; - q_vertexType texCoordArray[4*2]; + GLfloat vertexArray[4*2]; + GLfloat texCoordArray[4*2]; - glVertexPointer(2, q_vertexTypeEnum, 0, vertexArray); - glTexCoordPointer(2, q_vertexTypeEnum, 0, texCoordArray); + glVertexPointer(2, GL_FLOAT, 0, vertexArray); + glTexCoordPointer(2, GL_FLOAT, 0, texCoordArray); glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); @@ -5160,7 +5153,7 @@ void QOpenGLPaintEnginePrivate::composite(const QRectF &rect, const QPoint &mask Q_UNUSED(rect); Q_UNUSED(maskOffset); #else - q_vertexType vertexArray[8]; + GLfloat vertexArray[8]; qt_add_rect_to_array(rect, vertexArray); composite(GL_TRIANGLE_FAN, vertexArray, 4, maskOffset); @@ -5168,7 +5161,7 @@ void QOpenGLPaintEnginePrivate::composite(const QRectF &rect, const QPoint &mask } -void QOpenGLPaintEnginePrivate::composite(GLuint primitive, const q_vertexType *vertexArray, int vertexCount, const QPoint &maskOffset) +void QOpenGLPaintEnginePrivate::composite(GLuint primitive, const GLfloat *vertexArray, int vertexCount, const QPoint &maskOffset) { #ifdef QT_OPENGL_ES Q_UNUSED(primitive); @@ -5191,8 +5184,8 @@ void QOpenGLPaintEnginePrivate::composite(GLuint primitive, const q_vertexType * qreal minX = 1e9, minY = 1e9, maxX = -1e9, maxY = -1e9; for (int i = 0; i < vertexCount; ++i) { - qreal x = vt2f(vertexArray[2 * i]); - qreal y = vt2f(vertexArray[2 * i + 1]); + qreal x = vertexArray[2 * i]; + qreal y = vertexArray[2 * i + 1]; qreal tx, ty; matrix.map(x, y, &tx, &ty); @@ -5251,7 +5244,7 @@ void QOpenGLPaintEnginePrivate::composite(GLuint primitive, const q_vertexType * } glEnableClientState(GL_VERTEX_ARRAY); - glVertexPointer(2, q_vertexTypeEnum, 0, vertexArray); + glVertexPointer(2, GL_FLOAT, 0, vertexArray); glEnable(GL_FRAGMENT_PROGRAM_ARB); GLuint program = qt_gl_program_cache()->getProgram(device->context(), fragment_brush, |