From 7b7e776d9042fa34a17db3189af99efb7494d070 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Tue, 8 Sep 2009 11:36:52 +1000 Subject: Make the matrix and viewport logic in renderText() a bit better The original renderText() was using the highly unportable (to OpenGL/ES) glGetDoublev() and glGetIntegerv() functions. Reviewed-by: Sarah Smith --- src/opengl/qgl.cpp | 187 +++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 137 insertions(+), 50 deletions(-) diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 9e0c5f8..49dc8a2 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -63,6 +63,7 @@ #include "qpixmap.h" #include "qimage.h" +#include "qmatrix4x4.h" #include "qgl_p.h" #if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) @@ -251,46 +252,24 @@ QGLSignalProxy *QGLSignalProxy::instance() \sa QGLContext, QGLWidget */ -static inline void transform_point(GLdouble out[4], const GLdouble m[16], const GLdouble in[4]) +static inline void qgluProject + (qreal objx, qreal objy, qreal objz, + const QMatrix4x4& model, const QMatrix4x4& proj, const GLint viewport[4], + GLfloat *winx, GLfloat *winy, GLfloat* winz) { -#define M(row,col) m[col*4+row] - out[0] = - M(0, 0) * in[0] + M(0, 1) * in[1] + M(0, 2) * in[2] + M(0, 3) * in[3]; - out[1] = - M(1, 0) * in[0] + M(1, 1) * in[1] + M(1, 2) * in[2] + M(1, 3) * in[3]; - out[2] = - M(2, 0) * in[0] + M(2, 1) * in[1] + M(2, 2) * in[2] + M(2, 3) * in[3]; - out[3] = - M(3, 0) * in[0] + M(3, 1) * in[1] + M(3, 2) * in[2] + M(3, 3) * in[3]; -#undef M -} - -static inline GLint qgluProject(GLdouble objx, GLdouble objy, GLdouble objz, - const GLdouble model[16], const GLdouble proj[16], - const GLint viewport[4], - GLdouble * winx, GLdouble * winy, GLdouble * winz) -{ - GLdouble in[4], out[4]; - - in[0] = objx; - in[1] = objy; - in[2] = objz; - in[3] = 1.0; - transform_point(out, model, in); - transform_point(in, proj, out); + QVector4D transformed = proj.map(model.map(QVector4D(objx, objy, objz, 1))); - if (in[3] == 0.0) - return GL_FALSE; + qreal w = transformed.w(); + if (w == 0.0f) + w = 1.0f; // Just in case! - in[0] /= in[3]; - in[1] /= in[3]; - in[2] /= in[3]; + qreal x = transformed.x() / w; + qreal y = transformed.y() / w; - *winx = viewport[0] + (1 + in[0]) * viewport[2] / 2; - *winy = viewport[1] + (1 + in[1]) * viewport[3] / 2; + *winx = viewport[0] + (1 + x) * viewport[2] / 2; + *winy = viewport[1] + (1 + y) * viewport[3] / 2; - *winz = (1 + in[2]) / 2; - return GL_TRUE; + *winz = (1 + transformed.z() / w) / 2; } /*! @@ -4113,6 +4092,30 @@ static void qt_gl_draw_text(QPainter *p, int x, int y, const QString &str, p->setFont(old_font); } +#if defined(GL_OES_VERSION_1_0) && !defined(GL_OES_VERSION_1_1) + +// OpenGL/ES 1.0 cannot fetch viewports from the GL server. +// We therefore create a default viewport to simulate the fetch. + +static void qt_gl_get_viewport(GLint *view, int deviceWidth, int deviceHeight) +{ + view[0] = 0; + view[1] = 0; + view[2] = deviceWidth; + view[3] = deviceHeight; +} + +#else + +static void qt_gl_get_viewport(GLint *view, int deviceWidth, int deviceHeight) +{ + Q_UNUSED(deviceWidth); + Q_UNUSED(deviceHeight); + glGetIntegerv(GL_VIEWPORT, view); +} + +#endif + /*! Renders the string \a str into the GL context of this widget. @@ -4138,13 +4141,19 @@ void QGLWidget::renderText(int x, int y, const QString &str, const QFont &font, GLint view[4]; #ifndef QT_OPENGL_ES bool use_scissor_testing = glIsEnabled(GL_SCISSOR_TEST); - if (!use_scissor_testing) - glGetIntegerv(GL_VIEWPORT, &view[0]); #else bool use_scissor_testing = false; #endif int width = d->glcx->device()->width(); int height = d->glcx->device()->height(); + if (!use_scissor_testing) { + qt_gl_get_viewport(&view[0], width, height); + } else { + view[0] = 0; + view[1] = 0; + view[2] = width; + view[3] = height; + } bool auto_swap = autoBufferSwap(); QPaintEngine *engine = paintEngine(); @@ -4216,12 +4225,95 @@ void QGLWidget::renderText(int x, int y, const QString &str, const QFont &font, #endif } +#if defined(QT_OPENGL_ES_2) || \ + (defined(GL_OES_VERSION_1_0) && !defined(GL_OES_VERSION_1_1)) + +// OpenGL/ES 1.0 cannot fetch matrices from the GL server. +// OpenGL/ES 2.0 does not use fixed-function matrices at all. +// We therefore create some default matrices to simulate the fetch. + +static QMatrix4x4 qt_gl_projection_matrix(int deviceWidth, int deviceHeight) +{ + QMatrix4x4 m; + m.ortho(0, deviceWidth, deviceHeight, 0, -1, 1); + return m; +} + +static QMatrix4x4 qt_gl_modelview_matrix(void) +{ + return QMatrix4x4(); +} + +#else // !QT_OPENGL_ES_2 + +static QMatrix4x4 qt_gl_fetch_matrix(GLenum type) +{ + QMatrix4x4 matrix; +#if defined(QT_OPENGL_ES_1_CL) + GLfixed mat[16]; + glGetFixedv(type, mat); + qreal *m = matrix.data(); + for (int index = 0; index < 16; ++index) + m[index] = vt2f(mat[index]); +#else + if (sizeof(qreal) == sizeof(GLfloat)) { + glGetFloatv(type, reinterpret_cast(matrix.data())); +#if !defined(QT_OPENGL_ES) + } else if (sizeof(qreal) == sizeof(GLdouble)) { + glGetDoublev(type, reinterpret_cast(matrix.data())); +#endif + } else { + GLfloat mat[16]; + glGetFloatv(type, mat); + qreal *m = matrix.data(); + for (int index = 0; index < 16; ++index) + m[index] = mat[index]; + } +#endif + matrix.inferSpecialType(); + return matrix; +} + +static QMatrix4x4 qt_gl_projection_matrix(int deviceWidth, int deviceHeight) +{ + Q_UNUSED(deviceWidth); + Q_UNUSED(deviceHeight); + return qt_gl_fetch_matrix(GL_PROJECTION_MATRIX); +} + +static QMatrix4x4 qt_gl_modelview_matrix(void) +{ + return qt_gl_fetch_matrix(GL_MODELVIEW_MATRIX); +} + +#endif // !QT_OPENGL_ES_2 + /*! \overload \a x, \a y and \a z are specified in scene or object coordinates relative to the currently set projection and model matrices. This can be useful if you want to annotate models with text labels and have the labels move with the model as it is rotated etc. + + This function fetches the modelview matrix, projection matrix, and + current viewport from the GL server to map (\a x, \a y, \a z) + into window co-ordinates. This entails several round-trips to the GL + server which will probably impact performance. + + Fetching the modelview and projection matrices is not supported + under OpenGL/ES 1.0 and OpenGL/ES 2.0 so a default orthographic + projection will be used to map the co-ordinates on those platforms. + This probably will not give results that are consistent with desktop + and OpenGL/ES 1.1 systems. Fetching the viewport is not supported + under OpenGL/ES 1.0, so the full device will be used as the viewport. + + This function is deprecated because it is non-portable. It is + recommended that the application map the co-ordinates itself using + application-provided matrix data that reflects the desired + transformation. Then use QPainter::drawText() to draw \a str at + the mapped position. + + \sa QMatrix4x4 */ void QGLWidget::renderText(double x, double y, double z, const QString &str, const QFont &font, int) { @@ -4233,16 +4325,15 @@ void QGLWidget::renderText(double x, double y, double z, const QString &str, con int width = d->glcx->device()->width(); int height = d->glcx->device()->height(); - GLdouble model[4][4], proj[4][4]; + + QMatrix4x4 model = qt_gl_modelview_matrix(); + QMatrix4x4 proj = qt_gl_projection_matrix(width, height); GLint view[4]; -#ifndef QT_OPENGL_ES - glGetDoublev(GL_MODELVIEW_MATRIX, &model[0][0]); - glGetDoublev(GL_PROJECTION_MATRIX, &proj[0][0]); - glGetIntegerv(GL_VIEWPORT, &view[0]); -#endif - GLdouble win_x = 0, win_y = 0, win_z = 0; - qgluProject(x, y, z, &model[0][0], &proj[0][0], &view[0], - &win_x, &win_y, &win_z); + qt_gl_get_viewport(view, width, height); + + GLfloat win_x = 0, win_y = 0, win_z = 0; + qgluProject(qreal(x), qreal(y), qreal(z), + model, proj, &view[0], &win_x, &win_y, &win_z); win_y = height - win_y; // y is inverted QPaintEngine *engine = paintEngine(); @@ -4295,11 +4386,7 @@ void QGLWidget::renderText(double x, double y, double z, const QString &str, con glEnable(GL_ALPHA_TEST); if (use_depth_testing) glEnable(GL_DEPTH_TEST); -#ifndef QT_OPENGL_ES - glTranslated(0, 0, -win_z); -#else glTranslatef(0, 0, -win_z); -#endif #endif // !defined(QT_OPENGL_ES_2) qt_gl_draw_text(p, qRound(win_x), qRound(win_y), str, font); -- cgit v0.12 From ea19e075c7eb34a6a7979fa3cfb2dcc838d33c11 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Tue, 8 Sep 2009 11:43:41 +1000 Subject: Texture format must be GL_RGB when pixel type is GL_UNSIGNED_SHORT_5_6_5 QImage::Format_RGB16 textures were broken on some OpenGL/ES 1.1 systems because the "format" was set to GL_RGBA and the "texture_format" was set to GL_RGB, with a pixel type of GL_UNSIGNED_SHORT_5_6_5. OpenGL/ES 1.1, ES 2.0, and desktop GL all require the two format parameters to glTexImage2D() to be GL_RGB if the pixel type is GL_UNSIGNED_SHORT_5_6_5. Reviewed-by: Sarah Smith --- src/opengl/qgl.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 49dc8a2..087902b 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -2052,6 +2052,7 @@ QGLTexture* QGLContextPrivate::bindTexture(const QImage &image, GLenum target, G case QImage::Format_RGB16: pixel_type = GL_UNSIGNED_SHORT_5_6_5; texture_format = GL_RGB; + format = GL_RGB; break; case QImage::Format_RGB32: if (format == GL_RGBA) -- cgit v0.12 From 79ad2c1d4f5205245c929be1c0db2c678d185038 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Tue, 8 Sep 2009 12:23:31 +1000 Subject: Port examples/opengl/textures to OpenGL/ES 1.1 Reviewed-by: Sarah Smith --- examples/opengl/opengl.pro | 3 ++ examples/opengl/textures/glwidget.cpp | 74 ++++++++++++++++++++--------------- examples/opengl/textures/glwidget.h | 8 ++-- examples/opengl/textures/window.cpp | 4 +- 4 files changed, 51 insertions(+), 38 deletions(-) diff --git a/examples/opengl/opengl.pro b/examples/opengl/opengl.pro index 567eb7b..b86e0ba 100644 --- a/examples/opengl/opengl.pro +++ b/examples/opengl/opengl.pro @@ -5,6 +5,9 @@ contains(QT_CONFIG, opengles1)|contains(QT_CONFIG, opengles1cl)|contains(QT_CONF SUBDIRS = hellogl_es2 } else { SUBDIRS = hellogl_es + !contains(QT_CONFIG, opengles1cl) { + SUBDIRS += textures + } } } else { SUBDIRS = 2dpainting \ diff --git a/examples/opengl/textures/glwidget.cpp b/examples/opengl/textures/glwidget.cpp index cfb99b0..9c6d5ea 100644 --- a/examples/opengl/textures/glwidget.cpp +++ b/examples/opengl/textures/glwidget.cpp @@ -42,12 +42,17 @@ #include #include -#include - #include "glwidget.h" -GLuint GLWidget::sharedObject = 0; -int GLWidget::refCount = 0; +class CubeObject +{ +public: + GLuint textures[6]; + QVector vertices; + QVector texCoords; + + void draw(); +}; GLWidget::GLWidget(QWidget *parent, QGLWidget *shareWidget) : QGLWidget(parent, shareWidget) @@ -56,14 +61,12 @@ GLWidget::GLWidget(QWidget *parent, QGLWidget *shareWidget) xRot = 0; yRot = 0; zRot = 0; + cube = 0; } GLWidget::~GLWidget() { - if (--refCount == 0) { - makeCurrent(); - glDeleteLists(sharedObject, 1); - } + delete cube; } QSize GLWidget::minimumSizeHint() const @@ -92,9 +95,7 @@ void GLWidget::setClearColor(const QColor &color) void GLWidget::initializeGL() { - if (!sharedObject) - sharedObject = makeObject(); - ++refCount; + makeObject(); glEnable(GL_DEPTH_TEST); glEnable(GL_CULL_FACE); @@ -106,11 +107,11 @@ void GLWidget::paintGL() qglClearColor(clearColor); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); - glTranslated(0.0, 0.0, -10.0); - glRotated(xRot / 16.0, 1.0, 0.0, 0.0); - glRotated(yRot / 16.0, 0.0, 1.0, 0.0); - glRotated(zRot / 16.0, 0.0, 0.0, 1.0); - glCallList(sharedObject); + glTranslatef(0.0f, 0.0f, -10.0f); + glRotatef(xRot / 16.0f, 1.0f, 0.0f, 0.0f); + glRotatef(yRot / 16.0f, 0.0f, 1.0f, 0.0f); + glRotatef(zRot / 16.0f, 0.0f, 0.0f, 1.0f); + cube->draw(); } void GLWidget::resizeGL(int width, int height) @@ -120,7 +121,11 @@ void GLWidget::resizeGL(int width, int height) glMatrixMode(GL_PROJECTION); glLoadIdentity(); +#ifndef QT_OPENGL_ES glOrtho(-0.5, +0.5, +0.5, -0.5, 4.0, 15.0); +#else + glOrthof(-0.5, +0.5, +0.5, -0.5, 4.0, 15.0); +#endif glMatrixMode(GL_MODELVIEW); } @@ -147,7 +152,7 @@ void GLWidget::mouseReleaseEvent(QMouseEvent * /* event */) emit clicked(); } -GLuint GLWidget::makeObject() +void GLWidget::makeObject() { static const int coords[6][4][3] = { { { +1, -1, -1 }, { -1, -1, -1 }, { -1, +1, -1 }, { +1, +1, -1 } }, @@ -158,25 +163,32 @@ GLuint GLWidget::makeObject() { { -1, -1, +1 }, { +1, -1, +1 }, { +1, +1, +1 }, { -1, +1, +1 } } }; + cube = new CubeObject(); - GLuint textures[6]; - for (int j=0; j < 6; ++j) - textures[j] = bindTexture(QPixmap(QString(":/images/side%1.png").arg(j + 1)), - GL_TEXTURE_2D); + for (int j=0; j < 6; ++j) { + cube->textures[j] = bindTexture + (QPixmap(QString(":/images/side%1.png").arg(j + 1)), GL_TEXTURE_2D); + } - GLuint list = glGenLists(1); - glNewList(list, GL_COMPILE); for (int i = 0; i < 6; ++i) { - glBindTexture(GL_TEXTURE_2D, textures[i]); - glBegin(GL_QUADS); for (int j = 0; j < 4; ++j) { - glTexCoord2d(j == 0 || j == 3, j == 0 || j == 1); - glVertex3d(0.2 * coords[i][j][0], 0.2 * coords[i][j][1], - 0.2 * coords[i][j][2]); + cube->texCoords.append + (QVector2D(j == 0 || j == 3, j == 0 || j == 1)); + cube->vertices.append + (QVector3D(0.2 * coords[i][j][0], 0.2 * coords[i][j][1], + 0.2 * coords[i][j][2])); } - glEnd(); } +} - glEndList(); - return list; +void CubeObject::draw() +{ + glVertexPointer(3, GL_FLOAT, 0, vertices.constData()); + glTexCoordPointer(2, GL_FLOAT, 0, texCoords.constData()); + glEnableClientState(GL_VERTEX_ARRAY); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + for (int i = 0; i < 6; ++i) { + glBindTexture(GL_TEXTURE_2D, textures[i]); + glDrawArrays(GL_TRIANGLE_FAN, i * 4, 4); + } } diff --git a/examples/opengl/textures/glwidget.h b/examples/opengl/textures/glwidget.h index 68be8bc..f793d6d 100644 --- a/examples/opengl/textures/glwidget.h +++ b/examples/opengl/textures/glwidget.h @@ -44,6 +44,8 @@ #include +class CubeObject; + class GLWidget : public QGLWidget { Q_OBJECT @@ -69,16 +71,14 @@ protected: void mouseReleaseEvent(QMouseEvent *event); private: - GLuint makeObject(); + void makeObject(); QColor clearColor; QPoint lastPos; int xRot; int yRot; int zRot; - - static GLuint sharedObject; - static int refCount; + CubeObject *cube; }; #endif diff --git a/examples/opengl/textures/window.cpp b/examples/opengl/textures/window.cpp index ea64512..9bd7931 100644 --- a/examples/opengl/textures/window.cpp +++ b/examples/opengl/textures/window.cpp @@ -48,8 +48,6 @@ Window::Window() { QGridLayout *mainLayout = new QGridLayout; - glWidgets[0][0] = 0; - for (int i = 0; i < NumRows; ++i) { for (int j = 0; j < NumColumns; ++j) { QColor clearColor; @@ -57,7 +55,7 @@ Window::Window() / (NumRows * NumColumns - 1), 255, 63); - glWidgets[i][j] = new GLWidget(0, glWidgets[0][0]); + glWidgets[i][j] = new GLWidget(0, 0); glWidgets[i][j]->setClearColor(clearColor); glWidgets[i][j]->rotateBy(+42 * 16, +42 * 16, -21 * 16); mainLayout->addWidget(glWidgets[i][j], i, j); -- cgit v0.12 From 2ed2632acec45ce4979ce21a0fe93d286a16613c Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Tue, 8 Sep 2009 13:00:43 +1000 Subject: Add operator== and != to QGLFramebufferObjectFormat Reviewed-by: Sarah Smith --- src/opengl/qglframebufferobject.cpp | 28 +++++++++++++++++++++ src/opengl/qglframebufferobject.h | 3 +++ src/opengl/qpixmapdata_gl.cpp | 7 +----- tests/auto/qgl/tst_qgl.cpp | 49 +++++++++++++++++++++++++++++++++++++ 4 files changed, 81 insertions(+), 6 deletions(-) diff --git a/src/opengl/qglframebufferobject.cpp b/src/opengl/qglframebufferobject.cpp index 452f155..9990586 100644 --- a/src/opengl/qglframebufferobject.cpp +++ b/src/opengl/qglframebufferobject.cpp @@ -100,6 +100,13 @@ public: internal_format(other->internal_format) { } + bool equals(const QGLFramebufferObjectFormatPrivate *other) + { + return samples == other->samples && + attachment == other->attachment && + target == other->target && + internal_format == other->internal_format; + } QAtomicInt ref; int samples; @@ -311,6 +318,27 @@ void QGLFramebufferObjectFormat::setInternalTextureFormat(QMacCompatGLenum inter } #endif +/*! + Returns true if all the options of this framebuffer object format + are the same as \a other; otherwise returns false. +*/ +bool QGLFramebufferObjectFormat::operator==(const QGLFramebufferObjectFormat& other) const +{ + if (d == other.d) + return true; + else + return d->equals(other.d); +} + +/*! + Returns false if all the options of this framebuffer object format + are the same as \a other; otherwise returns true. +*/ +bool QGLFramebufferObjectFormat::operator!=(const QGLFramebufferObjectFormat& other) const +{ + return !(*this == other); +} + class QGLFramebufferObjectPrivate { public: diff --git a/src/opengl/qglframebufferobject.h b/src/opengl/qglframebufferobject.h index 6c1c0be..2778ec5 100644 --- a/src/opengl/qglframebufferobject.h +++ b/src/opengl/qglframebufferobject.h @@ -159,6 +159,9 @@ public: void setInternalTextureFormat(QMacCompatGLenum internalTextureFormat); #endif + bool operator==(const QGLFramebufferObjectFormat& other) const; + bool operator!=(const QGLFramebufferObjectFormat& other) const; + private: QGLFramebufferObjectFormatPrivate *d; diff --git a/src/opengl/qpixmapdata_gl.cpp b/src/opengl/qpixmapdata_gl.cpp index d63d2ad..a394716 100644 --- a/src/opengl/qpixmapdata_gl.cpp +++ b/src/opengl/qpixmapdata_gl.cpp @@ -80,12 +80,7 @@ QGLFramebufferObject *QGLFramebufferObjectPool::acquire(const QSize &requestSize for (int i = 0; !chosen && i < m_fbos.size(); ++i) { QGLFramebufferObject *fbo = m_fbos.at(i); - QGLFramebufferObjectFormat format = fbo->format(); - if (format.samples() == requestFormat.samples() - && format.attachment() == requestFormat.attachment() - && format.textureTarget() == requestFormat.textureTarget() - && format.internalTextureFormat() == requestFormat.internalTextureFormat()) - { + if (fbo->format() == requestFormat) { // choose the fbo with a matching format and the closest size if (!candidate || areaDiff(requestSize, candidate) > areaDiff(requestSize, fbo)) candidate = fbo; diff --git a/tests/auto/qgl/tst_qgl.cpp b/tests/auto/qgl/tst_qgl.cpp index 650c1ca..43f4227 100644 --- a/tests/auto/qgl/tst_qgl.cpp +++ b/tests/auto/qgl/tst_qgl.cpp @@ -1432,6 +1432,55 @@ void tst_QGL::fboFormat() QVERIFY(format1.attachment() == QGLFramebufferObject::CombinedDepthStencil); QCOMPARE(int(format1.textureTarget()), int(GL_TEXTURE_3D)); QCOMPARE(int(format1.internalTextureFormat()), int(GL_RGB16)); + + // operator== and operator!= for QGLFramebufferObjectFormat. + QGLFramebufferObjectFormat format1c; + QGLFramebufferObjectFormat format2c; + + QVERIFY(format1c == format2c); + QVERIFY(!(format1c != format2c)); + format1c.setSamples(8); + QVERIFY(!(format1c == format2c)); + QVERIFY(format1c != format2c); + format2c.setSamples(8); + QVERIFY(format1c == format2c); + QVERIFY(!(format1c != format2c)); + + format1c.setAttachment(QGLFramebufferObject::CombinedDepthStencil); + QVERIFY(!(format1c == format2c)); + QVERIFY(format1c != format2c); + format2c.setAttachment(QGLFramebufferObject::CombinedDepthStencil); + QVERIFY(format1c == format2c); + QVERIFY(!(format1c != format2c)); + + format1c.setTextureTarget(GL_TEXTURE_3D); + QVERIFY(!(format1c == format2c)); + QVERIFY(format1c != format2c); + format2c.setTextureTarget(GL_TEXTURE_3D); + QVERIFY(format1c == format2c); + QVERIFY(!(format1c != format2c)); + + format1c.setInternalTextureFormat(GL_RGB16); + QVERIFY(!(format1c == format2c)); + QVERIFY(format1c != format2c); + format2c.setInternalTextureFormat(GL_RGB16); + QVERIFY(format1c == format2c); + QVERIFY(!(format1c != format2c)); + + QGLFramebufferObjectFormat format3c(format1c); + QGLFramebufferObjectFormat format4c; + QVERIFY(format1c == format3c); + QVERIFY(!(format1c != format3c)); + format3c.setInternalTextureFormat(DEFAULT_FORMAT); + QVERIFY(!(format1c == format3c)); + QVERIFY(format1c != format3c); + + format4c = format1c; + QVERIFY(format1c == format4c); + QVERIFY(!(format1c != format4c)); + format4c.setInternalTextureFormat(DEFAULT_FORMAT); + QVERIFY(!(format1c == format4c)); + QVERIFY(format1c != format4c); } QTEST_MAIN(tst_QGL) -- cgit v0.12 From b74d10c45c3ff21c2d87871aebf0869d45b0f555 Mon Sep 17 00:00:00 2001 From: Kurt Korbatits Date: Tue, 8 Sep 2009 14:10:56 +1000 Subject: QAudioDeviceInfo::deviceList() wasn't working correctly if no audio device. The default was being added even when no audio devices were available. Change so that the default device is only added if there is at least one audio device. Reviewed-by:Bill King --- src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp b/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp index d8d974f..5de5c27 100644 --- a/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp +++ b/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp @@ -341,8 +341,6 @@ QList QAudioDeviceInfoPrivate::deviceList(QAudio::Mode mode) QList devices; - devices.append("default"); - if(mode == QAudio::AudioOutput) { WAVEOUTCAPS woc; unsigned long iNumDevs,i; @@ -365,6 +363,9 @@ QList QAudioDeviceInfoPrivate::deviceList(QAudio::Mode mode) } } + if(devices.count() > 0) + devices.append("default"); + return devices; } -- cgit v0.12 From 22e8dd8653281ebf79fc7fc0061b225c8daf2977 Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Tue, 8 Sep 2009 15:15:12 +1000 Subject: Fixed some focus-related tst_qlineedit failures. There are many places where the test assumes that a widget gets focus after some fixed timeout. Change it to block until the widget really gets focus. --- tests/auto/qlineedit/tst_qlineedit.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/auto/qlineedit/tst_qlineedit.cpp b/tests/auto/qlineedit/tst_qlineedit.cpp index 6bbdf5d..47f0730 100644 --- a/tests/auto/qlineedit/tst_qlineedit.cpp +++ b/tests/auto/qlineedit/tst_qlineedit.cpp @@ -343,6 +343,7 @@ void tst_QLineEdit::initTestCase() // to be safe and avoid failing setFocus with window managers qt_x11_wait_for_window_manager(testWidget); #endif + QTRY_VERIFY(testWidget->hasFocus()); changed_count = 0; edited_count = 0; @@ -1601,8 +1602,7 @@ void tst_QLineEdit::passwordEchoOnEdit() testWidget->setEchoMode(QLineEdit::PasswordEchoOnEdit); testWidget->setFocus(); testWidget->raise(); - QTest::qWait(250); - QVERIFY(testWidget->hasFocus()); + QTRY_VERIFY(testWidget->hasFocus()); QTest::keyPress(testWidget, '0'); QTest::keyPress(testWidget, '1'); @@ -1614,6 +1614,7 @@ void tst_QLineEdit::passwordEchoOnEdit() QVERIFY(!testWidget->hasFocus()); QCOMPARE(testWidget->displayText(), QString(5, fillChar)); testWidget->setFocus(); + QTRY_VERIFY(testWidget->hasFocus()); QCOMPARE(testWidget->displayText(), QString(5, fillChar)); QTest::keyPress(testWidget, '0'); @@ -3397,7 +3398,7 @@ void tst_QLineEdit::task210502_caseInsensitiveInlineCompletion() qt_x11_wait_for_window_manager(&lineEdit); #endif lineEdit.setFocus(); - QTest::qWait(200); + QTRY_VERIFY(lineEdit.hasFocus()); QTest::keyPress(&lineEdit, 'a'); QTest::keyPress(&lineEdit, Qt::Key_Return); QCOMPARE(lineEdit.text(), completion); @@ -3491,7 +3492,7 @@ void tst_QLineEdit::task241436_passwordEchoOnEditRestoreEchoMode() testWidget->setEchoMode(QLineEdit::PasswordEchoOnEdit); testWidget->setFocus(); - QTest::qWait(250); + QTRY_VERIFY(testWidget->hasFocus()); QTest::keyPress(testWidget, '0'); QCOMPARE(testWidget->displayText(), QString("0")); -- cgit v0.12 From 74fd14a305ce7402890de1919c3a27ac4d1cbf38 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Tue, 8 Sep 2009 09:28:41 +0200 Subject: Doc: keypad navigation is supported on Windows CE Reviewed-by: thartman --- src/gui/kernel/qapplication.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index 327f5ce..bc8ed96 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -4687,7 +4687,11 @@ void QApplicationPrivate::emitLastWindowClosed() If \a enable is true, Qt::Key_Up and Qt::Key_Down are used to change focus. - This feature is available in Qt for Embedded Linux only. + This feature is available in Qt for Embedded Linux and Windows CE only. + + \note On Windows CE this feature is disabled by default for touch device + mkspecs. To enable keypad navigation, build Qt with + QT_KEYPAD_NAVIGATION defined. \sa keypadNavigationEnabled() */ @@ -4700,7 +4704,11 @@ void QApplication::setKeypadNavigationEnabled(bool enable) Returns true if Qt is set to use keypad navigation; otherwise returns false. The default is false. - This feature is available in Qt for Embedded Linux only. + This feature is available in Qt for Embedded Linux and Windows CE only. + + \note On Windows CE this feature is disabled by default for touch device + mkspecs. To enable keypad navigation, build Qt with + QT_KEYPAD_NAVIGATION defined. \sa setKeypadNavigationEnabled() */ -- cgit v0.12 From 790d6d4dda03314cccf4cad0bf32d9d8c3da4980 Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Tue, 8 Sep 2009 10:12:22 +0200 Subject: make JavaScriptCore compile on platforms with case-insensitive file system There's a clash between "TypeInfo.h" and a standard header "typeinfo.h" that's included from a place we don't control. The fix is to rename "TypeInfo.h" to "JSTypeInfo.h". Reviewed-by: Simon Hausmann --- .../webkit/JavaScriptCore/JavaScriptCore.gypi | 2 +- .../webkit/JavaScriptCore/runtime/JSTypeInfo.h | 72 ++++++++++++++++++++++ .../webkit/JavaScriptCore/runtime/Structure.h | 2 +- .../webkit/JavaScriptCore/runtime/TypeInfo.h | 72 ---------------------- 4 files changed, 74 insertions(+), 74 deletions(-) create mode 100644 src/3rdparty/webkit/JavaScriptCore/runtime/JSTypeInfo.h delete mode 100644 src/3rdparty/webkit/JavaScriptCore/runtime/TypeInfo.h diff --git a/src/3rdparty/webkit/JavaScriptCore/JavaScriptCore.gypi b/src/3rdparty/webkit/JavaScriptCore/JavaScriptCore.gypi index 2d69c7d..5a75ab7 100644 --- a/src/3rdparty/webkit/JavaScriptCore/JavaScriptCore.gypi +++ b/src/3rdparty/webkit/JavaScriptCore/JavaScriptCore.gypi @@ -323,7 +323,7 @@ 'runtime/TimeoutChecker.cpp', 'runtime/TimeoutChecker.h', 'runtime/Tracing.h', - 'runtime/TypeInfo.h', + 'runtime/JSTypeInfo.h', 'runtime/UString.cpp', 'runtime/UString.h', 'wrec/CharacterClass.cpp', diff --git a/src/3rdparty/webkit/JavaScriptCore/runtime/JSTypeInfo.h b/src/3rdparty/webkit/JavaScriptCore/runtime/JSTypeInfo.h new file mode 100644 index 0000000..bea188b --- /dev/null +++ b/src/3rdparty/webkit/JavaScriptCore/runtime/JSTypeInfo.h @@ -0,0 +1,72 @@ +// -*- mode: c++; c-basic-offset: 4 -*- +/* + * Copyright (C) 2008 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef JSTypeInfo_h +#define JSTypeInfo_h + +#include "JSType.h" + +namespace JSC { + + // WebCore uses MasqueradesAsUndefined to make document.all and style.filter undetectable. + static const unsigned MasqueradesAsUndefined = 1; + static const unsigned ImplementsHasInstance = 1 << 1; + static const unsigned OverridesHasInstance = 1 << 2; + static const unsigned ImplementsDefaultHasInstance = 1 << 3; + static const unsigned NeedsThisConversion = 1 << 4; + static const unsigned HasStandardGetOwnPropertySlot = 1 << 5; + + class TypeInfo { + friend class JIT; + public: + TypeInfo(JSType type, unsigned flags = 0) + : m_type(type) + { + // ImplementsDefaultHasInstance means (ImplementsHasInstance & !OverridesHasInstance) + if ((flags & (ImplementsHasInstance | OverridesHasInstance)) == ImplementsHasInstance) + m_flags = flags | ImplementsDefaultHasInstance; + else + m_flags = flags; + } + + JSType type() const { return m_type; } + + bool masqueradesAsUndefined() const { return m_flags & MasqueradesAsUndefined; } + bool implementsHasInstance() const { return m_flags & ImplementsHasInstance; } + bool overridesHasInstance() const { return m_flags & OverridesHasInstance; } + bool needsThisConversion() const { return m_flags & NeedsThisConversion; } + bool hasStandardGetOwnPropertySlot() const { return m_flags & HasStandardGetOwnPropertySlot; } + + unsigned flags() const { return m_flags; } + + private: + JSType m_type; + unsigned m_flags; + }; + +} + +#endif // JSTypeInfo_h diff --git a/src/3rdparty/webkit/JavaScriptCore/runtime/Structure.h b/src/3rdparty/webkit/JavaScriptCore/runtime/Structure.h index dcd4e50..ca4552b 100644 --- a/src/3rdparty/webkit/JavaScriptCore/runtime/Structure.h +++ b/src/3rdparty/webkit/JavaScriptCore/runtime/Structure.h @@ -31,7 +31,7 @@ #include "JSValue.h" #include "PropertyMapHashTable.h" #include "StructureTransitionTable.h" -#include "TypeInfo.h" +#include "JSTypeInfo.h" #include "UString.h" #include #include diff --git a/src/3rdparty/webkit/JavaScriptCore/runtime/TypeInfo.h b/src/3rdparty/webkit/JavaScriptCore/runtime/TypeInfo.h deleted file mode 100644 index 70aeed3..0000000 --- a/src/3rdparty/webkit/JavaScriptCore/runtime/TypeInfo.h +++ /dev/null @@ -1,72 +0,0 @@ -// -*- mode: c++; c-basic-offset: 4 -*- -/* - * Copyright (C) 2008 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef TypeInfo_h -#define TypeInfo_h - -#include "JSType.h" - -namespace JSC { - - // WebCore uses MasqueradesAsUndefined to make document.all and style.filter undetectable. - static const unsigned MasqueradesAsUndefined = 1; - static const unsigned ImplementsHasInstance = 1 << 1; - static const unsigned OverridesHasInstance = 1 << 2; - static const unsigned ImplementsDefaultHasInstance = 1 << 3; - static const unsigned NeedsThisConversion = 1 << 4; - static const unsigned HasStandardGetOwnPropertySlot = 1 << 5; - - class TypeInfo { - friend class JIT; - public: - TypeInfo(JSType type, unsigned flags = 0) - : m_type(type) - { - // ImplementsDefaultHasInstance means (ImplementsHasInstance & !OverridesHasInstance) - if ((flags & (ImplementsHasInstance | OverridesHasInstance)) == ImplementsHasInstance) - m_flags = flags | ImplementsDefaultHasInstance; - else - m_flags = flags; - } - - JSType type() const { return m_type; } - - bool masqueradesAsUndefined() const { return m_flags & MasqueradesAsUndefined; } - bool implementsHasInstance() const { return m_flags & ImplementsHasInstance; } - bool overridesHasInstance() const { return m_flags & OverridesHasInstance; } - bool needsThisConversion() const { return m_flags & NeedsThisConversion; } - bool hasStandardGetOwnPropertySlot() const { return m_flags & HasStandardGetOwnPropertySlot; } - - unsigned flags() const { return m_flags; } - - private: - JSType m_type; - unsigned m_flags; - }; - -} - -#endif // TypeInfo_h -- cgit v0.12 From 9bd7e50a5aa6258a58979a22250ce264b69d4ee2 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Mon, 7 Sep 2009 11:29:23 +0200 Subject: use a single qplatformdefs.h for all Windows CE mkspecs Additionally, mkspecs/wince.conf was moved to mkspecs/common/wince/qmake.conf The common qplatformdefs.h is also in that directory. Task-number: 259850 Reviewed-by: mauricek --- mkspecs/common/wince.conf | 90 -------------- mkspecs/common/wince/qmake.conf | 90 ++++++++++++++ mkspecs/common/wince/qplatformdefs.h | 131 +++++++++++++++++++++ mkspecs/wince50standard-armv4i-msvc2005/qmake.conf | 2 +- .../qplatformdefs.h | 90 +------------- .../qplatformdefs.h | 2 +- mkspecs/wince50standard-mipsii-msvc2005/qmake.conf | 2 +- .../qplatformdefs.h | 90 +------------- .../qplatformdefs.h | 2 +- mkspecs/wince50standard-mipsiv-msvc2005/qmake.conf | 2 +- .../qplatformdefs.h | 90 +------------- .../qplatformdefs.h | 2 +- mkspecs/wince50standard-sh4-msvc2005/qmake.conf | 2 +- .../wince50standard-sh4-msvc2005/qplatformdefs.h | 90 +------------- .../wince50standard-sh4-msvc2008/qplatformdefs.h | 2 +- mkspecs/wince50standard-x86-msvc2005/qmake.conf | 2 +- .../wince50standard-x86-msvc2005/qplatformdefs.h | 90 +------------- .../wince50standard-x86-msvc2008/qplatformdefs.h | 2 +- .../qplatformdefs.h | 90 +------------- mkspecs/wincewm50pocket-msvc2005/qmake.conf | 2 +- mkspecs/wincewm50pocket-msvc2005/qplatformdefs.h | 90 +------------- mkspecs/wincewm50pocket-msvc2008/qplatformdefs.h | 2 +- mkspecs/wincewm50smart-msvc2005/qmake.conf | 2 +- mkspecs/wincewm50smart-msvc2005/qplatformdefs.h | 90 +------------- mkspecs/wincewm50smart-msvc2008/qplatformdefs.h | 2 +- .../wincewm60professional-msvc2005/qplatformdefs.h | 90 +------------- .../wincewm60professional-msvc2008/qplatformdefs.h | 2 +- mkspecs/wincewm60standard-msvc2005/qplatformdefs.h | 90 +------------- mkspecs/wincewm60standard-msvc2008/qplatformdefs.h | 2 +- .../wincewm65professional-msvc2005/qplatformdefs.h | 3 +- .../wincewm65professional-msvc2008/qplatformdefs.h | 2 +- 31 files changed, 250 insertions(+), 998 deletions(-) delete mode 100644 mkspecs/common/wince.conf create mode 100644 mkspecs/common/wince/qmake.conf create mode 100644 mkspecs/common/wince/qplatformdefs.h diff --git a/mkspecs/common/wince.conf b/mkspecs/common/wince.conf deleted file mode 100644 index d6e4ba7..0000000 --- a/mkspecs/common/wince.conf +++ /dev/null @@ -1,90 +0,0 @@ -# -# qmake configuration for common Windows CE -# - -MAKEFILE_GENERATOR = MSVC.NET -TEMPLATE = app -QT += core gui -CONFIG += qt warn_on release incremental flat link_prl precompile_header autogen_precompile_source copy_dir_files debug_and_release debug_and_release_target embed_manifest_dll embed_manifest_exe - -DEFINES += UNDER_CE WINCE _WINDOWS _UNICODE UNICODE _WIN32 QT_NO_PRINTER QT_NO_PRINTDIALOG - -QMAKE_COMPILER_DEFINES += _MSC_VER=1400 - -QMAKE_CC = cl -QMAKE_LEX = flex -QMAKE_LEXFLAGS = -QMAKE_YACC = byacc -QMAKE_YACCFLAGS = -d -QMAKE_CFLAGS = -nologo -Zm200 -Zc:wchar_t- -QMAKE_CFLAGS_WARN_ON = -W3 -QMAKE_CFLAGS_WARN_OFF = -W0 -QMAKE_CFLAGS_RELEASE = -O2 -MD -QMAKE_CFLAGS_LTCG = -GL -QMAKE_CFLAGS_DEBUG = -DDEBUG -D_DEBUG -Zi -MDd -QMAKE_CFLAGS_YACC = - -# Uncomment the following lines to reduce library sizes -# with potential cost of performance -# QMAKE_CFLAGS += -Os -# QMAKE_CFLAGS_RELEASE += -Os - -QMAKE_CXX = $$QMAKE_CC -QMAKE_CXXFLAGS = $$QMAKE_CFLAGS -QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON -w34100 -w34189 -QMAKE_CXXFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF -QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE -QMAKE_CXXFLAGS_DEBUG = $$QMAKE_CFLAGS_DEBUG -QMAKE_CXXFLAGS_LTCG = $$QMAKE_CFLAGS_LTCG -QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC -QMAKE_CXXFLAGS_STL_ON = -EHsc -QMAKE_CXXFLAGS_STL_OFF = -QMAKE_CXXFLAGS_RTTI_ON = -GR -QMAKE_CXXFLAGS_RTTI_OFF = -QMAKE_CXXFLAGS_EXCEPTIONS_ON = -EHsc -QMAKE_CXXFLAGS_EXCEPTIONS_OFF = -EHs-c- - -QMAKE_INCDIR = -QMAKE_INCDIR_QT = $$[QT_INSTALL_HEADERS] -QMAKE_LIBDIR_QT = $$[QT_INSTALL_LIBS] - -QMAKE_RUN_CC = $(CC) -c $(CFLAGS) $(INCPATH) -Fo$obj $src -QMAKE_RUN_CC_IMP = $(CC) -c $(CFLAGS) $(INCPATH) -Fo$@ $< -QMAKE_RUN_CC_IMP_BATCH = $(CC) -c $(CFLAGS) $(INCPATH) -Fo$@ @<< -QMAKE_RUN_CXX = $(CXX) -c $(CXXFLAGS) $(INCPATH) -Fo$obj $src -QMAKE_RUN_CXX_IMP = $(CXX) -c $(CXXFLAGS) $(INCPATH) -Fo$@ $< -QMAKE_RUN_CXX_IMP_BATCH = $(CXX) -c $(CXXFLAGS) $(INCPATH) -Fo$@ @<< - -QMAKE_LINK = link -QMAKE_LFLAGS = /NOLOGO /NODEFAULTLIB:OLDNAMES.LIB -QMAKE_LFLAGS_RELEASE = /INCREMENTAL:NO -QMAKE_LFLAGS_DEBUG = /DEBUG -QMAKE_LFLAGS_LTCG = /LTCG -QMAKE_LIBS_NETWORK = ws2.lib -QMAKE_LIBS_OPENGL = -QMAKE_LIBS_COMPAT = - -QMAKE_LIBS_QT_ENTRY = -lqtmain - -QMAKE_MOC = $$[QT_INSTALL_BINS]\moc.exe -QMAKE_UIC = $$[QT_INSTALL_BINS]\uic.exe -QMAKE_IDC = $$[QT_INSTALL_BINS]\idc.exe - -QMAKE_IDL = midl -QMAKE_LIB = lib -QMAKE_RC = rc - -QMAKE_ZIP = zip -r -9 - -QMAKE_COPY = copy /y -QMAKE_COPY_DIR = xcopy /s /q /y /i -QMAKE_MOVE = move -QMAKE_DEL_FILE = del -QMAKE_DEL_DIR = rmdir -QMAKE_CHK_DIR_EXISTS = if not exist -QMAKE_MKDIR = mkdir - -VCPROJ_EXTENSION = .vcproj -VCSOLUTION_EXTENSION = .sln -VCPROJ_KEYWORD = Qt4VSv1.0 -load(qt_config) diff --git a/mkspecs/common/wince/qmake.conf b/mkspecs/common/wince/qmake.conf new file mode 100644 index 0000000..d6e4ba7 --- /dev/null +++ b/mkspecs/common/wince/qmake.conf @@ -0,0 +1,90 @@ +# +# qmake configuration for common Windows CE +# + +MAKEFILE_GENERATOR = MSVC.NET +TEMPLATE = app +QT += core gui +CONFIG += qt warn_on release incremental flat link_prl precompile_header autogen_precompile_source copy_dir_files debug_and_release debug_and_release_target embed_manifest_dll embed_manifest_exe + +DEFINES += UNDER_CE WINCE _WINDOWS _UNICODE UNICODE _WIN32 QT_NO_PRINTER QT_NO_PRINTDIALOG + +QMAKE_COMPILER_DEFINES += _MSC_VER=1400 + +QMAKE_CC = cl +QMAKE_LEX = flex +QMAKE_LEXFLAGS = +QMAKE_YACC = byacc +QMAKE_YACCFLAGS = -d +QMAKE_CFLAGS = -nologo -Zm200 -Zc:wchar_t- +QMAKE_CFLAGS_WARN_ON = -W3 +QMAKE_CFLAGS_WARN_OFF = -W0 +QMAKE_CFLAGS_RELEASE = -O2 -MD +QMAKE_CFLAGS_LTCG = -GL +QMAKE_CFLAGS_DEBUG = -DDEBUG -D_DEBUG -Zi -MDd +QMAKE_CFLAGS_YACC = + +# Uncomment the following lines to reduce library sizes +# with potential cost of performance +# QMAKE_CFLAGS += -Os +# QMAKE_CFLAGS_RELEASE += -Os + +QMAKE_CXX = $$QMAKE_CC +QMAKE_CXXFLAGS = $$QMAKE_CFLAGS +QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON -w34100 -w34189 +QMAKE_CXXFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF +QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE +QMAKE_CXXFLAGS_DEBUG = $$QMAKE_CFLAGS_DEBUG +QMAKE_CXXFLAGS_LTCG = $$QMAKE_CFLAGS_LTCG +QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC +QMAKE_CXXFLAGS_STL_ON = -EHsc +QMAKE_CXXFLAGS_STL_OFF = +QMAKE_CXXFLAGS_RTTI_ON = -GR +QMAKE_CXXFLAGS_RTTI_OFF = +QMAKE_CXXFLAGS_EXCEPTIONS_ON = -EHsc +QMAKE_CXXFLAGS_EXCEPTIONS_OFF = -EHs-c- + +QMAKE_INCDIR = +QMAKE_INCDIR_QT = $$[QT_INSTALL_HEADERS] +QMAKE_LIBDIR_QT = $$[QT_INSTALL_LIBS] + +QMAKE_RUN_CC = $(CC) -c $(CFLAGS) $(INCPATH) -Fo$obj $src +QMAKE_RUN_CC_IMP = $(CC) -c $(CFLAGS) $(INCPATH) -Fo$@ $< +QMAKE_RUN_CC_IMP_BATCH = $(CC) -c $(CFLAGS) $(INCPATH) -Fo$@ @<< +QMAKE_RUN_CXX = $(CXX) -c $(CXXFLAGS) $(INCPATH) -Fo$obj $src +QMAKE_RUN_CXX_IMP = $(CXX) -c $(CXXFLAGS) $(INCPATH) -Fo$@ $< +QMAKE_RUN_CXX_IMP_BATCH = $(CXX) -c $(CXXFLAGS) $(INCPATH) -Fo$@ @<< + +QMAKE_LINK = link +QMAKE_LFLAGS = /NOLOGO /NODEFAULTLIB:OLDNAMES.LIB +QMAKE_LFLAGS_RELEASE = /INCREMENTAL:NO +QMAKE_LFLAGS_DEBUG = /DEBUG +QMAKE_LFLAGS_LTCG = /LTCG +QMAKE_LIBS_NETWORK = ws2.lib +QMAKE_LIBS_OPENGL = +QMAKE_LIBS_COMPAT = + +QMAKE_LIBS_QT_ENTRY = -lqtmain + +QMAKE_MOC = $$[QT_INSTALL_BINS]\moc.exe +QMAKE_UIC = $$[QT_INSTALL_BINS]\uic.exe +QMAKE_IDC = $$[QT_INSTALL_BINS]\idc.exe + +QMAKE_IDL = midl +QMAKE_LIB = lib +QMAKE_RC = rc + +QMAKE_ZIP = zip -r -9 + +QMAKE_COPY = copy /y +QMAKE_COPY_DIR = xcopy /s /q /y /i +QMAKE_MOVE = move +QMAKE_DEL_FILE = del +QMAKE_DEL_DIR = rmdir +QMAKE_CHK_DIR_EXISTS = if not exist +QMAKE_MKDIR = mkdir + +VCPROJ_EXTENSION = .vcproj +VCSOLUTION_EXTENSION = .sln +VCPROJ_KEYWORD = Qt4VSv1.0 +load(qt_config) diff --git a/mkspecs/common/wince/qplatformdefs.h b/mkspecs/common/wince/qplatformdefs.h new file mode 100644 index 0000000..4e67948 --- /dev/null +++ b/mkspecs/common/wince/qplatformdefs.h @@ -0,0 +1,131 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the qmake spec of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QPLATFORMDEFS_H +#define QPLATFORMDEFS_H + +#ifdef UNICODE +#ifndef _UNICODE +#define _UNICODE +#endif +#endif + +// Get Qt defines/settings + +#include "qglobal.h" +#include "qfunctions_wince.h" + +#define _POSIX_ +#include +#undef _POSIX_ + +#include +#include +#include +#include + +#define Q_FS_FAT +#ifdef QT_LARGEFILE_SUPPORT +#define QT_STATBUF struct _stati64 // non-ANSI defs +#define QT_STATBUF4TSTAT struct _stati64 // non-ANSI defs +#define QT_STAT ::_stati64 +#define QT_FSTAT ::_fstati64 +#else +#define QT_STATBUF struct stat // non-ANSI defs +#define QT_STATBUF4TSTAT struct stat // non-ANSI defs +#define QT_STAT ::qt_wince_stat +#define QT_FSTAT ::qt_wince__fstat +#endif +#define QT_STAT_REG _S_IFREG +#define QT_STAT_DIR _S_IFDIR +#define QT_STAT_MASK _S_IFMT +#if defined(_S_IFLNK) +# define QT_STAT_LNK _S_IFLNK +#endif +#define QT_FILENO ::qt_wince___fileno +#define QT_OPEN ::qt_wince_open +#define QT_CLOSE ::qt_wince__close +#ifdef QT_LARGEFILE_SUPPORT +#define QT_LSEEK ::_lseeki64 +#define QT_TSTAT ::_tstati64 +#else +#define QT_LSEEK ::qt_wince__lseek +#define QT_TSTAT ::_tstat +#endif +#define QT_READ ::qt_wince__read +#define QT_WRITE ::qt_wince__write +#define QT_ACCESS ::qt_wince__access +#define QT_GETCWD ::_getcwd +#define QT_CHDIR ::_chdir +#define QT_MKDIR ::qt_wince__mkdir +#define QT_RMDIR ::qt_wince__rmdir +#define QT_OPEN_RDONLY _O_RDONLY +#define QT_OPEN_WRONLY _O_WRONLY +#define QT_OPEN_RDWR _O_RDWR +#define QT_OPEN_CREAT _O_CREAT +#define QT_OPEN_TRUNC _O_TRUNC +#define QT_OPEN_APPEND _O_APPEND +# define QT_OPEN_TEXT _O_TEXT +# define QT_OPEN_BINARY _O_BINARY + +#define QT_FOPEN ::fopen +#define QT_FSEEK ::fseek +#define QT_FTELL ::ftell +#define QT_FGETPOS ::fgetpos +#define QT_FSETPOS ::fsetpos +#define QT_FPOS_T fpos_t +#define QT_OFF_T long + +#define QT_SIGNAL_ARGS int + +#define QT_VSNPRINTF(buffer, count, format, arg) \ + _vsnprintf(buffer, count, format, arg) + +#define QT_SNPRINTF ::_snprintf + +# define F_OK 0 +# define X_OK 1 +# define W_OK 2 +# define R_OK 4 + +typedef int mode_t; + +#endif // QPLATFORMDEFS_H diff --git a/mkspecs/wince50standard-armv4i-msvc2005/qmake.conf b/mkspecs/wince50standard-armv4i-msvc2005/qmake.conf index 45ebcf7..28ca6a6 100644 --- a/mkspecs/wince50standard-armv4i-msvc2005/qmake.conf +++ b/mkspecs/wince50standard-armv4i-msvc2005/qmake.conf @@ -3,7 +3,7 @@ # # Written for Microsoft VC2005.NET with Standard SDK for WindowsCE 5.0 (ARMV4I) # -include(../common/wince.conf) +include(../common/wince/qmake.conf) CE_SDK = STANDARDSDK_500 CE_ARCH = ARMV4I diff --git a/mkspecs/wince50standard-armv4i-msvc2005/qplatformdefs.h b/mkspecs/wince50standard-armv4i-msvc2005/qplatformdefs.h index 4e67948..cda4ff4 100644 --- a/mkspecs/wince50standard-armv4i-msvc2005/qplatformdefs.h +++ b/mkspecs/wince50standard-armv4i-msvc2005/qplatformdefs.h @@ -39,93 +39,5 @@ ** ****************************************************************************/ -#ifndef QPLATFORMDEFS_H -#define QPLATFORMDEFS_H +#include "../common/wince/qplatformdefs.h" -#ifdef UNICODE -#ifndef _UNICODE -#define _UNICODE -#endif -#endif - -// Get Qt defines/settings - -#include "qglobal.h" -#include "qfunctions_wince.h" - -#define _POSIX_ -#include -#undef _POSIX_ - -#include -#include -#include -#include - -#define Q_FS_FAT -#ifdef QT_LARGEFILE_SUPPORT -#define QT_STATBUF struct _stati64 // non-ANSI defs -#define QT_STATBUF4TSTAT struct _stati64 // non-ANSI defs -#define QT_STAT ::_stati64 -#define QT_FSTAT ::_fstati64 -#else -#define QT_STATBUF struct stat // non-ANSI defs -#define QT_STATBUF4TSTAT struct stat // non-ANSI defs -#define QT_STAT ::qt_wince_stat -#define QT_FSTAT ::qt_wince__fstat -#endif -#define QT_STAT_REG _S_IFREG -#define QT_STAT_DIR _S_IFDIR -#define QT_STAT_MASK _S_IFMT -#if defined(_S_IFLNK) -# define QT_STAT_LNK _S_IFLNK -#endif -#define QT_FILENO ::qt_wince___fileno -#define QT_OPEN ::qt_wince_open -#define QT_CLOSE ::qt_wince__close -#ifdef QT_LARGEFILE_SUPPORT -#define QT_LSEEK ::_lseeki64 -#define QT_TSTAT ::_tstati64 -#else -#define QT_LSEEK ::qt_wince__lseek -#define QT_TSTAT ::_tstat -#endif -#define QT_READ ::qt_wince__read -#define QT_WRITE ::qt_wince__write -#define QT_ACCESS ::qt_wince__access -#define QT_GETCWD ::_getcwd -#define QT_CHDIR ::_chdir -#define QT_MKDIR ::qt_wince__mkdir -#define QT_RMDIR ::qt_wince__rmdir -#define QT_OPEN_RDONLY _O_RDONLY -#define QT_OPEN_WRONLY _O_WRONLY -#define QT_OPEN_RDWR _O_RDWR -#define QT_OPEN_CREAT _O_CREAT -#define QT_OPEN_TRUNC _O_TRUNC -#define QT_OPEN_APPEND _O_APPEND -# define QT_OPEN_TEXT _O_TEXT -# define QT_OPEN_BINARY _O_BINARY - -#define QT_FOPEN ::fopen -#define QT_FSEEK ::fseek -#define QT_FTELL ::ftell -#define QT_FGETPOS ::fgetpos -#define QT_FSETPOS ::fsetpos -#define QT_FPOS_T fpos_t -#define QT_OFF_T long - -#define QT_SIGNAL_ARGS int - -#define QT_VSNPRINTF(buffer, count, format, arg) \ - _vsnprintf(buffer, count, format, arg) - -#define QT_SNPRINTF ::_snprintf - -# define F_OK 0 -# define X_OK 1 -# define W_OK 2 -# define R_OK 4 - -typedef int mode_t; - -#endif // QPLATFORMDEFS_H diff --git a/mkspecs/wince50standard-armv4i-msvc2008/qplatformdefs.h b/mkspecs/wince50standard-armv4i-msvc2008/qplatformdefs.h index f775941..cda4ff4 100644 --- a/mkspecs/wince50standard-armv4i-msvc2008/qplatformdefs.h +++ b/mkspecs/wince50standard-armv4i-msvc2008/qplatformdefs.h @@ -39,5 +39,5 @@ ** ****************************************************************************/ -#include "../wince50standard-armv4i-msvc2005/qplatformdefs.h" +#include "../common/wince/qplatformdefs.h" diff --git a/mkspecs/wince50standard-mipsii-msvc2005/qmake.conf b/mkspecs/wince50standard-mipsii-msvc2005/qmake.conf index 7d765de..0cc1ab0 100644 --- a/mkspecs/wince50standard-mipsii-msvc2005/qmake.conf +++ b/mkspecs/wince50standard-mipsii-msvc2005/qmake.conf @@ -3,7 +3,7 @@ # # Written for Microsoft VC2005.NET with Standard SDK for WindowsCE 5.0 (MIPSII) # -include(../common/wince.conf) +include(../common/wince/qmake.conf) CE_SDK = STANDARDSDK_500 CE_ARCH = MIPSII diff --git a/mkspecs/wince50standard-mipsii-msvc2005/qplatformdefs.h b/mkspecs/wince50standard-mipsii-msvc2005/qplatformdefs.h index 4e67948..cda4ff4 100644 --- a/mkspecs/wince50standard-mipsii-msvc2005/qplatformdefs.h +++ b/mkspecs/wince50standard-mipsii-msvc2005/qplatformdefs.h @@ -39,93 +39,5 @@ ** ****************************************************************************/ -#ifndef QPLATFORMDEFS_H -#define QPLATFORMDEFS_H +#include "../common/wince/qplatformdefs.h" -#ifdef UNICODE -#ifndef _UNICODE -#define _UNICODE -#endif -#endif - -// Get Qt defines/settings - -#include "qglobal.h" -#include "qfunctions_wince.h" - -#define _POSIX_ -#include -#undef _POSIX_ - -#include -#include -#include -#include - -#define Q_FS_FAT -#ifdef QT_LARGEFILE_SUPPORT -#define QT_STATBUF struct _stati64 // non-ANSI defs -#define QT_STATBUF4TSTAT struct _stati64 // non-ANSI defs -#define QT_STAT ::_stati64 -#define QT_FSTAT ::_fstati64 -#else -#define QT_STATBUF struct stat // non-ANSI defs -#define QT_STATBUF4TSTAT struct stat // non-ANSI defs -#define QT_STAT ::qt_wince_stat -#define QT_FSTAT ::qt_wince__fstat -#endif -#define QT_STAT_REG _S_IFREG -#define QT_STAT_DIR _S_IFDIR -#define QT_STAT_MASK _S_IFMT -#if defined(_S_IFLNK) -# define QT_STAT_LNK _S_IFLNK -#endif -#define QT_FILENO ::qt_wince___fileno -#define QT_OPEN ::qt_wince_open -#define QT_CLOSE ::qt_wince__close -#ifdef QT_LARGEFILE_SUPPORT -#define QT_LSEEK ::_lseeki64 -#define QT_TSTAT ::_tstati64 -#else -#define QT_LSEEK ::qt_wince__lseek -#define QT_TSTAT ::_tstat -#endif -#define QT_READ ::qt_wince__read -#define QT_WRITE ::qt_wince__write -#define QT_ACCESS ::qt_wince__access -#define QT_GETCWD ::_getcwd -#define QT_CHDIR ::_chdir -#define QT_MKDIR ::qt_wince__mkdir -#define QT_RMDIR ::qt_wince__rmdir -#define QT_OPEN_RDONLY _O_RDONLY -#define QT_OPEN_WRONLY _O_WRONLY -#define QT_OPEN_RDWR _O_RDWR -#define QT_OPEN_CREAT _O_CREAT -#define QT_OPEN_TRUNC _O_TRUNC -#define QT_OPEN_APPEND _O_APPEND -# define QT_OPEN_TEXT _O_TEXT -# define QT_OPEN_BINARY _O_BINARY - -#define QT_FOPEN ::fopen -#define QT_FSEEK ::fseek -#define QT_FTELL ::ftell -#define QT_FGETPOS ::fgetpos -#define QT_FSETPOS ::fsetpos -#define QT_FPOS_T fpos_t -#define QT_OFF_T long - -#define QT_SIGNAL_ARGS int - -#define QT_VSNPRINTF(buffer, count, format, arg) \ - _vsnprintf(buffer, count, format, arg) - -#define QT_SNPRINTF ::_snprintf - -# define F_OK 0 -# define X_OK 1 -# define W_OK 2 -# define R_OK 4 - -typedef int mode_t; - -#endif // QPLATFORMDEFS_H diff --git a/mkspecs/wince50standard-mipsii-msvc2008/qplatformdefs.h b/mkspecs/wince50standard-mipsii-msvc2008/qplatformdefs.h index 319d49a..cda4ff4 100644 --- a/mkspecs/wince50standard-mipsii-msvc2008/qplatformdefs.h +++ b/mkspecs/wince50standard-mipsii-msvc2008/qplatformdefs.h @@ -39,5 +39,5 @@ ** ****************************************************************************/ -#include "../wince50standard-mipsii-msvc2005/qplatformdefs.h" +#include "../common/wince/qplatformdefs.h" diff --git a/mkspecs/wince50standard-mipsiv-msvc2005/qmake.conf b/mkspecs/wince50standard-mipsiv-msvc2005/qmake.conf index 4750d88..a22505c 100644 --- a/mkspecs/wince50standard-mipsiv-msvc2005/qmake.conf +++ b/mkspecs/wince50standard-mipsiv-msvc2005/qmake.conf @@ -3,7 +3,7 @@ # # Written for Microsoft VC2005.NET with Standard SDK for WindowsCE 5.0 (MIPSIV) # -include(../common/wince.conf) +include(../common/wince/qmake.conf) CE_SDK = STANDARDSDK_500 CE_ARCH = MIPSIV diff --git a/mkspecs/wince50standard-mipsiv-msvc2005/qplatformdefs.h b/mkspecs/wince50standard-mipsiv-msvc2005/qplatformdefs.h index 4e67948..cda4ff4 100644 --- a/mkspecs/wince50standard-mipsiv-msvc2005/qplatformdefs.h +++ b/mkspecs/wince50standard-mipsiv-msvc2005/qplatformdefs.h @@ -39,93 +39,5 @@ ** ****************************************************************************/ -#ifndef QPLATFORMDEFS_H -#define QPLATFORMDEFS_H +#include "../common/wince/qplatformdefs.h" -#ifdef UNICODE -#ifndef _UNICODE -#define _UNICODE -#endif -#endif - -// Get Qt defines/settings - -#include "qglobal.h" -#include "qfunctions_wince.h" - -#define _POSIX_ -#include -#undef _POSIX_ - -#include -#include -#include -#include - -#define Q_FS_FAT -#ifdef QT_LARGEFILE_SUPPORT -#define QT_STATBUF struct _stati64 // non-ANSI defs -#define QT_STATBUF4TSTAT struct _stati64 // non-ANSI defs -#define QT_STAT ::_stati64 -#define QT_FSTAT ::_fstati64 -#else -#define QT_STATBUF struct stat // non-ANSI defs -#define QT_STATBUF4TSTAT struct stat // non-ANSI defs -#define QT_STAT ::qt_wince_stat -#define QT_FSTAT ::qt_wince__fstat -#endif -#define QT_STAT_REG _S_IFREG -#define QT_STAT_DIR _S_IFDIR -#define QT_STAT_MASK _S_IFMT -#if defined(_S_IFLNK) -# define QT_STAT_LNK _S_IFLNK -#endif -#define QT_FILENO ::qt_wince___fileno -#define QT_OPEN ::qt_wince_open -#define QT_CLOSE ::qt_wince__close -#ifdef QT_LARGEFILE_SUPPORT -#define QT_LSEEK ::_lseeki64 -#define QT_TSTAT ::_tstati64 -#else -#define QT_LSEEK ::qt_wince__lseek -#define QT_TSTAT ::_tstat -#endif -#define QT_READ ::qt_wince__read -#define QT_WRITE ::qt_wince__write -#define QT_ACCESS ::qt_wince__access -#define QT_GETCWD ::_getcwd -#define QT_CHDIR ::_chdir -#define QT_MKDIR ::qt_wince__mkdir -#define QT_RMDIR ::qt_wince__rmdir -#define QT_OPEN_RDONLY _O_RDONLY -#define QT_OPEN_WRONLY _O_WRONLY -#define QT_OPEN_RDWR _O_RDWR -#define QT_OPEN_CREAT _O_CREAT -#define QT_OPEN_TRUNC _O_TRUNC -#define QT_OPEN_APPEND _O_APPEND -# define QT_OPEN_TEXT _O_TEXT -# define QT_OPEN_BINARY _O_BINARY - -#define QT_FOPEN ::fopen -#define QT_FSEEK ::fseek -#define QT_FTELL ::ftell -#define QT_FGETPOS ::fgetpos -#define QT_FSETPOS ::fsetpos -#define QT_FPOS_T fpos_t -#define QT_OFF_T long - -#define QT_SIGNAL_ARGS int - -#define QT_VSNPRINTF(buffer, count, format, arg) \ - _vsnprintf(buffer, count, format, arg) - -#define QT_SNPRINTF ::_snprintf - -# define F_OK 0 -# define X_OK 1 -# define W_OK 2 -# define R_OK 4 - -typedef int mode_t; - -#endif // QPLATFORMDEFS_H diff --git a/mkspecs/wince50standard-mipsiv-msvc2008/qplatformdefs.h b/mkspecs/wince50standard-mipsiv-msvc2008/qplatformdefs.h index 9a6f3ed..cda4ff4 100644 --- a/mkspecs/wince50standard-mipsiv-msvc2008/qplatformdefs.h +++ b/mkspecs/wince50standard-mipsiv-msvc2008/qplatformdefs.h @@ -39,5 +39,5 @@ ** ****************************************************************************/ -#include "../wince50standard-mipsiv-msvc2005/qplatformdefs.h" +#include "../common/wince/qplatformdefs.h" diff --git a/mkspecs/wince50standard-sh4-msvc2005/qmake.conf b/mkspecs/wince50standard-sh4-msvc2005/qmake.conf index aa420f2..1ee8950 100644 --- a/mkspecs/wince50standard-sh4-msvc2005/qmake.conf +++ b/mkspecs/wince50standard-sh4-msvc2005/qmake.conf @@ -3,7 +3,7 @@ # # Written for Microsoft VC2005.NET with Standard SDK for WindowsCE 5.0 (SH4) # -include(../common/wince.conf) +include(../common/wince/qmake.conf) CE_SDK = STANDARDSDK_500 CE_ARCH = SH4 diff --git a/mkspecs/wince50standard-sh4-msvc2005/qplatformdefs.h b/mkspecs/wince50standard-sh4-msvc2005/qplatformdefs.h index 4e67948..cda4ff4 100644 --- a/mkspecs/wince50standard-sh4-msvc2005/qplatformdefs.h +++ b/mkspecs/wince50standard-sh4-msvc2005/qplatformdefs.h @@ -39,93 +39,5 @@ ** ****************************************************************************/ -#ifndef QPLATFORMDEFS_H -#define QPLATFORMDEFS_H +#include "../common/wince/qplatformdefs.h" -#ifdef UNICODE -#ifndef _UNICODE -#define _UNICODE -#endif -#endif - -// Get Qt defines/settings - -#include "qglobal.h" -#include "qfunctions_wince.h" - -#define _POSIX_ -#include -#undef _POSIX_ - -#include -#include -#include -#include - -#define Q_FS_FAT -#ifdef QT_LARGEFILE_SUPPORT -#define QT_STATBUF struct _stati64 // non-ANSI defs -#define QT_STATBUF4TSTAT struct _stati64 // non-ANSI defs -#define QT_STAT ::_stati64 -#define QT_FSTAT ::_fstati64 -#else -#define QT_STATBUF struct stat // non-ANSI defs -#define QT_STATBUF4TSTAT struct stat // non-ANSI defs -#define QT_STAT ::qt_wince_stat -#define QT_FSTAT ::qt_wince__fstat -#endif -#define QT_STAT_REG _S_IFREG -#define QT_STAT_DIR _S_IFDIR -#define QT_STAT_MASK _S_IFMT -#if defined(_S_IFLNK) -# define QT_STAT_LNK _S_IFLNK -#endif -#define QT_FILENO ::qt_wince___fileno -#define QT_OPEN ::qt_wince_open -#define QT_CLOSE ::qt_wince__close -#ifdef QT_LARGEFILE_SUPPORT -#define QT_LSEEK ::_lseeki64 -#define QT_TSTAT ::_tstati64 -#else -#define QT_LSEEK ::qt_wince__lseek -#define QT_TSTAT ::_tstat -#endif -#define QT_READ ::qt_wince__read -#define QT_WRITE ::qt_wince__write -#define QT_ACCESS ::qt_wince__access -#define QT_GETCWD ::_getcwd -#define QT_CHDIR ::_chdir -#define QT_MKDIR ::qt_wince__mkdir -#define QT_RMDIR ::qt_wince__rmdir -#define QT_OPEN_RDONLY _O_RDONLY -#define QT_OPEN_WRONLY _O_WRONLY -#define QT_OPEN_RDWR _O_RDWR -#define QT_OPEN_CREAT _O_CREAT -#define QT_OPEN_TRUNC _O_TRUNC -#define QT_OPEN_APPEND _O_APPEND -# define QT_OPEN_TEXT _O_TEXT -# define QT_OPEN_BINARY _O_BINARY - -#define QT_FOPEN ::fopen -#define QT_FSEEK ::fseek -#define QT_FTELL ::ftell -#define QT_FGETPOS ::fgetpos -#define QT_FSETPOS ::fsetpos -#define QT_FPOS_T fpos_t -#define QT_OFF_T long - -#define QT_SIGNAL_ARGS int - -#define QT_VSNPRINTF(buffer, count, format, arg) \ - _vsnprintf(buffer, count, format, arg) - -#define QT_SNPRINTF ::_snprintf - -# define F_OK 0 -# define X_OK 1 -# define W_OK 2 -# define R_OK 4 - -typedef int mode_t; - -#endif // QPLATFORMDEFS_H diff --git a/mkspecs/wince50standard-sh4-msvc2008/qplatformdefs.h b/mkspecs/wince50standard-sh4-msvc2008/qplatformdefs.h index 88ca7ab..cda4ff4 100644 --- a/mkspecs/wince50standard-sh4-msvc2008/qplatformdefs.h +++ b/mkspecs/wince50standard-sh4-msvc2008/qplatformdefs.h @@ -39,5 +39,5 @@ ** ****************************************************************************/ -#include "../wince50standard-sh4-msvc2005/qplatformdefs.h" +#include "../common/wince/qplatformdefs.h" diff --git a/mkspecs/wince50standard-x86-msvc2005/qmake.conf b/mkspecs/wince50standard-x86-msvc2005/qmake.conf index 13bcc9f..2fa7556 100644 --- a/mkspecs/wince50standard-x86-msvc2005/qmake.conf +++ b/mkspecs/wince50standard-x86-msvc2005/qmake.conf @@ -3,7 +3,7 @@ # # Written for Microsoft VC2005.NET with Standard SDK for WindowsCE 5.0 (x86) # -include(../common/wince.conf) +include(../common/wince/qmake.conf) CE_SDK = STANDARDSDK_500 CE_ARCH = x86 diff --git a/mkspecs/wince50standard-x86-msvc2005/qplatformdefs.h b/mkspecs/wince50standard-x86-msvc2005/qplatformdefs.h index 4e67948..cda4ff4 100644 --- a/mkspecs/wince50standard-x86-msvc2005/qplatformdefs.h +++ b/mkspecs/wince50standard-x86-msvc2005/qplatformdefs.h @@ -39,93 +39,5 @@ ** ****************************************************************************/ -#ifndef QPLATFORMDEFS_H -#define QPLATFORMDEFS_H +#include "../common/wince/qplatformdefs.h" -#ifdef UNICODE -#ifndef _UNICODE -#define _UNICODE -#endif -#endif - -// Get Qt defines/settings - -#include "qglobal.h" -#include "qfunctions_wince.h" - -#define _POSIX_ -#include -#undef _POSIX_ - -#include -#include -#include -#include - -#define Q_FS_FAT -#ifdef QT_LARGEFILE_SUPPORT -#define QT_STATBUF struct _stati64 // non-ANSI defs -#define QT_STATBUF4TSTAT struct _stati64 // non-ANSI defs -#define QT_STAT ::_stati64 -#define QT_FSTAT ::_fstati64 -#else -#define QT_STATBUF struct stat // non-ANSI defs -#define QT_STATBUF4TSTAT struct stat // non-ANSI defs -#define QT_STAT ::qt_wince_stat -#define QT_FSTAT ::qt_wince__fstat -#endif -#define QT_STAT_REG _S_IFREG -#define QT_STAT_DIR _S_IFDIR -#define QT_STAT_MASK _S_IFMT -#if defined(_S_IFLNK) -# define QT_STAT_LNK _S_IFLNK -#endif -#define QT_FILENO ::qt_wince___fileno -#define QT_OPEN ::qt_wince_open -#define QT_CLOSE ::qt_wince__close -#ifdef QT_LARGEFILE_SUPPORT -#define QT_LSEEK ::_lseeki64 -#define QT_TSTAT ::_tstati64 -#else -#define QT_LSEEK ::qt_wince__lseek -#define QT_TSTAT ::_tstat -#endif -#define QT_READ ::qt_wince__read -#define QT_WRITE ::qt_wince__write -#define QT_ACCESS ::qt_wince__access -#define QT_GETCWD ::_getcwd -#define QT_CHDIR ::_chdir -#define QT_MKDIR ::qt_wince__mkdir -#define QT_RMDIR ::qt_wince__rmdir -#define QT_OPEN_RDONLY _O_RDONLY -#define QT_OPEN_WRONLY _O_WRONLY -#define QT_OPEN_RDWR _O_RDWR -#define QT_OPEN_CREAT _O_CREAT -#define QT_OPEN_TRUNC _O_TRUNC -#define QT_OPEN_APPEND _O_APPEND -# define QT_OPEN_TEXT _O_TEXT -# define QT_OPEN_BINARY _O_BINARY - -#define QT_FOPEN ::fopen -#define QT_FSEEK ::fseek -#define QT_FTELL ::ftell -#define QT_FGETPOS ::fgetpos -#define QT_FSETPOS ::fsetpos -#define QT_FPOS_T fpos_t -#define QT_OFF_T long - -#define QT_SIGNAL_ARGS int - -#define QT_VSNPRINTF(buffer, count, format, arg) \ - _vsnprintf(buffer, count, format, arg) - -#define QT_SNPRINTF ::_snprintf - -# define F_OK 0 -# define X_OK 1 -# define W_OK 2 -# define R_OK 4 - -typedef int mode_t; - -#endif // QPLATFORMDEFS_H diff --git a/mkspecs/wince50standard-x86-msvc2008/qplatformdefs.h b/mkspecs/wince50standard-x86-msvc2008/qplatformdefs.h index 76dc923..cda4ff4 100644 --- a/mkspecs/wince50standard-x86-msvc2008/qplatformdefs.h +++ b/mkspecs/wince50standard-x86-msvc2008/qplatformdefs.h @@ -39,5 +39,5 @@ ** ****************************************************************************/ -#include "../wince50standard-x86-msvc2005/qplatformdefs.h" +#include "../common/wince/qplatformdefs.h" diff --git a/mkspecs/wince60standard-armv4i-msvc2005/qplatformdefs.h b/mkspecs/wince60standard-armv4i-msvc2005/qplatformdefs.h index 4e67948..cda4ff4 100644 --- a/mkspecs/wince60standard-armv4i-msvc2005/qplatformdefs.h +++ b/mkspecs/wince60standard-armv4i-msvc2005/qplatformdefs.h @@ -39,93 +39,5 @@ ** ****************************************************************************/ -#ifndef QPLATFORMDEFS_H -#define QPLATFORMDEFS_H +#include "../common/wince/qplatformdefs.h" -#ifdef UNICODE -#ifndef _UNICODE -#define _UNICODE -#endif -#endif - -// Get Qt defines/settings - -#include "qglobal.h" -#include "qfunctions_wince.h" - -#define _POSIX_ -#include -#undef _POSIX_ - -#include -#include -#include -#include - -#define Q_FS_FAT -#ifdef QT_LARGEFILE_SUPPORT -#define QT_STATBUF struct _stati64 // non-ANSI defs -#define QT_STATBUF4TSTAT struct _stati64 // non-ANSI defs -#define QT_STAT ::_stati64 -#define QT_FSTAT ::_fstati64 -#else -#define QT_STATBUF struct stat // non-ANSI defs -#define QT_STATBUF4TSTAT struct stat // non-ANSI defs -#define QT_STAT ::qt_wince_stat -#define QT_FSTAT ::qt_wince__fstat -#endif -#define QT_STAT_REG _S_IFREG -#define QT_STAT_DIR _S_IFDIR -#define QT_STAT_MASK _S_IFMT -#if defined(_S_IFLNK) -# define QT_STAT_LNK _S_IFLNK -#endif -#define QT_FILENO ::qt_wince___fileno -#define QT_OPEN ::qt_wince_open -#define QT_CLOSE ::qt_wince__close -#ifdef QT_LARGEFILE_SUPPORT -#define QT_LSEEK ::_lseeki64 -#define QT_TSTAT ::_tstati64 -#else -#define QT_LSEEK ::qt_wince__lseek -#define QT_TSTAT ::_tstat -#endif -#define QT_READ ::qt_wince__read -#define QT_WRITE ::qt_wince__write -#define QT_ACCESS ::qt_wince__access -#define QT_GETCWD ::_getcwd -#define QT_CHDIR ::_chdir -#define QT_MKDIR ::qt_wince__mkdir -#define QT_RMDIR ::qt_wince__rmdir -#define QT_OPEN_RDONLY _O_RDONLY -#define QT_OPEN_WRONLY _O_WRONLY -#define QT_OPEN_RDWR _O_RDWR -#define QT_OPEN_CREAT _O_CREAT -#define QT_OPEN_TRUNC _O_TRUNC -#define QT_OPEN_APPEND _O_APPEND -# define QT_OPEN_TEXT _O_TEXT -# define QT_OPEN_BINARY _O_BINARY - -#define QT_FOPEN ::fopen -#define QT_FSEEK ::fseek -#define QT_FTELL ::ftell -#define QT_FGETPOS ::fgetpos -#define QT_FSETPOS ::fsetpos -#define QT_FPOS_T fpos_t -#define QT_OFF_T long - -#define QT_SIGNAL_ARGS int - -#define QT_VSNPRINTF(buffer, count, format, arg) \ - _vsnprintf(buffer, count, format, arg) - -#define QT_SNPRINTF ::_snprintf - -# define F_OK 0 -# define X_OK 1 -# define W_OK 2 -# define R_OK 4 - -typedef int mode_t; - -#endif // QPLATFORMDEFS_H diff --git a/mkspecs/wincewm50pocket-msvc2005/qmake.conf b/mkspecs/wincewm50pocket-msvc2005/qmake.conf index d75d86e..676be5a 100644 --- a/mkspecs/wincewm50pocket-msvc2005/qmake.conf +++ b/mkspecs/wincewm50pocket-msvc2005/qmake.conf @@ -3,7 +3,7 @@ # # Written for Microsoft VC2005.NET with Windows Mobile 5.0 SDK for Pocket PC (ARMV4I) # -include(../common/wince.conf) +include(../common/wince/qmake.conf) CE_SDK = Windows Mobile 5.0 Pocket PC SDK CE_ARCH = ARMV4I diff --git a/mkspecs/wincewm50pocket-msvc2005/qplatformdefs.h b/mkspecs/wincewm50pocket-msvc2005/qplatformdefs.h index 4e67948..cda4ff4 100644 --- a/mkspecs/wincewm50pocket-msvc2005/qplatformdefs.h +++ b/mkspecs/wincewm50pocket-msvc2005/qplatformdefs.h @@ -39,93 +39,5 @@ ** ****************************************************************************/ -#ifndef QPLATFORMDEFS_H -#define QPLATFORMDEFS_H +#include "../common/wince/qplatformdefs.h" -#ifdef UNICODE -#ifndef _UNICODE -#define _UNICODE -#endif -#endif - -// Get Qt defines/settings - -#include "qglobal.h" -#include "qfunctions_wince.h" - -#define _POSIX_ -#include -#undef _POSIX_ - -#include -#include -#include -#include - -#define Q_FS_FAT -#ifdef QT_LARGEFILE_SUPPORT -#define QT_STATBUF struct _stati64 // non-ANSI defs -#define QT_STATBUF4TSTAT struct _stati64 // non-ANSI defs -#define QT_STAT ::_stati64 -#define QT_FSTAT ::_fstati64 -#else -#define QT_STATBUF struct stat // non-ANSI defs -#define QT_STATBUF4TSTAT struct stat // non-ANSI defs -#define QT_STAT ::qt_wince_stat -#define QT_FSTAT ::qt_wince__fstat -#endif -#define QT_STAT_REG _S_IFREG -#define QT_STAT_DIR _S_IFDIR -#define QT_STAT_MASK _S_IFMT -#if defined(_S_IFLNK) -# define QT_STAT_LNK _S_IFLNK -#endif -#define QT_FILENO ::qt_wince___fileno -#define QT_OPEN ::qt_wince_open -#define QT_CLOSE ::qt_wince__close -#ifdef QT_LARGEFILE_SUPPORT -#define QT_LSEEK ::_lseeki64 -#define QT_TSTAT ::_tstati64 -#else -#define QT_LSEEK ::qt_wince__lseek -#define QT_TSTAT ::_tstat -#endif -#define QT_READ ::qt_wince__read -#define QT_WRITE ::qt_wince__write -#define QT_ACCESS ::qt_wince__access -#define QT_GETCWD ::_getcwd -#define QT_CHDIR ::_chdir -#define QT_MKDIR ::qt_wince__mkdir -#define QT_RMDIR ::qt_wince__rmdir -#define QT_OPEN_RDONLY _O_RDONLY -#define QT_OPEN_WRONLY _O_WRONLY -#define QT_OPEN_RDWR _O_RDWR -#define QT_OPEN_CREAT _O_CREAT -#define QT_OPEN_TRUNC _O_TRUNC -#define QT_OPEN_APPEND _O_APPEND -# define QT_OPEN_TEXT _O_TEXT -# define QT_OPEN_BINARY _O_BINARY - -#define QT_FOPEN ::fopen -#define QT_FSEEK ::fseek -#define QT_FTELL ::ftell -#define QT_FGETPOS ::fgetpos -#define QT_FSETPOS ::fsetpos -#define QT_FPOS_T fpos_t -#define QT_OFF_T long - -#define QT_SIGNAL_ARGS int - -#define QT_VSNPRINTF(buffer, count, format, arg) \ - _vsnprintf(buffer, count, format, arg) - -#define QT_SNPRINTF ::_snprintf - -# define F_OK 0 -# define X_OK 1 -# define W_OK 2 -# define R_OK 4 - -typedef int mode_t; - -#endif // QPLATFORMDEFS_H diff --git a/mkspecs/wincewm50pocket-msvc2008/qplatformdefs.h b/mkspecs/wincewm50pocket-msvc2008/qplatformdefs.h index f444562..cda4ff4 100644 --- a/mkspecs/wincewm50pocket-msvc2008/qplatformdefs.h +++ b/mkspecs/wincewm50pocket-msvc2008/qplatformdefs.h @@ -39,5 +39,5 @@ ** ****************************************************************************/ -#include "../wincewm50pocket-msvc2005/qplatformdefs.h" +#include "../common/wince/qplatformdefs.h" diff --git a/mkspecs/wincewm50smart-msvc2005/qmake.conf b/mkspecs/wincewm50smart-msvc2005/qmake.conf index 372b266..c0f09cc 100644 --- a/mkspecs/wincewm50smart-msvc2005/qmake.conf +++ b/mkspecs/wincewm50smart-msvc2005/qmake.conf @@ -3,7 +3,7 @@ # # Written for Microsoft VC2005.NET with Windows Mobile 5.0 SDK for Smartphone (ARMV4I) # -include(../common/wince.conf) +include(../common/wince/qmake.conf) CE_SDK = Windows Mobile 5.0 Smartphone SDK CE_ARCH = ARMV4I diff --git a/mkspecs/wincewm50smart-msvc2005/qplatformdefs.h b/mkspecs/wincewm50smart-msvc2005/qplatformdefs.h index 4e67948..cda4ff4 100644 --- a/mkspecs/wincewm50smart-msvc2005/qplatformdefs.h +++ b/mkspecs/wincewm50smart-msvc2005/qplatformdefs.h @@ -39,93 +39,5 @@ ** ****************************************************************************/ -#ifndef QPLATFORMDEFS_H -#define QPLATFORMDEFS_H +#include "../common/wince/qplatformdefs.h" -#ifdef UNICODE -#ifndef _UNICODE -#define _UNICODE -#endif -#endif - -// Get Qt defines/settings - -#include "qglobal.h" -#include "qfunctions_wince.h" - -#define _POSIX_ -#include -#undef _POSIX_ - -#include -#include -#include -#include - -#define Q_FS_FAT -#ifdef QT_LARGEFILE_SUPPORT -#define QT_STATBUF struct _stati64 // non-ANSI defs -#define QT_STATBUF4TSTAT struct _stati64 // non-ANSI defs -#define QT_STAT ::_stati64 -#define QT_FSTAT ::_fstati64 -#else -#define QT_STATBUF struct stat // non-ANSI defs -#define QT_STATBUF4TSTAT struct stat // non-ANSI defs -#define QT_STAT ::qt_wince_stat -#define QT_FSTAT ::qt_wince__fstat -#endif -#define QT_STAT_REG _S_IFREG -#define QT_STAT_DIR _S_IFDIR -#define QT_STAT_MASK _S_IFMT -#if defined(_S_IFLNK) -# define QT_STAT_LNK _S_IFLNK -#endif -#define QT_FILENO ::qt_wince___fileno -#define QT_OPEN ::qt_wince_open -#define QT_CLOSE ::qt_wince__close -#ifdef QT_LARGEFILE_SUPPORT -#define QT_LSEEK ::_lseeki64 -#define QT_TSTAT ::_tstati64 -#else -#define QT_LSEEK ::qt_wince__lseek -#define QT_TSTAT ::_tstat -#endif -#define QT_READ ::qt_wince__read -#define QT_WRITE ::qt_wince__write -#define QT_ACCESS ::qt_wince__access -#define QT_GETCWD ::_getcwd -#define QT_CHDIR ::_chdir -#define QT_MKDIR ::qt_wince__mkdir -#define QT_RMDIR ::qt_wince__rmdir -#define QT_OPEN_RDONLY _O_RDONLY -#define QT_OPEN_WRONLY _O_WRONLY -#define QT_OPEN_RDWR _O_RDWR -#define QT_OPEN_CREAT _O_CREAT -#define QT_OPEN_TRUNC _O_TRUNC -#define QT_OPEN_APPEND _O_APPEND -# define QT_OPEN_TEXT _O_TEXT -# define QT_OPEN_BINARY _O_BINARY - -#define QT_FOPEN ::fopen -#define QT_FSEEK ::fseek -#define QT_FTELL ::ftell -#define QT_FGETPOS ::fgetpos -#define QT_FSETPOS ::fsetpos -#define QT_FPOS_T fpos_t -#define QT_OFF_T long - -#define QT_SIGNAL_ARGS int - -#define QT_VSNPRINTF(buffer, count, format, arg) \ - _vsnprintf(buffer, count, format, arg) - -#define QT_SNPRINTF ::_snprintf - -# define F_OK 0 -# define X_OK 1 -# define W_OK 2 -# define R_OK 4 - -typedef int mode_t; - -#endif // QPLATFORMDEFS_H diff --git a/mkspecs/wincewm50smart-msvc2008/qplatformdefs.h b/mkspecs/wincewm50smart-msvc2008/qplatformdefs.h index 37c8f62..cda4ff4 100644 --- a/mkspecs/wincewm50smart-msvc2008/qplatformdefs.h +++ b/mkspecs/wincewm50smart-msvc2008/qplatformdefs.h @@ -39,5 +39,5 @@ ** ****************************************************************************/ -#include "../wincewm50smart-msvc2005/qplatformdefs.h" +#include "../common/wince/qplatformdefs.h" diff --git a/mkspecs/wincewm60professional-msvc2005/qplatformdefs.h b/mkspecs/wincewm60professional-msvc2005/qplatformdefs.h index 4e67948..cda4ff4 100644 --- a/mkspecs/wincewm60professional-msvc2005/qplatformdefs.h +++ b/mkspecs/wincewm60professional-msvc2005/qplatformdefs.h @@ -39,93 +39,5 @@ ** ****************************************************************************/ -#ifndef QPLATFORMDEFS_H -#define QPLATFORMDEFS_H +#include "../common/wince/qplatformdefs.h" -#ifdef UNICODE -#ifndef _UNICODE -#define _UNICODE -#endif -#endif - -// Get Qt defines/settings - -#include "qglobal.h" -#include "qfunctions_wince.h" - -#define _POSIX_ -#include -#undef _POSIX_ - -#include -#include -#include -#include - -#define Q_FS_FAT -#ifdef QT_LARGEFILE_SUPPORT -#define QT_STATBUF struct _stati64 // non-ANSI defs -#define QT_STATBUF4TSTAT struct _stati64 // non-ANSI defs -#define QT_STAT ::_stati64 -#define QT_FSTAT ::_fstati64 -#else -#define QT_STATBUF struct stat // non-ANSI defs -#define QT_STATBUF4TSTAT struct stat // non-ANSI defs -#define QT_STAT ::qt_wince_stat -#define QT_FSTAT ::qt_wince__fstat -#endif -#define QT_STAT_REG _S_IFREG -#define QT_STAT_DIR _S_IFDIR -#define QT_STAT_MASK _S_IFMT -#if defined(_S_IFLNK) -# define QT_STAT_LNK _S_IFLNK -#endif -#define QT_FILENO ::qt_wince___fileno -#define QT_OPEN ::qt_wince_open -#define QT_CLOSE ::qt_wince__close -#ifdef QT_LARGEFILE_SUPPORT -#define QT_LSEEK ::_lseeki64 -#define QT_TSTAT ::_tstati64 -#else -#define QT_LSEEK ::qt_wince__lseek -#define QT_TSTAT ::_tstat -#endif -#define QT_READ ::qt_wince__read -#define QT_WRITE ::qt_wince__write -#define QT_ACCESS ::qt_wince__access -#define QT_GETCWD ::_getcwd -#define QT_CHDIR ::_chdir -#define QT_MKDIR ::qt_wince__mkdir -#define QT_RMDIR ::qt_wince__rmdir -#define QT_OPEN_RDONLY _O_RDONLY -#define QT_OPEN_WRONLY _O_WRONLY -#define QT_OPEN_RDWR _O_RDWR -#define QT_OPEN_CREAT _O_CREAT -#define QT_OPEN_TRUNC _O_TRUNC -#define QT_OPEN_APPEND _O_APPEND -# define QT_OPEN_TEXT _O_TEXT -# define QT_OPEN_BINARY _O_BINARY - -#define QT_FOPEN ::fopen -#define QT_FSEEK ::fseek -#define QT_FTELL ::ftell -#define QT_FGETPOS ::fgetpos -#define QT_FSETPOS ::fsetpos -#define QT_FPOS_T fpos_t -#define QT_OFF_T long - -#define QT_SIGNAL_ARGS int - -#define QT_VSNPRINTF(buffer, count, format, arg) \ - _vsnprintf(buffer, count, format, arg) - -#define QT_SNPRINTF ::_snprintf - -# define F_OK 0 -# define X_OK 1 -# define W_OK 2 -# define R_OK 4 - -typedef int mode_t; - -#endif // QPLATFORMDEFS_H diff --git a/mkspecs/wincewm60professional-msvc2008/qplatformdefs.h b/mkspecs/wincewm60professional-msvc2008/qplatformdefs.h index a0737ae..cda4ff4 100644 --- a/mkspecs/wincewm60professional-msvc2008/qplatformdefs.h +++ b/mkspecs/wincewm60professional-msvc2008/qplatformdefs.h @@ -39,5 +39,5 @@ ** ****************************************************************************/ -#include "../wincewm60professional-msvc2005/qplatformdefs.h" +#include "../common/wince/qplatformdefs.h" diff --git a/mkspecs/wincewm60standard-msvc2005/qplatformdefs.h b/mkspecs/wincewm60standard-msvc2005/qplatformdefs.h index 4e67948..cda4ff4 100644 --- a/mkspecs/wincewm60standard-msvc2005/qplatformdefs.h +++ b/mkspecs/wincewm60standard-msvc2005/qplatformdefs.h @@ -39,93 +39,5 @@ ** ****************************************************************************/ -#ifndef QPLATFORMDEFS_H -#define QPLATFORMDEFS_H +#include "../common/wince/qplatformdefs.h" -#ifdef UNICODE -#ifndef _UNICODE -#define _UNICODE -#endif -#endif - -// Get Qt defines/settings - -#include "qglobal.h" -#include "qfunctions_wince.h" - -#define _POSIX_ -#include -#undef _POSIX_ - -#include -#include -#include -#include - -#define Q_FS_FAT -#ifdef QT_LARGEFILE_SUPPORT -#define QT_STATBUF struct _stati64 // non-ANSI defs -#define QT_STATBUF4TSTAT struct _stati64 // non-ANSI defs -#define QT_STAT ::_stati64 -#define QT_FSTAT ::_fstati64 -#else -#define QT_STATBUF struct stat // non-ANSI defs -#define QT_STATBUF4TSTAT struct stat // non-ANSI defs -#define QT_STAT ::qt_wince_stat -#define QT_FSTAT ::qt_wince__fstat -#endif -#define QT_STAT_REG _S_IFREG -#define QT_STAT_DIR _S_IFDIR -#define QT_STAT_MASK _S_IFMT -#if defined(_S_IFLNK) -# define QT_STAT_LNK _S_IFLNK -#endif -#define QT_FILENO ::qt_wince___fileno -#define QT_OPEN ::qt_wince_open -#define QT_CLOSE ::qt_wince__close -#ifdef QT_LARGEFILE_SUPPORT -#define QT_LSEEK ::_lseeki64 -#define QT_TSTAT ::_tstati64 -#else -#define QT_LSEEK ::qt_wince__lseek -#define QT_TSTAT ::_tstat -#endif -#define QT_READ ::qt_wince__read -#define QT_WRITE ::qt_wince__write -#define QT_ACCESS ::qt_wince__access -#define QT_GETCWD ::_getcwd -#define QT_CHDIR ::_chdir -#define QT_MKDIR ::qt_wince__mkdir -#define QT_RMDIR ::qt_wince__rmdir -#define QT_OPEN_RDONLY _O_RDONLY -#define QT_OPEN_WRONLY _O_WRONLY -#define QT_OPEN_RDWR _O_RDWR -#define QT_OPEN_CREAT _O_CREAT -#define QT_OPEN_TRUNC _O_TRUNC -#define QT_OPEN_APPEND _O_APPEND -# define QT_OPEN_TEXT _O_TEXT -# define QT_OPEN_BINARY _O_BINARY - -#define QT_FOPEN ::fopen -#define QT_FSEEK ::fseek -#define QT_FTELL ::ftell -#define QT_FGETPOS ::fgetpos -#define QT_FSETPOS ::fsetpos -#define QT_FPOS_T fpos_t -#define QT_OFF_T long - -#define QT_SIGNAL_ARGS int - -#define QT_VSNPRINTF(buffer, count, format, arg) \ - _vsnprintf(buffer, count, format, arg) - -#define QT_SNPRINTF ::_snprintf - -# define F_OK 0 -# define X_OK 1 -# define W_OK 2 -# define R_OK 4 - -typedef int mode_t; - -#endif // QPLATFORMDEFS_H diff --git a/mkspecs/wincewm60standard-msvc2008/qplatformdefs.h b/mkspecs/wincewm60standard-msvc2008/qplatformdefs.h index 819f150..cda4ff4 100644 --- a/mkspecs/wincewm60standard-msvc2008/qplatformdefs.h +++ b/mkspecs/wincewm60standard-msvc2008/qplatformdefs.h @@ -39,5 +39,5 @@ ** ****************************************************************************/ -#include "../wincewm60standard-msvc2005/qplatformdefs.h" +#include "../common/wince/qplatformdefs.h" diff --git a/mkspecs/wincewm65professional-msvc2005/qplatformdefs.h b/mkspecs/wincewm65professional-msvc2005/qplatformdefs.h index c3270e2..cda4ff4 100644 --- a/mkspecs/wincewm65professional-msvc2005/qplatformdefs.h +++ b/mkspecs/wincewm65professional-msvc2005/qplatformdefs.h @@ -39,4 +39,5 @@ ** ****************************************************************************/ -#include "../wincewm60professional-msvc2005/qplatformdefs.h" +#include "../common/wince/qplatformdefs.h" + diff --git a/mkspecs/wincewm65professional-msvc2008/qplatformdefs.h b/mkspecs/wincewm65professional-msvc2008/qplatformdefs.h index 35219d0..cda4ff4 100644 --- a/mkspecs/wincewm65professional-msvc2008/qplatformdefs.h +++ b/mkspecs/wincewm65professional-msvc2008/qplatformdefs.h @@ -39,5 +39,5 @@ ** ****************************************************************************/ -#include "../wincewm65professional-msvc2005/qplatformdefs.h" +#include "../common/wince/qplatformdefs.h" -- cgit v0.12 From 593172d298258c9dac13340ec712afc1473d5f34 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Tue, 8 Sep 2009 10:18:13 +0200 Subject: mkspec wince60standard-x86-msvc2005 added This is a mkspec template for creating x86 Windows CE 6 mkspecs. Task-number: 259850 Reviewed-by: mauricek --- mkspecs/wince60standard-armv4i-msvc2005/qmake.conf | 79 ++-------------------- mkspecs/wince60standard-x86-msvc2005/qmake.conf | 27 ++++++++ .../wince60standard-x86-msvc2005/qplatformdefs.h | 43 ++++++++++++ 3 files changed, 76 insertions(+), 73 deletions(-) create mode 100644 mkspecs/wince60standard-x86-msvc2005/qmake.conf create mode 100644 mkspecs/wince60standard-x86-msvc2005/qplatformdefs.h diff --git a/mkspecs/wince60standard-armv4i-msvc2005/qmake.conf b/mkspecs/wince60standard-armv4i-msvc2005/qmake.conf index 6386141..3bb18af 100644 --- a/mkspecs/wince60standard-armv4i-msvc2005/qmake.conf +++ b/mkspecs/wince60standard-armv4i-msvc2005/qmake.conf @@ -1,65 +1,20 @@ # # qmake configuration for wince-msvc2005 # -# Written for Microsoft VC2005.NET with Standard SDK for WindowsCE 6.0 (ARMV4I) +# Written for Microsoft VS 2005 for WindowsCE 6.0 (ARMV4I) +# This is just a template for creating Windows CE 6 mkspecs. # -MAKEFILE_GENERATOR = MSVC.NET -TEMPLATE = app -CONFIG += qt warn_on release incremental flat link_prl precompile_header autogen_precompile_source copy_dir_files debug_and_release debug_and_release_target embed_manifest_dll embed_manifest_exe -QT += core gui -CE_SDK = STANDARDSDK_600 -CE_ARCH = ARMV4I - -DEFINES += UNDER_CE WINCE _WINDOWS _UNICODE UNICODE STANDARDSHELL_UI_MODEL _WIN32_WCE=0x600 $$CE_ARCH _ARMV4I_ armv4i _ARM_ ARM _M_ARM ARM _WIN32 __arm__ Q_OS_WINCE_STD QT_NO_PRINTER QT_NO_PRINTDIALOG - -QMAKE_COMPILER_DEFINES += _MSC_VER=1400 - -QMAKE_CC = cl -QMAKE_LEX = flex -QMAKE_LEXFLAGS = -QMAKE_YACC = byacc -QMAKE_YACCFLAGS = -d -QMAKE_CFLAGS = -nologo -Zm200 -Zc:wchar_t- -QRarch4T -QRinterwork-return -QMAKE_CFLAGS_WARN_ON = -W3 -QMAKE_CFLAGS_WARN_OFF = -W0 -QMAKE_CFLAGS_RELEASE = -O2 -GL -MD -QMAKE_CFLAGS_DEBUG = -DDEBUG -D_DEBUG -Zi -MDd -QMAKE_CFLAGS_YACC = - -QMAKE_CXX = $$QMAKE_CC -QMAKE_CXXFLAGS = $$QMAKE_CFLAGS -QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON -w34100 -w34189 -QMAKE_CXXFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF -QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE -QMAKE_CXXFLAGS_DEBUG = $$QMAKE_CFLAGS_DEBUG -QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC -QMAKE_CXXFLAGS_STL_ON = -EHsc -QMAKE_CXXFLAGS_STL_OFF = -QMAKE_CXXFLAGS_RTTI_ON = -GR -QMAKE_CXXFLAGS_RTTI_OFF = -QMAKE_CXXFLAGS_EXCEPTIONS_ON = -EHsc -QMAKE_CXXFLAGS_EXCEPTIONS_OFF = +include(../common/wince/qmake.conf) -QMAKE_INCDIR = -QMAKE_INCDIR_QT = $$[QT_INSTALL_HEADERS] -QMAKE_LIBDIR_QT = $$[QT_INSTALL_LIBS] +CE_SDK = STANDARDSDK_600 # replace with actual SDK name +CE_ARCH = ARMV4I -QMAKE_RUN_CC = $(CC) -c $(CFLAGS) $(INCPATH) -Fo$obj $src -QMAKE_RUN_CC_IMP = $(CC) -c $(CFLAGS) $(INCPATH) -Fo$@ $< -QMAKE_RUN_CC_IMP_BATCH = $(CC) -c $(CFLAGS) $(INCPATH) -Fo$@ @<< -QMAKE_RUN_CXX = $(CXX) -c $(CXXFLAGS) $(INCPATH) -Fo$obj $src -QMAKE_RUN_CXX_IMP = $(CXX) -c $(CXXFLAGS) $(INCPATH) -Fo$@ $< -QMAKE_RUN_CXX_IMP_BATCH = $(CXX) -c $(CXXFLAGS) $(INCPATH) -Fo$@ @<< +DEFINES += STANDARDSHELL_UI_MODEL _WIN32_WCE=0x600 $$CE_ARCH _ARMV4I_ armv4i _ARM_ ARM _M_ARM ARM _WIN32 __arm__ -QMAKE_LINK = link -QMAKE_LFLAGS = /NOLOGO /NODEFAULTLIB:OLDNAMES.LIB -QMAKE_LFLAGS_RELEASE = /LTCG /INCREMENTAL:NO -QMAKE_LFLAGS_DEBUG = /DEBUG QMAKE_LFLAGS_CONSOLE = /SUBSYSTEM:WINDOWSCE,6.00 /MACHINE:THUMB /ENTRY:mainACRTStartup QMAKE_LFLAGS_WINDOWS = /SUBSYSTEM:WINDOWSCE,6.00 /MACHINE:THUMB QMAKE_LFLAGS_DLL = /SUBSYSTEM:WINDOWSCE,6.00 /MACHINE:THUMB /DLL /SAFESEH:NO -QMAKE_LIBFLAGS = $$QMAKE_LFLAGS_WINDOWS QMAKE_LIBFLAGS_RELEASE = /LTCG QMAKE_LIBS = corelibc.lib coredll.lib QMAKE_LIBS_CORE = libcmt.lib corelibc.lib ole32.lib oleaut32.lib uuid.lib commctrl.lib coredll.lib winsock.lib @@ -68,27 +23,5 @@ QMAKE_LIBS_NETWORK = ws2.lib $$QMAKE_LIBS_GUI QMAKE_LIBS_OPENGL = QMAKE_LIBS_COMPAT = -QMAKE_LIBS_QT_ENTRY = -lqtmain - -QMAKE_MOC = $$[QT_INSTALL_BINS]\moc.exe -QMAKE_UIC = $$[QT_INSTALL_BINS]\uic.exe -QMAKE_IDC = $$[QT_INSTALL_BINS]\idc.exe - -QMAKE_IDL = midl -QMAKE_LIB = lib QMAKE_RC = rc /DUNDER_CE=600 /D_WIN32_WCE=0x600 -QMAKE_ZIP = zip -r -9 - -QMAKE_COPY = copy /y -QMAKE_COPY_DIR = xcopy /s /q /y /i -QMAKE_MOVE = move -QMAKE_DEL_FILE = del -QMAKE_DEL_DIR = rmdir -QMAKE_CHK_DIR_EXISTS = if not exist -QMAKE_MKDIR = mkdir - -VCPROJ_EXTENSION = .vcproj -VCSOLUTION_EXTENSION = .sln -VCPROJ_KEYWORD = Qt4VSv1.0 -load(qt_config) diff --git a/mkspecs/wince60standard-x86-msvc2005/qmake.conf b/mkspecs/wince60standard-x86-msvc2005/qmake.conf new file mode 100644 index 0000000..2896c69 --- /dev/null +++ b/mkspecs/wince60standard-x86-msvc2005/qmake.conf @@ -0,0 +1,27 @@ +# +# qmake configuration for wince-msvc2005 +# +# Written for Microsoft VS 2005 for WindowsCE 6.0 (x86) +# This is just a template for creating Windows CE 6 mkspecs. +# + +include(../common/wince/qmake.conf) + +CE_SDK = STANDARDSDK_600 # replace with actual SDK name +CE_ARCH = x86 + +DEFINES += STANDARDSHELL_UI_MODEL _WIN32_WCE=0x600 $$CE_ARCH _X86_ _M_IX86 + +QMAKE_LFLAGS_CONSOLE = /SUBSYSTEM:WINDOWSCE,6.00 /MACHINE:X86 /ENTRY:mainACRTStartup +QMAKE_LFLAGS_WINDOWS = /SUBSYSTEM:WINDOWSCE,6.00 /MACHINE:X86 +QMAKE_LFLAGS_DLL = /SUBSYSTEM:WINDOWSCE,6.00 /MACHINE:X86 /DLL /SAFESEH:NO +QMAKE_LIBFLAGS_RELEASE = /LTCG +QMAKE_LIBS = corelibc.lib coredll.lib +QMAKE_LIBS_CORE = corelibc.lib ole32.lib oleaut32.lib uuid.lib commctrl.lib coredll.lib winsock.lib +QMAKE_LIBS_GUI = ceshell.lib ole32.lib $$QMAKE_LIBS_CORE +QMAKE_LIBS_NETWORK = ws2.lib $$QMAKE_LIBS_GUI +QMAKE_LIBS_OPENGL = +QMAKE_LIBS_COMPAT = + +QMAKE_RC = rc /DUNDER_CE=600 /D_WIN32_WCE=0x600 + diff --git a/mkspecs/wince60standard-x86-msvc2005/qplatformdefs.h b/mkspecs/wince60standard-x86-msvc2005/qplatformdefs.h new file mode 100644 index 0000000..cda4ff4 --- /dev/null +++ b/mkspecs/wince60standard-x86-msvc2005/qplatformdefs.h @@ -0,0 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the qmake spec of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "../common/wince/qplatformdefs.h" + -- cgit v0.12 From 115d2c10b56228fbcdab5a8506c24d7b4745d95c Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Mon, 7 Sep 2009 16:46:47 +0200 Subject: Tests: Do not execute network tests at all if DNS setup is broken. Reviewed-by: Jesper --- tests/auto/network-settings.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/auto/network-settings.h b/tests/auto/network-settings.h index 144f7b3..6ffb6f4 100644 --- a/tests/auto/network-settings.h +++ b/tests/auto/network-settings.h @@ -328,3 +328,18 @@ QByteArray QtNetworkSettings::imapExpectedReplySsl; #else #define Q_SET_DEFAULT_IAP #endif + + +class QtNetworkSettingsInitializerCode { +public: + QtNetworkSettingsInitializerCode() { + QHostInfo testServerResult = QHostInfo::fromName(QtNetworkSettings::serverName()); + if (testServerResult.error() != QHostInfo::NoError) { + qWarning() << "Could not lookup" << QtNetworkSettings::serverName(); + qWarning() << "Please configure the test environment!"; + qWarning() << "See /etc/hosts or network-settings.h"; + qFatal("Exiting"); + } + } +}; +QtNetworkSettingsInitializerCode qtNetworkSettingsInitializer; -- cgit v0.12 From deff8fcf0ed060b949c3ec0fa0ec4bd81c253825 Mon Sep 17 00:00:00 2001 From: mae Date: Tue, 8 Sep 2009 10:45:27 +0200 Subject: Fix autotest The piece table test relied on previous automatic edit command grouping. The grouping now has to be enforced explicitely with beginEditGroup()/endEditGroup() --- tests/auto/qtextpiecetable/tst_qtextpiecetable.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/auto/qtextpiecetable/tst_qtextpiecetable.cpp b/tests/auto/qtextpiecetable/tst_qtextpiecetable.cpp index 6f8dd2b..61f4456 100644 --- a/tests/auto/qtextpiecetable/tst_qtextpiecetable.cpp +++ b/tests/auto/qtextpiecetable/tst_qtextpiecetable.cpp @@ -772,7 +772,9 @@ void tst_QTextPieceTable::blockRemoval1() QVERIFY(table->blocksFind(6).position() == 5); QVERIFY(table->blocksFind(11).position() == 10); + table->beginEditBlock(); table->remove(5, 5); + table->endEditBlock(); QVERIFY(table->blocksFind(4).blockFormat() == QTextBlockFormat()); QVERIFY(table->blocksFind(5).blockFormat() == fmt2); QVERIFY(table->blocksFind(4).position() == 0); @@ -864,7 +866,10 @@ void tst_QTextPieceTable::blockRemoval3() QVERIFY(table->blocksFind(6).position() == 5); QVERIFY(table->blocksFind(11).position() == 10); + table->beginEditBlock(); table->remove(3, 4); + table->endEditBlock(); + QVERIFY(table->blocksFind(1).blockFormat() == QTextBlockFormat()); QVERIFY(table->blocksFind(5).blockFormat() == QTextBlockFormat()); QVERIFY(table->blocksFind(1).position() == 0); @@ -958,7 +963,10 @@ void tst_QTextPieceTable::blockRemoval5() QVERIFY(table->blocksFind(6).position() == 5); QVERIFY(table->blocksFind(11).position() == 10); + table->beginEditBlock(); table->remove(3, 8); + table->endEditBlock(); + QVERIFY(table->blocksFind(0).blockFormat() == QTextBlockFormat()); QVERIFY(table->blocksFind(5).blockFormat() == QTextBlockFormat()); QVERIFY(table->blocksFind(1).position() == 0); -- cgit v0.12 From fa889cf4b80868249c70715275069eb150b597cc Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 8 Sep 2009 10:45:57 +0200 Subject: Try to make test more robust. By using QTRY_{COMPARE,VERIFY} instead of waiting an arbitrary amount of time waiting for the window manager to do his job. Also use QApplication::setActiveWindow which seems to be more robust then QWidget::activateWindow --- tests/auto/qabstractbutton/tst_qabstractbutton.cpp | 5 +-- tests/auto/qbuttongroup/tst_qbuttongroup.cpp | 8 ++--- tests/auto/qcompleter/tst_qcompleter.cpp | 10 ++++-- tests/auto/qdoublespinbox/tst_qdoublespinbox.cpp | 7 ++-- tests/auto/qfocusevent/tst_qfocusevent.cpp | 25 +++++++------ tests/auto/qgridlayout/tst_qgridlayout.cpp | 11 +++--- tests/auto/qgroupbox/tst_qgroupbox.cpp | 6 ++-- tests/auto/qitemdelegate/tst_qitemdelegate.cpp | 9 ++--- tests/auto/qmdisubwindow/tst_qmdisubwindow.cpp | 42 ++++++++++++---------- tests/auto/qmenu/tst_qmenu.cpp | 14 +++++--- tests/auto/qpushbutton/tst_qpushbutton.cpp | 8 +++-- tests/auto/qspinbox/tst_qspinbox.cpp | 20 ++++++----- tests/auto/qstackedlayout/tst_qstackedlayout.cpp | 13 ++++--- tests/auto/qtableview/tst_qtableview.cpp | 25 +++++++------ tests/auto/qtextbrowser/tst_qtextbrowser.cpp | 6 +++- tests/auto/qtreeview/tst_qtreeview.cpp | 5 +-- 16 files changed, 130 insertions(+), 84 deletions(-) diff --git a/tests/auto/qabstractbutton/tst_qabstractbutton.cpp b/tests/auto/qabstractbutton/tst_qabstractbutton.cpp index de2d9f4..7ee52ad 100644 --- a/tests/auto/qabstractbutton/tst_qabstractbutton.cpp +++ b/tests/auto/qabstractbutton/tst_qabstractbutton.cpp @@ -550,6 +550,7 @@ void tst_QAbstractButton::setShortcut() { QKeySequence seq( Qt::Key_A ); testWidget->setShortcut( seq ); + QApplication::setActiveWindow(testWidget); // must be active to get shortcuts for (int i = 0; !testWidget->isActiveWindow() && i < 100; ++i) { @@ -557,8 +558,8 @@ void tst_QAbstractButton::setShortcut() QApplication::instance()->processEvents(); QTest::qWait(100); } - QVERIFY(testWidget->isActiveWindow()); - + QVERIFY(testWidget->isActiveWindow()); + QTest::keyClick( testWidget, 'A' ); QTest::qWait(300); // Animate click takes time QCOMPARE(click_count, (uint)1); diff --git a/tests/auto/qbuttongroup/tst_qbuttongroup.cpp b/tests/auto/qbuttongroup/tst_qbuttongroup.cpp index f49568d..82969b9 100644 --- a/tests/auto/qbuttongroup/tst_qbuttongroup.cpp +++ b/tests/auto/qbuttongroup/tst_qbuttongroup.cpp @@ -100,7 +100,7 @@ private slots: #if QT_VERSION >= 0x040600 void autoIncrementId(); #endif - + void task209485_removeFromGroupInEventHandler_data(); void task209485_removeFromGroupInEventHandler(); }; @@ -333,12 +333,12 @@ void tst_QButtonGroup::testSignals() QCOMPARE(clickedSpy.count(), 1); QCOMPARE(clickedIdSpy.count(), 1); - - int expectedId = -1; + + int expectedId = -1; #if QT_VERSION >= 0x040600 expectedId = -2; #endif - + QVERIFY(clickedIdSpy.takeFirst().at(0).toInt() == expectedId); QCOMPARE(pressedSpy.count(), 1); QCOMPARE(pressedIdSpy.count(), 1); diff --git a/tests/auto/qcompleter/tst_qcompleter.cpp b/tests/auto/qcompleter/tst_qcompleter.cpp index 928d826..7eefb26 100644 --- a/tests/auto/qcompleter/tst_qcompleter.cpp +++ b/tests/auto/qcompleter/tst_qcompleter.cpp @@ -1025,6 +1025,7 @@ void tst_QCompleter::multipleWidgets() #ifdef Q_WS_X11 qt_x11_wait_for_window_manager(&window); #endif + QApplication::setActiveWindow(&window); QTest::qWait(50); QTRY_VERIFY(qApp->focusWidget() == comboBox); comboBox->lineEdit()->setText("it"); @@ -1058,6 +1059,7 @@ void tst_QCompleter::focusIn() window.show(); QTest::qWait(100); window.activateWindow(); + QApplication::setActiveWindow(&window); QTest::qWait(100); QTRY_COMPARE(qApp->activeWindow(), &window); @@ -1322,8 +1324,10 @@ void tst_QCompleter::task253125_lineEditCompletion() #ifdef Q_WS_X11 qt_x11_wait_for_window_manager(&edit); #endif + QTest::qWait(10); + QApplication::setActiveWindow(&edit); + QTRY_COMPARE(QApplication::activeWindow(), &edit); - QTest::qWait(100); QTest::keyClick(&edit, 'i'); QCOMPARE(edit.completer()->currentCompletion(), QString("iota")); QTest::keyClick(edit.completer()->popup(), Qt::Key_Down); @@ -1358,7 +1362,9 @@ void tst_QCompleter::task247560_keyboardNavigation() qt_x11_wait_for_window_manager(&edit); #endif - QTest::qWait(100); + QTest::qWait(10); + QApplication::setActiveWindow(&edit); + QTRY_COMPARE(QApplication::activeWindow(), &edit); QTest::keyClick(&edit, 'r'); QTest::keyClick(edit.completer()->popup(), Qt::Key_Down); diff --git a/tests/auto/qdoublespinbox/tst_qdoublespinbox.cpp b/tests/auto/qdoublespinbox/tst_qdoublespinbox.cpp index 6162be0..aa3ccb7 100644 --- a/tests/auto/qdoublespinbox/tst_qdoublespinbox.cpp +++ b/tests/auto/qdoublespinbox/tst_qdoublespinbox.cpp @@ -52,6 +52,9 @@ #include #include + +#include "../../shared/util.h" + //TESTED_CLASS= //TESTED_FILES=gui/widgets/qspinbox.h gui/widgets/qspinbox.cpp gui/widgets/qabstractspinbox.cpp gui/widgets/qabstractspinbox_p.h gui/widgets/qabstractspinbox.h @@ -772,8 +775,8 @@ void tst_QDoubleSpinBox::editingFinished() layout->addWidget(box2); testFocusWidget->show(); - QTest::qWait(100); - QVERIFY(box->isActiveWindow()); + QTest::qWait(10); + QTRY_VERIFY(box->isActiveWindow()); box->setFocus(); QSignalSpy editingFinishedSpy1(box, SIGNAL(editingFinished())); diff --git a/tests/auto/qfocusevent/tst_qfocusevent.cpp b/tests/auto/qfocusevent/tst_qfocusevent.cpp index 662f115..5ad78de 100644 --- a/tests/auto/qfocusevent/tst_qfocusevent.cpp +++ b/tests/auto/qfocusevent/tst_qfocusevent.cpp @@ -56,6 +56,8 @@ #include #include +#include "../../shared/util.h" + QT_FORWARD_DECLARE_CLASS(QWidget) //TESTED_CLASS= @@ -168,6 +170,7 @@ void tst_QFocusEvent::initWidget() { // On X11 we have to ensure the event was processed before doing any checking, on Windows // this is processed straight away. + QApplication::setActiveWindow(childFocusWidgetOne); for (int i = 0; i < 1000; ++i) { if (childFocusWidgetOne->isActiveWindow() && childFocusWidgetOne->hasFocus()) @@ -243,9 +246,9 @@ void tst_QFocusEvent::checkReason_BackTab() // Now test the backtab key QTest::keyClick( childFocusWidgetOne, Qt::Key_Backtab ); - QTest::qWait(2000); + QTest::qWait(200); - QVERIFY(childFocusWidgetOne->focusOutEventRecieved); + QTRY_VERIFY(childFocusWidgetOne->focusOutEventRecieved); QVERIFY(childFocusWidgetTwo->focusInEventRecieved); QVERIFY(childFocusWidgetOne->focusOutEventLostFocus); QVERIFY(childFocusWidgetTwo->focusInEventGotFocus); @@ -265,9 +268,9 @@ void tst_QFocusEvent::checkReason_Popup() Q3PopupMenu* popupMenu = new Q3PopupMenu( testFocusWidget ); popupMenu->insertItem( "Test" ); popupMenu->popup( QPoint(0,0) ); - QTest::qWait(500); + QTest::qWait(50); - QVERIFY(childFocusWidgetOne->focusOutEventLostFocus); + QTRY_VERIFY(childFocusWidgetOne->focusOutEventLostFocus); QVERIFY( childFocusWidgetOne->hasFocus() ); QVERIFY( !childFocusWidgetOne->focusInEventRecieved ); @@ -290,11 +293,11 @@ void tst_QFocusEvent::checkReason_Popup() QMenu* popupMenu = new QMenu( testFocusWidget ); popupMenu->addMenu( "Test" ); popupMenu->popup( QPoint(0,0) ); - QTest::qWait(500); + QTest::qWait(50); - QVERIFY(childFocusWidgetOne->focusOutEventLostFocus); + QTRY_VERIFY(childFocusWidgetOne->focusOutEventLostFocus); - QVERIFY( childFocusWidgetOne->hasFocus() ); + QTRY_VERIFY( childFocusWidgetOne->hasFocus() ); QVERIFY( !childFocusWidgetOne->focusInEventRecieved ); QVERIFY( childFocusWidgetOne->focusOutEventRecieved ); QVERIFY( !childFocusWidgetTwo->focusInEventRecieved ); @@ -368,13 +371,13 @@ void tst_QFocusEvent::checkReason_focusWidget() QLineEdit edit1; QLineEdit edit2; - QVBoxLayout outerLayout; + QVBoxLayout outerLayout; outerLayout.addWidget(&frame1); outerLayout.addWidget(&frame2); window1.setLayout(&outerLayout); - - QVBoxLayout leftLayout; - QVBoxLayout rightLayout; + + QVBoxLayout leftLayout; + QVBoxLayout rightLayout; leftLayout.addWidget(&edit1); rightLayout.addWidget(&edit2); frame1.setLayout(&leftLayout); diff --git a/tests/auto/qgridlayout/tst_qgridlayout.cpp b/tests/auto/qgridlayout/tst_qgridlayout.cpp index 13d79b1..590bafa 100644 --- a/tests/auto/qgridlayout/tst_qgridlayout.cpp +++ b/tests/auto/qgridlayout/tst_qgridlayout.cpp @@ -51,6 +51,8 @@ #include #include +#include "../../shared/util.h" + //TESTED_CLASS= //TESTED_FILES=gui/kernel/qlayout.cpp gui/kernel/qlayout.h @@ -788,8 +790,8 @@ void tst_QGridLayout::minMaxSize_data() QTest::addColumn("fixedSize"); //input and expected output QTest::addColumn("sizeinfos"); - - QTest::newRow("3x1 grid, extend to minimumSize") << QString() << 3 << 1 + + QTest::newRow("3x1 grid, extend to minimumSize") << QString() << 3 << 1 << int(QSizePolicy::Minimum) << QSize(152, 50) << (SizeInfoList() << SizeInfo(QRect(10, 10, 43, 30), QSize( 75, 75), QSize(0,0)) << SizeInfo(QRect(10 + 45, 10, 43, 30), QSize(75, 75), QSize( 0, 0)) @@ -917,13 +919,14 @@ void tst_QGridLayout::minMaxSize() #if defined(Q_WS_X11) qt_x11_wait_for_window_manager(m_toplevel); // wait for the show #endif + QTest::qWait(20); m_toplevel->adjustSize(); - QTest::qWait(200); // wait for the implicit adjustSize + QTest::qWait(20); // wait for the implicit adjustSize // If the following fails we might have to wait longer. // If that does not help there is likely a problem with the implicit adjustSize in show() if (!fixedSize.isValid()) { // Note that this can fail if the desktop has large fonts on windows. - QCOMPARE(m_toplevel->size(), m_toplevel->sizeHint()); + QTRY_COMPARE(m_toplevel->size(), m_toplevel->sizeHint()); } // We are relying on the order here... for (int pi = 0; pi < sizehinters.count(); ++pi) { diff --git a/tests/auto/qgroupbox/tst_qgroupbox.cpp b/tests/auto/qgroupbox/tst_qgroupbox.cpp index 94b70e6..7346700 100644 --- a/tests/auto/qgroupbox/tst_qgroupbox.cpp +++ b/tests/auto/qgroupbox/tst_qgroupbox.cpp @@ -49,6 +49,8 @@ #include "qgroupbox.h" +#include "../../shared/util.h" + //TESTED_CLASS= //TESTED_FILES= @@ -81,7 +83,7 @@ private slots: void toggledVsClicked(); void childrenAreDisabled(); void propagateFocus(); - + private: bool checked; qint64 timeStamp; @@ -467,7 +469,7 @@ void tst_QGroupBox::propagateFocus() box.show(); box.setFocus(); QTest::qWait(250); - QCOMPARE(qApp->focusWidget(), static_cast(&lineEdit)); + QTRY_COMPARE(qApp->focusWidget(), static_cast(&lineEdit)); } QTEST_MAIN(tst_QGroupBox) diff --git a/tests/auto/qitemdelegate/tst_qitemdelegate.cpp b/tests/auto/qitemdelegate/tst_qitemdelegate.cpp index 1ef77c0..9871da3 100644 --- a/tests/auto/qitemdelegate/tst_qitemdelegate.cpp +++ b/tests/auto/qitemdelegate/tst_qitemdelegate.cpp @@ -63,6 +63,8 @@ #include #include +#include "../../shared/util.h" + Q_DECLARE_METATYPE(QAbstractItemDelegate::EndEditHint) //TESTED_CLASS= @@ -862,6 +864,8 @@ void tst_QItemDelegate::decoration() #ifdef Q_WS_X11 qt_x11_wait_for_window_manager(&table); #endif + QApplication::setActiveWindow(&table); + QTRY_COMPARE(QApplication::activeWindow(), &table); QVariant value; switch ((QVariant::Type)type) { @@ -1164,10 +1168,7 @@ void tst_QItemDelegate::task257859_finalizeEdit() QDialog dialog; QTimer::singleShot(100, &dialog, SLOT(close())); dialog.exec(); - - QTest::qWait(100); - - QVERIFY(!editor); + QTRY_VERIFY(!editor); } diff --git a/tests/auto/qmdisubwindow/tst_qmdisubwindow.cpp b/tests/auto/qmdisubwindow/tst_qmdisubwindow.cpp index 78ba46b..4d5160b 100644 --- a/tests/auto/qmdisubwindow/tst_qmdisubwindow.cpp +++ b/tests/auto/qmdisubwindow/tst_qmdisubwindow.cpp @@ -63,6 +63,9 @@ #include #endif +#include "../../shared/util.h" + + QT_BEGIN_NAMESPACE #if defined(Q_WS_X11) extern void qt_x11_wait_for_window_manager(QWidget *w); @@ -1004,15 +1007,16 @@ void tst_QMdiSubWindow::setSystemMenu() qt_x11_wait_for_window_manager(&mainWindow); #endif - QVERIFY(subWindow->isVisible()); - QPoint globalPopupPos = subWindow->mapToGlobal(subWindow->contentsRect().topLeft()); + QTRY_VERIFY(subWindow->isVisible()); + QPoint globalPopupPos; // Show system menu QVERIFY(!qApp->activePopupWidget()); subWindow->showSystemMenu(); - QTest::qWait(250); - QCOMPARE(qApp->activePopupWidget(), qobject_cast(systemMenu)); - QCOMPARE(systemMenu->mapToGlobal(QPoint(0, 0)), globalPopupPos); + QTest::qWait(25); + QTRY_COMPARE(qApp->activePopupWidget(), qobject_cast(systemMenu)); + QTRY_COMPARE(systemMenu->mapToGlobal(QPoint(0, 0)), + (globalPopupPos = subWindow->mapToGlobal(subWindow->contentsRect().topLeft())) ); systemMenu->hide(); QVERIFY(!qApp->activePopupWidget()); @@ -1034,9 +1038,9 @@ void tst_QMdiSubWindow::setSystemMenu() // Show the new system menu QVERIFY(!qApp->activePopupWidget()); subWindow->showSystemMenu(); - QTest::qWait(250); - QCOMPARE(qApp->activePopupWidget(), qobject_cast(systemMenu)); - QCOMPARE(systemMenu->mapToGlobal(QPoint(0, 0)), globalPopupPos); + QTest::qWait(25); + QTRY_COMPARE(qApp->activePopupWidget(), qobject_cast(systemMenu)); + QTRY_COMPARE(systemMenu->mapToGlobal(QPoint(0, 0)), globalPopupPos); systemMenu->hide(); QVERIFY(!qApp->activePopupWidget()); @@ -1048,12 +1052,12 @@ void tst_QMdiSubWindow::setSystemMenu() QWidget *menuLabel = subWindow->maximizedSystemMenuIconWidget(); QVERIFY(menuLabel); subWindow->showSystemMenu(); - QTest::qWait(250); - QCOMPARE(qApp->activePopupWidget(), qobject_cast(systemMenu)); - globalPopupPos = menuLabel->mapToGlobal(QPoint(0, menuLabel->y() + menuLabel->height())); - QCOMPARE(systemMenu->mapToGlobal(QPoint(0, 0)), globalPopupPos); + QTest::qWait(25); + QTRY_COMPARE(qApp->activePopupWidget(), qobject_cast(systemMenu)); + QCOMPARE(systemMenu->mapToGlobal(QPoint(0, 0)), + (globalPopupPos = menuLabel->mapToGlobal(QPoint(0, menuLabel->y() + menuLabel->height())))); systemMenu->hide(); - QVERIFY(!qApp->activePopupWidget()); + QTRY_VERIFY(!qApp->activePopupWidget()); subWindow->showNormal(); #endif @@ -1064,11 +1068,11 @@ void tst_QMdiSubWindow::setSystemMenu() subWindow->showSystemMenu(); QTest::qWait(250); - QCOMPARE(qApp->activePopupWidget(), qobject_cast(systemMenu)); + QTRY_COMPARE(qApp->activePopupWidget(), qobject_cast(systemMenu)); // + QPoint(1, 0) because topRight() == QPoint(left() + width() -1, top()) globalPopupPos = subWindow->mapToGlobal(subWindow->contentsRect().topRight()) + QPoint(1, 0); globalPopupPos -= QPoint(systemMenu->sizeHint().width(), 0); - QCOMPARE(systemMenu->mapToGlobal(QPoint(0, 0)), globalPopupPos); + QTRY_COMPARE(systemMenu->mapToGlobal(QPoint(0, 0)), globalPopupPos); systemMenu->hide(); QVERIFY(!qApp->activePopupWidget()); @@ -1081,10 +1085,10 @@ void tst_QMdiSubWindow::setSystemMenu() QVERIFY(menuLabel); subWindow->showSystemMenu(); QTest::qWait(250); - QCOMPARE(qApp->activePopupWidget(), qobject_cast(systemMenu)); + QTRY_COMPARE(qApp->activePopupWidget(), qobject_cast(systemMenu)); globalPopupPos = menuLabel->mapToGlobal(QPoint(menuLabel->width(), menuLabel->y() + menuLabel->height())); globalPopupPos -= QPoint(systemMenu->sizeHint().width(), 0); - QCOMPARE(systemMenu->mapToGlobal(QPoint(0, 0)), globalPopupPos); + QTRY_COMPARE(systemMenu->mapToGlobal(QPoint(0, 0)), globalPopupPos); #endif delete systemMenu; @@ -1902,7 +1906,7 @@ void tst_QMdiSubWindow::task_182852() mainWindow.show(); mainWindow.menuBar()->setVisible(true); qApp->setActiveWindow(&mainWindow); - + QString originalWindowTitle = QString::fromLatin1("MainWindow - [foo]"); mainWindow.setWindowTitle(originalWindowTitle); @@ -1917,7 +1921,7 @@ void tst_QMdiSubWindow::task_182852() window->showMaximized(); qApp->processEvents(); QVERIFY(window->isMaximized()); - + QCOMPARE(mainWindow.windowTitle(), QString::fromLatin1("%1 - [%2]") .arg(originalWindowTitle, window->widget()->windowTitle())); diff --git a/tests/auto/qmenu/tst_qmenu.cpp b/tests/auto/qmenu/tst_qmenu.cpp index ab8dd48..4a4231a 100644 --- a/tests/auto/qmenu/tst_qmenu.cpp +++ b/tests/auto/qmenu/tst_qmenu.cpp @@ -55,6 +55,9 @@ #include #include #include + +#include "../../shared/util.h" + //TESTED_CLASS= //TESTED_FILES= @@ -437,15 +440,16 @@ void tst_QMenu::overrideMenuAction() m->addAction(aQuit); w.show(); - QTest::qWait(200); + w.setFocus(); + QTRY_VERIFY(w.hasFocus()); //test of the action inside the menu QTest::keyClick(&w, Qt::Key_X, Qt::ControlModifier); - QCOMPARE(activated, aQuit); + QTRY_COMPARE(activated, aQuit); //test if the menu still pops out QTest::keyClick(&w, Qt::Key_F, Qt::AltModifier); - QVERIFY(m->isVisible()); + QTRY_VERIFY(m->isVisible()); delete aFileMenu; @@ -703,12 +707,12 @@ void tst_QMenu::task250673_activeMultiColumnSubMenuPosition() }; QMenu sub; - + if (sub.style()->styleHint(QStyle::SH_Menu_Scrollable, 0, &sub)) { //the style prevents the menus from getting columns QSKIP("the style doesn't support multiple columns, it makes the menu scrollable", SkipSingle); } - + sub.addAction("Sub-Item1"); QAction *subAction = sub.addAction("Sub-Item2"); diff --git a/tests/auto/qpushbutton/tst_qpushbutton.cpp b/tests/auto/qpushbutton/tst_qpushbutton.cpp index 5059578..2013258 100644 --- a/tests/auto/qpushbutton/tst_qpushbutton.cpp +++ b/tests/auto/qpushbutton/tst_qpushbutton.cpp @@ -54,6 +54,8 @@ #include #include +#include "../../shared/util.h" + Q_DECLARE_METATYPE(QPushButton*) //TESTED_CLASS= @@ -413,6 +415,7 @@ void tst_QPushButton::setAccel() // The shortcut will not be activated unless the button is in a active // window and has focus + QApplication::setActiveWindow(testWidget); testWidget->setFocus(); for (int i = 0; !testWidget->isActiveWindow() && i < 1000; ++i) { testWidget->activateWindow(); @@ -421,8 +424,8 @@ void tst_QPushButton::setAccel() } QVERIFY(testWidget->isActiveWindow()); QTest::keyClick( testWidget, 'A', Qt::AltModifier ); - QTest::qWait( 500 ); - QVERIFY( click_count == 1 ); + QTest::qWait( 50 ); + QTRY_VERIFY( click_count == 1 ); QVERIFY( press_count == 1 ); QVERIFY( release_count == 1 ); QVERIFY( toggle_count == 0 ); @@ -430,6 +433,7 @@ void tst_QPushButton::setAccel() // wait 200 ms because setAccel uses animateClick. // if we don't wait this may screw up a next test. QTest::qWait(200); + QTRY_VERIFY( !testWidget->isDown() ); } void tst_QPushButton::animateClick() diff --git a/tests/auto/qspinbox/tst_qspinbox.cpp b/tests/auto/qspinbox/tst_qspinbox.cpp index 73d25a2..f4d70d1 100644 --- a/tests/auto/qspinbox/tst_qspinbox.cpp +++ b/tests/auto/qspinbox/tst_qspinbox.cpp @@ -140,7 +140,7 @@ private slots: void removeAll(); void startWithDash(); void undoRedo(); - + void specialValue(); void textFromValue(); @@ -750,11 +750,13 @@ void tst_QSpinBox::editingFinished() QSpinBox *box2 = new QSpinBox(testFocusWidget); layout->addWidget(box2); + testFocusWidget->show(); + QApplication::setActiveWindow(testFocusWidget); box->activateWindow(); - QTest::qWait(1000);//qApp->processEvents(); + QTest::qWait(100);//qApp->processEvents(); box->setFocus(); - QTRY_VERIFY(qApp->focusWidget() == box); + QTRY_COMPARE(qApp->focusWidget(), box); QSignalSpy editingFinishedSpy1(box, SIGNAL(editingFinished())); QSignalSpy editingFinishedSpy2(box2, SIGNAL(editingFinished())); @@ -910,7 +912,7 @@ void tst_QSpinBox::undoRedo() void tst_QSpinBox::specialValue() { QString specialText="foo"; - + QWidget topWidget; QVBoxLayout layout(&topWidget); SpinBox spin(&topWidget); @@ -937,7 +939,7 @@ void tst_QSpinBox::specialValue() QCOMPARE(spin.text(), QString("0")); QTest::keyClick(&spin, Qt::Key_Return); QCOMPARE(spin.text(), specialText); - + spin.setValue(50); QTest::keyClick(&spin, Qt::Key_Return); QTest::keyClick(&spin, '0'); @@ -987,17 +989,17 @@ void tst_QSpinBox::sizeHint() QVERIFY(spinBox->sizeHintRequests > 0); // Suffix - spinBox->sizeHintRequests = 0; + spinBox->sizeHintRequests = 0; spinBox->setSuffix(QLatin1String("abcdefghij")); qApp->processEvents(); - QVERIFY(spinBox->sizeHintRequests > 0); + QVERIFY(spinBox->sizeHintRequests > 0); // Range - spinBox->sizeHintRequests = 0; + spinBox->sizeHintRequests = 0; spinBox->setRange(0, 1234567890); spinBox->setValue(spinBox->maximum()); qApp->processEvents(); - QVERIFY(spinBox->sizeHintRequests > 0); + QVERIFY(spinBox->sizeHintRequests > 0); } QTEST_MAIN(tst_QSpinBox) diff --git a/tests/auto/qstackedlayout/tst_qstackedlayout.cpp b/tests/auto/qstackedlayout/tst_qstackedlayout.cpp index c6a30a5..481ee2c 100644 --- a/tests/auto/qstackedlayout/tst_qstackedlayout.cpp +++ b/tests/auto/qstackedlayout/tst_qstackedlayout.cpp @@ -47,6 +47,8 @@ #include #include +#include "../../shared/util.h" + //TESTED_CLASS= //TESTED_FILES=gui/kernel/qlayout.cpp gui/kernel/qlayout.h @@ -149,7 +151,7 @@ void tst_QStackedLayout::testCase() QStackedLayout onStack(testWidget); QStackedLayout *testLayout = &onStack; testWidget->setLayout(testLayout); - + QSignalSpy spy(testLayout,SIGNAL(currentChanged(int))); // Nothing in layout @@ -350,12 +352,15 @@ void tst_QStackedLayout::keepFocusAfterSetCurrent() stackLayout->setCurrentIndex(0); + testWidget->show(); + QTest::qWait(25); + QApplication::setActiveWindow(testWidget); + edit1->setFocus(); - QTest::qWait(250); edit1->activateWindow(); - QTest::qWait(100); + QTest::qWait(25); - QVERIFY(edit1->hasFocus()); + QTRY_VERIFY(edit1->hasFocus()); stackLayout->setCurrentIndex(1); QVERIFY(!edit1->hasFocus()); diff --git a/tests/auto/qtableview/tst_qtableview.cpp b/tests/auto/qtableview/tst_qtableview.cpp index 6fe2963..51d0e33 100644 --- a/tests/auto/qtableview/tst_qtableview.cpp +++ b/tests/auto/qtableview/tst_qtableview.cpp @@ -2334,8 +2334,10 @@ void tst_QTableView::scrollTo() QtTestTableView view; view.show(); - view.resize(columnWidth * 2, rowHeight * 2); + QSize forcedSize(columnWidth * 2, rowHeight * 2); + view.resize(forcedSize); QTest::qWait(0); + QTRY_COMPARE(view.size(), forcedSize); view.setModel(&model); view.setSpan(row, column, rowSpan, columnSpan); @@ -2910,6 +2912,7 @@ void tst_QTableView::tabFocus() window.setFocus(); QTest::qWait(100); window.activateWindow(); + QApplication::setActiveWindow(&window); QTest::qWait(100); qApp->processEvents(); @@ -2926,43 +2929,43 @@ void tst_QTableView::tabFocus() for (int i = 0; i < 2; ++i) { // tab to view QTest::keyPress(qApp->focusWidget(), Qt::Key_Tab); - QVERIFY(!window.hasFocus()); + QTRY_VERIFY(!window.hasFocus()); QVERIFY(view->hasFocus()); QVERIFY(!edit->hasFocus()); // tab to edit QTest::keyPress(qApp->focusWidget(), Qt::Key_Tab); + QTRY_VERIFY(edit->hasFocus()); QVERIFY(!window.hasFocus()); QVERIFY(!view->hasFocus()); - QVERIFY(edit->hasFocus()); } // backtab to view QTest::keyPress(qApp->focusWidget(), Qt::Key_Backtab); + QTRY_VERIFY(view->hasFocus()); QVERIFY(!window.hasFocus()); - QVERIFY(view->hasFocus()); QVERIFY(!edit->hasFocus()); // backtab to edit QTest::keyPress(qApp->focusWidget(), Qt::Key_Backtab); + QTRY_VERIFY(edit->hasFocus()); QVERIFY(!window.hasFocus()); QVERIFY(!view->hasFocus()); - QVERIFY(edit->hasFocus()); QStandardItemModel *model = new QStandardItemModel; view->setModel(model); // backtab to view QTest::keyPress(qApp->focusWidget(), Qt::Key_Backtab); + QTRY_VERIFY(view->hasFocus()); QVERIFY(!window.hasFocus()); - QVERIFY(view->hasFocus()); QVERIFY(!edit->hasFocus()); // backtab to edit QTest::keyPress(qApp->focusWidget(), Qt::Key_Backtab); + QTRY_VERIFY(edit->hasFocus()); QVERIFY(!window.hasFocus()); QVERIFY(!view->hasFocus()); - QVERIFY(edit->hasFocus()); model->insertRow(0, new QStandardItem("Hei")); model->insertRow(0, new QStandardItem("Hei")); @@ -2970,8 +2973,8 @@ void tst_QTableView::tabFocus() // backtab to view QTest::keyPress(qApp->focusWidget(), Qt::Key_Backtab); + QTRY_VERIFY(view->hasFocus()); QVERIFY(!window.hasFocus()); - QVERIFY(view->hasFocus()); QVERIFY(!edit->hasFocus()); // backtab to edit doesn't work @@ -2984,14 +2987,14 @@ void tst_QTableView::tabFocus() // backtab to edit QTest::keyPress(qApp->focusWidget(), Qt::Key_Backtab); + QTRY_VERIFY(edit->hasFocus()); QVERIFY(!window.hasFocus()); QVERIFY(!view->hasFocus()); - QVERIFY(edit->hasFocus()); QTest::keyPress(qApp->focusWidget(), Qt::Key_Tab); - QVERIFY(view->hasFocus()); + QTRY_VERIFY(view->hasFocus()); QTest::keyPress(qApp->focusWidget(), Qt::Key_Tab); - QVERIFY(edit->hasFocus()); + QTRY_VERIFY(edit->hasFocus()); delete model; } diff --git a/tests/auto/qtextbrowser/tst_qtextbrowser.cpp b/tests/auto/qtextbrowser/tst_qtextbrowser.cpp index 0311900..966e9c9 100644 --- a/tests/auto/qtextbrowser/tst_qtextbrowser.cpp +++ b/tests/auto/qtextbrowser/tst_qtextbrowser.cpp @@ -49,6 +49,8 @@ #include #include +#include "../../shared/util.h" + //TESTED_CLASS= //TESTED_FILES= @@ -64,9 +66,11 @@ public: #ifdef Q_WS_X11 qt_x11_wait_for_window_manager(this); #endif + QApplication::setActiveWindow(this); activateWindow(); setFocus(); - QTest::qWait(100); + QTest::qWait(50); + QTRY_VERIFY(hasFocus()); } virtual QVariant loadResource(int type, const QUrl &name); diff --git a/tests/auto/qtreeview/tst_qtreeview.cpp b/tests/auto/qtreeview/tst_qtreeview.cpp index fae4b26..f42d5f6 100644 --- a/tests/auto/qtreeview/tst_qtreeview.cpp +++ b/tests/auto/qtreeview/tst_qtreeview.cpp @@ -3354,7 +3354,7 @@ void tst_QTreeView::task246536_scrollbarsNotWorking() o.count = 0; tree.verticalScrollBar()->setValue(50); QTest::qWait(100); - QVERIFY(o.count > 0); + QTRY_VERIFY(o.count > 0); } void tst_QTreeView::task250683_wrongSectionSize() @@ -3404,8 +3404,9 @@ void tst_QTreeView::task239271_addRowsWithFirstColumnHidden() QStandardItem sub1("sub1"), sub11("sub11"); root0.appendRow(QList() << &sub1 << &sub11); - QTest::qWait(200); + QTest::qWait(20); //items in the 2nd column should have been painted + QTRY_VERIFY(!delegate.paintedIndexes.isEmpty()); QVERIFY(delegate.paintedIndexes.contains(sub00.index())); QVERIFY(delegate.paintedIndexes.contains(sub11.index())); } -- cgit v0.12 From 2075cb4fc05dc077db1bb9437dd0fcf75605fe9c Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Tue, 8 Sep 2009 12:31:10 +0200 Subject: doc: Fixed several qdoc errors. That's the last of them... for now. --- doc/src/frameworks-technologies/gestures.qdoc | 8 ++++---- src/gui/kernel/qstandardgestures.cpp | 6 ++++++ src/gui/painting/qpaintengine.cpp | 1 + 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/doc/src/frameworks-technologies/gestures.qdoc b/doc/src/frameworks-technologies/gestures.qdoc index 317bb31..7929331 100644 --- a/doc/src/frameworks-technologies/gestures.qdoc +++ b/doc/src/frameworks-technologies/gestures.qdoc @@ -81,7 +81,7 @@ \table \header \o New State \o Description \o QGesture Actions on Entering this State - \row \o Qt::NoGesture \o Initial value \o emit \l {QGesture::cancelled()}{cancelled()} + \row \o Qt::NoGesture \o Initial value \o emit \l {QGesture::canceled()}{canceled()} \row \o Qt::GestureStarted \o A continuous gesture has started \o emit \l{QGesture::started()}{started()} and emit \l{QGesture::triggered()}{triggered()} \row \o Qt::GestureUpdated \o A gesture continues \o emit \l{QGesture::triggered()}{triggered()} \row \o Qt::GestureFinished \o A gesture has finished. \o emit \l{QGesture::finished()}{finished()} @@ -130,13 +130,13 @@ then the gesture is considered to have finished whether or not the appropriate touch or mouse event has occurred. Also if a large jump in the position of the event occurs, as calculated by the \l {QPoint::manhattanLength()}{manhattanLength()} - call, then the gesture is cancelled by calling \l{QGesture::reset()}{reset()} + call, then the gesture is canceled by calling \l{QGesture::reset()}{reset()} which tidies up and uses \l{QGesture::updateState()}{updateState()} to - change state to NoGesture which will result in the \l{QGesture::cancelled()}{cancelled()} + change state to NoGesture which will result in the \l{QGesture::canceled()}{canceled()} signal being emitted by the recognizer. ImageWidget handles the signals by connecting the slots to the signals, - although \c cancelled() is not connected here. + although \c canceled() is not connected here. \snippet doc/src/snippets/gestures/imageviewer/imagewidget.cpp imagewidget-connect diff --git a/src/gui/kernel/qstandardgestures.cpp b/src/gui/kernel/qstandardgestures.cpp index 8e76715..b3e137d 100644 --- a/src/gui/kernel/qstandardgestures.cpp +++ b/src/gui/kernel/qstandardgestures.cpp @@ -535,6 +535,12 @@ void QPinchGesture::reset() QGesture::reset(); } +/*! \enum QPinchGesture::WhatChange + \value ScaleFactorChanged + \value RotationAngleChanged + \value CenterPointChanged +*/ + /*! \property QPinchGesture::whatChanged diff --git a/src/gui/painting/qpaintengine.cpp b/src/gui/painting/qpaintengine.cpp index f442788..42da637 100644 --- a/src/gui/painting/qpaintengine.cpp +++ b/src/gui/painting/qpaintengine.cpp @@ -386,6 +386,7 @@ void QPaintEngine::drawPolygon(const QPoint *points, int pointCount, PolygonDraw \value User First user type ID \value MaxUser Last user type ID \value OpenGL2 + \value PaintBuffer */ /*! -- cgit v0.12 From 9a90fcca3e9a9a49cee228054017ff7d15645082 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Thu, 3 Sep 2009 13:41:19 +0200 Subject: Animations of redocking widgets are broken The problem is that when starting an animation, we delay it by starting a 0-timer. That doesn't work on windows while dragging a native window. Task-number: 260772 Reviewed-by: prasanth --- src/corelib/animation/qabstractanimation.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/corelib/animation/qabstractanimation.cpp b/src/corelib/animation/qabstractanimation.cpp index e1b8509..31f0841 100644 --- a/src/corelib/animation/qabstractanimation.cpp +++ b/src/corelib/animation/qabstractanimation.cpp @@ -157,6 +157,19 @@ #define DEFAULT_TIMER_INTERVAL 16 +#ifdef Q_WS_WIN + /// Fix for Qt 4.7 + //on windows if you're currently dragging a widget an inner eventloop was started by the system + //to make sure that this timer is getting fired, we need to make sure to use the system timers + //that will send a WM_TIMER event. We do that by settings the timer interval to 11 + //It is 11 because QEventDispatcherWin32Private::registerTimer specifically checks if the interval + //is greater than 10 to determine if it should use a system timer (or the multimedia timer). +#define STARTSTOP_TIMER_DELAY 11 +#else +#define STARTSTOP_TIMER_DELAY 0 +#endif + + QT_BEGIN_NAMESPACE Q_GLOBAL_STATIC(QThreadStorage, unifiedTimer) @@ -217,7 +230,7 @@ void QUnifiedTimer::registerAnimation(QAbstractAnimation *animation) if (animations.contains(animation) || animationsToStart.contains(animation)) return; animationsToStart << animation; - startStopAnimationTimer.start(0, this); // we delay the check if we should start/stop the global timer + startStopAnimationTimer.start(STARTSTOP_TIMER_DELAY, this); // we delay the check if we should start/stop the global timer } void QUnifiedTimer::unregisterAnimation(QAbstractAnimation *animation) @@ -233,7 +246,7 @@ void QUnifiedTimer::unregisterAnimation(QAbstractAnimation *animation) } else { animationsToStart.removeOne(animation); } - startStopAnimationTimer.start(0, this); // we delay the check if we should start/stop the global timer + startStopAnimationTimer.start(STARTSTOP_TIMER_DELAY, this); // we delay the check if we should start/stop the global timer } -- cgit v0.12 From 9d9b7f53750dce2da88d7d11d312b4b36250b5c5 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Tue, 8 Sep 2009 12:59:44 +0200 Subject: Fixes a regression in QListView in 4.6 regarding the selection In icon mode, if you click on the viewport (with extended selection), the selection should be cleared when you release the mouse button. Reviewed-by: ogoffart --- src/gui/itemviews/qabstractitemview.cpp | 4 ++++ tests/auto/qlistview/tst_qlistview.cpp | 30 ++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp index 52529ff..99e9aeb 100644 --- a/src/gui/itemviews/qabstractitemview.cpp +++ b/src/gui/itemviews/qabstractitemview.cpp @@ -1661,6 +1661,10 @@ void QAbstractItemView::mouseReleaseEvent(QMouseEvent *event) EditTrigger trigger = (selectedClicked ? SelectedClicked : NoEditTriggers); bool edited = edit(index, trigger, event); + //in the case the user presses on no item we might decide to clear the selection + if (d->selectionModel && !index.isValid()) + d->selectionModel->select(QModelIndex(), selectionCommand(index, event)); + setState(NoState); if (click) { diff --git a/tests/auto/qlistview/tst_qlistview.cpp b/tests/auto/qlistview/tst_qlistview.cpp index 2be1a03..2831747 100644 --- a/tests/auto/qlistview/tst_qlistview.cpp +++ b/tests/auto/qlistview/tst_qlistview.cpp @@ -113,6 +113,7 @@ private slots: void task254449_draggingItemToNegativeCoordinates(); void keyboardSearch(); void shiftSelectionWithNonUniformItemSizes(); + void clickOnViewportClearsSelection(); }; // Testing get/set functions @@ -1733,5 +1734,34 @@ void tst_QListView::shiftSelectionWithNonUniformItemSizes() } } +void tst_QListView::clickOnViewportClearsSelection() +{ + QStringList items; + items << "Text1"; + QStringListModel model(items); + QListView view; + view.setModel(&model); + view.setSelectionMode(QListView::ExtendedSelection); + + view.selectAll(); + QModelIndex index = model.index(0); + QCOMPARE(view.selectionModel()->selectedIndexes().count(), 1); + QVERIFY(view.selectionModel()->isSelected(index)); + + //we try to click outside of the index + const QPoint point = view.visualRect(index).bottomRight() + QPoint(10,10); + + QTest::mousePress(view.viewport(), Qt::LeftButton, 0, point); + //at this point, the selection shouldn't have changed + QCOMPARE(view.selectionModel()->selectedIndexes().count(), 1); + QVERIFY(view.selectionModel()->isSelected(index)); + + QTest::mouseRelease(view.viewport(), Qt::LeftButton, 0, point); + //now the selection should be cleared + QVERIFY(!view.selectionModel()->hasSelection()); + +} + + QTEST_MAIN(tst_QListView) #include "tst_qlistview.moc" -- cgit v0.12 From a9572a07f1512fe1266629632e5c4f1613abeb8d Mon Sep 17 00:00:00 2001 From: Adriano Rezende Date: Tue, 8 Sep 2009 13:15:49 +0200 Subject: Fixed QLineEdit to correctly adjust the horizontal scrolling The widget needs to use the naturalTextWidth to adjust the horizontal scrolling, otherwise it will not fit correctly the text in the visible area when resized. Merge-request: 1410 Reviewed-by: Alan Alpert --- src/gui/widgets/qlinecontrol_p.h | 6 ++++++ src/gui/widgets/qlineedit.cpp | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/gui/widgets/qlinecontrol_p.h b/src/gui/widgets/qlinecontrol_p.h index a81f138..f46abf1 100644 --- a/src/gui/widgets/qlinecontrol_p.h +++ b/src/gui/widgets/qlinecontrol_p.h @@ -109,6 +109,7 @@ public: int width() const; int height() const; int ascent() const; + qreal naturalTextWidth() const; void setSelection(int start, int length); @@ -410,6 +411,11 @@ inline int QLineControl::width() const return qRound(m_textLayout.lineAt(0).width()) + 1; } +inline qreal QLineControl::naturalTextWidth() const +{ + return m_textLayout.lineAt(0).naturalTextWidth(); +} + inline int QLineControl::height() const { return qRound(m_textLayout.lineAt(0).height()) + 1; diff --git a/src/gui/widgets/qlineedit.cpp b/src/gui/widgets/qlineedit.cpp index 3065c7f..9571860 100644 --- a/src/gui/widgets/qlineedit.cpp +++ b/src/gui/widgets/qlineedit.cpp @@ -1808,7 +1808,7 @@ void QLineEdit::paintEvent(QPaintEvent *) // (cix). int minLB = qMax(0, -fm.minLeftBearing()); int minRB = qMax(0, -fm.minRightBearing()); - int widthUsed = d->control->width() + minRB; + int widthUsed = qRound(d->control->naturalTextWidth()) + 1 + minRB; if ((minLB + widthUsed) <= lineRect.width()) { // text fits in lineRect; use hscroll for alignment switch (va & ~(Qt::AlignAbsolute|Qt::AlignVertical_Mask)) { -- cgit v0.12 From 0399ace27c7441b4454911da3aaa4ea17b931b99 Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Tue, 8 Sep 2009 21:36:42 +1000 Subject: Add license header. Reviewed-by: Trust Me --- .../src_corelib_statemachine_qstatemachine.cpp | 41 ++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/doc/src/snippets/code/src_corelib_statemachine_qstatemachine.cpp b/doc/src/snippets/code/src_corelib_statemachine_qstatemachine.cpp index 128799f..8933ef3 100644 --- a/doc/src/snippets/code/src_corelib_statemachine_qstatemachine.cpp +++ b/doc/src/snippets/code/src_corelib_statemachine_qstatemachine.cpp @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + //! [simple state machine] QPushButton button; -- cgit v0.12 From beea786c9d1362b1fb12fdff209b842e21ef9cf8 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Tue, 8 Sep 2009 14:45:09 +0300 Subject: Fixed resolving absolute paths in Symbian. Fixed resolving absolute path using QFileInfo for paths that were relative but contained the drive letter (e.g. "c:my.dll"). Absolute paths should now be properly cleaned in Symbian, too. Task-number: 255326 Reviewed-by: Janne Anttila --- src/corelib/io/qfsfileengine_unix.cpp | 23 ++++++++++++++++++----- tests/auto/qfileinfo/tst_qfileinfo.cpp | 14 +++++++++++--- 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/src/corelib/io/qfsfileengine_unix.cpp b/src/corelib/io/qfsfileengine_unix.cpp index 50b4af7..80ccda3 100644 --- a/src/corelib/io/qfsfileengine_unix.cpp +++ b/src/corelib/io/qfsfileengine_unix.cpp @@ -865,15 +865,22 @@ QString QFSFileEngine::fileName(FileName file) const QString ret; if (!isRelativePathSymbian(d->filePath)) { if (d->filePath.size() > 2 && d->filePath.at(1) == QLatin1Char(':') - && d->filePath.at(2) != slashChar || // It's a drive-relative path, so Z:a.txt -> Z:\currentpath\a.txt - d->filePath.startsWith(slashChar) // It's a absolute path to the current drive, so \a.txt -> Z:\a.txt - ) { - ret = QString(QDir::currentPath().left(2) + QDir::fromNativeSeparators(d->filePath)); + && d->filePath.at(2) != slashChar){ + // It's a drive-relative path, so C:a.txt -> C:/currentpath/a.txt, + // or if it's different drive than current, Z:a.txt -> Z:/a.txt + QString currentPath = QDir::currentPath(); + if (0 == currentPath.left(1).compare(d->filePath.left(1), Qt::CaseInsensitive)) + ret = currentPath + slashChar + d->filePath.mid(2); + else + ret = d->filePath.left(2) + slashChar + d->filePath.mid(2); + } else if (d->filePath.startsWith(slashChar)) { + // It's a absolute path to the current drive, so /a.txt -> C:/a.txt + ret = QDir::currentPath().left(2) + d->filePath; } else { ret = d->filePath; } } else { - ret = QDir::cleanPath(QDir::currentPath() + slashChar + d->filePath); + ret = QDir::currentPath() + slashChar + d->filePath; } // The path should be absolute at this point. @@ -889,6 +896,12 @@ QString QFSFileEngine::fileName(FileName file) const ret[0] = ret.at(0).toUpper(); } + // Clean up the path + bool isDir = ret.endsWith(slashChar); + ret = QDir::cleanPath(ret); + if (isDir) + ret += slashChar; + if (file == AbsolutePathName) { int slash = ret.lastIndexOf(slashChar); if (slash < 0) diff --git a/tests/auto/qfileinfo/tst_qfileinfo.cpp b/tests/auto/qfileinfo/tst_qfileinfo.cpp index d951a86..076934c 100644 --- a/tests/auto/qfileinfo/tst_qfileinfo.cpp +++ b/tests/auto/qfileinfo/tst_qfileinfo.cpp @@ -411,6 +411,10 @@ void tst_QFileInfo::absolutePath_data() QString drivePrefix; #if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE)) || defined(Q_OS_SYMBIAN) drivePrefix = QDir::currentPath().left(2); + + // Make sure drive-relative paths return correct absolute paths (task 255326) + QTest::newRow("c:my.dll") << "c:my.dll" << QDir::currentPath() << "my.dll"; + QTest::newRow("x:my.dll") << "x:my.dll" << "X:/" << "my.dll"; #endif QTest::newRow("0") << "/machine/share/dir1/" << drivePrefix + "/machine/share/dir1" << ""; QTest::newRow("1") << "/machine/share/dir1" << drivePrefix + "/machine/share" << "dir1"; @@ -449,6 +453,10 @@ void tst_QFileInfo::absFilePath_data() curr.remove(0, 2); // Make it a absolute path with no drive specifier: \depot\qt-4.2\tests\auto\qfileinfo QTest::newRow(".") << curr << QDir::currentPath(); QTest::newRow("absFilePath") << "c:\\home\\andy\\tmp.txt" << "C:/home/andy/tmp.txt"; + + // Make sure drive-relative paths return correct absolute paths (task 255326) + QTest::newRow("c:my.dll") << "c:temp/my.dll" << QDir::currentPath() + "/temp/my.dll"; + QTest::newRow("x:my.dll") << "x:temp/my.dll" << "X:/temp/my.dll"; #else QTest::newRow("absFilePath") << "/home/andy/tmp.txt" << "/home/andy/tmp.txt"; #endif @@ -1052,19 +1060,19 @@ void tst_QFileInfo::isHidden_data() QFile file(hiddenFileName); if (file.open(QIODevice::WriteOnly)) { QTextStream t(&file); - t << "foobar"; + t << "foobar"; } else { qWarning("Failed to create hidden file"); } QFile file2(notHiddenFileName); if (file2.open(QIODevice::WriteOnly)) { QTextStream t(&file); - t << "foobar"; + t << "foobar"; } else { qWarning("Failed to create non-hidden file"); } } - + RFs rfs; TInt err = rfs.Connect(); if (err == KErrNone) { -- cgit v0.12 From 039e178ae3dff6761627de9b3fa790a64afb7bee Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 8 Sep 2009 13:49:01 +0200 Subject: Make tst_qmdiarea more robust --- tests/auto/qmdiarea/tst_qmdiarea.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/tests/auto/qmdiarea/tst_qmdiarea.cpp b/tests/auto/qmdiarea/tst_qmdiarea.cpp index 65dab48..246410d 100644 --- a/tests/auto/qmdiarea/tst_qmdiarea.cpp +++ b/tests/auto/qmdiarea/tst_qmdiarea.cpp @@ -62,6 +62,8 @@ #endif #include +#include "../../shared/util.h" + static const Qt::WindowFlags DefaultWindowFlags = Qt::SubWindow | Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint; @@ -467,7 +469,7 @@ void tst_QMdiArea::subWindowActivated2() qt_x11_wait_for_window_manager(&mdiArea); #endif - QCOMPARE(spy.count(), 5); + QTRY_COMPARE(spy.count(), 5); QCOMPARE(mdiArea.activeSubWindow(), mdiArea.subWindowList().back()); spy.clear(); @@ -493,7 +495,7 @@ void tst_QMdiArea::subWindowActivated2() qt_x11_wait_for_window_manager(&mdiArea); #endif QTest::qWait(100); - QCOMPARE(spy.count(), 1); + QTRY_COMPARE(spy.count(), 1); QVERIFY(!mdiArea.activeSubWindow()); QCOMPARE(mdiArea.currentSubWindow(), activeSubWindow); spy.clear(); @@ -503,7 +505,7 @@ void tst_QMdiArea::subWindowActivated2() qt_x11_wait_for_window_manager(&mdiArea); #endif QTest::qWait(100); - QCOMPARE(spy.count(), 1); + QTRY_COMPARE(spy.count(), 1); QCOMPARE(mdiArea.activeSubWindow(), activeSubWindow); spy.clear(); @@ -516,14 +518,14 @@ void tst_QMdiArea::subWindowActivated2() if (!macHasAccessToWindowsServer()) QEXPECT_FAIL("", "showMinimized doesn't really minimize if you don't have access to the server", Abort); #endif - QTest::qWait(100); + QTest::qWait(10); #if defined(Q_WS_QWS) QEXPECT_FAIL("", "task 168682", Abort); #endif #ifdef Q_OS_WINCE QSKIP("Not fixed yet. See Task 197453", SkipAll); #endif - QCOMPARE(spy.count(), 1); + QTRY_COMPARE(spy.count(), 1); QVERIFY(!mdiArea.activeSubWindow()); QCOMPARE(mdiArea.currentSubWindow(), activeSubWindow); spy.clear(); @@ -533,7 +535,7 @@ void tst_QMdiArea::subWindowActivated2() qt_x11_wait_for_window_manager(&mdiArea); #endif QTest::qWait(100); - QCOMPARE(spy.count(), 1); + QTRY_COMPARE(spy.count(), 1); QCOMPARE(mdiArea.activeSubWindow(), activeSubWindow); spy.clear(); } @@ -1734,6 +1736,7 @@ void tst_QMdiArea::tileSubWindows() qt_x11_wait_for_window_manager(&workspace); #endif qApp->processEvents(); + QTRY_COMPARE(workspace.size(), QSize(350, 150)); const QSize minSize(300, 100); foreach (QMdiSubWindow *subWindow, workspace.subWindowList()) @@ -1885,7 +1888,7 @@ void tst_QMdiArea::resizeMaximizedChildWindows() workspace.resize(workspaceSize + QSize(increment, increment)); QTest::qWait(100); qApp->processEvents(); - QCOMPARE(workspace.size(), workspaceSize + QSize(increment, increment)); + QTRY_COMPARE(workspace.size(), workspaceSize + QSize(increment, increment)); QCOMPARE(window->size(), windowSize + QSize(increment, increment)); workspaceSize = workspace.size(); } -- cgit v0.12 From 89982a2c1678f2c42c9abf1021b35ed45004278c Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Tue, 8 Sep 2009 13:48:13 +0200 Subject: fix major memory leak in JavaScriptCore RegisterFile on Windows CE On Widows CE we must decommit all committed pages before we release them. See VirtualFree documentation. Desktop Windows behaves much smoother in this situation. Reviewed-by: ariya --- src/3rdparty/webkit/JavaScriptCore/interpreter/RegisterFile.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/3rdparty/webkit/JavaScriptCore/interpreter/RegisterFile.cpp b/src/3rdparty/webkit/JavaScriptCore/interpreter/RegisterFile.cpp index 29a13ca..de5175e 100644 --- a/src/3rdparty/webkit/JavaScriptCore/interpreter/RegisterFile.cpp +++ b/src/3rdparty/webkit/JavaScriptCore/interpreter/RegisterFile.cpp @@ -36,6 +36,9 @@ RegisterFile::~RegisterFile() #if HAVE(MMAP) munmap(reinterpret_cast(m_buffer), ((m_max - m_start) + m_maxGlobals) * sizeof(Register)); #elif HAVE(VIRTUALALLOC) +#if PLATFORM(WINCE) + VirtualFree(m_buffer, DWORD(m_commitEnd) - DWORD(m_buffer), MEM_DECOMMIT); +#endif VirtualFree(m_buffer, 0, MEM_RELEASE); #else fastFree(m_buffer); -- cgit v0.12 From b8e6f86ed8b27504f22da2167cb6aa9ecf829a71 Mon Sep 17 00:00:00 2001 From: Jedrzej Nowacki Date: Tue, 8 Sep 2009 14:03:05 +0200 Subject: QScriptDebuggerBackend crash fix. QScriptDebuggerBackend::contextCount() method was trying to count number of context push & pop and result was not equal to elements count in QScriptDebuggerBackend::contextIds() list. Patch change QScriptDebuggerBackend::contextCount() to call count() on ids list. Task-number: 260719 Reviewed-by: Kent Hansen --- src/scripttools/debugging/qscriptdebuggerbackend.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/scripttools/debugging/qscriptdebuggerbackend.cpp b/src/scripttools/debugging/qscriptdebuggerbackend.cpp index 2efff04..feaea63 100644 --- a/src/scripttools/debugging/qscriptdebuggerbackend.cpp +++ b/src/scripttools/debugging/qscriptdebuggerbackend.cpp @@ -805,13 +805,7 @@ int QScriptDebuggerBackend::contextCount() const { if (!engine()) return 0; - int count = 0; - QScriptContext *ctx = engine()->currentContext(); - while (ctx) { - ++count; - ctx = ctx->parentContext(); - } - return count; + return contextIds().count(); } /*! -- cgit v0.12 From 512a265f760c9207b94d7ba61cef9316b23cf4e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Tue, 8 Sep 2009 14:32:30 +0200 Subject: Added a public function to enforce usage og the old GL engine. Some applications that uses a mix of OpenGL and QPainter code may not work correctly with the new GL 2 engine (e.g. the composition demo). The same is most likely also true for user apps, therefore we need a way to enforce the usage of the old GL 1 engine for the sake of compatibility. Task-number: 260872 Reviewed-by: Samuel --- demos/composition/main.cpp | 6 ++++ dist/changes-4.6.0 | 11 ++++++-- src/opengl/qgl.cpp | 68 ++++++++++++++++++++++++++++++++++++++++++++++ src/opengl/qgl.h | 3 ++ src/opengl/qgl_p.h | 10 +------ 5 files changed, 87 insertions(+), 11 deletions(-) diff --git a/demos/composition/main.cpp b/demos/composition/main.cpp index 3a959a9..fe142ad 100644 --- a/demos/composition/main.cpp +++ b/demos/composition/main.cpp @@ -42,11 +42,17 @@ #include "composition.h" #include +#ifdef QT_OPENGL_SUPPORT +#include +#endif int main(int argc, char **argv) { // Q_INIT_RESOURCE(deform); +#ifdef QT_OPENGL_SUPPORT + QGL::setPreferredPaintEngine(QPaintEngine::OpenGL); +#endif QApplication app(argc, argv); CompositionWidget compWidget(0); diff --git a/dist/changes-4.6.0 b/dist/changes-4.6.0 index ca984ac..f9984d3 100644 --- a/dist/changes-4.6.0 +++ b/dist/changes-4.6.0 @@ -54,8 +54,15 @@ information about a particular change. this is that Nokia focuses on OpenGL for desktop hardware accelerated rendering. - - When mixing OpenGL and QPainter calls you need to surround your custom - OpenGL calls with QPainter::beginNativePainting() and + - The default engine used to draw onto OpenGL buffers has changed in + Qt 4.6. The QPaintEngine::OpenGL2 engine is now used as the default + engine. This *may* cause compatibility problems for applications + that use a mix of QPainter and native OpenGL calls to draw into a GL + buffer. Use the QGL::setPreferredPaintEngine() function to enforce + usage of the old GL paint engine. + + - When mixing OpenGL and QPainter calls you need to surround your + custom OpenGL calls with QPainter::beginNativePainting() and QPainter::endNativePainting(). This is to ensure that the paint engine flushes any pending drawing and sets up the GL modelview/projection matrices properly before you can issue custom diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 087902b..02bb8f9 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -141,6 +141,48 @@ QGLSignalProxy *QGLSignalProxy::instance() return theSignalProxy(); } + +class QGLEngineSelector +{ +public: + QGLEngineSelector() : engineType(QPaintEngine::MaxUser) { } + + void setPreferredPaintEngine(QPaintEngine::Type type) { + if (type == QPaintEngine::OpenGL || type == QPaintEngine::OpenGL2) + engineType = type; + } + + QPaintEngine::Type preferredPaintEngine() { + if (engineType == QPaintEngine::MaxUser) { + // No user-set engine - use the defaults +#if defined(QT_OPENGL_ES_2) + engineType = QPaintEngine::OpenGL2; +#else + // We can't do this in the constructor for this object because it + // needs to be called *before* the QApplication constructor + if ((QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_2_0) + && qgetenv("QT_GL_USE_OPENGL1ENGINE").isEmpty()) + engineType = QPaintEngine::OpenGL2; + else + engineType = QPaintEngine::OpenGL; +#endif + } + return engineType; + } + +private: + QPaintEngine::Type engineType; +}; + +Q_GLOBAL_STATIC(QGLEngineSelector, qgl_engine_selector) + + +bool qt_gl_preferGL2Engine() +{ + return qgl_engine_selector()->preferredPaintEngine() == QPaintEngine::OpenGL2; +} + + /*! \namespace QGL \inmodule QtOpenGL @@ -181,6 +223,32 @@ QGLSignalProxy *QGLSignalProxy::instance() \sa {Sample Buffers Example} */ +/*! + \fn void QGL::setPreferredPaintEngine(QPaintEngine::Type engineType) + + \since 4.6 + + Sets the preferred OpenGL paint engine that is used to draw onto + QGLWidgets, QGLPixelBuffers and QGLFrameBufferObjects with QPainter + in Qt. + + The \a engineType parameter specifies which of the GL engines to + use. Only \c QPaintEngine::OpenGL and \c QPaintEngine::OpenGL2 are + valid parameters to this function. All other values are ignored. + + By default, the \c QPaintEngine::OpenGL2 engine is used if GL/GLES + version 2.0 is available, otherwise \c QPaintEngine::OpenGL is + used. + + \warning This function must be called before the QApplication + constructor is called. +*/ +void QGL::setPreferredPaintEngine(QPaintEngine::Type engineType) +{ + qgl_engine_selector()->setPreferredPaintEngine(engineType); +} + + /***************************************************************************** QGLFormat implementation *****************************************************************************/ diff --git a/src/opengl/qgl.h b/src/opengl/qgl.h index daac760..b110665 100644 --- a/src/opengl/qgl.h +++ b/src/opengl/qgl.h @@ -43,6 +43,7 @@ #define QGL_H #include +#include #include #include #include @@ -130,6 +131,8 @@ class QGLContextPrivate; // Namespace class: namespace QGL { + Q_OPENGL_EXPORT void setPreferredPaintEngine(QPaintEngine::Type engineType); + enum FormatOption { DoubleBuffer = 0x0001, DepthBuffer = 0x0002, diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index d4b7597..f8158a0 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -519,15 +519,7 @@ extern QPaintEngine* qt_qgl_paint_engine(); extern EGLDisplay qt_qgl_egl_display(); #endif -inline bool qt_gl_preferGL2Engine() -{ -#if defined(QT_OPENGL_ES_2) - return true; -#else - return (QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_2_0) - && qgetenv("QT_GL_USE_OPENGL1ENGINE").isEmpty(); -#endif -} +bool qt_gl_preferGL2Engine(); inline GLenum qt_gl_preferredTextureFormat() { -- cgit v0.12 From 20a61e1cf39ee66cf0880c6f8f36634115cf610e Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Tue, 8 Sep 2009 14:35:42 +0200 Subject: Fix QWS autotests after S60 integration Reviewed-by: trustme --- tests/auto/qmultiscreen/qmultiscreen.pro | 1 - tests/auto/qtransformedscreen/qtransformedscreen.pro | 1 - tests/auto/qwsembedwidget/qwsembedwidget.pro | 1 - tests/auto/qwsinputmethod/qwsinputmethod.pro | 1 - tests/auto/qwswindowsystem/qwswindowsystem.pro | 1 - 5 files changed, 5 deletions(-) diff --git a/tests/auto/qmultiscreen/qmultiscreen.pro b/tests/auto/qmultiscreen/qmultiscreen.pro index 4e92a65..30666d7 100644 --- a/tests/auto/qmultiscreen/qmultiscreen.pro +++ b/tests/auto/qmultiscreen/qmultiscreen.pro @@ -1,6 +1,5 @@ load(qttest_p4) SOURCES += tst_qmultiscreen.cpp -QT = core requires(embedded) diff --git a/tests/auto/qtransformedscreen/qtransformedscreen.pro b/tests/auto/qtransformedscreen/qtransformedscreen.pro index 39e3700..6914054 100644 --- a/tests/auto/qtransformedscreen/qtransformedscreen.pro +++ b/tests/auto/qtransformedscreen/qtransformedscreen.pro @@ -1,6 +1,5 @@ load(qttest_p4) SOURCES += tst_qtransformedscreen.cpp -QT = core embedded:!contains(gfx-drivers, transformed) { LIBS += ../../../plugins/gfxdrivers/libqgfxtransformed.so diff --git a/tests/auto/qwsembedwidget/qwsembedwidget.pro b/tests/auto/qwsembedwidget/qwsembedwidget.pro index bd3c32c..c34212b 100644 --- a/tests/auto/qwsembedwidget/qwsembedwidget.pro +++ b/tests/auto/qwsembedwidget/qwsembedwidget.pro @@ -1,3 +1,2 @@ load(qttest_p4) SOURCES += tst_qwsembedwidget.cpp -QT = core diff --git a/tests/auto/qwsinputmethod/qwsinputmethod.pro b/tests/auto/qwsinputmethod/qwsinputmethod.pro index 69cce78..d549de0 100644 --- a/tests/auto/qwsinputmethod/qwsinputmethod.pro +++ b/tests/auto/qwsinputmethod/qwsinputmethod.pro @@ -1,3 +1,2 @@ load(qttest_p4) SOURCES += tst_qwsinputmethod.cpp -QT = core diff --git a/tests/auto/qwswindowsystem/qwswindowsystem.pro b/tests/auto/qwswindowsystem/qwswindowsystem.pro index 49466ee..ee33935 100644 --- a/tests/auto/qwswindowsystem/qwswindowsystem.pro +++ b/tests/auto/qwswindowsystem/qwswindowsystem.pro @@ -1,3 +1,2 @@ load(qttest_p4) SOURCES += tst_qwswindowsystem.cpp -QT = core -- cgit v0.12 From 69e5a3fce4d355822367dc1a17179a364111632e Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Tue, 8 Sep 2009 15:00:35 +0200 Subject: network-settings.h: Compile fix relating to some tests Reviewed-by: TrustMe --- tests/auto/network-settings.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/auto/network-settings.h b/tests/auto/network-settings.h index 6ffb6f4..40178fb 100644 --- a/tests/auto/network-settings.h +++ b/tests/auto/network-settings.h @@ -40,9 +40,7 @@ ****************************************************************************/ #include -#ifdef QT_NETWORK_LIB #include -#endif #ifdef Q_OS_SYMBIAN -- cgit v0.12 From 7c9dc76f67fd662077f3f28f3f9313e2a07987d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lindeijer?= Date: Tue, 8 Sep 2009 15:07:38 +0200 Subject: Fixed usage of QMargins in QStyleSheetStyle The order of the parameters to the QMargins constructor changed in commit 758f4735bcae034ac25730e53bb371df3b7d6e8a. Reviewed-by: Alessandro Portale --- src/gui/styles/qstylesheetstyle.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gui/styles/qstylesheetstyle.cpp b/src/gui/styles/qstylesheetstyle.cpp index 3d8dec6..b1fd415 100644 --- a/src/gui/styles/qstylesheetstyle.cpp +++ b/src/gui/styles/qstylesheetstyle.cpp @@ -1130,10 +1130,10 @@ void QRenderRule::drawBorderImage(QPainter *p, const QRect& rect) const QStyleSheetBorderImageData *borderImageData = border()->borderImage(); const int *targetBorders = border()->borders; const int *sourceBorders = borderImageData->cuts; - QMargins sourceMargins(sourceBorders[TopEdge], sourceBorders[LeftEdge], - sourceBorders[BottomEdge], sourceBorders[RightEdge]); - QMargins targetMargins(targetBorders[TopEdge], targetBorders[LeftEdge], - targetBorders[BottomEdge], targetBorders[RightEdge]); + QMargins sourceMargins(sourceBorders[LeftEdge], sourceBorders[TopEdge], + sourceBorders[RightEdge], sourceBorders[BottomEdge]); + QMargins targetMargins(targetBorders[LeftEdge], targetBorders[TopEdge], + targetBorders[RightEdge], targetBorders[BottomEdge]); bool wasSmoothPixmapTransform = p->renderHints() & QPainter::SmoothPixmapTransform; p->setRenderHint(QPainter::SmoothPixmapTransform); -- cgit v0.12 From 38b5e603ede02cfabba6ac845793cc4d28f484db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Tue, 8 Sep 2009 15:19:17 +0200 Subject: Doc: fixing a QFileInfo snippet type Task-number: 258371 --- doc/src/snippets/code/src_corelib_io_qfileinfo.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/src/snippets/code/src_corelib_io_qfileinfo.cpp b/doc/src/snippets/code/src_corelib_io_qfileinfo.cpp index f01757a..d2096cf 100644 --- a/doc/src/snippets/code/src_corelib_io_qfileinfo.cpp +++ b/doc/src/snippets/code/src_corelib_io_qfileinfo.cpp @@ -72,9 +72,9 @@ info1.size(); // returns 743 info1.symLinkTarget(); // returns "C:/Pretty++/untabify" QFileInfo info2(info1.symLinkTarget()); -info1.isSymLink(); // returns false -info1.absoluteFilePath(); // returns "C:/Pretty++/untabify" -info1.size(); // returns 63942 +info2.isSymLink(); // returns false +info2.absoluteFilePath(); // returns "C:/Pretty++/untabify" +info2.size(); // returns 63942 #endif //! [1] -- cgit v0.12 From 6180d5cb66a98efa7c181ef51ef4a209b68c4234 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Tue, 8 Sep 2009 15:46:13 +0200 Subject: Revert "network-settings.h: Compile fix relating to some tests" This reverts commit 69e5a3fce4d355822367dc1a17179a364111632e. --- tests/auto/network-settings.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/auto/network-settings.h b/tests/auto/network-settings.h index 40178fb..6ffb6f4 100644 --- a/tests/auto/network-settings.h +++ b/tests/auto/network-settings.h @@ -40,7 +40,9 @@ ****************************************************************************/ #include +#ifdef QT_NETWORK_LIB #include +#endif #ifdef Q_OS_SYMBIAN -- cgit v0.12 From 97fad21de75f2753cc9804f5924074b7b0d99262 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Tue, 8 Sep 2009 15:51:40 +0200 Subject: network-settings.h: Check for DNS setup only when needed --- tests/auto/network-settings.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/auto/network-settings.h b/tests/auto/network-settings.h index 6ffb6f4..a770f8e 100644 --- a/tests/auto/network-settings.h +++ b/tests/auto/network-settings.h @@ -329,7 +329,7 @@ QByteArray QtNetworkSettings::imapExpectedReplySsl; #define Q_SET_DEFAULT_IAP #endif - +#ifdef QT_NETWORK_LIB class QtNetworkSettingsInitializerCode { public: QtNetworkSettingsInitializerCode() { @@ -343,3 +343,4 @@ public: } }; QtNetworkSettingsInitializerCode qtNetworkSettingsInitializer; +#endif -- cgit v0.12 From e31047fd3afd10e7d2d457b1a1bd4ee9bd48979a Mon Sep 17 00:00:00 2001 From: mread Date: Tue, 8 Sep 2009 14:36:38 +0100 Subject: exception safety fix for QList::operator+= (const QList&) The refactoring of current++ and src++ out of the new line makes the code easier to understand but it also seems to be significant at least in the ::isComplex case. I suspect that the ordering increment operations vs throw from new is not well defined, or not implemented as you might hope (with the ++ happening very last). The changes in the catch blocks mean that it deletes the created objects, rather than trying with the first failed object. The test code has been updated with a +=(Container) test, and to force testing of both static and moveable types. Reviewed-by: Harald Fernengel --- src/corelib/tools/qlist.h | 19 ++-- .../tst_exceptionsafety_objects.cpp | 117 ++++++++++++++++----- 2 files changed, 104 insertions(+), 32 deletions(-) diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h index c2bdbee..f316fec 100644 --- a/src/corelib/tools/qlist.h +++ b/src/corelib/tools/qlist.h @@ -367,21 +367,26 @@ Q_INLINE_TEMPLATE void QList::node_copy(Node *from, Node *to, Node *src) if (QTypeInfo::isLarge || QTypeInfo::isStatic) { QT_TRY { while(current != to) { - (current++)->v = new T(*reinterpret_cast((src++)->v)); + current->v = new T(*reinterpret_cast(src->v)); + ++current; + ++src; } } QT_CATCH(...) { - while (current != from) - delete reinterpret_cast(current--); + while (current-- != from) + delete reinterpret_cast(current->v); QT_RETHROW; } } else if (QTypeInfo::isComplex) { QT_TRY { - while(current != to) - new (current++) T(*reinterpret_cast(src++)); + while(current != to) { + new (current) T(*reinterpret_cast(src)); + ++current; + ++src; + } } QT_CATCH(...) { - while (current != from) - (reinterpret_cast(current--))->~T(); + while (current-- != from) + (reinterpret_cast(current))->~T(); QT_RETHROW; } } else { diff --git a/tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp b/tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp index 075fa01..46d5b9d 100644 --- a/tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp +++ b/tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp @@ -462,22 +462,62 @@ struct Integer int Integer::instanceCount = 0; -template class Container> +struct IntegerMoveable + { + IntegerMoveable(int value = 42) + : val(value) + { + delete new int; + ++instanceCount; + } + + IntegerMoveable(const IntegerMoveable &other) + : val(other.val) + { + delete new int; + ++instanceCount; + } + + IntegerMoveable &operator=(const IntegerMoveable &other) + { + delete new int; + val = other.val; + return *this; + } + + ~IntegerMoveable() + { + --instanceCount; + } + + int value() const + { + return val; + } + + int val; + static int instanceCount; + }; + +int IntegerMoveable::instanceCount = 0; +Q_DECLARE_TYPEINFO(IntegerMoveable, Q_MOVABLE_TYPE); + +template class Container > void containerInsertTest(QObject*) { - Container container; + Container container; // insert an item in an empty container try { container.insert(container.begin(), 41); } catch (...) { QVERIFY(container.isEmpty()); - QCOMPARE(Integer::instanceCount, 0); + QCOMPARE(T::instanceCount, 0); return; } QCOMPARE(container.size(), 1); - QCOMPARE(Integer::instanceCount, 1); + QCOMPARE(T::instanceCount, 1); // insert an item before another item try { @@ -485,11 +525,11 @@ void containerInsertTest(QObject*) } catch (...) { QCOMPARE(container.size(), 1); QCOMPARE(container.first().value(), 41); - QCOMPARE(Integer::instanceCount, 1); + QCOMPARE(T::instanceCount, 1); return; } - QCOMPARE(Integer::instanceCount, 2); + QCOMPARE(T::instanceCount, 2); // insert an item in between try { @@ -498,24 +538,24 @@ void containerInsertTest(QObject*) QCOMPARE(container.size(), 2); QCOMPARE(container.first().value(), 41); QCOMPARE((container.begin() + 1)->value(), 42); - QCOMPARE(Integer::instanceCount, 2); + QCOMPARE(T::instanceCount, 2); return; } - QCOMPARE(Integer::instanceCount, 3); + QCOMPARE(T::instanceCount, 3); } -template class Container> +template class Container> void containerAppendTest(QObject*) { - Container container; + Container container; // append to an empty container try { container.append(42); } catch (...) { QCOMPARE(container.size(), 0); - QCOMPARE(Integer::instanceCount, 0); + QCOMPARE(T::instanceCount, 0); return; } @@ -525,15 +565,38 @@ void containerAppendTest(QObject*) } catch (...) { QCOMPARE(container.size(), 1); QCOMPARE(container.first().value(), 42); - QCOMPARE(Integer::instanceCount, 1); + QCOMPARE(T::instanceCount, 1); return; } + + Container container2; + + try { + container2.append(44); + } catch (...) { + // don't care + return; + } + QCOMPARE(T::instanceCount, 3); + + // append another container with one item + try { + container += container2; + } catch (...) { + QCOMPARE(container.size(), 2); + QCOMPARE(container.first().value(), 42); + QCOMPARE((container.begin() + 1)->value(), 43); + QCOMPARE(T::instanceCount, 3); + return; + } + + QCOMPARE(T::instanceCount, 4); } -template class Container> +template class Container> void containerEraseTest(QObject*) { - Container container; + Container container; try { container.append(42); @@ -548,7 +611,7 @@ void containerEraseTest(QObject*) // sanity checks QCOMPARE(container.size(), 5); - QCOMPARE(Integer::instanceCount, 5); + QCOMPARE(T::instanceCount, 5); // delete the first one try { @@ -556,20 +619,20 @@ void containerEraseTest(QObject*) } catch (...) { QCOMPARE(container.size(), 5); QCOMPARE(container.first().value(), 42); - QCOMPARE(Integer::instanceCount, 5); + QCOMPARE(T::instanceCount, 5); return; } QCOMPARE(container.size(), 4); QCOMPARE(container.first().value(), 43); - QCOMPARE(Integer::instanceCount, 4); + QCOMPARE(T::instanceCount, 4); // delete the last one try { container.erase(container.end() - 1); } catch (...) { QCOMPARE(container.size(), 4); - QCOMPARE(Integer::instanceCount, 4); + QCOMPARE(T::instanceCount, 4); return; } @@ -577,7 +640,7 @@ void containerEraseTest(QObject*) QCOMPARE(container.first().value(), 43); QCOMPARE((container.begin() + 1)->value(), 44); QCOMPARE((container.begin() + 2)->value(), 45); - QCOMPARE(Integer::instanceCount, 3); + QCOMPARE(T::instanceCount, 3); // delete the middle one try { @@ -587,14 +650,14 @@ void containerEraseTest(QObject*) QCOMPARE(container.first().value(), 43); QCOMPARE((container.begin() + 1)->value(), 44); QCOMPARE((container.begin() + 2)->value(), 45); - QCOMPARE(Integer::instanceCount, 3); + QCOMPARE(T::instanceCount, 3); return; } QCOMPARE(container.size(), 2); QCOMPARE(container.first().value(), 43); QCOMPARE((container.begin() + 1)->value(), 45); - QCOMPARE(Integer::instanceCount, 2); + QCOMPARE(T::instanceCount, 2); } template class Container> @@ -602,9 +665,12 @@ static void containerData() { QTest::addColumn("testFunction"); - QTest::newRow("insert") << static_cast(containerInsertTest); - QTest::newRow("append") << static_cast(containerAppendTest); - QTest::newRow("erase") << static_cast(containerEraseTest); + QTest::newRow("insert static") << static_cast(containerInsertTest); + QTest::newRow("append static") << static_cast(containerAppendTest); + QTest::newRow("erase static") << static_cast(containerEraseTest); + QTest::newRow("insert moveable") << static_cast(containerInsertTest); + QTest::newRow("append moveable") << static_cast(containerAppendTest); + QTest::newRow("erase moveable") << static_cast(containerEraseTest); } void tst_ExceptionSafetyObjects::vector_data() @@ -616,7 +682,8 @@ void tst_ExceptionSafetyObjects::vector() { QFETCH(TestFunction, testFunction); - if (QLatin1String(QTest::currentDataTag()) == QLatin1String("insert")) + if (QLatin1String(QTest::currentDataTag()) == QLatin1String("insert static") + || QLatin1String(QTest::currentDataTag()) == QLatin1String("insert moveable")) QSKIP("QVector::insert is currently not strongly exception safe", SkipSingle); doOOMTest(testFunction, 0); -- cgit v0.12 From 7499d6c71a6579968189386e1e06e2479c1a6747 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Tue, 8 Sep 2009 15:58:24 +0200 Subject: tst_qbytearray: set SRCDIR to ./ on Windows CE Reviewed-by: thartman --- tests/auto/qbytearray/qbytearray.pro | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tests/auto/qbytearray/qbytearray.pro b/tests/auto/qbytearray/qbytearray.pro index d14534b..a0c143e 100644 --- a/tests/auto/qbytearray/qbytearray.pro +++ b/tests/auto/qbytearray/qbytearray.pro @@ -4,16 +4,17 @@ SOURCES += tst_qbytearray.cpp QT = core -wince*|symbian: { +wince*|symbian { addFile.sources = rfc3252.txt addFile.path = . DEPLOYMENT += addFile } -wince: { - DEFINES += SRCDIR=\\\"\\\" -} symbian: { +wince* { + DEFINES += SRCDIR=\\\"./\\\" +} else:symbian { TARGET.EPOCHEAPSIZE="0x100 0x800000" } else { - DEFINES += SRCDIR=\\\"$$PWD/\\\" + DEFINES += SRCDIR=\\\"$$PWD/\\\" } + -- cgit v0.12 From 5364fd96a72c89b281f0540da909fe64d0575ccf Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Tue, 8 Sep 2009 16:41:51 +0200 Subject: Take right bearing of glyphs into account when doing text layout To support correctly breaking text and calculating the bounding rect of text that has a right bearing (like italic text), we need to take the bearing into account when doing the layout. We add the bearing when checking whether we need to break the text, and we add it to the natural width of the text whenever we've finished a text line, so that we get the correct bounding rectangle. This patch only takes the last glyph's bearing into account. The theoretically correct approach would be to take all bearings into account and use the one which gives the longest text width. However, in practice the bearing of the glyph will not be great enough for it to span over several other glyphs. Also refactored a little to make the code simpler. Task-number: 176401 Reviewed-by: Simon Hausmann --- src/gui/text/qtextlayout.cpp | 155 ++++++++++++++++++++++++++++--------------- 1 file changed, 101 insertions(+), 54 deletions(-) diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index b150f50..60e5296 100644 --- a/src/gui/text/qtextlayout.cpp +++ b/src/gui/text/qtextlayout.cpp @@ -1589,27 +1589,54 @@ void QTextLine::setNumColumns(int numColumns, qreal alignmentWidth) #define LB_DEBUG if (0) qDebug #endif -static inline bool checkFullOtherwiseExtend(QScriptLine &line, QScriptLine &tmpData, QScriptLine &spaceData, - int glyphCount, int maxGlyphs, QFixed &minw, bool manualWrap, - QFixed softHyphenWidth = QFixed()) -{ +namespace { + + struct LineBreakHelper + { + LineBreakHelper() : glyphCount(0), maxGlyphs(0), manualWrap(false) {} + + QScriptLine tmpData; + QScriptLine spaceData; + + int glyphCount; + int maxGlyphs; + + QFixed minw; + QFixed softHyphenWidth; + QFixed rightBearing; + + bool manualWrap; + + bool checkFullOtherwiseExtend(QScriptLine &line); + }; + +inline bool LineBreakHelper::checkFullOtherwiseExtend(QScriptLine &line) +{ LB_DEBUG("possible break width %f, spacew=%f", tmpData.textWidth.toReal(), spaceData.textWidth.toReal()); - if (line.length && !manualWrap && - (line.textWidth + tmpData.textWidth + spaceData.textWidth + softHyphenWidth > line.width || glyphCount > maxGlyphs)) + + QFixed newWidth = line.textWidth + tmpData.textWidth + spaceData.textWidth + softHyphenWidth + rightBearing; + if (line.length && !manualWrap && (newWidth > line.width || glyphCount > maxGlyphs)) return true; + minw = qMax(minw, tmpData.textWidth); line += tmpData; line.textWidth += spaceData.textWidth; + line.length += spaceData.length; tmpData.textWidth = 0; tmpData.length = 0; spaceData.textWidth = 0; spaceData.length = 0; + return false; } +} // anonymous namespace + + static inline void addNextCluster(int &pos, int end, QScriptLine &line, int &glyphCount, - const QScriptItem ¤t, const unsigned short *logClusters, const QGlyphLayout &glyphs) + const QScriptItem ¤t, const unsigned short *logClusters, + const QGlyphLayout &glyphs) { int glyphPosition = logClusters[pos]; do { // got to the first next cluster @@ -1642,9 +1669,13 @@ void QTextLine::layout_helper(int maxGlyphs) Q_ASSERT(line.from < eng->layoutData->string.length()); + LineBreakHelper lbh; + + lbh.maxGlyphs = maxGlyphs; + QTextOption::WrapMode wrapMode = eng->option.wrapMode(); bool breakany = (wrapMode == QTextOption::WrapAnywhere); - bool manualWrap = (wrapMode == QTextOption::ManualWrap || wrapMode == QTextOption::NoWrap); + lbh.manualWrap = (wrapMode == QTextOption::ManualWrap || wrapMode == QTextOption::NoWrap); // #### binary search! int item = -1; @@ -1654,12 +1685,7 @@ void QTextLine::layout_helper(int maxGlyphs) break; } - QFixed minw = 0; - int glyphCount = 0; - LB_DEBUG("from: %d: item=%d, total %d, width available %f", line.from, newItem, eng->layoutData->items.size(), line.width.toReal()); - QScriptLine tmpData; - QScriptLine spaceData; Qt::Alignment alignment = eng->option.alignment(); @@ -1668,7 +1694,10 @@ void QTextLine::layout_helper(int maxGlyphs) int end = 0; QGlyphLayout glyphs; const unsigned short *logClusters = eng->layoutData->logClustersPtr; + while (newItem < eng->layoutData->items.size()) { + lbh.rightBearing = 0; + lbh.softHyphenWidth = 0; if (newItem != item) { item = newItem; const QScriptItem ¤t = eng->layoutData->items[item]; @@ -1683,57 +1712,60 @@ void QTextLine::layout_helper(int maxGlyphs) } const QScriptItem ¤t = eng->layoutData->items[item]; - tmpData.ascent = qMax(tmpData.ascent, current.ascent); - tmpData.descent = qMax(tmpData.descent, current.descent); + lbh.tmpData.ascent = qMax(lbh.tmpData.ascent, current.ascent); + lbh.tmpData.descent = qMax(lbh.tmpData.descent, current.descent); if (current.analysis.flags == QScriptAnalysis::Tab && (alignment & (Qt::AlignLeft | Qt::AlignRight | Qt::AlignCenter | Qt::AlignJustify))) { - if (checkFullOtherwiseExtend(line, tmpData, spaceData, glyphCount, maxGlyphs, minw, manualWrap)) + if (lbh.checkFullOtherwiseExtend(line)) goto found; - QFixed x = line.x + line.textWidth + tmpData.textWidth + spaceData.textWidth; - spaceData.textWidth += eng->calculateTabWidth(item, x); - spaceData.length++; + QFixed x = line.x + line.textWidth + lbh.tmpData.textWidth + lbh.spaceData.textWidth; + lbh.spaceData.textWidth += eng->calculateTabWidth(item, x); + lbh.spaceData.length++; newItem = item + 1; - ++glyphCount; - if (checkFullOtherwiseExtend(line, tmpData, spaceData, glyphCount, maxGlyphs, minw, manualWrap)) + ++lbh.glyphCount; + if (lbh.checkFullOtherwiseExtend(line)) goto found; } else if (current.analysis.flags == QScriptAnalysis::LineOrParagraphSeparator) { // if the line consists only of the line separator make sure // we have a sane height - if (!line.length && !tmpData.length) + if (!line.length && !lbh.tmpData.length) line.setDefaultHeight(eng); if (eng->option.flags() & QTextOption::ShowLineAndParagraphSeparators) { - addNextCluster(pos, end, tmpData, glyphCount, current, logClusters, glyphs); + addNextCluster(pos, end, lbh.tmpData, lbh.glyphCount, + current, logClusters, glyphs); } else { - tmpData.length++; + lbh.tmpData.length++; } - line += tmpData; + line += lbh.tmpData; goto found; } else if (current.analysis.flags == QScriptAnalysis::Object) { - tmpData.length++; + lbh.tmpData.length++; QTextFormat format = eng->formats()->format(eng->formatIndex(&eng->layoutData->items[item])); if (eng->block.docHandle()) eng->docLayout()->positionInlineObject(QTextInlineObject(item, eng), eng->block.position() + current.position, format); - tmpData.textWidth += current.width; + lbh.tmpData.textWidth += current.width; newItem = item + 1; - ++glyphCount; - if (checkFullOtherwiseExtend(line, tmpData, spaceData, glyphCount, maxGlyphs, minw, manualWrap)) + ++lbh.glyphCount; + if (lbh.checkFullOtherwiseExtend(line)) goto found; } else if (attributes[pos].whiteSpace) { while (pos < end && attributes[pos].whiteSpace) - addNextCluster(pos, end, spaceData, glyphCount, current, logClusters, glyphs); + addNextCluster(pos, end, lbh.spaceData, lbh.glyphCount, + current, logClusters, glyphs); - if (!manualWrap && spaceData.textWidth > line.width) { - spaceData.textWidth = line.width; // ignore spaces that fall out of the line. + if (!lbh.manualWrap && lbh.spaceData.textWidth > line.width) { + lbh.spaceData.textWidth = line.width; // ignore spaces that fall out of the line. goto found; } } else { bool sb_or_ws = false; do { - addNextCluster(pos, end, tmpData, glyphCount, current, logClusters, glyphs); + addNextCluster(pos, end, lbh.tmpData, lbh.glyphCount, + current, logClusters, glyphs); if (attributes[pos].whiteSpace || attributes[pos-1].lineBreakType != HB_NoBreak) { sb_or_ws = true; @@ -1742,9 +1774,8 @@ void QTextLine::layout_helper(int maxGlyphs) break; } } while (pos < end); - minw = qMax(tmpData.textWidth, minw); + lbh.minw = qMax(lbh.tmpData.textWidth, lbh.minw); - QFixed softHyphenWidth; if (pos && attributes[pos - 1].lineBreakType == HB_SoftHyphen) { // if we are splitting up a word because of // a soft hyphen then we ... @@ -1763,16 +1794,29 @@ void QTextLine::layout_helper(int maxGlyphs) // and thus become invisible again. // if (line.length) - softHyphenWidth = glyphs.advances_x[logClusters[pos - 1]]; + lbh.softHyphenWidth = glyphs.advances_x[logClusters[pos - 1]]; else if (breakany) - tmpData.textWidth += glyphs.advances_x[logClusters[pos - 1]]; + lbh.tmpData.textWidth += glyphs.advances_x[logClusters[pos - 1]]; } - if ((sb_or_ws|breakany) - && checkFullOtherwiseExtend(line, tmpData, spaceData, glyphCount, maxGlyphs, minw, manualWrap, softHyphenWidth)) { + // The actual width of the text needs to take the right bearing into account. The + // right bearing is left-ward, which means that if the rightmost pixel is to the right + // of the advance of the glyph, the bearing will be negative. We flip the sign + // for the code to be more readable. Logic borrowed from qfontmetrics.cpp. + if (pos) { + QFontEngine *fontEngine = eng->fontEngine(current); + glyph_t glyph = glyphs.glyphs[logClusters[pos - 1]]; + glyph_metrics_t gi = fontEngine->boundingBox(glyph); + lbh.rightBearing = -qRound(gi.xoff - gi.x - gi.width); + } + + if ((sb_or_ws|breakany) && lbh.checkFullOtherwiseExtend(line)) { if (!breakany) { - line.textWidth += softHyphenWidth; + line.textWidth += lbh.softHyphenWidth; } + + line.textWidth += lbh.rightBearing; + goto found; } } @@ -1780,45 +1824,48 @@ void QTextLine::layout_helper(int maxGlyphs) newItem = item + 1; } LB_DEBUG("reached end of line"); - checkFullOtherwiseExtend(line, tmpData, spaceData, glyphCount, maxGlyphs, minw, manualWrap); -found: + lbh.checkFullOtherwiseExtend(line); + line.textWidth += lbh.rightBearing; + +found: if (line.length == 0) { LB_DEBUG("no break available in line, adding temp: length %d, width %f, space: length %d, width %f", - tmpData.length, tmpData.textWidth.toReal(), spaceData.length, spaceData.textWidth.toReal()); - line += tmpData; + lbh.tmpData.length, lbh.tmpData.textWidth.toReal(), + lbh.spaceData.length, lbh.spaceData.textWidth.toReal()); + line += lbh.tmpData; } LB_DEBUG("line length = %d, ascent=%f, descent=%f, textWidth=%f (spacew=%f)", line.length, line.ascent.toReal(), - line.descent.toReal(), line.textWidth.toReal(), spaceData.width.toReal()); + line.descent.toReal(), line.textWidth.toReal(), lbh.spaceData.width.toReal()); LB_DEBUG(" : '%s'", eng->layoutData->string.mid(line.from, line.length).toUtf8().data()); - if (manualWrap) { + if (lbh.manualWrap) { eng->minWidth = qMax(eng->minWidth, line.textWidth); eng->maxWidth = qMax(eng->maxWidth, line.textWidth); } else { - eng->minWidth = qMax(eng->minWidth, minw); + eng->minWidth = qMax(eng->minWidth, lbh.minw); eng->maxWidth += line.textWidth; } if (line.textWidth > 0 && item < eng->layoutData->items.size()) - eng->maxWidth += spaceData.textWidth; + eng->maxWidth += lbh.spaceData.textWidth; if (eng->option.flags() & QTextOption::IncludeTrailingSpaces) - line.textWidth += spaceData.textWidth; - line.length += spaceData.length; - if (spaceData.length) + line.textWidth += lbh.spaceData.textWidth; + line.length += lbh.spaceData.length; + if (lbh.spaceData.length) line.hasTrailingSpaces = true; line.justified = false; line.gridfitted = false; if (eng->option.wrapMode() == QTextOption::WrapAtWordBoundaryOrAnywhere) { - if ((maxGlyphs != INT_MAX && glyphCount > maxGlyphs) - || (maxGlyphs == INT_MAX && line.textWidth > line.width)) { + if ((lbh.maxGlyphs != INT_MAX && lbh.glyphCount > lbh.maxGlyphs) + || (lbh.maxGlyphs == INT_MAX && line.textWidth > line.width)) { eng->option.setWrapMode(QTextOption::WrapAnywhere); line.length = 0; line.textWidth = 0; - layout_helper(maxGlyphs); + layout_helper(lbh.maxGlyphs); eng->option.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere); } } -- cgit v0.12 From 10563ce08c79c88c762d463ec7b008524d1c1a67 Mon Sep 17 00:00:00 2001 From: Geir Vattekar Date: Tue, 8 Sep 2009 16:54:55 +0200 Subject: Doc: Fixed bug in style sheet syntax documentation. Task-number: 234366 Reviewed-by: Trust Me --- doc/src/widgets-and-layouts/stylesheet.qdoc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/doc/src/widgets-and-layouts/stylesheet.qdoc b/doc/src/widgets-and-layouts/stylesheet.qdoc index 354050d..c137d6a 100644 --- a/doc/src/widgets-and-layouts/stylesheet.qdoc +++ b/doc/src/widgets-and-layouts/stylesheet.qdoc @@ -230,9 +230,11 @@ \o \c{QPushButton[flat="false"]} \o Matches instances of QPushButton that are not \l{QPushButton::}{flat}. You may use this selector to test - for any Qt property specified using Q_PROPERTY(). In - addition, the special \c class property is supported, for - the name of the class. + for any Qt \l{Qt's Property System}{property} that supports + QVariant::toString() (see the \l{QVariant::}{toString()} + function documentation for details). In addition, the + special \c class property is supported, for the name of the + class. This selector may also be used to test dynamic properties. For more information on customization using dynamic properties, -- cgit v0.12 From 5a3d0e73121e191fe2f1337ac8f6761c35868b66 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Tue, 8 Sep 2009 17:24:37 +0200 Subject: Fix crash when instantiating multiple QApplications on QWS Copy variable initialization/cleanup code from X11 Reviewed-by: Tom --- src/gui/kernel/qapplication_qws.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/gui/kernel/qapplication_qws.cpp b/src/gui/kernel/qapplication_qws.cpp index e3bd786..ba2e6a6 100644 --- a/src/gui/kernel/qapplication_qws.cpp +++ b/src/gui/kernel/qapplication_qws.cpp @@ -2202,6 +2202,8 @@ void qt_init(QApplicationPrivate *priv, int type) mouse_double_click_distance = read_int_env_var("QWS_DBLCLICK_DISTANCE", 5); + priv->inputContext = 0; + int flags = 0; char *p; int argc = priv->argc; @@ -2361,6 +2363,11 @@ void qt_cleanup() delete mouseInWidget; mouseInWidget = 0; + +#if !defined(QT_NO_IM) + delete QApplicationPrivate::inputContext; + QApplicationPrivate::inputContext = 0; +#endif } -- cgit v0.12 From 7c59abc1883a24e54ac3bb2193acc2cac5ad416a Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Thu, 27 Aug 2009 16:08:20 +0200 Subject: Replace QGLDrawable with a new QGLPaintDevice This patch adds a new abstract base class which inherits from QPaintDevice called QGLPaintDevice. This base class will contain everything the GL paint engines need to know about the surface they are drawing onto. As such, new surfaces can be targeted by the GL paint engines without having to modify QtOpenGL. This is very useful for plugins, specifically QGraphicsSystem plugins. To unify things a little, the GL paint engines will use the same QGLPaintDevice API to render into existing target surfaces (QGLWidget, QGLPixelBuffer & QGLFrameBufferObject). Ideally we'd make QGLPaintDevice a common ancestor for these surfaces, but obviously that wil break B/C. This patch only implements QGLWidget using the new interface. Rendering to other surfaces will be fixed in following patches. --- src/corelib/global/qnamespace.h | 3 +- .../gl2paintengineex/qpaintengineex_opengl2.cpp | 65 +++---- .../gl2paintengineex/qpaintengineex_opengl2_p.h | 3 +- src/opengl/opengl.pro | 6 +- src/opengl/qgl.cpp | 5 +- src/opengl/qgl.h | 2 + src/opengl/qgl_p.h | 7 +- src/opengl/qgl_x11.cpp | 3 +- src/opengl/qglpaintdevice.cpp | 192 +++++++++++++++++++++ src/opengl/qglpaintdevice_p.h | 168 ++++++++++++++++++ src/opengl/qpaintengine_opengl.cpp | 113 ++++++------ 11 files changed, 483 insertions(+), 84 deletions(-) create mode 100644 src/opengl/qglpaintdevice.cpp create mode 100644 src/opengl/qglpaintdevice_p.h diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h index 8f34e30..93de911 100644 --- a/src/corelib/global/qnamespace.h +++ b/src/corelib/global/qnamespace.h @@ -1655,7 +1655,8 @@ public: FramebufferObject = 0x07, // GL framebuffer object CustomRaster = 0x08, MacQuartz = 0x09, - PaintBuffer = 0x0a + PaintBuffer = 0x0a, + OpenGL = 0x0b }; enum RelayoutType { RelayoutNormal, diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index e24539b..8fee83d 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -710,7 +710,7 @@ void QGL2PaintEngineEx::beginNativePainting() { mtx.dx(), mtx.dy(), 0, mtx.m33() } }; - const QSize sz = d->drawable.size(); + const QSize sz = d->device->size(); glMatrixMode(GL_PROJECTION); glLoadIdentity(); @@ -1308,21 +1308,28 @@ bool QGL2PaintEngineEx::begin(QPaintDevice *pdev) Q_D(QGL2PaintEngineEx); // qDebug("QGL2PaintEngineEx::begin()"); - d->drawable.setDevice(pdev); - d->ctx = d->drawable.context(); + if (pdev->devType() == QInternal::OpenGL) + d->device = static_cast(pdev); + else + d->device = QGLPaintDevice::getDevice(pdev); + + if (!d->device) + return false; + + d->ctx = d->device->context(); if (d->ctx->d_ptr->active_engine) { QGL2PaintEngineEx *engine = static_cast(d->ctx->d_ptr->active_engine); QGL2PaintEngineExPrivate *p = static_cast(engine->d_ptr.data()); p->transferMode(BrushDrawingMode); - p->drawable.doneCurrent(); + p->device->context()->doneCurrent(); } d->ctx->d_ptr->active_engine = this; d->last_created_state = 0; - d->drawable.makeCurrent(); - QSize sz = d->drawable.size(); + d->device->beginPaint(); + QSize sz = d->device->size(); d->width = sz.width(); d->height = sz.height(); d->mode = BrushDrawingMode; @@ -1358,28 +1365,29 @@ bool QGL2PaintEngineEx::begin(QPaintDevice *pdev) glDisable(GL_MULTISAMPLE); #endif - QGLPixmapData *source = d->drawable.copyOnBegin(); - if (d->drawable.context()->d_func()->clear_on_painter_begin && d->drawable.autoFillBackground()) { - if (d->drawable.hasTransparentBackground()) +// QGLPixmapData *source = d->drawable.copyOnBegin(); + if (d->ctx->d_func()->clear_on_painter_begin && d->device->autoFillBackground()) { + if (d->device->hasTransparentBackground()) glClearColor(0.0, 0.0, 0.0, 0.0); else { - const QColor &c = d->drawable.backgroundColor(); + const QColor &c = d->device->backgroundColor(); float alpha = c.alphaF(); glClearColor(c.redF() * alpha, c.greenF() * alpha, c.blueF() * alpha, alpha); } glClear(GL_COLOR_BUFFER_BIT); - } else if (source) { - QGLContext *ctx = d->ctx; - - d->transferMode(ImageDrawingMode); - - glActiveTexture(GL_TEXTURE0 + QT_IMAGE_TEXTURE_UNIT); - source->bind(false); - - QRect rect(0, 0, source->width(), source->height()); - d->updateTextureFilter(GL_TEXTURE_2D, GL_REPEAT, false); - d->drawTexture(QRectF(rect), QRectF(rect), rect.size(), true); } +// else if (source) { +// QGLContext *ctx = d->ctx; +// +// d->transferMode(ImageDrawingMode); +// +// glActiveTexture(GL_TEXTURE0 + QT_IMAGE_TEXTURE_UNIT); +// source->bind(false); +// +// QRect rect(0, 0, source->width(), source->height()); +// d->updateTextureFilter(GL_TEXTURE_2D, GL_REPEAT, false); +// d->drawTexture(QRectF(rect), QRectF(rect), rect.size(), true); +// } d->systemStateChanged(); return true; @@ -1394,14 +1402,15 @@ bool QGL2PaintEngineEx::end() if (engine && engine->isActive()) { QGL2PaintEngineExPrivate *p = static_cast(engine->d_ptr.data()); p->transferMode(BrushDrawingMode); - p->drawable.doneCurrent(); + p->device->context()->doneCurrent(); } - d->drawable.makeCurrent(); + d->device->context()->makeCurrent(); } glUseProgram(0); d->transferMode(BrushDrawingMode); - d->drawable.swapBuffers(); + d->device->endPaint(); + #if defined(Q_WS_X11) // On some (probably all) drivers, deleting an X pixmap which has been bound to a texture // before calling glFinish/swapBuffers renders garbage. Presumably this is because X deletes @@ -1410,7 +1419,6 @@ bool QGL2PaintEngineEx::end() // them here, after swapBuffers, where they can be safely deleted. ctx->d_func()->boundPixmaps.clear(); #endif - d->drawable.doneCurrent(); d->ctx->d_ptr->active_engine = 0; d->resetGLState(); @@ -1431,15 +1439,14 @@ void QGL2PaintEngineEx::ensureActive() if (engine && engine->isActive()) { QGL2PaintEngineExPrivate *p = static_cast(engine->d_ptr.data()); p->transferMode(BrushDrawingMode); - p->drawable.doneCurrent(); + p->device->context()->doneCurrent(); } - d->drawable.context()->makeCurrent(); - d->drawable.makeCurrent(); + d->device->context()->makeCurrent(); ctx->d_ptr->active_engine = this; d->needsSync = true; } else { - d->drawable.context()->makeCurrent(); + d->device->context()->makeCurrent(); } if (d->needsSync) { diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h index cb23b11..2fbee1b 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h @@ -58,6 +58,7 @@ #include #include #include +#include enum EngineMode { ImageDrawingMode, @@ -199,7 +200,7 @@ public: static QGLEngineShaderManager* shaderManagerForEngine(QGL2PaintEngineEx *engine) { return engine->d_func()->shaderManager; } QGL2PaintEngineEx* q; - QGLDrawable drawable; + QGLPaintDevice* device; int width, height; QGLContext *ctx; EngineMode mode; diff --git a/src/opengl/opengl.pro b/src/opengl/opengl.pro index 560d31f..2aefe41 100644 --- a/src/opengl/opengl.pro +++ b/src/opengl/opengl.pro @@ -22,13 +22,17 @@ HEADERS += qgl.h \ qglpixelbuffer.h \ qglpixelbuffer_p.h \ qglframebufferobject.h \ - qglextensions_p.h + qglextensions_p.h \ + qglpaintdevice_p.h \ + SOURCES += qgl.cpp \ qglcolormap.cpp \ qglpixelbuffer.cpp \ qglframebufferobject.cpp \ qglextensions.cpp \ + qglpaintdevice.cpp \ + !contains(QT_CONFIG, opengles2) { HEADERS += qpaintengine_opengl_p.h diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 02bb8f9..ad54298 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -4815,6 +4815,8 @@ void QGLWidgetPrivate::initContext(QGLContext *context, const QGLWidget* shareWi { Q_Q(QGLWidget); + glDevice.setWidget(q); + QGLExtensions::init(); glcx = 0; autoSwap = true; @@ -4850,6 +4852,7 @@ Q_OPENGL_EXPORT const QString qt_gl_library_name() } #endif +#if 0 void QGLDrawable::setDevice(QPaintDevice *pdev) { wasBound = false; @@ -5084,7 +5087,7 @@ bool QGLDrawable::autoFillBackground() const else return false; } - +#endif bool QGLShareRegister::checkSharing(const QGLContext *context1, const QGLContext *context2) { bool sharing = (context1 && context2 && context1->d_ptr->group == context2->d_ptr->group); diff --git a/src/opengl/qgl.h b/src/opengl/qgl.h index b110665..46efe23 100644 --- a/src/opengl/qgl.h +++ b/src/opengl/qgl.h @@ -542,6 +542,8 @@ private: friend class QGLContext; friend class QGLOverlayWidget; friend class QOpenGLPaintEngine; + friend class QGLPaintDevice; + friend class QGLWidgetGLPaintDevice; }; diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index f8158a0..03532c8 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -62,6 +62,7 @@ #include "QtCore/qatomic.h" #include "private/qwidget_p.h" #include "qcache.h" +#include "qglpaintdevice_p.h" #ifndef QT_OPENGL_ES_1_CL #define q_vertexType float @@ -189,7 +190,8 @@ public: bool renderCxPm(QPixmap *pixmap); void cleanupColormaps(); - QGLContext *glcx; + QGLContext *glcx; // ### Keep for compatability with QGLDrawable (if that gets left in) + QGLWidgetGLPaintDevice glDevice; bool autoSwap; QGLColormap cmap; @@ -337,6 +339,7 @@ Q_SIGNALS: void aboutToDestroyContext(const QGLContext *context); }; +#if 0 class QGLPixelBuffer; class QGLFramebufferObject; class QWSGLWindowSurface; @@ -388,6 +391,8 @@ private: int previous_fbo; }; +#endif + // GL extension definitions class QGLExtensions { public: diff --git a/src/opengl/qgl_x11.cpp b/src/opengl/qgl_x11.cpp index 81985cd..5da128d 100644 --- a/src/opengl/qgl_x11.cpp +++ b/src/opengl/qgl_x11.cpp @@ -41,6 +41,7 @@ #include "qgl.h" #include "qgl_p.h" +#include "qglpaintdevice_p.h" #include "qmap.h" #include "qapplication.h" @@ -1307,7 +1308,7 @@ void QGLWidget::setContext(QGLContext *context, d->glcx->doneCurrent(); QGLContext* oldcx = d->glcx; d->glcx = context; - + d->glDevice.setContext(context); // ### Do this for all platforms if (parentWidget()) { // force creation of delay-created widgets diff --git a/src/opengl/qglpaintdevice.cpp b/src/opengl/qglpaintdevice.cpp new file mode 100644 index 0000000..f7bd2a3 --- /dev/null +++ b/src/opengl/qglpaintdevice.cpp @@ -0,0 +1,192 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtOpenGL module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include + +QGLPaintDevice::QGLPaintDevice() + : m_context(0) +{ +} + +QGLPaintDevice::~QGLPaintDevice() +{ +} + +//extern QPaintEngine* qt_gl_engine(); // in qgl.cpp +//extern QPaintEngine* qt_gl_2_engine(); // in qgl.cpp + +//inline bool qt_gl_preferGL2Engine() +//{ +//#if defined(QT_OPENGL_ES_2) +// return true; +//#else +// return (QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_2_0) +// && qgetenv("QT_GL_USE_OPENGL1ENGINE").isEmpty(); +//#endif +//} + +//QPaintEngine* QGLPaintDevice::paintEngine() const +//{ +//#if defined(QT_OPENGL_ES_1) || defined(QT_OPENGL_ES_1_CL) +// return qt_gl_engine(); +//#elif defined(QT_OPENGL_ES_2) +// return qt_gl_2_engine(); +//#else +// if (!qt_gl_preferGL2Engine()) +// return qt_gl_engine(); +// else +// return qt_gl_2_engine(); +//#endif +//} + +void QGLPaintDevice::beginPaint() +{ + m_context->makeCurrent(); +} + +void QGLPaintDevice::endPaint() +{ +} + +QColor QGLPaintDevice::backgroundColor() const +{ + return QColor(); +} + +bool QGLPaintDevice::autoFillBackground() const +{ + return false; +} + +bool QGLPaintDevice::hasTransparentBackground() const +{ + return false; +} + +QGLContext* QGLPaintDevice::context() const +{ + return m_context; +} + +QGLFormat QGLPaintDevice::format() const +{ + return m_context->format(); +} + +QSize QGLPaintDevice::size() const +{ + return QSize(); +} + +void QGLPaintDevice::setContext(QGLContext* c) +{ + m_context = c; +} + + + +QGLWidgetGLPaintDevice::QGLWidgetGLPaintDevice() +{ +} + +QPaintEngine* QGLWidgetGLPaintDevice::paintEngine() const +{ + return glWidget->paintEngine(); +} + +QColor QGLWidgetGLPaintDevice::backgroundColor() const +{ + return glWidget->palette().brush(glWidget->backgroundRole()).color(); +} + +bool QGLWidgetGLPaintDevice::autoFillBackground() const +{ + return glWidget->autoFillBackground(); +} + +bool QGLWidgetGLPaintDevice::hasTransparentBackground() const +{ + return glWidget->testAttribute(Qt::WA_TranslucentBackground); +} + +void QGLWidgetGLPaintDevice::setWidget(QGLWidget* w) +{ + glWidget = w; +} + +//void QGLWidgetGLPaintDevice::beginPaint() +//{ +// glWidget->makeCurrent(); +//} + +void QGLWidgetGLPaintDevice::endPaint() +{ + if (glWidget->autoBufferSwap()) + glWidget->swapBuffers(); +} + + +QSize QGLWidgetGLPaintDevice::size() const +{ + return glWidget->size(); +} + +// returns the QGLPaintDevice for the given QPaintDevice +QGLPaintDevice* QGLPaintDevice::getDevice(QPaintDevice* pd) +{ + QGLPaintDevice* glpd = 0; + + switch(pd->devType()) { + case QInternal::Widget: + // Should not be called on a non-gl widget: + Q_ASSERT(qobject_cast(static_cast(pd))); + glpd = &(static_cast(pd)->d_func()->glDevice); + break; + default: + qWarning("QGLPaintDevice::getDevice() - Unknown device type %d", pd->devType()); + break; + } + + return glpd; +} + + diff --git a/src/opengl/qglpaintdevice_p.h b/src/opengl/qglpaintdevice_p.h new file mode 100644 index 0000000..ad680a9 --- /dev/null +++ b/src/opengl/qglpaintdevice_p.h @@ -0,0 +1,168 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtOpenGL module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QGLPAINTDEVICE_P_H +#define QGLPAINTDEVICE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of the QtOpenGL module. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// + +#include +#include + +class QGLPaintDevice : public QPaintDevice +{ +public: + QGLPaintDevice(); + virtual ~QGLPaintDevice(); + + virtual void beginPaint(); + virtual void endPaint(); + + virtual QColor backgroundColor() const; + virtual bool autoFillBackground() const; + virtual bool hasTransparentBackground() const; + + // inline these? + QGLContext* context() const; + QGLFormat format() const; + virtual QSize size() const; + + // returns the QGLPaintDevice for the given QPaintDevice + static QGLPaintDevice* getDevice(QPaintDevice*); + +protected: + // Inline? + void setContext(QGLContext* c); + +private: + QGLContext* m_context; +}; + + +// Wraps a QGLWidget +class QGLWidget; +class QGLWidgetGLPaintDevice : public QGLPaintDevice +{ +public: + QGLWidgetGLPaintDevice(); + + virtual QPaintEngine* paintEngine() const; + + virtual QColor backgroundColor() const; + virtual bool autoFillBackground() const; + virtual bool hasTransparentBackground() const; + + // QGLWidgets need to do swapBufers in endPaint: + virtual void endPaint(); + virtual QSize size() const; + + void setWidget(QGLWidget*); + +private: + friend class QGLWidget; + QGLWidget *glWidget; +}; + + + +/* +Replaces: + +class QGLPixelBuffer; +class QGLFramebufferObject; +class QWSGLWindowSurface; +class QGLWindowSurface; +class QGLPixmapData; +class QGLDrawable { +public: + QGLDrawable() : widget(0), buffer(0), fbo(0) +#if defined(Q_WS_QWS) || (!defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL)) + , wsurf(0) +#endif +#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) + , pixmapData(0) +#endif + {} + void setDevice(QPaintDevice *pdev); + void swapBuffers(); + void makeCurrent(); + void doneCurrent(); + QSize size() const; + QGLFormat format() const; + GLuint bindTexture(const QImage &image, GLenum target = GL_TEXTURE_2D, GLint format = GL_RGBA); + GLuint bindTexture(const QPixmap &pixmap, GLenum target = GL_TEXTURE_2D, GLint format = GL_RGBA); + QColor backgroundColor() const; + QGLContext *context() const; + bool autoFillBackground() const; + bool hasTransparentBackground() const; + +#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) + QGLPixmapData *copyOnBegin() const; +#endif + +private: + bool wasBound; + QGLWidget *widget; + QGLPixelBuffer *buffer; + QGLFramebufferObject *fbo; +#ifdef Q_WS_QWS + QWSGLWindowSurface *wsurf; +#elif !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) + QGLWindowSurface *wsurf; +#endif + +#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) + QGLPixmapData *pixmapData; +#endif + int previous_fbo; +}; +*/ + +#endif // QGLPAINTDEVICE_P_H diff --git a/src/opengl/qpaintengine_opengl.cpp b/src/opengl/qpaintengine_opengl.cpp index bf4d4b9..634067d 100644 --- a/src/opengl/qpaintengine_opengl.cpp +++ b/src/opengl/qpaintengine_opengl.cpp @@ -49,6 +49,7 @@ #include "qbrush.h" #include "qgl.h" #include +#include #include #include "qmap.h" #include @@ -75,7 +76,7 @@ #include "qgl_cl_p.h" #endif -#define QGL_FUNC_CONTEXT QGLContext *ctx = const_cast(drawable.context()); +#define QGL_FUNC_CONTEXT QGLContext *ctx = const_cast(device->context()); #include #include "qpaintengine_opengl_p.h" @@ -286,7 +287,8 @@ public Q_SLOTS: } private: - QGLDrawable drawable; +// QGLDrawable drawable; + QGLPaintDevice* device; QGLFramebufferObject *offscreen; QGLContext *ctx; @@ -305,7 +307,13 @@ private: inline void QGLOffscreen::setDevice(QPaintDevice *pdev) { - drawable.setDevice(pdev); + if (pdev->devType() == QInternal::OpenGL) + device = static_cast(pdev); + else + device = QGLPaintDevice::getDevice(pdev); + + if (!device) + return; drawable_fbo = (pdev->devType() == QInternal::FramebufferObject); } @@ -329,12 +337,12 @@ void QGLOffscreen::initialize() activated = true; initialized = true; - int dim = qMax(2048, static_cast(qt_next_power_of_two(qMax(drawable.size().width(), drawable.size().height())))); + int dim = qMax(2048, static_cast(qt_next_power_of_two(qMax(device->size().width(), device->size().height())))); - bool shared_context = qgl_share_reg()->checkSharing(drawable.context(), ctx); + bool shared_context = qgl_share_reg()->checkSharing(device->context(), ctx); bool would_fail = last_failed_size.isValid() && - (drawable.size().width() >= last_failed_size.width() || - drawable.size().height() >= last_failed_size.height()); + (device->size().width() >= last_failed_size.width() || + device->size().height() >= last_failed_size.height()); bool needs_refresh = dim > mask_dim || !shared_context; if (needs_refresh && !would_fail) { @@ -348,13 +356,13 @@ void QGLOffscreen::initialize() delete offscreen; offscreen = 0; mask_dim = 0; - last_failed_size = drawable.size(); + last_failed_size = device->size(); } } qt_mask_texture_cache()->setOffscreenSize(offscreenSize()); - qt_mask_texture_cache()->setDrawableSize(drawable.size()); - ctx = drawable.context(); + qt_mask_texture_cache()->setDrawableSize(device->size()); + ctx = device->context(); #endif } @@ -428,11 +436,11 @@ inline void QGLOffscreen::release() DEBUG_ONCE_STR("QGLOffscreen: releasing offscreen"); if (drawable_fbo) - drawable.makeCurrent(); + device->context()->makeCurrent(); //### else offscreen->release(); - QSize sz(drawable.size()); + QSize sz(device->size()); glViewport(0, 0, sz.width(), sz.height()); glMatrixMode(GL_PROJECTION); @@ -455,7 +463,7 @@ inline bool QGLOffscreen::isBound() const inline QSize QGLOffscreen::drawableSize() const { - return drawable.size(); + return device->size(); } inline QSize QGLOffscreen::offscreenSize() const @@ -757,7 +765,8 @@ public: GLubyte pen_color[4]; GLubyte brush_color[4]; QTransform::TransformationType txop; - QGLDrawable drawable; +// QGLDrawable drawable; + QGLPaintDevice* device; QGLOffscreen offscreen; qreal inverseScale; @@ -1167,7 +1176,7 @@ void QOpenGLPaintEnginePrivate::createGradientPaletteTexture(const QGradient& g) #ifdef QT_OPENGL_ES //### Q_UNUSED(g); #else - GLuint texId = qt_opengl_gradient_cache()->getBuffer(g, opacity, drawable.context()); + GLuint texId = qt_opengl_gradient_cache()->getBuffer(g, opacity, device->context()); glBindTexture(GL_TEXTURE_1D, texId); grad_palette = texId; if (g.spread() == QGradient::RepeatSpread || g.type() == QGradient::ConicalGradient) @@ -1236,12 +1245,19 @@ bool QOpenGLPaintEngine::begin(QPaintDevice *pdev) { Q_D(QOpenGLPaintEngine); - d->drawable.setDevice(pdev); + if (pdev->devType() == QInternal::OpenGL) + d->device = static_cast(pdev); + else + d->device = QGLPaintDevice::getDevice(pdev); + + if (!d->device) + return false; + d->offscreen.setDevice(pdev); d->has_fast_pen = false; d->inverseScale = 1; d->opacity = 1; - d->drawable.makeCurrent(); + d->device->beginPaint(); d->matrix = QTransform(); d->has_antialiasing = false; d->high_quality_antialiasing = false; @@ -1256,7 +1272,7 @@ bool QOpenGLPaintEngine::begin(QPaintDevice *pdev) bool has_frag_program = (QGLExtensions::glExtensions & QGLExtensions::FragmentProgram) && (pdev->devType() != QInternal::Pixmap); - QGLContext *ctx = const_cast(d->drawable.context()); + QGLContext *ctx = const_cast(d->device->context()); if (!ctx) { qWarning() << "QOpenGLPaintEngine: paint device doesn't have a valid GL context."; return false; @@ -1265,9 +1281,9 @@ bool QOpenGLPaintEngine::begin(QPaintDevice *pdev) if (has_frag_program) has_frag_program = qt_resolve_frag_program_extensions(ctx) && qt_resolve_version_1_3_functions(ctx); - d->use_stencil_method = d->drawable.format().stencil() + d->use_stencil_method = d->device->format().stencil() && (QGLExtensions::glExtensions & QGLExtensions::StencilWrap); - if (d->drawable.format().directRendering() + if (d->device->format().directRendering() && (d->use_stencil_method && QGLExtensions::glExtensions & QGLExtensions::StencilTwoSide)) d->has_stencil_face_ext = qt_resolve_stencil_face_extension(ctx); @@ -1333,12 +1349,12 @@ bool QOpenGLPaintEngine::begin(QPaintDevice *pdev) d->offscreen.begin(); - if (d->drawable.context()->d_func()->clear_on_painter_begin && d->drawable.autoFillBackground()) { + if (d->device->context()->d_func()->clear_on_painter_begin && d->device->autoFillBackground()) { - if (d->drawable.hasTransparentBackground()) + if (d->device->hasTransparentBackground()) glClearColor(0.0, 0.0, 0.0, 0.0); else { - const QColor &c = d->drawable.backgroundColor(); + const QColor &c = d->device->backgroundColor(); glClearColor(c.redF(), c.greenF(), c.blueF(), 1.0); } @@ -1349,7 +1365,7 @@ bool QOpenGLPaintEngine::begin(QPaintDevice *pdev) glClear(clearBits); } - QSize sz(d->drawable.size()); + QSize sz(d->device->size()); glViewport(0, 0, sz.width(), sz.height()); // XXX (Embedded): We need a solution for GLWidgets that draw in a part or a bigger surface... glMatrixMode(GL_PROJECTION); glLoadIdentity(); @@ -1366,7 +1382,7 @@ bool QOpenGLPaintEngine::begin(QPaintDevice *pdev) #ifdef QT_OPENGL_ES d->max_texture_size = ctx->d_func()->maxTextureSize(); #else - bool shared_ctx = qgl_share_reg()->checkSharing(d->drawable.context(), d->shader_ctx); + bool shared_ctx = qgl_share_reg()->checkSharing(d->device->context(), d->shader_ctx); if (shared_ctx) { d->max_texture_size = d->shader_ctx->d_func()->maxTextureSize(); @@ -1382,7 +1398,7 @@ bool QOpenGLPaintEngine::begin(QPaintDevice *pdev) glDeleteTextures(1, &d->drawable_texture); ctx->makeCurrent(); } - d->shader_ctx = d->drawable.context(); + d->shader_ctx = d->device->context(); glGenTextures(1, &d->grad_palette); qt_mask_texture_cache()->clearCache(); @@ -1417,7 +1433,7 @@ bool QOpenGLPaintEngine::end() Q_D(QOpenGLPaintEngine); d->flushDrawQueue(); d->offscreen.end(); - QGLContext *ctx = const_cast(d->drawable.context()); + QGLContext *ctx = const_cast(d->device->context()); if (!ctx->d_ptr->internal_context) { glMatrixMode(GL_TEXTURE); glPopMatrix(); @@ -1434,8 +1450,7 @@ bool QOpenGLPaintEngine::end() glPopClientAttrib(); } #endif - d->drawable.swapBuffers(); - d->drawable.doneCurrent(); + d->device->endPaint(); qt_mask_texture_cache()->maintainCache(); return true; @@ -1961,7 +1976,7 @@ void QOpenGLPaintEnginePrivate::fillVertexArray(Qt::FillRule fillRule) const int left = rect.left(); const int width = rect.width(); - const int bottom = drawable.size().height() - (rect.bottom() + 1); + const int bottom = device->size().height() - (rect.bottom() + 1); const int height = rect.height(); glScissor(left, bottom, width, height); @@ -2242,7 +2257,7 @@ void QOpenGLPaintEnginePrivate::updateDepthClip() const int left = fastClip.left(); const int width = fastClip.width(); - const int bottom = drawable.size().height() - (fastClip.bottom() + 1); + const int bottom = device->size().height() - (fastClip.bottom() + 1); const int height = fastClip.height(); glScissor(left, bottom, width, height); @@ -2325,7 +2340,7 @@ void QOpenGLPaintEngine::updateClipRegion(const QRegion &clipRegion, Qt::ClipOpe // clipping is only supported when a stencil or depth buffer is // available - if (!d->drawable.format().depth()) + if (!d->device->format().depth()) return; d->use_system_clip = false; @@ -2362,7 +2377,7 @@ void QOpenGLPaintEngine::updateClipRegion(const QRegion &clipRegion, Qt::ClipOpe path.addRect(untransformedRects[0]); path = d->matrix.map(path); - if (path.contains(QRectF(QPointF(), d->drawable.size()))) + if (path.contains(QRectF(QPointF(), d->device->size()))) isScreenClip = true; } } @@ -3369,7 +3384,7 @@ void QOpenGLPaintEnginePrivate::drawOffscreenPath(const QPainterPath &path) disableClipping(); - GLuint program = qt_gl_program_cache()->getProgram(drawable.context(), + GLuint program = qt_gl_program_cache()->getProgram(device->context(), FRAGMENT_PROGRAM_MASK_TRAPEZOID_AA, 0, true); QGLPathMaskGenerator maskGenerator(path, matrix, offscreen, program); addItem(qt_mask_texture_cache()->getMask(maskGenerator, this)); @@ -3506,7 +3521,7 @@ void QOpenGLPaintEngine::drawRects(const QRectF *rects, int rectCount) if (d->has_brush) { d->disableClipping(); - GLuint program = qt_gl_program_cache()->getProgram(d->drawable.context(), + GLuint program = qt_gl_program_cache()->getProgram(d->device->context(), FRAGMENT_PROGRAM_MASK_TRAPEZOID_AA, 0, true); if (d->matrix.type() >= QTransform::TxProject) { @@ -3916,7 +3931,7 @@ void QOpenGLPaintEnginePrivate::strokeLines(const QPainterPath &path) qreal penWidth = cpen.widthF(); - GLuint program = qt_gl_program_cache()->getProgram(drawable.context(), + GLuint program = qt_gl_program_cache()->getProgram(device->context(), FRAGMENT_PROGRAM_MASK_TRAPEZOID_AA, 0, true); QGLLineMaskGenerator maskGenerator(path, matrix, penWidth == 0 ? 1.0 : penWidth, offscreen, program); @@ -4302,7 +4317,7 @@ void QOpenGLPaintEngine::drawPixmap(const QRectF &r, const QPixmap &pm, const QR else { GLenum target = qt_gl_preferredTextureTarget(); d->flushDrawQueue(); - d->drawable.bindTexture(pm, target); + d->device->context()->bindTexture(pm, target); drawTextureRect(pm.width(), pm.height(), r, sr, target); } } @@ -4336,9 +4351,9 @@ void QOpenGLPaintEngine::drawTiledPixmap(const QRectF &r, const QPixmap &pm, con d->flushDrawQueue(); if (scaled.isNull()) - d->drawable.bindTexture(pm); + d->device->context()->bindTexture(pm); else - d->drawable.bindTexture(scaled); + d->device->context()->bindTexture(scaled); updateTextureFilter(GL_TEXTURE_2D, GL_REPEAT, d->use_smooth_pixmap_transform); #ifndef QT_OPENGL_ES @@ -4404,7 +4419,7 @@ void QOpenGLPaintEngine::drawImage(const QRectF &r, const QImage &image, const Q else { GLenum target = qt_gl_preferredTextureTarget(); d->flushDrawQueue(); - d->drawable.bindTexture(image, target); + d->device->context()->bindTexture(image, target); drawTextureRect(image.width(), image.height(), r, sr, target); } } @@ -4871,7 +4886,7 @@ void QOpenGLPaintEngine::drawTextItem(const QPointF &p, const QTextItem &textIte ti.fontEngine->getGlyphPositions(ti.glyphs, matrix, ti.flags, glyphs, positions); // make sure the glyphs we want to draw are in the cache - qt_glyph_cache()->cacheGlyphs(d->drawable.context(), ti, glyphs); + qt_glyph_cache()->cacheGlyphs(d->device->context(), ti, glyphs); d->setGradientOps(Qt::SolidPattern, QRectF()); // turns off gradient ops qt_glColor4ubv(d->pen_color); @@ -4949,7 +4964,7 @@ void QOpenGLPaintEngine::drawEllipse(const QRectF &rect) glPushMatrix(); glLoadIdentity(); - GLuint program = qt_gl_program_cache()->getProgram(d->drawable.context(), + GLuint program = qt_gl_program_cache()->getProgram(d->device->context(), FRAGMENT_PROGRAM_MASK_ELLIPSE_AA, 0, true); QGLEllipseMaskGenerator maskGenerator(rect, d->matrix, @@ -5084,10 +5099,10 @@ void QOpenGLPaintEnginePrivate::copyDrawable(const QRectF &rect) QRectF screen_rect = rect.adjusted(-1, -1, 1, 1); int left = qMax(0, static_cast(screen_rect.left())); - int width = qMin(drawable.size().width() - left, static_cast(screen_rect.width()) + 1); + int width = qMin(device->size().width() - left, static_cast(screen_rect.width()) + 1); - int bottom = qMax(0, static_cast(drawable.size().height() - screen_rect.bottom())); - int height = qMin(drawable.size().height() - bottom, static_cast(screen_rect.height()) + 1); + int bottom = qMax(0, static_cast(device->size().height() - screen_rect.bottom())); + int height = qMin(device->size().height() - bottom, static_cast(screen_rect.height()) + 1); glBindTexture(GL_TEXTURE_2D, drawable_texture); glCopyTexSubImage2D(GL_TEXTURE_2D, 0, left, bottom, left, bottom, width, height); @@ -5181,9 +5196,9 @@ void QOpenGLPaintEnginePrivate::composite(GLuint primitive, const q_vertexType * glActiveTexture(GL_TEXTURE0 + brush_texture_location); if (current_style == Qt::TexturePattern) - drawable.bindTexture(cbrush.textureImage()); + device->context()->bindTexture(cbrush.textureImage()); else - drawable.bindTexture(qt_imageForBrush(current_style, true)); + device->context()->bindTexture(qt_imageForBrush(current_style, true)); updateTextureFilter(GL_TEXTURE_2D, GL_REPEAT, use_smooth_pixmap_transform); } @@ -5191,7 +5206,7 @@ void QOpenGLPaintEnginePrivate::composite(GLuint primitive, const q_vertexType * glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(2, q_vertexTypeEnum, 0, vertexArray); glEnable(GL_FRAGMENT_PROGRAM_ARB); - GLuint program = qt_gl_program_cache()->getProgram(drawable.context(), + GLuint program = qt_gl_program_cache()->getProgram(device->context(), fragment_brush, fragment_composition_mode, false); glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, program); @@ -5263,7 +5278,7 @@ void QOpenGLPaintEnginePrivate::drawItem(const QDrawQueueItem &item) setGradientOps(item.brush, item.location.screen_rect); composite(item.location.screen_rect, item.location.rect.topLeft() - item.location.screen_rect.topLeft() - - QPoint(0, offscreen.offscreenSize().height() - drawable.size().height())); + - QPoint(0, offscreen.offscreenSize().height() - device->size().height())); } void QOpenGLPaintEnginePrivate::flushDrawQueue() -- cgit v0.12 From b7963df603a315136b32297b861f089c0cd49acd Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Mon, 31 Aug 2009 13:28:14 +0200 Subject: Make QGLPixelBuffer work again using new QGLPaintDevice API Add a new QGLPBufferGLPaintDevice implementation which allows the GL engines to target QGLPixelBuffers again. --- src/opengl/qglpaintdevice.cpp | 7 ++++++- src/opengl/qglpixelbuffer.cpp | 8 ++++++++ src/opengl/qglpixelbuffer.h | 2 ++ src/opengl/qglpixelbuffer_p.h | 13 +++++++++++++ 4 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/opengl/qglpaintdevice.cpp b/src/opengl/qglpaintdevice.cpp index f7bd2a3..9815add 100644 --- a/src/opengl/qglpaintdevice.cpp +++ b/src/opengl/qglpaintdevice.cpp @@ -41,6 +41,7 @@ #include #include +#include QGLPaintDevice::QGLPaintDevice() : m_context(0) @@ -85,11 +86,12 @@ void QGLPaintDevice::beginPaint() void QGLPaintDevice::endPaint() { + glFlush(); } QColor QGLPaintDevice::backgroundColor() const { - return QColor(); + return QApplication::palette().brush(QPalette::Background).color(); } bool QGLPaintDevice::autoFillBackground() const @@ -181,6 +183,9 @@ QGLPaintDevice* QGLPaintDevice::getDevice(QPaintDevice* pd) Q_ASSERT(qobject_cast(static_cast(pd))); glpd = &(static_cast(pd)->d_func()->glDevice); break; + case QInternal::Pbuffer: + glpd = &(static_cast(pd)->d_func()->glDevice); + break; default: qWarning("QGLPaintDevice::getDevice() - Unknown device type %d", pd->devType()); break; diff --git a/src/opengl/qglpixelbuffer.cpp b/src/opengl/qglpixelbuffer.cpp index f082ff0..f7cb3cc 100644 --- a/src/opengl/qglpixelbuffer.cpp +++ b/src/opengl/qglpixelbuffer.cpp @@ -100,6 +100,13 @@ void qgl_cleanup_glyph_cache(QGLContext *) {} extern QImage qt_gl_read_framebuffer(const QSize&, bool, bool); + +void QGLPBufferGLPaintDevice::setPBuffer(QGLPixelBuffer* pb) +{ + pbuf = pb; + setContext(pb->d_func()->qctx); +} + void QGLPixelBufferPrivate::common_init(const QSize &size, const QGLFormat &format, QGLWidget *shareWidget) { Q_Q(QGLPixelBuffer); @@ -115,6 +122,7 @@ void QGLPixelBufferPrivate::common_init(const QSize &size, const QGLFormat &form shareWidget->d_func()->glcx->d_func()->sharing = true; } + glDevice.setPBuffer(q); qctx->d_func()->paintDevice = q; qctx->d_func()->valid = true; #if defined(Q_WS_WIN) && !defined(QT_OPENGL_ES) diff --git a/src/opengl/qglpixelbuffer.h b/src/opengl/qglpixelbuffer.h index 5e81ea3..fe313a6 100644 --- a/src/opengl/qglpixelbuffer.h +++ b/src/opengl/qglpixelbuffer.h @@ -110,6 +110,8 @@ private: QScopedPointer d_ptr; friend class QGLDrawable; friend class QGLWindowSurface; + friend class QGLPaintDevice; + friend class QGLPBufferGLPaintDevice; }; QT_END_NAMESPACE diff --git a/src/opengl/qglpixelbuffer_p.h b/src/opengl/qglpixelbuffer_p.h index 74cb330..e24d1ea 100644 --- a/src/opengl/qglpixelbuffer_p.h +++ b/src/opengl/qglpixelbuffer_p.h @@ -58,6 +58,7 @@ QT_BEGIN_NAMESPACE QT_BEGIN_INCLUDE_NAMESPACE #include "QtOpenGL/qglpixelbuffer.h" #include +#include #if defined(Q_WS_X11) && !defined(QT_OPENGL_ES) #include @@ -135,6 +136,17 @@ QT_END_INCLUDE_NAMESPACE class QEglContext; + +class QGLPBufferGLPaintDevice : public QGLPaintDevice +{ +public: + virtual QPaintEngine* paintEngine() const {return pbuf->paintEngine();} + virtual QSize size() const {return pbuf->size();} + void setPBuffer(QGLPixelBuffer* pb); +private: + QGLPixelBuffer* pbuf; +}; + class QGLPixelBufferPrivate { Q_DECLARE_PUBLIC(QGLPixelBuffer) public: @@ -154,6 +166,7 @@ public: QGLPixelBuffer *q_ptr; bool invalid; QGLContext *qctx; + QGLPBufferGLPaintDevice glDevice; QGLFormat format; QGLFormat req_format; -- cgit v0.12 From e8b5bfa8a86b2d7c79aabcc4566f740f0a9afe7c Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Tue, 1 Sep 2009 15:52:44 +0200 Subject: Make QGLFramebufferObject work again using new QGLPaintDevice API This patch also refactors QGL2PaintEngineEx::ensureActive() and the logic which handles multiple paint engines rendering to the same QGLContext. In a nut-shell: * QGLPaintDevice::beginPaint() stores the currently bound FBO * QGLPaintDevice::ensureActiveTarget() makes sure that GL rendering will end up in the paint device (I.e. the right context is current and the right FBO is bound). If a different context or FBO was bound, it is _not_ remembered. * QGLPaintDevice::endPaint() restores whatever FBO was bound when beginPaint() was called. This logic allows interleaved painter rendering to multiple FBOs and contexts to work as expected. It also allows a stacked begin/end to work properly when it's mixed with native GL rendering (as far as current render target is concerened. GL state clobbering is obviously a different topic). QGLPaintDevice::context() also had to be made virtual as there's no good place to call setContext. This might be possible to change in the future though. Finally, to make this work, QGLFramebufferObjectPrivate had to be moved into it's own private header. --- .../gl2paintengineex/qpaintengineex_opengl2.cpp | 28 +--- src/opengl/opengl.pro | 1 + src/opengl/qgl.h | 4 +- src/opengl/qgl_x11.cpp | 2 +- src/opengl/qglframebufferobject.cpp | 113 ++++++--------- src/opengl/qglframebufferobject.h | 4 +- src/opengl/qglframebufferobject_p.h | 151 +++++++++++++++++++++ src/opengl/qglpaintdevice.cpp | 82 +++++------ src/opengl/qglpaintdevice_p.h | 10 +- src/opengl/qglpixelbuffer.cpp | 12 +- src/opengl/qglpixelbuffer_p.h | 2 + 11 files changed, 257 insertions(+), 152 deletions(-) create mode 100644 src/opengl/qglframebufferobject_p.h diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index 8fee83d..fcfd818 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -1318,13 +1318,6 @@ bool QGL2PaintEngineEx::begin(QPaintDevice *pdev) d->ctx = d->device->context(); - if (d->ctx->d_ptr->active_engine) { - QGL2PaintEngineEx *engine = static_cast(d->ctx->d_ptr->active_engine); - QGL2PaintEngineExPrivate *p = static_cast(engine->d_ptr.data()); - p->transferMode(BrushDrawingMode); - p->device->context()->doneCurrent(); - } - d->ctx->d_ptr->active_engine = this; d->last_created_state = 0; @@ -1397,15 +1390,6 @@ bool QGL2PaintEngineEx::end() { Q_D(QGL2PaintEngineEx); QGLContext *ctx = d->ctx; - if (ctx->d_ptr->active_engine != this) { - QGL2PaintEngineEx *engine = static_cast(ctx->d_ptr->active_engine); - if (engine && engine->isActive()) { - QGL2PaintEngineExPrivate *p = static_cast(engine->d_ptr.data()); - p->transferMode(BrushDrawingMode); - p->device->context()->doneCurrent(); - } - d->device->context()->makeCurrent(); - } glUseProgram(0); d->transferMode(BrushDrawingMode); @@ -1435,20 +1419,12 @@ void QGL2PaintEngineEx::ensureActive() QGLContext *ctx = d->ctx; if (isActive() && ctx->d_ptr->active_engine != this) { - QGL2PaintEngineEx *engine = static_cast(ctx->d_ptr->active_engine); - if (engine && engine->isActive()) { - QGL2PaintEngineExPrivate *p = static_cast(engine->d_ptr.data()); - p->transferMode(BrushDrawingMode); - p->device->context()->doneCurrent(); - } - d->device->context()->makeCurrent(); - ctx->d_ptr->active_engine = this; d->needsSync = true; - } else { - d->device->context()->makeCurrent(); } + d->device->ensureActiveTarget(); + if (d->needsSync) { glViewport(0, 0, d->width, d->height); glDepthMask(false); diff --git a/src/opengl/opengl.pro b/src/opengl/opengl.pro index 2aefe41..d479c2e 100644 --- a/src/opengl/opengl.pro +++ b/src/opengl/opengl.pro @@ -22,6 +22,7 @@ HEADERS += qgl.h \ qglpixelbuffer.h \ qglpixelbuffer_p.h \ qglframebufferobject.h \ + qglframebufferobject_p.h \ qglextensions_p.h \ qglpaintdevice_p.h \ diff --git a/src/opengl/qgl.h b/src/opengl/qgl.h index 46efe23..ce50c58 100644 --- a/src/opengl/qgl.h +++ b/src/opengl/qgl.h @@ -385,7 +385,7 @@ private: friend class QGLPixelBuffer; friend class QGLPixelBufferPrivate; friend class QGLWidget; - friend class QGLDrawable; +// friend class QGLDrawable; friend class QGLWidgetPrivate; friend class QGLGlyphCache; friend class QOpenGLPaintEngine; @@ -407,6 +407,8 @@ private: #endif friend class QGLFramebufferObject; friend class QGLFramebufferObjectPrivate; + friend class QGLFBOGLPaintDevice; + friend class QGLPaintDevice; private: Q_DISABLE_COPY(QGLContext) }; diff --git a/src/opengl/qgl_x11.cpp b/src/opengl/qgl_x11.cpp index 5da128d..fc29264 100644 --- a/src/opengl/qgl_x11.cpp +++ b/src/opengl/qgl_x11.cpp @@ -1308,7 +1308,7 @@ void QGLWidget::setContext(QGLContext *context, d->glcx->doneCurrent(); QGLContext* oldcx = d->glcx; d->glcx = context; - d->glDevice.setContext(context); // ### Do this for all platforms +// d->glDevice.setContext(context); // ### Do this for all platforms if (parentWidget()) { // force creation of delay-created widgets diff --git a/src/opengl/qglframebufferobject.cpp b/src/opengl/qglframebufferobject.cpp index 9990586..f60eb62 100644 --- a/src/opengl/qglframebufferobject.cpp +++ b/src/opengl/qglframebufferobject.cpp @@ -40,6 +40,7 @@ ****************************************************************************/ #include "qglframebufferobject.h" +#include "qglframebufferobject_p.h" #include #include @@ -74,47 +75,6 @@ extern QImage qt_gl_read_framebuffer(const QSize&, bool, bool); } \ } -#ifndef QT_OPENGL_ES -#define DEFAULT_FORMAT GL_RGBA8 -#else -#define DEFAULT_FORMAT GL_RGBA -#endif - -class QGLFramebufferObjectFormatPrivate -{ -public: - QGLFramebufferObjectFormatPrivate() - : ref(1), - samples(0), - attachment(QGLFramebufferObject::NoAttachment), - target(GL_TEXTURE_2D), - internal_format(DEFAULT_FORMAT) - { - } - QGLFramebufferObjectFormatPrivate - (const QGLFramebufferObjectFormatPrivate *other) - : ref(1), - samples(other->samples), - attachment(other->attachment), - target(other->target), - internal_format(other->internal_format) - { - } - bool equals(const QGLFramebufferObjectFormatPrivate *other) - { - return samples == other->samples && - attachment == other->attachment && - target == other->target && - internal_format == other->internal_format; - } - - QAtomicInt ref; - int samples; - QGLFramebufferObject::Attachment attachment; - GLenum target; - GLenum internal_format; -}; - /*! \class QGLFramebufferObjectFormat \brief The QGLFramebufferObjectFormat class specifies the format of an OpenGL @@ -339,28 +299,32 @@ bool QGLFramebufferObjectFormat::operator!=(const QGLFramebufferObjectFormat& ot return !(*this == other); } -class QGLFramebufferObjectPrivate +void QGLFBOGLPaintDevice::ensureActiveTarget() +{ + QGLContext* ctx = const_cast(QGLContext::currentContext()); + Q_ASSERT(ctx); + const GLuint fboId = fbo->d_func()->fbo; + if (ctx->d_func()->current_fbo != fboId) { + ctx->d_func()->current_fbo = fboId; + glBindFramebuffer(GL_FRAMEBUFFER_EXT, fboId); + } +} + +void QGLFBOGLPaintDevice::beginPaint() +{ + // We let QFBO track the previously bound FBO rather than doing it + // ourselves here. This has the advantage that begin/release & bind/end + // work as expected. + wasBound = fbo->isBound(); + if (!wasBound) + fbo->bind(); +} + +void QGLFBOGLPaintDevice::endPaint() { -public: - QGLFramebufferObjectPrivate() : depth_stencil_buffer(0), valid(false), ctx(0), previous_fbo(0), engine(0) {} - ~QGLFramebufferObjectPrivate() {} - - void init(const QSize& sz, QGLFramebufferObject::Attachment attachment, - GLenum internal_format, GLenum texture_target, GLint samples = 0); - bool checkFramebufferStatus() const; - GLuint texture; - GLuint fbo; - GLuint depth_stencil_buffer; - GLuint color_buffer; - GLenum target; - QSize size; - QGLFramebufferObjectFormat format; - uint valid : 1; - QGLFramebufferObject::Attachment fbo_attachment; - QGLContextGroup *ctx; // for Windows extension ptrs - GLuint previous_fbo; - mutable QPaintEngine *engine; -}; + if (!wasBound) + fbo->release(); +} bool QGLFramebufferObjectPrivate::checkFramebufferStatus() const { @@ -406,11 +370,13 @@ bool QGLFramebufferObjectPrivate::checkFramebufferStatus() const return false; } -void QGLFramebufferObjectPrivate::init(const QSize &sz, QGLFramebufferObject::Attachment attachment, +void QGLFramebufferObjectPrivate::init(QGLFramebufferObject *q, const QSize &sz, + QGLFramebufferObject::Attachment attachment, GLenum texture_target, GLenum internal_format, GLint samples) { QGLContext *currentContext = const_cast(QGLContext::currentContext()); ctx = QGLContextPrivate::contextGroup(currentContext); + glDevice.setFBO(q); bool ext_detected = (QGLExtensions::glExtensions & QGLExtensions::FramebufferObject); if (!ext_detected || (ext_detected && !qt_resolve_framebufferobject_extensions(currentContext))) return; @@ -669,7 +635,8 @@ QGLFramebufferObject::QGLFramebufferObject(const QSize &size, GLenum target) : d_ptr(new QGLFramebufferObjectPrivate) { Q_D(QGLFramebufferObject); - d->init(size, NoAttachment, target, DEFAULT_FORMAT); + d->glDevice.setFBO(this); + d->init(this, size, NoAttachment, target, DEFAULT_FORMAT); } #ifdef Q_MAC_COMPAT_GL_FUNCTIONS @@ -693,7 +660,7 @@ QGLFramebufferObject::QGLFramebufferObject(int width, int height, GLenum target) : d_ptr(new QGLFramebufferObjectPrivate) { Q_D(QGLFramebufferObject); - d->init(QSize(width, height), NoAttachment, target, DEFAULT_FORMAT); + d->init(this, QSize(width, height), NoAttachment, target, DEFAULT_FORMAT); } /*! \overload @@ -706,7 +673,8 @@ QGLFramebufferObject::QGLFramebufferObject(const QSize &size, const QGLFramebuff : d_ptr(new QGLFramebufferObjectPrivate) { Q_D(QGLFramebufferObject); - d->init(size, format.attachment(), format.textureTarget(), format.internalTextureFormat(), format.samples()); + d->init(this, size, format.attachment(), format.textureTarget(), format.internalTextureFormat(), + format.samples()); } /*! \overload @@ -719,7 +687,8 @@ QGLFramebufferObject::QGLFramebufferObject(int width, int height, const QGLFrame : d_ptr(new QGLFramebufferObjectPrivate) { Q_D(QGLFramebufferObject); - d->init(QSize(width, height), format.attachment(), format.textureTarget(), format.internalTextureFormat(), format.samples()); + d->init(this, QSize(width, height), format.attachment(), format.textureTarget(), + format.internalTextureFormat(), format.samples()); } #ifdef Q_MAC_COMPAT_GL_FUNCTIONS @@ -728,7 +697,7 @@ QGLFramebufferObject::QGLFramebufferObject(int width, int height, QMacCompatGLen : d_ptr(new QGLFramebufferObjectPrivate) { Q_D(QGLFramebufferObject); - d->init(QSize(width, height), NoAttachment, target, DEFAULT_FORMAT); + d->init(this, QSize(width, height), NoAttachment, target, DEFAULT_FORMAT); } #endif @@ -749,7 +718,7 @@ QGLFramebufferObject::QGLFramebufferObject(int width, int height, Attachment att : d_ptr(new QGLFramebufferObjectPrivate) { Q_D(QGLFramebufferObject); - d->init(QSize(width, height), attachment, target, internal_format); + d->init(this, QSize(width, height), attachment, target, internal_format); } #ifdef Q_MAC_COMPAT_GL_FUNCTIONS @@ -759,7 +728,7 @@ QGLFramebufferObject::QGLFramebufferObject(int width, int height, Attachment att : d_ptr(new QGLFramebufferObjectPrivate) { Q_D(QGLFramebufferObject); - d->init(QSize(width, height), attachment, target, internal_format); + d->init(this, QSize(width, height), attachment, target, internal_format); } #endif @@ -780,7 +749,7 @@ QGLFramebufferObject::QGLFramebufferObject(const QSize &size, Attachment attachm : d_ptr(new QGLFramebufferObjectPrivate) { Q_D(QGLFramebufferObject); - d->init(size, attachment, target, internal_format); + d->init(this, size, attachment, target, internal_format); } #ifdef Q_MAC_COMPAT_GL_FUNCTIONS @@ -790,7 +759,7 @@ QGLFramebufferObject::QGLFramebufferObject(const QSize &size, Attachment attachm : d_ptr(new QGLFramebufferObjectPrivate) { Q_D(QGLFramebufferObject); - d->init(size, attachment, target, internal_format); + d->init(this, size, attachment, target, internal_format); } #endif diff --git a/src/opengl/qglframebufferobject.h b/src/opengl/qglframebufferobject.h index 2778ec5..29b1f97 100644 --- a/src/opengl/qglframebufferobject.h +++ b/src/opengl/qglframebufferobject.h @@ -130,7 +130,9 @@ protected: private: Q_DISABLE_COPY(QGLFramebufferObject) QScopedPointer d_ptr; - friend class QGLDrawable; +// friend class QGLDrawable; + friend class QGLPaintDevice; + friend class QGLFBOGLPaintDevice; }; class QGLFramebufferObjectFormatPrivate; diff --git a/src/opengl/qglframebufferobject_p.h b/src/opengl/qglframebufferobject_p.h new file mode 100644 index 0000000..65fcf54 --- /dev/null +++ b/src/opengl/qglframebufferobject_p.h @@ -0,0 +1,151 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtOpenGL module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QGLFRAMEBUFFEROBJECT_P_H +#define QGLFRAMEBUFFEROBJECT_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of the QLibrary class. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// + +QT_BEGIN_NAMESPACE + +QT_BEGIN_INCLUDE_NAMESPACE + +#include +#include +#include + +QT_END_INCLUDE_NAMESPACE + +#ifndef QT_OPENGL_ES +#define DEFAULT_FORMAT GL_RGBA8 +#else +#define DEFAULT_FORMAT GL_RGBA +#endif + +class QGLFramebufferObjectFormatPrivate +{ +public: + QGLFramebufferObjectFormatPrivate() + : ref(1), + samples(0), + attachment(QGLFramebufferObject::NoAttachment), + target(GL_TEXTURE_2D), + internal_format(DEFAULT_FORMAT) + { + } + QGLFramebufferObjectFormatPrivate + (const QGLFramebufferObjectFormatPrivate *other) + : ref(1), + samples(other->samples), + attachment(other->attachment), + target(other->target), + internal_format(other->internal_format) + { + } + bool equals(const QGLFramebufferObjectFormatPrivate *other) + { + return samples == other->samples && + attachment == other->attachment && + target == other->target && + internal_format == other->internal_format; + } + + QAtomicInt ref; + int samples; + QGLFramebufferObject::Attachment attachment; + GLenum target; + GLenum internal_format; +}; + +class QGLFBOGLPaintDevice : public QGLPaintDevice +{ +public: + virtual QPaintEngine* paintEngine() const {return fbo->paintEngine();} + virtual QSize size() const {return fbo->size();} + virtual QGLContext* context() const {return const_cast(QGLContext::currentContext());} + void setFBO(QGLFramebufferObject* f) {fbo = f; } + virtual void ensureActiveTarget(); + virtual void beginPaint(); + virtual void endPaint(); + +private: + bool wasBound; + QGLFramebufferObject* fbo; +}; + +class QGLFramebufferObjectPrivate +{ +public: + QGLFramebufferObjectPrivate() : depth_stencil_buffer(0), valid(false), ctx(0), previous_fbo(0), engine(0) {} + ~QGLFramebufferObjectPrivate() {} + + void init(QGLFramebufferObject *q, const QSize& sz, + QGLFramebufferObject::Attachment attachment, + GLenum internal_format, GLenum texture_target, GLint samples = 0); + bool checkFramebufferStatus() const; + GLuint texture; + GLuint fbo; + GLuint depth_stencil_buffer; + GLuint color_buffer; + GLenum target; + QSize size; + QGLFramebufferObjectFormat format; + uint valid : 1; + QGLFramebufferObject::Attachment fbo_attachment; + QGLContextGroup *ctx; // for Windows extension ptrs + GLuint previous_fbo; + mutable QPaintEngine *engine; + QGLFBOGLPaintDevice glDevice; +}; + + +QT_END_NAMESPACE + +#endif // QGLFRAMEBUFFEROBJECT_P_H diff --git a/src/opengl/qglpaintdevice.cpp b/src/opengl/qglpaintdevice.cpp index 9815add..51f9627 100644 --- a/src/opengl/qglpaintdevice.cpp +++ b/src/opengl/qglpaintdevice.cpp @@ -42,9 +42,9 @@ #include #include #include +#include QGLPaintDevice::QGLPaintDevice() - : m_context(0) { } @@ -52,41 +52,38 @@ QGLPaintDevice::~QGLPaintDevice() { } -//extern QPaintEngine* qt_gl_engine(); // in qgl.cpp -//extern QPaintEngine* qt_gl_2_engine(); // in qgl.cpp - -//inline bool qt_gl_preferGL2Engine() -//{ -//#if defined(QT_OPENGL_ES_2) -// return true; -//#else -// return (QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_2_0) -// && qgetenv("QT_GL_USE_OPENGL1ENGINE").isEmpty(); -//#endif -//} - -//QPaintEngine* QGLPaintDevice::paintEngine() const -//{ -//#if defined(QT_OPENGL_ES_1) || defined(QT_OPENGL_ES_1_CL) -// return qt_gl_engine(); -//#elif defined(QT_OPENGL_ES_2) -// return qt_gl_2_engine(); -//#else -// if (!qt_gl_preferGL2Engine()) -// return qt_gl_engine(); -// else -// return qt_gl_2_engine(); -//#endif -//} void QGLPaintDevice::beginPaint() { - m_context->makeCurrent(); + // Record the currently bound FBO so we can restore it again + // in endPaint() + QGLContext *ctx = context(); + ctx->makeCurrent(); + m_previousFBO = ctx->d_func()->current_fbo; + if (m_previousFBO != 0) { + ctx->d_ptr->current_fbo = 0; + glBindFramebuffer(GL_FRAMEBUFFER_EXT, 0); + } +} + +void QGLPaintDevice::ensureActiveTarget() +{ + QGLContext* ctx = context(); + if (ctx != QGLContext::currentContext()) + ctx->makeCurrent(); + + if (ctx->d_ptr->current_fbo != 0) + glBindFramebuffer(GL_FRAMEBUFFER_EXT, 0); } void QGLPaintDevice::endPaint() { - glFlush(); + // Make sure the FBO bound at beginPaint is re-bound again here: + QGLContext *ctx = context(); + if (m_previousFBO != ctx->d_func()->current_fbo) { + ctx->d_ptr->current_fbo = m_previousFBO; + glBindFramebuffer(GL_FRAMEBUFFER_EXT, m_previousFBO); + } } QColor QGLPaintDevice::backgroundColor() const @@ -104,14 +101,9 @@ bool QGLPaintDevice::hasTransparentBackground() const return false; } -QGLContext* QGLPaintDevice::context() const -{ - return m_context; -} - QGLFormat QGLPaintDevice::format() const { - return m_context->format(); + return context()->format(); } QSize QGLPaintDevice::size() const @@ -119,12 +111,6 @@ QSize QGLPaintDevice::size() const return QSize(); } -void QGLPaintDevice::setContext(QGLContext* c) -{ - m_context = c; -} - - QGLWidgetGLPaintDevice::QGLWidgetGLPaintDevice() { @@ -155,15 +141,11 @@ void QGLWidgetGLPaintDevice::setWidget(QGLWidget* w) glWidget = w; } -//void QGLWidgetGLPaintDevice::beginPaint() -//{ -// glWidget->makeCurrent(); -//} - void QGLWidgetGLPaintDevice::endPaint() { if (glWidget->autoBufferSwap()) glWidget->swapBuffers(); + QGLPaintDevice::endPaint(); } @@ -172,6 +154,11 @@ QSize QGLWidgetGLPaintDevice::size() const return glWidget->size(); } +QGLContext* QGLWidgetGLPaintDevice::context() const +{ + return const_cast(glWidget->context()); +} + // returns the QGLPaintDevice for the given QPaintDevice QGLPaintDevice* QGLPaintDevice::getDevice(QPaintDevice* pd) { @@ -186,6 +173,9 @@ QGLPaintDevice* QGLPaintDevice::getDevice(QPaintDevice* pd) case QInternal::Pbuffer: glpd = &(static_cast(pd)->d_func()->glDevice); break; + case QInternal::FramebufferObject: + glpd = &(static_cast(pd)->d_func()->glDevice); + break; default: qWarning("QGLPaintDevice::getDevice() - Unknown device type %d", pd->devType()); break; diff --git a/src/opengl/qglpaintdevice_p.h b/src/opengl/qglpaintdevice_p.h index ad680a9..c5fa626 100644 --- a/src/opengl/qglpaintdevice_p.h +++ b/src/opengl/qglpaintdevice_p.h @@ -63,14 +63,14 @@ public: virtual ~QGLPaintDevice(); virtual void beginPaint(); + virtual void ensureActiveTarget(); virtual void endPaint(); virtual QColor backgroundColor() const; virtual bool autoFillBackground() const; virtual bool hasTransparentBackground() const; - // inline these? - QGLContext* context() const; + virtual QGLContext* context() const = 0; QGLFormat format() const; virtual QSize size() const; @@ -79,10 +79,11 @@ public: protected: // Inline? - void setContext(QGLContext* c); +// void setContext(QGLContext* c); private: - QGLContext* m_context; +// QGLContext* m_context; + GLuint m_previousFBO; }; @@ -102,6 +103,7 @@ public: // QGLWidgets need to do swapBufers in endPaint: virtual void endPaint(); virtual QSize size() const; + virtual QGLContext* context() const; void setWidget(QGLWidget*); diff --git a/src/opengl/qglpixelbuffer.cpp b/src/opengl/qglpixelbuffer.cpp index f7cb3cc..45ab3bc 100644 --- a/src/opengl/qglpixelbuffer.cpp +++ b/src/opengl/qglpixelbuffer.cpp @@ -101,10 +101,20 @@ void qgl_cleanup_glyph_cache(QGLContext *) {} extern QImage qt_gl_read_framebuffer(const QSize&, bool, bool); +QGLContext* QGLPBufferGLPaintDevice::context() const +{ + return pbuf->d_func()->qctx; +} + +void QGLPBufferGLPaintDevice::endPaint() { + glFlush(); + QGLPaintDevice::endPaint(); +} + void QGLPBufferGLPaintDevice::setPBuffer(QGLPixelBuffer* pb) { pbuf = pb; - setContext(pb->d_func()->qctx); +// setContext(pb->d_func()->qctx); } void QGLPixelBufferPrivate::common_init(const QSize &size, const QGLFormat &format, QGLWidget *shareWidget) diff --git a/src/opengl/qglpixelbuffer_p.h b/src/opengl/qglpixelbuffer_p.h index e24d1ea..96d41d7 100644 --- a/src/opengl/qglpixelbuffer_p.h +++ b/src/opengl/qglpixelbuffer_p.h @@ -142,6 +142,8 @@ class QGLPBufferGLPaintDevice : public QGLPaintDevice public: virtual QPaintEngine* paintEngine() const {return pbuf->paintEngine();} virtual QSize size() const {return pbuf->size();} + virtual QGLContext* context() const; + virtual void endPaint(); void setPBuffer(QGLPixelBuffer* pb); private: QGLPixelBuffer* pbuf; -- cgit v0.12 From 4feed48fdd738ed99cba86a4214e238a3e7275ed Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Mon, 7 Sep 2009 10:58:31 +0200 Subject: Move buffer clear out of the paint engine and into the QGLPaintDevices Previously, the paint engine cleared the surface's buffers in begin. This logic really belongs in QGLPaintDevice::beginPaint as not all paint devices will want this behaviour (in fact most don't). This also makes QGLPaintDevice API much simpler as the virtual getters for the clear color, etc. can be removed. It's much cleaner this way. The only possible problem is with the GL1 engine, which also cleared the accumulation & depth buffers in begin. However, the engine will also clear the depth buffer later as part of it's clipping logic. It also doesn't use the accumulation buffer, so clearing it seems unnessisary. --- .../gl2paintengineex/qpaintengineex_opengl2.cpp | 12 +--- src/opengl/qgl.cpp | 9 ++- src/opengl/qgl_p.h | 4 +- src/opengl/qglpaintdevice.cpp | 64 ++++++++++++++-------- src/opengl/qglpaintdevice_p.h | 16 ++++-- src/opengl/qpaintengine_opengl.cpp | 16 ------ 6 files changed, 58 insertions(+), 63 deletions(-) diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index fcfd818..c280803 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -1359,17 +1359,7 @@ bool QGL2PaintEngineEx::begin(QPaintDevice *pdev) #endif // QGLPixmapData *source = d->drawable.copyOnBegin(); - if (d->ctx->d_func()->clear_on_painter_begin && d->device->autoFillBackground()) { - if (d->device->hasTransparentBackground()) - glClearColor(0.0, 0.0, 0.0, 0.0); - else { - const QColor &c = d->device->backgroundColor(); - float alpha = c.alphaF(); - glClearColor(c.redF() * alpha, c.greenF() * alpha, c.blueF() * alpha, alpha); - } - glClear(GL_COLOR_BUFFER_BIT); - } -// else if (source) { +// if (source) { // QGLContext *ctx = d->ctx; // // d->transferMode(ImageDrawingMode); diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index ad54298..8ad9860 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -1399,7 +1399,6 @@ void QGLContextPrivate::init(QPaintDevice *dev, const QGLFormat &format) crWin = false; initDone = false; sharing = false; - clear_on_painter_begin = true; max_texture_size = -1; version_flags_cached = false; version_flags = QGLFormat::OpenGL_Version_None; @@ -4254,7 +4253,7 @@ void QGLWidget::renderText(int x, int y, const QString &str, const QFont &font, } else { setAutoBufferSwap(false); // disable glClear() as a result of QPainter::begin() - d->glcx->d_func()->clear_on_painter_begin = false; + d->disable_clear_on_painter_begin = true; if (engine->type() == QPaintEngine::OpenGL2) { qt_save_gl_state(); #ifndef QT_OPENGL_ES_2 @@ -4284,7 +4283,7 @@ void QGLWidget::renderText(int x, int y, const QString &str, const QFont &font, p->end(); delete p; setAutoBufferSwap(auto_swap); - d->glcx->d_func()->clear_on_painter_begin = true; + d->disable_clear_on_painter_begin = false; if (engine->type() == QPaintEngine::OpenGL2) qt_restore_gl_state(); } @@ -4427,7 +4426,7 @@ void QGLWidget::renderText(double x, double y, double z, const QString &str, con } else { setAutoBufferSwap(false); // disable glClear() as a result of QPainter::begin() - d->glcx->d_func()->clear_on_painter_begin = false; + d->disable_clear_on_painter_begin = true; if (engine->type() == QPaintEngine::OpenGL2) qt_save_gl_state(); p = new QPainter(this); @@ -4467,7 +4466,7 @@ void QGLWidget::renderText(double x, double y, double z, const QString &str, con if (engine->type() == QPaintEngine::OpenGL2) qt_restore_gl_state(); setAutoBufferSwap(auto_swap); - d->glcx->d_func()->clear_on_painter_begin = true; + d->disable_clear_on_painter_begin = false; } #ifndef QT_OPENGL_ES if (engine->type() == QPaintEngine::OpenGL2) diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index 03532c8..e86b843 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -175,6 +175,7 @@ class QGLWidgetPrivate : public QWidgetPrivate Q_DECLARE_PUBLIC(QGLWidget) public: QGLWidgetPrivate() : QWidgetPrivate() + , disable_clear_on_painter_begin(false) #ifdef Q_WS_QWS , wsurf(0) #endif @@ -197,6 +198,8 @@ public: QGLColormap cmap; QMap displayListCache; + bool disable_clear_on_painter_begin; + #if defined(Q_WS_WIN) void updateColormap(); QGLContext *olcx; @@ -295,7 +298,6 @@ public: uint sharing : 1; uint initDone : 1; uint crWin : 1; - uint clear_on_painter_begin : 1; uint internal_context : 1; uint version_flags_cached : 1; QPaintDevice *paintDevice; diff --git a/src/opengl/qglpaintdevice.cpp b/src/opengl/qglpaintdevice.cpp index 51f9627..4f000ba 100644 --- a/src/opengl/qglpaintdevice.cpp +++ b/src/opengl/qglpaintdevice.cpp @@ -86,20 +86,20 @@ void QGLPaintDevice::endPaint() } } -QColor QGLPaintDevice::backgroundColor() const -{ - return QApplication::palette().brush(QPalette::Background).color(); -} +//QColor QGLPaintDevice::backgroundColor() const +//{ +// return QApplication::palette().brush(QPalette::Background).color(); +//} -bool QGLPaintDevice::autoFillBackground() const -{ - return false; -} +//bool QGLPaintDevice::autoFillBackground() const +//{ +// return false; +//} -bool QGLPaintDevice::hasTransparentBackground() const -{ - return false; -} +//bool QGLPaintDevice::hasTransparentBackground() const +//{ +// return false; +//} QGLFormat QGLPaintDevice::format() const { @@ -112,6 +112,7 @@ QSize QGLPaintDevice::size() const } + QGLWidgetGLPaintDevice::QGLWidgetGLPaintDevice() { } @@ -121,26 +122,41 @@ QPaintEngine* QGLWidgetGLPaintDevice::paintEngine() const return glWidget->paintEngine(); } -QColor QGLWidgetGLPaintDevice::backgroundColor() const -{ - return glWidget->palette().brush(glWidget->backgroundRole()).color(); -} +//QColor QGLWidgetGLPaintDevice::backgroundColor() const +//{ +// return glWidget->palette().brush(glWidget->backgroundRole()).color(); +//} -bool QGLWidgetGLPaintDevice::autoFillBackground() const -{ - return glWidget->autoFillBackground(); -} +//bool QGLWidgetGLPaintDevice::autoFillBackground() const +//{ +// return glWidget->autoFillBackground(); +//} -bool QGLWidgetGLPaintDevice::hasTransparentBackground() const -{ - return glWidget->testAttribute(Qt::WA_TranslucentBackground); -} +//bool QGLWidgetGLPaintDevice::hasTransparentBackground() const +//{ +// return glWidget->testAttribute(Qt::WA_TranslucentBackground); +//} void QGLWidgetGLPaintDevice::setWidget(QGLWidget* w) { glWidget = w; } +void QGLWidgetGLPaintDevice::beginPaint() +{ + QGLPaintDevice::beginPaint(); + if (!glWidget->d_func()->disable_clear_on_painter_begin && glWidget->autoFillBackground()) { + if (glWidget->testAttribute(Qt::WA_TranslucentBackground)) + glClearColor(0.0, 0.0, 0.0, 0.0); + else { + const QColor &c = glWidget->palette().brush(glWidget->backgroundRole()).color(); + float alpha = c.alphaF(); + glClearColor(c.redF() * alpha, c.greenF() * alpha, c.blueF() * alpha, alpha); + } + glClear(GL_COLOR_BUFFER_BIT); + } +} + void QGLWidgetGLPaintDevice::endPaint() { if (glWidget->autoBufferSwap()) diff --git a/src/opengl/qglpaintdevice_p.h b/src/opengl/qglpaintdevice_p.h index c5fa626..6d34b1b 100644 --- a/src/opengl/qglpaintdevice_p.h +++ b/src/opengl/qglpaintdevice_p.h @@ -66,9 +66,11 @@ public: virtual void ensureActiveTarget(); virtual void endPaint(); - virtual QColor backgroundColor() const; - virtual bool autoFillBackground() const; - virtual bool hasTransparentBackground() const; +// virtual void clearOnBegin() const; +// virtual QColor clearColor() const; +// virtual QColor backgroundColor() const; +// virtual bool autoFillBackground() const; +// virtual bool hasTransparentBackground() const; virtual QGLContext* context() const = 0; QGLFormat format() const; @@ -96,11 +98,13 @@ public: virtual QPaintEngine* paintEngine() const; - virtual QColor backgroundColor() const; - virtual bool autoFillBackground() const; - virtual bool hasTransparentBackground() const; +// virtual void clearOnBegin() const; +// virtual QColor clearColor() const; +// virtual bool autoFillBackground() const; +// virtual bool hasTransparentBackground() const; // QGLWidgets need to do swapBufers in endPaint: + virtual void beginPaint(); virtual void endPaint(); virtual QSize size() const; virtual QGLContext* context() const; diff --git a/src/opengl/qpaintengine_opengl.cpp b/src/opengl/qpaintengine_opengl.cpp index 634067d..36a0081 100644 --- a/src/opengl/qpaintengine_opengl.cpp +++ b/src/opengl/qpaintengine_opengl.cpp @@ -1349,22 +1349,6 @@ bool QOpenGLPaintEngine::begin(QPaintDevice *pdev) d->offscreen.begin(); - if (d->device->context()->d_func()->clear_on_painter_begin && d->device->autoFillBackground()) { - - if (d->device->hasTransparentBackground()) - glClearColor(0.0, 0.0, 0.0, 0.0); - else { - const QColor &c = d->device->backgroundColor(); - glClearColor(c.redF(), c.greenF(), c.blueF(), 1.0); - } - - GLbitfield clearBits = GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT; -#ifndef QT_OPENGL_ES - clearBits |= GL_ACCUM_BUFFER_BIT; -#endif - glClear(clearBits); - } - QSize sz(d->device->size()); glViewport(0, 0, sz.width(), sz.height()); // XXX (Embedded): We need a solution for GLWidgets that draw in a part or a bigger surface... glMatrixMode(GL_PROJECTION); -- cgit v0.12 From e3e7cf545116c194bd5cfe79b28ea37c8bf78219 Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Mon, 7 Sep 2009 17:10:35 +0200 Subject: Make QGLWindowSurface use new QGLPaintDevice API --- src/gui/kernel/qwidget.h | 1 + src/opengl/qglpaintdevice.cpp | 9 +++--- src/opengl/qglpaintdevice_p.h | 4 ++- src/opengl/qwindowsurface_gl.cpp | 65 ++++++++++++++++++++++++++-------------- src/opengl/qwindowsurface_gl_p.h | 19 ++++++++---- 5 files changed, 65 insertions(+), 33 deletions(-) diff --git a/src/gui/kernel/qwidget.h b/src/gui/kernel/qwidget.h index 284558f..bd30cad 100644 --- a/src/gui/kernel/qwidget.h +++ b/src/gui/kernel/qwidget.h @@ -731,6 +731,7 @@ private: friend class QGLContext; friend class QGLWidget; friend class QGLWindowSurface; + friend class QGLWindowSurfaceGLPaintDevice; friend class QVGWindowSurface; friend class QX11PaintEngine; friend class QWin32PaintEngine; diff --git a/src/opengl/qglpaintdevice.cpp b/src/opengl/qglpaintdevice.cpp index 4f000ba..4cdeb76 100644 --- a/src/opengl/qglpaintdevice.cpp +++ b/src/opengl/qglpaintdevice.cpp @@ -43,6 +43,7 @@ #include #include #include +#include QGLPaintDevice::QGLPaintDevice() { @@ -106,10 +107,10 @@ QGLFormat QGLPaintDevice::format() const return context()->format(); } -QSize QGLPaintDevice::size() const -{ - return QSize(); -} +//QSize QGLPaintDevice::size() const +//{ +// return QSize(); +//} diff --git a/src/opengl/qglpaintdevice_p.h b/src/opengl/qglpaintdevice_p.h index 6d34b1b..b0e8826 100644 --- a/src/opengl/qglpaintdevice_p.h +++ b/src/opengl/qglpaintdevice_p.h @@ -62,6 +62,8 @@ public: QGLPaintDevice(); virtual ~QGLPaintDevice(); + int devType() const {return QInternal::OpenGL;} + virtual void beginPaint(); virtual void ensureActiveTarget(); virtual void endPaint(); @@ -74,7 +76,7 @@ public: virtual QGLContext* context() const = 0; QGLFormat format() const; - virtual QSize size() const; + virtual QSize size() const = 0; // returns the QGLPaintDevice for the given QPaintDevice static QGLPaintDevice* getDevice(QPaintDevice*); diff --git a/src/opengl/qwindowsurface_gl.cpp b/src/opengl/qwindowsurface_gl.cpp index a85b9ae..3a6ed06 100644 --- a/src/opengl/qwindowsurface_gl.cpp +++ b/src/opengl/qwindowsurface_gl.cpp @@ -229,6 +229,7 @@ QGLWidget* qt_gl_share_widget() return _qt_gl_share_widget()->shareWidget(); } + struct QGLWindowSurfacePrivate { QGLFramebufferObject *fbo; @@ -248,10 +249,49 @@ struct QGLWindowSurfacePrivate QSize size; QList buffers; + QGLWindowSurfaceGLPaintDevice glDevice; + QGLWindowSurface* q_ptr; }; QGLFormat QGLWindowSurface::surfaceFormat; +void QGLWindowSurfaceGLPaintDevice::endPaint() +{ + glFlush(); + QGLPaintDevice::endPaint(); +} + +QSize QGLWindowSurfaceGLPaintDevice::size() const +{ + return d->size; +} + +QGLContext* QGLWindowSurfaceGLPaintDevice::context() const +{ + return d->ctx; +} + + +int QGLWindowSurfaceGLPaintDevice::metric(PaintDeviceMetric m) const +{ + return d->q_ptr->window()->metric(m); +} + +Q_GLOBAL_STATIC(QGL2PaintEngineEx, qt_gl_window_surface_2_engine) + +#if !defined (QT_OPENGL_ES_2) +Q_GLOBAL_STATIC(QOpenGLPaintEngine, qt_gl_window_surface_engine) +#endif + +QPaintEngine *QGLWindowSurfaceGLPaintDevice::paintEngine() const +{ +#if !defined(QT_OPENGL_ES_2) + if (!qt_gl_preferGL2Engine()) + return qt_gl_window_surface_engine(); +#endif + return qt_gl_window_surface_2_engine(); +} + QGLWindowSurface::QGLWindowSurface(QWidget *window) : QWindowSurface(window), d_ptr(new QGLWindowSurfacePrivate) { @@ -263,6 +303,8 @@ QGLWindowSurface::QGLWindowSurface(QWidget *window) d_ptr->tried_fbo = false; d_ptr->tried_pb = false; d_ptr->destructive_swap_buffers = qgetenv("QT_GL_SWAPBUFFER_PRESERVE").isNull(); + d_ptr->glDevice.d = d_ptr; + d_ptr->q_ptr = this; } QGLWindowSurface::~QGLWindowSurface() @@ -320,27 +362,6 @@ void QGLWindowSurface::hijackWindow(QWidget *widget) qDebug() << "hijackWindow() context created for" << widget << d_ptr->contexts.size(); } -Q_GLOBAL_STATIC(QGL2PaintEngineEx, qt_gl_window_surface_2_engine) - -#if !defined (QT_OPENGL_ES_2) -Q_GLOBAL_STATIC(QOpenGLPaintEngine, qt_gl_window_surface_engine) -#endif - -/*! \reimp */ -QPaintEngine *QGLWindowSurface::paintEngine() const -{ -#if !defined(QT_OPENGL_ES_2) - if (!qt_gl_preferGL2Engine()) - return qt_gl_window_surface_engine(); -#endif - return qt_gl_window_surface_2_engine(); -} - -int QGLWindowSurface::metric(PaintDeviceMetric m) const -{ - return window()->metric(m); -} - QGLContext *QGLWindowSurface::context() const { return d_ptr->ctx; @@ -354,7 +375,7 @@ QPaintDevice *QGLWindowSurface::paintDevice() return d_ptr->pb; if (d_ptr->ctx) - return this; + return &d_ptr->glDevice; QGLContext *ctx = reinterpret_cast(window()->d_func()->extraData()->glContext); ctx->makeCurrent(); diff --git a/src/opengl/qwindowsurface_gl_p.h b/src/opengl/qwindowsurface_gl_p.h index ad583b2..7b18f2e 100644 --- a/src/opengl/qwindowsurface_gl_p.h +++ b/src/opengl/qwindowsurface_gl_p.h @@ -56,6 +56,7 @@ #include #include #include +#include QT_BEGIN_NAMESPACE @@ -65,7 +66,18 @@ class QRegion; class QWidget; struct QGLWindowSurfacePrivate; -class QGLWindowSurface : public QObject, public QWindowSurface, public QPaintDevice +class QGLWindowSurfaceGLPaintDevice : public QGLPaintDevice +{ +public: + QPaintEngine* paintEngine() const; + void endPaint(); + QSize size() const; + int metric(PaintDeviceMetric m) const; + QGLContext* context() const; + QGLWindowSurfacePrivate* d; +}; + +class QGLWindowSurface : public QObject, public QWindowSurface // , public QPaintDevice { Q_OBJECT public: @@ -87,11 +99,6 @@ public: static QGLFormat surfaceFormat; - QPaintEngine *paintEngine() const; - -protected: - int metric(PaintDeviceMetric metric) const; - private slots: void deleted(QObject *object); -- cgit v0.12 From 31d8058a32a1d2d2d6bc1ba3d48f5a382d7b87a7 Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Tue, 8 Sep 2009 15:09:00 +0200 Subject: Make QGLPixmapData work with the new QGLPaintDevice API This patch changes the ordering of QGL2PaintEngine::begin a bit because QGLPixmapData needs to use the paint engine's drawTexture method within beginPaint(). Also, this initialises needsSync to true and removes the setState call. So now all the state initialisation is done in ensureActive rather than begin. --- .../gl2paintengineex/qpaintengineex_opengl2.cpp | 24 +---- src/opengl/qglframebufferobject.cpp | 9 ++ src/opengl/qglframebufferobject_p.h | 3 +- src/opengl/qglpaintdevice.cpp | 29 ++++-- src/opengl/qglpaintdevice_p.h | 4 +- src/opengl/qpixmapdata_gl.cpp | 116 ++++++++++++++------- src/opengl/qpixmapdata_gl_p.h | 52 +++++---- 7 files changed, 152 insertions(+), 85 deletions(-) diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index c280803..e028e63 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -1321,7 +1321,6 @@ bool QGL2PaintEngineEx::begin(QPaintDevice *pdev) d->ctx->d_ptr->active_engine = this; d->last_created_state = 0; - d->device->beginPaint(); QSize sz = d->device->size(); d->width = sz.width(); d->height = sz.height(); @@ -1333,8 +1332,6 @@ bool QGL2PaintEngineEx::begin(QPaintDevice *pdev) d->shaderManager = new QGLEngineShaderManager(d->ctx); - glViewport(0, 0, d->width, d->height); - d->brushTextureDirty = true; d->brushUniformsDirty = true; d->matrixDirty = true; @@ -1343,10 +1340,12 @@ bool QGL2PaintEngineEx::begin(QPaintDevice *pdev) d->simpleShaderDepthUniformDirty = true; d->depthUniformDirty = true; d->opacityUniformDirty = true; - d->needsSync = false; - + d->needsSync = true; d->use_system_clip = !systemClip().isEmpty(); + + d->device->beginPaint(); + if (!d->inRenderText) { glDisable(GL_DEPTH_TEST); glDisable(GL_SCISSOR_TEST); @@ -1358,21 +1357,6 @@ bool QGL2PaintEngineEx::begin(QPaintDevice *pdev) glDisable(GL_MULTISAMPLE); #endif -// QGLPixmapData *source = d->drawable.copyOnBegin(); -// if (source) { -// QGLContext *ctx = d->ctx; -// -// d->transferMode(ImageDrawingMode); -// -// glActiveTexture(GL_TEXTURE0 + QT_IMAGE_TEXTURE_UNIT); -// source->bind(false); -// -// QRect rect(0, 0, source->width(), source->height()); -// d->updateTextureFilter(GL_TEXTURE_2D, GL_REPEAT, false); -// d->drawTexture(QRectF(rect), QRectF(rect), rect.size(), true); -// } - - d->systemStateChanged(); return true; } diff --git a/src/opengl/qglframebufferobject.cpp b/src/opengl/qglframebufferobject.cpp index f60eb62..9dbf5c8 100644 --- a/src/opengl/qglframebufferobject.cpp +++ b/src/opengl/qglframebufferobject.cpp @@ -299,6 +299,12 @@ bool QGLFramebufferObjectFormat::operator!=(const QGLFramebufferObjectFormat& ot return !(*this == other); } +void QGLFBOGLPaintDevice::setFBO(QGLFramebufferObject* f) +{ + fbo = f; + m_thisFBO = fbo->d_func()->fbo; // This shouldn't be needed +} + void QGLFBOGLPaintDevice::ensureActiveTarget() { QGLContext* ctx = const_cast(QGLContext::currentContext()); @@ -377,6 +383,7 @@ void QGLFramebufferObjectPrivate::init(QGLFramebufferObject *q, const QSize &sz, QGLContext *currentContext = const_cast(QGLContext::currentContext()); ctx = QGLContextPrivate::contextGroup(currentContext); glDevice.setFBO(q); + bool ext_detected = (QGLExtensions::glExtensions & QGLExtensions::FramebufferObject); if (!ext_detected || (ext_detected && !qt_resolve_framebufferobject_extensions(currentContext))) return; @@ -389,6 +396,8 @@ void QGLFramebufferObjectPrivate::init(QGLFramebufferObject *q, const QSize &sz, glGenFramebuffers(1, &fbo); glBindFramebuffer(GL_FRAMEBUFFER_EXT, fbo); + glDevice.setFBO(q); + QT_CHECK_GLERROR(); // init texture if (samples == 0) { diff --git a/src/opengl/qglframebufferobject_p.h b/src/opengl/qglframebufferobject_p.h index 65fcf54..58e6505 100644 --- a/src/opengl/qglframebufferobject_p.h +++ b/src/opengl/qglframebufferobject_p.h @@ -110,11 +110,12 @@ public: virtual QPaintEngine* paintEngine() const {return fbo->paintEngine();} virtual QSize size() const {return fbo->size();} virtual QGLContext* context() const {return const_cast(QGLContext::currentContext());} - void setFBO(QGLFramebufferObject* f) {fbo = f; } virtual void ensureActiveTarget(); virtual void beginPaint(); virtual void endPaint(); + void setFBO(QGLFramebufferObject* f); + private: bool wasBound; QGLFramebufferObject* fbo; diff --git a/src/opengl/qglpaintdevice.cpp b/src/opengl/qglpaintdevice.cpp index 4cdeb76..15ea217 100644 --- a/src/opengl/qglpaintdevice.cpp +++ b/src/opengl/qglpaintdevice.cpp @@ -44,8 +44,10 @@ #include #include #include +#include QGLPaintDevice::QGLPaintDevice() + : m_thisFBO(0) { } @@ -56,14 +58,17 @@ QGLPaintDevice::~QGLPaintDevice() void QGLPaintDevice::beginPaint() { - // Record the currently bound FBO so we can restore it again - // in endPaint() + // Make sure our context is the current one: QGLContext *ctx = context(); - ctx->makeCurrent(); + if (ctx != QGLContext::currentContext()) + ctx->makeCurrent(); + + // Record the currently bound FBO so we can restore it again + // in endPaint() and bind this device's FBO m_previousFBO = ctx->d_func()->current_fbo; - if (m_previousFBO != 0) { - ctx->d_ptr->current_fbo = 0; - glBindFramebuffer(GL_FRAMEBUFFER_EXT, 0); + if (m_previousFBO != m_thisFBO) { + ctx->d_ptr->current_fbo = m_thisFBO; + glBindFramebuffer(GL_FRAMEBUFFER_EXT, m_thisFBO); } } @@ -73,8 +78,10 @@ void QGLPaintDevice::ensureActiveTarget() if (ctx != QGLContext::currentContext()) ctx->makeCurrent(); - if (ctx->d_ptr->current_fbo != 0) - glBindFramebuffer(GL_FRAMEBUFFER_EXT, 0); + if (ctx->d_ptr->current_fbo != m_thisFBO) { + ctx->d_ptr->current_fbo = m_thisFBO; + glBindFramebuffer(GL_FRAMEBUFFER_EXT, m_thisFBO); + } } void QGLPaintDevice::endPaint() @@ -193,6 +200,12 @@ QGLPaintDevice* QGLPaintDevice::getDevice(QPaintDevice* pd) case QInternal::FramebufferObject: glpd = &(static_cast(pd)->d_func()->glDevice); break; + case QInternal::Pixmap: { + QPixmapData* pmd = static_cast(pd)->pixmapData(); + Q_ASSERT(pmd->classId() == QPixmapData::OpenGLClass); + glpd = static_cast(pmd)->glDevice(); + break; + } default: qWarning("QGLPaintDevice::getDevice() - Unknown device type %d", pd->devType()); break; diff --git a/src/opengl/qglpaintdevice_p.h b/src/opengl/qglpaintdevice_p.h index b0e8826..a175b8c 100644 --- a/src/opengl/qglpaintdevice_p.h +++ b/src/opengl/qglpaintdevice_p.h @@ -84,10 +84,10 @@ public: protected: // Inline? // void setContext(QGLContext* c); - + GLuint m_previousFBO; + GLuint m_thisFBO; private: // QGLContext* m_context; - GLuint m_previousFBO; }; diff --git a/src/opengl/qpixmapdata_gl.cpp b/src/opengl/qpixmapdata_gl.cpp index a394716..ae616a8 100644 --- a/src/opengl/qpixmapdata_gl.cpp +++ b/src/opengl/qpixmapdata_gl.cpp @@ -127,6 +127,76 @@ void QGLFramebufferObjectPool::release(QGLFramebufferObject *fbo) m_fbos << fbo; } + +QPaintEngine* QGLPixmapGLPaintDevice::paintEngine() const +{ + return data->paintEngine(); +} + +void QGLPixmapGLPaintDevice::beginPaint() +{ + if (!data->isValid()) + return; + + // QGLPaintDevice::beginPaint will store the current binding and replace + // it with m_thisFBO: + m_thisFBO = data->m_renderFbo->handle(); + QGLPaintDevice::beginPaint(); + + Q_ASSERT(data->paintEngine()->type() == QPaintEngine::OpenGL2); + + // QPixmap::fill() is deferred until now, where we actually need to do the fill: + if (data->needsFill()) { + const QColor &c = data->fillColor(); + float alpha = c.alphaF(); + glClearColor(c.redF() * alpha, c.greenF() * alpha, c.blueF() * alpha, alpha); + glClear(GL_COLOR_BUFFER_BIT); + } + else if (!data->isUninitialized()) { + // If the pixmap (GL Texture) has valid content (it has been + // uploaded from an image or rendered into before), we need to + // copy it from the texture to the render FBO. + + // Pass false to tell bind to _not_ copy the FBO into the texture! + GLuint texId = data->bind(false); + + QGL2PaintEngineEx* pe = static_cast(data->paintEngine()); + QRect rect(0, 0, data->width(), data->height()); + pe->drawTexture(QRectF(rect), texId, rect.size(), QRectF(rect)); + } +} + +void QGLPixmapGLPaintDevice::endPaint() +{ + if (!data->isValid()) + return; + + data->copyBackFromRenderFbo(false); + + data->m_renderFbo->release(); + qgl_fbo_pool()->release(data->m_renderFbo); + data->m_renderFbo = 0; + + // Base's endPaint will restore the previous FBO binding + QGLPaintDevice::endPaint(); +} + +QGLContext* QGLPixmapGLPaintDevice::context() const +{ + data->ensureCreated(); + return data->m_ctx; +} + +QSize QGLPixmapGLPaintDevice::size() const +{ + return data->size(); +} + +void QGLPixmapGLPaintDevice::setPixmapData(QGLPixmapData* d) +{ + data = d; +} + static int qt_gl_pixmap_serial = 0; QGLPixmapData::QGLPixmapData(PixelType type) @@ -139,6 +209,7 @@ QGLPixmapData::QGLPixmapData(PixelType type) , m_hasAlpha(false) { setSerialNumber(++qt_gl_pixmap_serial); + m_glDevice.setPixmapData(this); } QGLPixmapData::~QGLPixmapData() @@ -232,11 +303,6 @@ void QGLPixmapData::ensureCreated() const m_texture.options &= ~QGLContext::MemoryManagedBindOption; } -QGLFramebufferObject *QGLPixmapData::fbo() const -{ - return m_renderFbo; -} - void QGLPixmapData::fromImage(const QImage &image, Qt::ImageConversionFlags) { @@ -412,31 +478,6 @@ void QGLPixmapData::copyBackFromRenderFbo(bool keepCurrentFboBound) const glBindFramebuffer(GL_FRAMEBUFFER_EXT, ctx->d_ptr->current_fbo); } -void QGLPixmapData::swapBuffers() -{ - if (!isValid()) - return; - - copyBackFromRenderFbo(false); - m_renderFbo->release(); - - qgl_fbo_pool()->release(m_renderFbo); - - m_renderFbo = 0; -} - -void QGLPixmapData::makeCurrent() -{ - if (isValid() && m_renderFbo) - m_renderFbo->bind(); -} - -void QGLPixmapData::doneCurrent() -{ - if (isValid() && m_renderFbo) - m_renderFbo->release(); -} - bool QGLPixmapData::useFramebufferObjects() { return QGLFramebufferObject::hasOpenGLFramebufferObjects() @@ -485,6 +526,10 @@ QPaintEngine* QGLPixmapData::paintEngine() const return m_source.paintEngine(); } + +// If copyBack is true, bind will copy the contents of the render +// FBO to the texture (which is not bound to the texture, as it's +// a multisample FBO). GLuint QGLPixmapData::bind(bool copyBack) const { if (m_renderFbo && copyBack) { @@ -504,12 +549,6 @@ GLuint QGLPixmapData::bind(bool copyBack) const return id; } -GLuint QGLPixmapData::textureId() const -{ - ensureCreated(); - return m_texture.id; -} - QGLTexture* QGLPixmapData::texture() const { return &m_texture; @@ -548,4 +587,9 @@ int QGLPixmapData::metric(QPaintDevice::PaintDeviceMetric metric) const } } +QGLPaintDevice *QGLPixmapData::glDevice() const +{ + return &m_glDevice; +} + QT_END_NAMESPACE diff --git a/src/opengl/qpixmapdata_gl_p.h b/src/opengl/qpixmapdata_gl_p.h index ab1ff47..31ae7c7 100644 --- a/src/opengl/qpixmapdata_gl_p.h +++ b/src/opengl/qpixmapdata_gl_p.h @@ -57,12 +57,14 @@ #include "qgl.h" #include "private/qpixmapdata_p.h" +#include "private/qglpaintdevice_p.h" QT_BEGIN_NAMESPACE class QPaintEngine; class QGLFramebufferObject; class QGLFramebufferObjectFormat; +class QGLPixmapData; class QGLFramebufferObjectPool { @@ -76,31 +78,50 @@ private: QGLFramebufferObjectPool* qgl_fbo_pool(); + +class QGLPixmapGLPaintDevice : public QGLPaintDevice +{ +public: + QPaintEngine* paintEngine() const; + + void beginPaint(); + void endPaint(); + QGLContext* context() const; + QSize size() const; + + void setPixmapData(QGLPixmapData*); +private: + QGLPixmapData *data; +}; + + class QGLPixmapData : public QPixmapData { public: QGLPixmapData(PixelType type); ~QGLPixmapData(); - bool isValid() const; - + // Re-implemented from QPixmapData: void resize(int width, int height); - void fromImage(const QImage &image, - Qt::ImageConversionFlags flags); + void fromImage(const QImage &image, Qt::ImageConversionFlags flags); void copy(const QPixmapData *data, const QRect &rect); - bool scroll(int dx, int dy, const QRect &rect); - void fill(const QColor &color); bool hasAlphaChannel() const; QImage toImage() const; QPaintEngine *paintEngine() const; + int metric(QPaintDevice::PaintDeviceMetric metric) const; + // For accessing as a target: + QGLPaintDevice *glDevice() const; + + // For accessing as a source: + bool isValidContext(const QGLContext *ctx) const; GLuint bind(bool copyBack = true) const; - GLuint textureId() const; QGLTexture *texture() const; - bool isValidContext(const QGLContext *ctx) const; +private: + bool isValid() const; void ensureCreated() const; @@ -109,22 +130,13 @@ public: bool needsFill() const { return m_hasFillColor; } QColor fillColor() const { return m_fillColor; } - QSize size() const { return QSize(w, h); } - - QGLFramebufferObject *fbo() const; - void makeCurrent(); - void doneCurrent(); - void swapBuffers(); -protected: - int metric(QPaintDevice::PaintDeviceMetric metric) const; - -private: QGLPixmapData(const QGLPixmapData &other); QGLPixmapData &operator=(const QGLPixmapData &other); void copyBackFromRenderFbo(bool keepCurrentFboBound) const; + QSize size() const { return QSize(w, h); } static bool useFramebufferObjects(); @@ -145,6 +157,10 @@ private: mutable bool m_hasFillColor; mutable bool m_hasAlpha; + + mutable QGLPixmapGLPaintDevice m_glDevice; + + friend class QGLPixmapGLPaintDevice; }; QT_END_NAMESPACE -- cgit v0.12 From f6f099e33773e5739ef89681bc97a1a91ff168c8 Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Tue, 8 Sep 2009 18:03:00 +0200 Subject: Cleanup of QGLPaintDevice before it goes in This is the last patch in the QGLPaintDevice series. Although previous patches have not been reviewed individually, Samuel's reviewed QGLPaintDevice API and all the changes as the code stands with this patch. Reviewed-by: Samuel --- src/opengl/qgl.cpp | 237 ------------------------------------- src/opengl/qgl.h | 1 - src/opengl/qgl_p.h | 56 +-------- src/opengl/qgl_x11.cpp | 2 - src/opengl/qglframebufferobject.h | 1 - src/opengl/qglpaintdevice.cpp | 66 +++-------- src/opengl/qglpaintdevice_p.h | 100 +++------------- src/opengl/qglpixelbuffer.cpp | 1 - src/opengl/qpaintengine_opengl.cpp | 4 +- 9 files changed, 38 insertions(+), 430 deletions(-) diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 8ad9860..a0b2d3a 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -4851,243 +4851,6 @@ Q_OPENGL_EXPORT const QString qt_gl_library_name() } #endif -#if 0 -void QGLDrawable::setDevice(QPaintDevice *pdev) -{ - wasBound = false; - widget = 0; - buffer = 0; - fbo = 0; -#ifdef Q_WS_QWS - wsurf = 0; -#endif - -#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) - if (pdev->devType() == QInternal::Pixmap) { - QPixmapData *data = static_cast(pdev)->pixmapData(); - Q_ASSERT(data->classId() == QPixmapData::OpenGLClass); - pixmapData = static_cast(data); - - fbo = pixmapData->fbo(); - } -#else - Q_ASSERT(pdev->devType() != QInternal::Pixmap); -#endif - - if (pdev->devType() == QInternal::Widget) - widget = static_cast(pdev); - else if (pdev->devType() == QInternal::Pbuffer) - buffer = static_cast(pdev); - else if (pdev->devType() == QInternal::FramebufferObject) - fbo = static_cast(pdev); -#ifdef Q_WS_QWS - else if (pdev->devType() == QInternal::UnknownDevice) - wsurf = static_cast(pdev)->windowSurface(); -#elif !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) - else if (pdev->devType() == QInternal::UnknownDevice) - wsurf = static_cast(pdev); -#endif -} - -void QGLDrawable::swapBuffers() -{ - if (widget) { - if (widget->autoBufferSwap()) - widget->swapBuffers(); -#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) - } else if (pixmapData) { - pixmapData->swapBuffers(); -#endif - } else { - glFlush(); - } -} - -void QGLDrawable::makeCurrent() -{ - previous_fbo = 0; -#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) - if (!pixmapData && !fbo) { -#else - if (!fbo) { -#endif - QGLContext *ctx = context(); - previous_fbo = ctx->d_ptr->current_fbo; - ctx->d_ptr->current_fbo = 0; - if (previous_fbo) - glBindFramebuffer(GL_FRAMEBUFFER_EXT, 0); - } - - if (widget) - widget->makeCurrent(); -#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) - else if (pixmapData) - pixmapData->makeCurrent(); -#endif - else if (buffer) - buffer->makeCurrent(); -#if defined(Q_WS_QWS) || (!defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL)) - else if (wsurf) - wsurf->context()->makeCurrent(); -#endif - else if (fbo) { - wasBound = fbo->isBound(); - if (!wasBound) - fbo->bind(); - } -} - -#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) -QGLPixmapData *QGLDrawable::copyOnBegin() const -{ - if (!pixmapData || pixmapData->isUninitialized()) - return 0; - return pixmapData; -} -#endif - -void QGLDrawable::doneCurrent() -{ -#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) - if (pixmapData) { - pixmapData->doneCurrent(); - return; - } -#endif - - if (previous_fbo) { - QGLContext *ctx = context(); - ctx->d_ptr->current_fbo = previous_fbo; - glBindFramebuffer(GL_FRAMEBUFFER_EXT, previous_fbo); - } - - if (fbo && !wasBound) - fbo->release(); -} - -QSize QGLDrawable::size() const -{ - if (widget) { - return QSize(widget->d_func()->glcx->device()->width(), - widget->d_func()->glcx->device()->height()); -#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) - } else if (pixmapData) { - return pixmapData->size(); -#endif - } else if (buffer) { - return buffer->size(); - } else if (fbo) { - return fbo->size(); - } -#ifdef Q_WS_QWS - else if (wsurf) - return wsurf->window()->frameSize(); -#elif !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) - else if (wsurf) - return QSize(wsurf->width(), wsurf->height()); -#endif - return QSize(); -} - -QGLFormat QGLDrawable::format() const -{ - if (widget) - return widget->format(); - else if (buffer) - return buffer->format(); -#if defined(Q_WS_QWS) || (!defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL)) - else if (wsurf) - return wsurf->context()->format(); -#endif - else if (fbo && QGLContext::currentContext()) { - QGLFormat fmt = QGLContext::currentContext()->format(); - fmt.setStencil(fbo->attachment() == QGLFramebufferObject::CombinedDepthStencil); - fmt.setDepth(fbo->attachment() != QGLFramebufferObject::NoAttachment); - return fmt; - } - - return QGLFormat(); -} - -GLuint QGLDrawable::bindTexture(const QImage &image, GLenum target, GLint format, - QGLContext::BindOptions options) -{ - QGLTexture *texture = 0; - options |= QGLContext::MemoryManagedBindOption; - if (widget) - texture = widget->d_func()->glcx->d_func()->bindTexture(image, target, format, options); - else if (buffer) - texture = buffer->d_func()->qctx->d_func()->bindTexture(image, target, format, options); - else if (fbo && QGLContext::currentContext()) - texture = const_cast(QGLContext::currentContext())->d_func()->bindTexture(image, target, format, options); -#if defined(Q_WS_QWS) || (!defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL)) - else if (wsurf) - texture = wsurf->context()->d_func()->bindTexture(image, target, format, options); -#endif - return texture->id; -} - -GLuint QGLDrawable::bindTexture(const QPixmap &pixmap, GLenum target, GLint format, - QGLContext::BindOptions options) -{ - QGLTexture *texture = 0; - if (widget) - texture = widget->d_func()->glcx->d_func()->bindTexture(pixmap, target, format, options); - else if (buffer) - texture = buffer->d_func()->qctx->d_func()->bindTexture(pixmap, target, format, options); - else if (fbo && QGLContext::currentContext()) - texture = const_cast(QGLContext::currentContext())->d_func()->bindTexture(pixmap, target, format, options); -#if defined(Q_WS_QWS) || (!defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL)) - else if (wsurf) - texture = wsurf->context()->d_func()->bindTexture(pixmap, target, format, options); -#endif - return texture->id; -} - -QColor QGLDrawable::backgroundColor() const -{ - if (widget) - return widget->palette().brush(widget->backgroundRole()).color(); -#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) - else if (pixmapData) - return pixmapData->fillColor(); -#endif - return QApplication::palette().brush(QPalette::Background).color(); -} - -bool QGLDrawable::hasTransparentBackground() const -{ - return widget && widget->testAttribute(Qt::WA_TranslucentBackground); -} - -QGLContext *QGLDrawable::context() const -{ - if (widget) - return widget->d_func()->glcx; - else if (buffer) - return buffer->d_func()->qctx; - else if (fbo) - return const_cast(QGLContext::currentContext()); -#if defined(Q_WS_QWS) || (!defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL)) - else if (wsurf) - return wsurf->context(); -#endif - return 0; -} - -bool QGLDrawable::autoFillBackground() const -{ - if (widget) - return widget->autoFillBackground(); -#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) - else if (pixmapData) - return pixmapData->needsFill(); -#endif - else - return false; -} -#endif - bool QGLShareRegister::checkSharing(const QGLContext *context1, const QGLContext *context2) { bool sharing = (context1 && context2 && context1->d_ptr->group == context2->d_ptr->group); return sharing; diff --git a/src/opengl/qgl.h b/src/opengl/qgl.h index ce50c58..151c7c4 100644 --- a/src/opengl/qgl.h +++ b/src/opengl/qgl.h @@ -385,7 +385,6 @@ private: friend class QGLPixelBuffer; friend class QGLPixelBufferPrivate; friend class QGLWidget; -// friend class QGLDrawable; friend class QGLWidgetPrivate; friend class QGLGlyphCache; friend class QOpenGLPaintEngine; diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index e86b843..b10d5da 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -191,7 +191,7 @@ public: bool renderCxPm(QPixmap *pixmap); void cleanupColormaps(); - QGLContext *glcx; // ### Keep for compatability with QGLDrawable (if that gets left in) + QGLContext *glcx; QGLWidgetGLPaintDevice glDevice; bool autoSwap; @@ -341,60 +341,6 @@ Q_SIGNALS: void aboutToDestroyContext(const QGLContext *context); }; -#if 0 -class QGLPixelBuffer; -class QGLFramebufferObject; -class QWSGLWindowSurface; -class QGLWindowSurface; -class QGLPixmapData; -class QGLDrawable { -public: - QGLDrawable() : widget(0), buffer(0), fbo(0) -#if defined(Q_WS_QWS) || (!defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL)) - , wsurf(0) -#endif -#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) - , pixmapData(0) -#endif - {} - void setDevice(QPaintDevice *pdev); - void swapBuffers(); - void makeCurrent(); - void doneCurrent(); - QSize size() const; - QGLFormat format() const; - GLuint bindTexture(const QImage &image, GLenum target = GL_TEXTURE_2D, GLint format = GL_RGBA, - QGLContext::BindOptions = QGLContext::InternalBindOption); - GLuint bindTexture(const QPixmap &pixmap, GLenum target = GL_TEXTURE_2D, GLint format = GL_RGBA, - QGLContext::BindOptions = QGLContext::InternalBindOption); - QColor backgroundColor() const; - QGLContext *context() const; - bool autoFillBackground() const; - bool hasTransparentBackground() const; - -#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) - QGLPixmapData *copyOnBegin() const; -#endif - -private: - bool wasBound; - QGLWidget *widget; - QGLPixelBuffer *buffer; - QGLFramebufferObject *fbo; -#ifdef Q_WS_QWS - QWSGLWindowSurface *wsurf; -#elif !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) - QGLWindowSurface *wsurf; -#endif - -#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) - QGLPixmapData *pixmapData; -#endif - int previous_fbo; -}; - -#endif - // GL extension definitions class QGLExtensions { public: diff --git a/src/opengl/qgl_x11.cpp b/src/opengl/qgl_x11.cpp index fc29264..a7376b2 100644 --- a/src/opengl/qgl_x11.cpp +++ b/src/opengl/qgl_x11.cpp @@ -41,7 +41,6 @@ #include "qgl.h" #include "qgl_p.h" -#include "qglpaintdevice_p.h" #include "qmap.h" #include "qapplication.h" @@ -1308,7 +1307,6 @@ void QGLWidget::setContext(QGLContext *context, d->glcx->doneCurrent(); QGLContext* oldcx = d->glcx; d->glcx = context; -// d->glDevice.setContext(context); // ### Do this for all platforms if (parentWidget()) { // force creation of delay-created widgets diff --git a/src/opengl/qglframebufferobject.h b/src/opengl/qglframebufferobject.h index 29b1f97..6efbb73 100644 --- a/src/opengl/qglframebufferobject.h +++ b/src/opengl/qglframebufferobject.h @@ -130,7 +130,6 @@ protected: private: Q_DISABLE_COPY(QGLFramebufferObject) QScopedPointer d_ptr; -// friend class QGLDrawable; friend class QGLPaintDevice; friend class QGLFBOGLPaintDevice; }; diff --git a/src/opengl/qglpaintdevice.cpp b/src/opengl/qglpaintdevice.cpp index 15ea217..a89b884 100644 --- a/src/opengl/qglpaintdevice.cpp +++ b/src/opengl/qglpaintdevice.cpp @@ -9,8 +9,8 @@ ** No Commercial Usage ** This file contains pre-release code and may not be distributed. ** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. +** contained in the Technology Preview License Agreement accompanying +** this package. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser @@ -21,20 +21,20 @@ ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this ** package. ** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** ** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -46,6 +46,8 @@ #include #include +QT_BEGIN_NAMESPACE + QGLPaintDevice::QGLPaintDevice() : m_thisFBO(0) { @@ -94,33 +96,16 @@ void QGLPaintDevice::endPaint() } } -//QColor QGLPaintDevice::backgroundColor() const -//{ -// return QApplication::palette().brush(QPalette::Background).color(); -//} - -//bool QGLPaintDevice::autoFillBackground() const -//{ -// return false; -//} - -//bool QGLPaintDevice::hasTransparentBackground() const -//{ -// return false; -//} - QGLFormat QGLPaintDevice::format() const { return context()->format(); } -//QSize QGLPaintDevice::size() const -//{ -// return QSize(); -//} +////////////////// QGLWidgetGLPaintDevice ////////////////// + QGLWidgetGLPaintDevice::QGLWidgetGLPaintDevice() { } @@ -130,21 +115,6 @@ QPaintEngine* QGLWidgetGLPaintDevice::paintEngine() const return glWidget->paintEngine(); } -//QColor QGLWidgetGLPaintDevice::backgroundColor() const -//{ -// return glWidget->palette().brush(glWidget->backgroundRole()).color(); -//} - -//bool QGLWidgetGLPaintDevice::autoFillBackground() const -//{ -// return glWidget->autoFillBackground(); -//} - -//bool QGLWidgetGLPaintDevice::hasTransparentBackground() const -//{ -// return glWidget->testAttribute(Qt::WA_TranslucentBackground); -//} - void QGLWidgetGLPaintDevice::setWidget(QGLWidget* w) { glWidget = w; @@ -214,4 +184,4 @@ QGLPaintDevice* QGLPaintDevice::getDevice(QPaintDevice* pd) return glpd; } - +QT_END_NAMESPACE diff --git a/src/opengl/qglpaintdevice_p.h b/src/opengl/qglpaintdevice_p.h index a175b8c..32a1275 100644 --- a/src/opengl/qglpaintdevice_p.h +++ b/src/opengl/qglpaintdevice_p.h @@ -9,8 +9,8 @@ ** No Commercial Usage ** This file contains pre-release code and may not be distributed. ** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. +** contained in the Technology Preview License Agreement accompanying +** this package. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser @@ -21,20 +21,20 @@ ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this ** package. ** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** ** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -53,9 +53,13 @@ // We mean it. // + #include #include + +QT_BEGIN_NAMESPACE + class QGLPaintDevice : public QPaintDevice { public: @@ -68,12 +72,6 @@ public: virtual void ensureActiveTarget(); virtual void endPaint(); -// virtual void clearOnBegin() const; -// virtual QColor clearColor() const; -// virtual QColor backgroundColor() const; -// virtual bool autoFillBackground() const; -// virtual bool hasTransparentBackground() const; - virtual QGLContext* context() const = 0; QGLFormat format() const; virtual QSize size() const = 0; @@ -82,12 +80,8 @@ public: static QGLPaintDevice* getDevice(QPaintDevice*); protected: - // Inline? -// void setContext(QGLContext* c); GLuint m_previousFBO; GLuint m_thisFBO; -private: -// QGLContext* m_context; }; @@ -100,11 +94,6 @@ public: virtual QPaintEngine* paintEngine() const; -// virtual void clearOnBegin() const; -// virtual QColor clearColor() const; -// virtual bool autoFillBackground() const; -// virtual bool hasTransparentBackground() const; - // QGLWidgets need to do swapBufers in endPaint: virtual void beginPaint(); virtual void endPaint(); @@ -118,59 +107,6 @@ private: QGLWidget *glWidget; }; - - -/* -Replaces: - -class QGLPixelBuffer; -class QGLFramebufferObject; -class QWSGLWindowSurface; -class QGLWindowSurface; -class QGLPixmapData; -class QGLDrawable { -public: - QGLDrawable() : widget(0), buffer(0), fbo(0) -#if defined(Q_WS_QWS) || (!defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL)) - , wsurf(0) -#endif -#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) - , pixmapData(0) -#endif - {} - void setDevice(QPaintDevice *pdev); - void swapBuffers(); - void makeCurrent(); - void doneCurrent(); - QSize size() const; - QGLFormat format() const; - GLuint bindTexture(const QImage &image, GLenum target = GL_TEXTURE_2D, GLint format = GL_RGBA); - GLuint bindTexture(const QPixmap &pixmap, GLenum target = GL_TEXTURE_2D, GLint format = GL_RGBA); - QColor backgroundColor() const; - QGLContext *context() const; - bool autoFillBackground() const; - bool hasTransparentBackground() const; - -#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) - QGLPixmapData *copyOnBegin() const; -#endif - -private: - bool wasBound; - QGLWidget *widget; - QGLPixelBuffer *buffer; - QGLFramebufferObject *fbo; -#ifdef Q_WS_QWS - QWSGLWindowSurface *wsurf; -#elif !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) - QGLWindowSurface *wsurf; -#endif - -#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) - QGLPixmapData *pixmapData; -#endif - int previous_fbo; -}; -*/ +QT_END_NAMESPACE #endif // QGLPAINTDEVICE_P_H diff --git a/src/opengl/qglpixelbuffer.cpp b/src/opengl/qglpixelbuffer.cpp index 45ab3bc..b6a919c 100644 --- a/src/opengl/qglpixelbuffer.cpp +++ b/src/opengl/qglpixelbuffer.cpp @@ -114,7 +114,6 @@ void QGLPBufferGLPaintDevice::endPaint() { void QGLPBufferGLPaintDevice::setPBuffer(QGLPixelBuffer* pb) { pbuf = pb; -// setContext(pb->d_func()->qctx); } void QGLPixelBufferPrivate::common_init(const QSize &size, const QGLFormat &format, QGLWidget *shareWidget) diff --git a/src/opengl/qpaintengine_opengl.cpp b/src/opengl/qpaintengine_opengl.cpp index 36a0081..34fff10 100644 --- a/src/opengl/qpaintengine_opengl.cpp +++ b/src/opengl/qpaintengine_opengl.cpp @@ -287,7 +287,6 @@ public Q_SLOTS: } private: -// QGLDrawable drawable; QGLPaintDevice* device; QGLFramebufferObject *offscreen; @@ -436,7 +435,7 @@ inline void QGLOffscreen::release() DEBUG_ONCE_STR("QGLOffscreen: releasing offscreen"); if (drawable_fbo) - device->context()->makeCurrent(); //### + device->ensureActiveTarget(); //### else offscreen->release(); @@ -765,7 +764,6 @@ public: GLubyte pen_color[4]; GLubyte brush_color[4]; QTransform::TransformationType txop; -// QGLDrawable drawable; QGLPaintDevice* device; QGLOffscreen offscreen; -- cgit v0.12 From eeb31d201371c5e0a118d5d89616e0ed092c836b Mon Sep 17 00:00:00 2001 From: David Boddie Date: Tue, 8 Sep 2009 19:05:52 +0200 Subject: Doc: A timeline's current value is not reset when the duration changes. Task-number: 219152 Reviewed-by: Trust Me --- src/corelib/tools/qtimeline.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/corelib/tools/qtimeline.cpp b/src/corelib/tools/qtimeline.cpp index 052c456..28ec963 100644 --- a/src/corelib/tools/qtimeline.cpp +++ b/src/corelib/tools/qtimeline.cpp @@ -388,6 +388,10 @@ void QTimeLine::setDirection(Direction direction) By default, this value is 1000 (i.e., 1 second), but you can change this by either passing a duration to QTimeLine's constructor, or by calling setDuration(). The duration must be larger than 0. + + \note Changing the duration does not cause the current time to be reset + to zero or the new duration. You also need to call setCurrentTime() with + the desired value. */ int QTimeLine::duration() const { -- cgit v0.12 From 83335faff7f33808b8253fa64f5d59e0f5fe0836 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Tue, 8 Sep 2009 11:16:54 -0700 Subject: memset DFBWindowDescription to 0 This makes debugging easier. Reviewed-by: TrustMe --- src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp index b1ffe69..82c2f81 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp @@ -127,6 +127,8 @@ void QDirectFBWindowSurface::createWindow(const QRect &rect) qFatal("QDirectFBWindowSurface: Unable to get primary display layer!"); DFBWindowDescription description; + memset(&description, 0, sizeof(DFBWindowDescription)); + description.caps = DWCAPS_NODECORATION|DWCAPS_DOUBLEBUFFER; description.flags = DWDESC_CAPS|DWDESC_SURFACE_CAPS|DWDESC_PIXELFORMAT|DWDESC_HEIGHT|DWDESC_WIDTH|DWDESC_POSX|DWDESC_POSY; -- cgit v0.12 From 381c17536c4fdf1a7fc3ee47c7d1d29cdce4b1f2 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Tue, 8 Sep 2009 12:04:48 -0700 Subject: Fix define in QDirectFBScreen It's QT_NO_DIRECTFB.*, not QT_DIRECTFB_NO.* Reviewed-by: TrustMe --- src/plugins/gfxdrivers/directfb/qdirectfbscreen.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h index 46d06ef..5955f27 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h @@ -66,7 +66,7 @@ QT_MODULE(Gui) #if !defined QT_DIRECTFB_IMAGECACHE && !defined QT_NO_DIRECTFB_IMAGECACHE #define QT_NO_DIRECTFB_IMAGECACHE #endif -#if !defined QT_DIRECTFB_NO_IMAGEPROVIDER && !defined QT_DIRECTFB_IMAGEPROVIDER +#if !defined QT_NO_DIRECTFB_IMAGEPROVIDER && !defined QT_DIRECTFB_IMAGEPROVIDER #define QT_DIRECTFB_IMAGEPROVIDER #endif #if !defined QT_DIRECTFB_IMAGEPROVIDER_KEEPALIVE && !defined QT_NO_DIRECTFB_IMAGEPROVIDER_KEEPALIVE -- cgit v0.12 From d0b29a5238def992bf7946d5c3eb36129b0cc44b Mon Sep 17 00:00:00 2001 From: Bill King Date: Wed, 9 Sep 2009 08:21:47 +1000 Subject: Fixes "Out of heap space" error when compiling on some setups. The original fix was for "out of stack space" due to to low a value, this one is for too high a value. --- demos/boxes/boxes.pro | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/demos/boxes/boxes.pro b/demos/boxes/boxes.pro index 59c9132..4963fb9 100644 --- a/demos/boxes/boxes.pro +++ b/demos/boxes/boxes.pro @@ -44,6 +44,6 @@ wince*: { win32-msvc* { QMAKE_CXXFLAGS -= -Zm200 QMAKE_CFLAGS -= -Zm200 - QMAKE_CXXFLAGS += -Zm1200 - QMAKE_CFLAGS += -Zm1200 + QMAKE_CXXFLAGS += -Zm500 + QMAKE_CFLAGS += -Zm500 } -- cgit v0.12 From f52dc5bf1e885c9a4d226c2484249e7d9faf0a99 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Tue, 8 Sep 2009 10:20:36 -0700 Subject: Fix QDirectFBPixmapData::fromImage This fix should optimize pixmap loading on most platforms and also fixes a bug on a certain hardware where the alpha channel of an image was not retained upon loading it. This patch also takes care of handling dithering better in QDirectFBPixmapData::fromImage(). Reviewed-by: Donald Carr --- .../gfxdrivers/directfb/qdirectfbpixmap.cpp | 36 ++++++++++++++++++---- 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp index 6550683..f88055e 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp @@ -330,17 +330,17 @@ bool QDirectFBPixmapData::fromDataBufferDescription(const DFBDataBufferDescripti #endif -void QDirectFBPixmapData::fromImage(const QImage &image, +void QDirectFBPixmapData::fromImage(const QImage &img, Qt::ImageConversionFlags flags) { - if (image.depth() == 1) { - fromImage(image.convertToFormat(screen->alphaPixmapFormat()), flags); + if (img.depth() == 1) { + fromImage(img.convertToFormat(screen->alphaPixmapFormat()), flags); return; } - if (image.hasAlphaChannel() + if (img.hasAlphaChannel() #ifndef QT_NO_DIRECTFB_OPAQUE_DETECTION - && (flags & Qt::NoOpaqueDetection || QDirectFBPixmapData::hasAlphaChannel(image)) + && (flags & Qt::NoOpaqueDetection || QDirectFBPixmapData::hasAlphaChannel(img)) #endif ) { alpha = true; @@ -349,13 +349,37 @@ void QDirectFBPixmapData::fromImage(const QImage &image, alpha = false; imageFormat = screen->pixelFormat(); } + QImage image; + if (flags != Qt::AutoColor) { + image = img.convertToFormat(imageFormat, flags); + flags = Qt::AutoColor; + } else { + image = img; + } + + IDirectFBSurface *imageSurface = screen->createDFBSurface(image, image.format(), QDirectFBScreen::DontTrackSurface); + if (!imageSurface) { + qWarning("QDirectFBPixmapData::fromImage()"); + invalidate(); + return; + } - dfbSurface = screen->createDFBSurface(image, imageFormat, QDirectFBScreen::TrackSurface|QDirectFBScreen::NoPreallocated); + dfbSurface = screen->createDFBSurface(image.size(), imageFormat, QDirectFBScreen::TrackSurface); if (!dfbSurface) { qWarning("QDirectFBPixmapData::fromImage()"); invalidate(); return; } + + if (image.hasAlphaChannel()) { + dfbSurface->Clear(dfbSurface, 0, 0, 0, 0); + dfbSurface->SetBlittingFlags(dfbSurface, DSBLIT_BLEND_ALPHACHANNEL); + } else { + dfbSurface->SetBlittingFlags(dfbSurface, DSBLIT_NOFX); + } + dfbSurface->Blit(dfbSurface, imageSurface, 0, 0, 0); + imageSurface->Release(imageSurface); + w = image.width(); h = image.height(); is_null = (w <= 0 || h <= 0); -- cgit v0.12 From 03050f1495a9071a7123ed70caff83466df8c6e5 Mon Sep 17 00:00:00 2001 From: abcd Date: Wed, 9 Sep 2009 10:55:15 +1000 Subject: Fix windows implemetation of QLocalSocket to emit bytesWritten() signal Have QWindowsPipeWriter emit a bytesWritten signal and have QLocalSocket connect this to its own bytesWritten signal. This change contains an autotest to check for the signal emission. Previously there was no implementation to emit the signal. --- src/corelib/io/qwindowspipewriter.cpp | 1 + src/corelib/io/qwindowspipewriter_p.h | 1 + src/network/socket/qlocalsocket_win.cpp | 3 +- tests/auto/qlocalsocket/tst_qlocalsocket.cpp | 61 ++++++++++++++++++++++++---- 4 files changed, 58 insertions(+), 8 deletions(-) diff --git a/src/corelib/io/qwindowspipewriter.cpp b/src/corelib/io/qwindowspipewriter.cpp index f32eb92..0e707f3 100644 --- a/src/corelib/io/qwindowspipewriter.cpp +++ b/src/corelib/io/qwindowspipewriter.cpp @@ -160,6 +160,7 @@ void QWindowsPipeWriter::run() hasWritten = true; lock.unlock(); } + emit bytesWritten(totalWritten); emit canWrite(); } CloseHandle(overl.hEvent); diff --git a/src/corelib/io/qwindowspipewriter_p.h b/src/corelib/io/qwindowspipewriter_p.h index d651629..8f8c4a0 100644 --- a/src/corelib/io/qwindowspipewriter_p.h +++ b/src/corelib/io/qwindowspipewriter_p.h @@ -121,6 +121,7 @@ class Q_CORE_EXPORT QWindowsPipeWriter : public QThread Q_SIGNALS: void canWrite(); + void bytesWritten(qint64 bytes); public: QWindowsPipeWriter(HANDLE writePipe, QObject * parent = 0); diff --git a/src/network/socket/qlocalsocket_win.cpp b/src/network/socket/qlocalsocket_win.cpp index 96dfa6e..e15ac65 100644 --- a/src/network/socket/qlocalsocket_win.cpp +++ b/src/network/socket/qlocalsocket_win.cpp @@ -302,8 +302,9 @@ qint64 QLocalSocket::writeData(const char *data, qint64 maxSize) Q_D(QLocalSocket); if (!d->pipeWriter) { d->pipeWriter = new QWindowsPipeWriter(d->handle, this); - d->pipeWriter->start(); connect(d->pipeWriter, SIGNAL(canWrite()), this, SLOT(_q_canWrite())); + connect(d->pipeWriter, SIGNAL(bytesWritten(qint64)), this, SIGNAL(bytesWritten(qint64))); + d->pipeWriter->start(); } return d->pipeWriter->write(data, maxSize); } diff --git a/tests/auto/qlocalsocket/tst_qlocalsocket.cpp b/tests/auto/qlocalsocket/tst_qlocalsocket.cpp index fdfbd8a..ce4bf6e 100644 --- a/tests/auto/qlocalsocket/tst_qlocalsocket.cpp +++ b/tests/auto/qlocalsocket/tst_qlocalsocket.cpp @@ -110,6 +110,7 @@ private slots: void writeToClientAndDisconnect(); void debug(); + void bytesWrittenSignal(); #ifdef Q_OS_SYMBIAN @@ -423,7 +424,7 @@ void tst_QLocalSocket::listenAndConnect() for (int j = 0; j < spyStateChanged.count(); ++j) { QLocalSocket::LocalSocketState s; s = qVariantValue(spyStateChanged.at(j).at(0)); - qDebug() << s; + qDebug() << s; } #endif if (canListen) @@ -508,11 +509,11 @@ void tst_QLocalSocket::sendData() if (server.hasPendingConnections()) { QString testLine = "test"; #ifdef Q_OS_SYMBIAN - for (int i = 0; i < 25 * 1024; ++i) + for (int i = 0; i < 25 * 1024; ++i) #else - for (int i = 0; i < 50000; ++i) + for (int i = 0; i < 50000; ++i) #endif - testLine += "a"; + testLine += "a"; QLocalSocket *serverSocket = server.nextPendingConnection(); QVERIFY(serverSocket); QCOMPARE(serverSocket->state(), QLocalSocket::ConnectedState); @@ -646,7 +647,7 @@ public: ++tries; } while ((socket.error() == QLocalSocket::ServerNotFoundError || socket.error() == QLocalSocket::ConnectionRefusedError) - && tries < 1000); + && tries < 1000); if (tries == 0 && socket.state() != QLocalSocket::ConnectedState) { QVERIFY(socket.waitForConnected(3000)); QVERIFY(socket.state() == QLocalSocket::ConnectedState); @@ -738,8 +739,8 @@ void tst_QLocalSocket::threadedConnection() while (!clients.isEmpty()) { QVERIFY(clients.first()->wait(3000)); Client *client =clients.takeFirst(); - client->terminate(); - delete client; + client->terminate(); + delete client; } } @@ -906,6 +907,52 @@ void tst_QLocalSocket::debug() qDebug() << QLocalSocket::ConnectionRefusedError << QLocalSocket::UnconnectedState; } +class WriteThread : public QThread +{ +Q_OBJECT +public: + void run() { + QLocalSocket socket; + socket.connectToServer("qlocalsocket_readyread"); + + if (!socket.waitForConnected(3000)) + exec(); + connect(&socket, SIGNAL(bytesWritten(qint64)), + this, SLOT(bytesWritten(qint64)), Qt::QueuedConnection); + socket.write("testing\n"); + exec(); + } +public slots: + void bytesWritten(qint64) { + exit(); + } + +private: +}; + +/* + Tests the emission of the bytesWritten(qint64) + signal. + + Create a thread that will write to a socket. + If the bytesWritten(qint64) signal is generated, + the slot connected to it will exit the thread, + indicating test success. + +*/ +void tst_QLocalSocket::bytesWrittenSignal() +{ + QLocalServer server; + QVERIFY(server.listen("qlocalsocket_readyread")); + WriteThread writeThread; + writeThread.start(); + bool timedOut = false; + QVERIFY(server.waitForNewConnection(3000, &timedOut)); + QVERIFY(!timedOut); + QTest::qWait(2000); + QVERIFY(writeThread.wait(2000)); +} + #ifdef Q_OS_SYMBIAN void tst_QLocalSocket::unlink(QString name) { -- cgit v0.12