summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/corelib/codecs/qtextcodec.cpp52
-rw-r--r--src/gui/dialogs/qprintdialog_mac.mm9
-rw-r--r--src/gui/graphicsview/qgraphicslinearlayout.cpp8
-rw-r--r--src/gui/graphicsview/qgridlayoutengine.cpp23
-rw-r--r--src/gui/image/qgifhandler.cpp13
-rw-r--r--src/gui/image/qjpeghandler.cpp32
-rw-r--r--src/gui/image/qpnghandler.cpp92
-rw-r--r--src/gui/painting/qgrayraster.c4
-rw-r--r--src/gui/painting/qpaintengineex.cpp2
-rw-r--r--src/gui/painting/qpainter.cpp2
-rw-r--r--src/gui/painting/qrasterdefs_p.h2
-rw-r--r--src/gui/painting/qstroker.cpp9
-rw-r--r--src/gui/painting/qstroker_p.h3
-rw-r--r--src/opengl/qgl.cpp36
-rw-r--r--src/opengl/qgl_egl.cpp1
-rw-r--r--src/opengl/qgl_p.h3
-rw-r--r--src/opengl/qglpixelbuffer_win.cpp21
-rw-r--r--src/opengl/qpaintengine_opengl.cpp4
18 files changed, 184 insertions, 132 deletions
diff --git a/src/corelib/codecs/qtextcodec.cpp b/src/corelib/codecs/qtextcodec.cpp
index c9fbec8..83e1f0c 100644
--- a/src/corelib/codecs/qtextcodec.cpp
+++ b/src/corelib/codecs/qtextcodec.cpp
@@ -110,6 +110,10 @@ Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
(QTextCodecFactoryInterface_iid, QLatin1String("/codecs")))
#endif
+//Cache for QTextCodec::codecForName and codecForMib.
+typedef QHash<QByteArray, QTextCodec *> QTextCodecCache;
+Q_GLOBAL_STATIC(QTextCodecCache, qTextCodecCache)
+
static char qtolower(register char c)
{ if (c >= 'A' && c <= 'Z') return c + 0x20; return c; }
@@ -181,7 +185,6 @@ static QTextCodec *createForMib(int mib)
}
static QList<QTextCodec*> *all = 0;
-static int clearCaches = 0; // flags specifying if caches should be invalided: 0x1 codecForName, 0x2 codecForMib
#ifdef Q_DEBUG_TEXTCODEC
static bool destroying_is_ok = false;
#endif
@@ -1007,7 +1010,9 @@ QTextCodec::~QTextCodec()
QMutexLocker locker(textCodecsMutex());
#endif
all->removeAll(this);
- clearCaches = 0x1 | 0x2;
+ QTextCodecCache *cache = qTextCodecCache();
+ if (cache)
+ cache->clear();
}
}
@@ -1037,32 +1042,33 @@ QTextCodec *QTextCodec::codecForName(const QByteArray &name)
if (!validCodecs())
return 0;
- static QHash <QByteArray, QTextCodec *> cache;
- if (clearCaches & 0x1) {
- cache.clear();
- clearCaches &= ~0x1;
+ QTextCodecCache *cache = qTextCodecCache();
+ QTextCodec *codec;
+ if (cache) {
+ codec = cache->value(name);
+ if (codec)
+ return codec;
}
- QTextCodec *codec = cache.value(name);
- if (codec)
- return codec;
for (int i = 0; i < all->size(); ++i) {
QTextCodec *cursor = all->at(i);
if (nameMatch(cursor->name(), name)) {
- cache.insert(name, cursor);
+ if (cache)
+ cache->insert(name, cursor);
return cursor;
}
QList<QByteArray> aliases = cursor->aliases();
for (int y = 0; y < aliases.size(); ++y)
if (nameMatch(aliases.at(y), name)) {
- cache.insert(name, cursor);
+ if (cache)
+ cache->insert(name, cursor);
return cursor;
}
}
codec = createForName(name);
- if (codec)
- cache.insert(name, codec);
+ if (codec && cache)
+ cache->insert(name, codec);
return codec;
}
@@ -1081,20 +1087,18 @@ QTextCodec* QTextCodec::codecForMib(int mib)
if (!validCodecs())
return 0;
- static QHash <int, QTextCodec *> cache;
- if (clearCaches & 0x2) {
- cache.clear();
- clearCaches &= ~0x2;
- }
- QTextCodec *codec = cache.value(mib);
- if (codec)
- return codec;
+ QByteArray key = "MIB: " + QByteArray::number(mib);
+ QTextCodecCache *cache = qTextCodecCache();
+ QTextCodec *codec;
+ if (cache)
+ codec = cache->value(key);
QList<QTextCodec*>::ConstIterator i;
for (int i = 0; i < all->size(); ++i) {
QTextCodec *cursor = all->at(i);
if (cursor->mibEnum() == mib) {
- cache.insert(mib, cursor);
+ if (cache)
+ cache->insert(key, cursor);
return cursor;
}
}
@@ -1106,8 +1110,8 @@ QTextCodec* QTextCodec::codecForMib(int mib)
if (!codec && mib == 1000)
return codecForMib(1015);
- if (codec)
- cache.insert(mib, codec);
+ if (codec && cache)
+ cache->insert(key, codec);
return codec;
}
diff --git a/src/gui/dialogs/qprintdialog_mac.mm b/src/gui/dialogs/qprintdialog_mac.mm
index 84a72db..82e4db5 100644
--- a/src/gui/dialogs/qprintdialog_mac.mm
+++ b/src/gui/dialogs/qprintdialog_mac.mm
@@ -140,11 +140,6 @@ QT_USE_NAMESPACE
QPrintDialogPrivate *d = static_cast<QPrintDialogPrivate *>(contextInfo);
QPrintDialog *dialog = d->printDialog();
- // temporary hack to work around bug in deleteLater() in Qt/Mac Cocoa
-#if 1
- bool deleteDialog = dialog->testAttribute(Qt::WA_DeleteOnClose);
- dialog->setAttribute(Qt::WA_DeleteOnClose, false);
-#endif
if (returnCode == NSOKButton) {
UInt32 frompage, topage;
@@ -192,10 +187,6 @@ QT_USE_NAMESPACE
}
dialog->done((returnCode == NSOKButton) ? QDialog::Accepted : QDialog::Rejected);
-#if 1
- if (deleteDialog)
- delete dialog;
-#endif
}
@end
diff --git a/src/gui/graphicsview/qgraphicslinearlayout.cpp b/src/gui/graphicsview/qgraphicslinearlayout.cpp
index 1588364..7e8d19f 100644
--- a/src/gui/graphicsview/qgraphicslinearlayout.cpp
+++ b/src/gui/graphicsview/qgraphicslinearlayout.cpp
@@ -275,13 +275,17 @@ void QGraphicsLinearLayout::insertItem(int index, QGraphicsLayoutItem *item)
qWarning("QGraphicsLinearLayout::insertItem: cannot insert itself");
return;
}
+ Q_ASSERT(item);
+
+ //the order of the following instructions is very important because
+ //invalidating the layout before adding the child item will make the layout happen
+ //before we try to paint the item
+ invalidate();
d->addChildLayoutItem(item);
- Q_ASSERT(item);
d->fixIndex(&index);
d->engine.insertRow(index, d->orientation);
new QGridLayoutItem(&d->engine, item, d->gridRow(index), d->gridColumn(index), 1, 1, 0, index);
- invalidate();
}
/*!
diff --git a/src/gui/graphicsview/qgridlayoutengine.cpp b/src/gui/graphicsview/qgridlayoutengine.cpp
index 98e6781..f8cd593 100644
--- a/src/gui/graphicsview/qgridlayoutengine.cpp
+++ b/src/gui/graphicsview/qgridlayoutengine.cpp
@@ -306,20 +306,19 @@ void QGridLayoutRowData::calculateGeometries(int start, int end, qreal targetSiz
ultimatePreferredSize = ultimatePreferredSize * 3 / 2;
ultimateSumPreferredSizes = ultimateSumPreferredSizes * 3 / 2;
- qreal ultimateFactor = (stretch * ultimateSumPreferredSizes
- / sumStretches)
- - (box.q_preferredSize);
- qreal transitionalFactor = sumCurrentAvailable
- * (ultimatePreferredSize - box.q_preferredSize)
- / (ultimateSumPreferredSizes
- - sumPreferredSizes);
-
- qreal alpha = qMin(sumCurrentAvailable,
- ultimateSumPreferredSizes - sumPreferredSizes);
qreal beta = ultimateSumPreferredSizes - sumPreferredSizes;
+ if (!beta) {
+ factors[i] = 1;
+ } else {
+ qreal alpha = qMin(sumCurrentAvailable, beta);
+ qreal ultimateFactor = (stretch * ultimateSumPreferredSizes / sumStretches)
+ - (box.q_preferredSize);
+ qreal transitionalFactor = sumCurrentAvailable * (ultimatePreferredSize - box.q_preferredSize) / beta;
+
+ factors[i] = ((alpha * ultimateFactor)
+ + ((beta - alpha) * transitionalFactor)) / beta;
+ }
- factors[i] = ((alpha * ultimateFactor)
- + ((beta - alpha) * transitionalFactor)) / beta;
}
sumFactors += factors[i];
if (desired < sumCurrentAvailable)
diff --git a/src/gui/image/qgifhandler.cpp b/src/gui/image/qgifhandler.cpp
index 124d27b..a050baf 100644
--- a/src/gui/image/qgifhandler.cpp
+++ b/src/gui/image/qgifhandler.cpp
@@ -505,17 +505,26 @@ int QGIFFormat::decode(QImage *image, const uchar *buffer, int length,
code=oldcode;
}
while (code>=clear_code+2) {
+ if (code >= max_code) {
+ state = Error;
+ return -1;
+ }
*sp++=table[1][code];
if (code==table[0][code]) {
state=Error;
- break;
+ return -1;
}
if (sp-stack>=(1<<(max_lzw_bits))*2) {
state=Error;
- break;
+ return -1;
}
code=table[0][code];
}
+ if (code < 0) {
+ state = Error;
+ return -1;
+ }
+
*sp++=firstcode=table[1][code];
code=max_code;
if (code<(1<<max_lzw_bits)) {
diff --git a/src/gui/image/qjpeghandler.cpp b/src/gui/image/qjpeghandler.cpp
index b9eda05..d47cc82 100644
--- a/src/gui/image/qjpeghandler.cpp
+++ b/src/gui/image/qjpeghandler.cpp
@@ -648,22 +648,28 @@ static bool write_jpeg_image(const QImage &image, QIODevice *device, int sourceQ
break;
case QImage::Format_RGB32:
case QImage::Format_ARGB32:
- case QImage::Format_ARGB32_Premultiplied: {
- const QRgb* rgb = (const QRgb*)image.constScanLine(cinfo.next_scanline);
- for (int i=0; i<w; i++) {
- *row++ = qRed(*rgb);
- *row++ = qGreen(*rgb);
- *row++ = qBlue(*rgb);
- ++rgb;
+ case QImage::Format_ARGB32_Premultiplied:
+ {
+ const QRgb* rgb = (const QRgb*)image.constScanLine(cinfo.next_scanline);
+ for (int i=0; i<w; i++) {
+ *row++ = qRed(*rgb);
+ *row++ = qGreen(*rgb);
+ *row++ = qBlue(*rgb);
+ ++rgb;
+ }
}
break;
- }
default:
- for (int i=0; i<w; i++) {
- QRgb pix = image.pixel(i, cinfo.next_scanline);
- *row++ = qRed(pix);
- *row++ = qGreen(pix);
- *row++ = qBlue(pix);
+ {
+ // (Testing shows that this way is actually faster than converting to RGB888 + memcpy)
+ QImage rowImg = image.copy(0, cinfo.next_scanline, w, 1).convertToFormat(QImage::Format_RGB32);
+ const QRgb* rgb = (const QRgb*)rowImg.constScanLine(0);
+ for (int i=0; i<w; i++) {
+ *row++ = qRed(*rgb);
+ *row++ = qGreen(*rgb);
+ *row++ = qBlue(*rgb);
+ ++rgb;
+ }
}
break;
}
diff --git a/src/gui/image/qpnghandler.cpp b/src/gui/image/qpnghandler.cpp
index dc54313..935aba0 100644
--- a/src/gui/image/qpnghandler.cpp
+++ b/src/gui/image/qpnghandler.cpp
@@ -678,41 +678,19 @@ bool QPNGImageWriter::writeImage(const QImage& image, int off_x, int off_y)
return writeImage(image, -1, QString(), off_x, off_y);
}
-bool Q_INTERNAL_WIN_NO_THROW QPNGImageWriter::writeImage(const QImage& image_in, int quality_in, const QString &description,
+bool Q_INTERNAL_WIN_NO_THROW QPNGImageWriter::writeImage(const QImage& image, int quality_in, const QString &description,
int off_x_in, int off_y_in)
{
#ifdef QT_NO_IMAGE_TEXT
Q_UNUSED(description);
#endif
- QImage image;
- switch (image_in.format()) {
- case QImage::Format_ARGB32_Premultiplied:
- case QImage::Format_ARGB4444_Premultiplied:
- case QImage::Format_ARGB8555_Premultiplied:
- case QImage::Format_ARGB8565_Premultiplied:
- case QImage::Format_ARGB6666_Premultiplied:
- image = image_in.convertToFormat(QImage::Format_ARGB32);
- break;
- case QImage::Format_RGB16:
- case QImage::Format_RGB444:
- case QImage::Format_RGB555:
- case QImage::Format_RGB666:
- case QImage::Format_RGB888:
- image = image_in.convertToFormat(QImage::Format_RGB32);
- break;
- default:
- image = image_in;
- break;
- }
-
QPoint offset = image.offset();
int off_x = off_x_in + offset.x();
int off_y = off_y_in + offset.y();
png_structp png_ptr;
png_infop info_ptr;
- png_bytep* row_pointers;
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,0,0,0);
if (!png_ptr) {
@@ -743,13 +721,18 @@ bool Q_INTERNAL_WIN_NO_THROW QPNGImageWriter::writeImage(const QImage& image_in,
png_set_write_fn(png_ptr, (void*)this, qpiw_write_fn, qpiw_flush_fn);
+
+ int color_type = 0;
+ if (image.colorCount())
+ color_type = PNG_COLOR_TYPE_PALETTE;
+ else if (image.hasAlphaChannel())
+ color_type = PNG_COLOR_TYPE_RGB_ALPHA;
+ else
+ color_type = PNG_COLOR_TYPE_RGB;
+
png_set_IHDR(png_ptr, info_ptr, image.width(), image.height(),
- image.depth() == 1 ? 1 : 8 /* per channel */,
- image.depth() == 32
- ? image.format() == QImage::Format_RGB32
- ? PNG_COLOR_TYPE_RGB
- : PNG_COLOR_TYPE_RGB_ALPHA
- : PNG_COLOR_TYPE_PALETTE, 0, 0, 0); // also sets #channels
+ image.depth() == 1 ? 1 : 8, // per channel
+ color_type, 0, 0, 0); // sets #channels
if (gamma != 0.0) {
png_set_gAMA(png_ptr, info_ptr, 1.0/gamma);
@@ -794,8 +777,9 @@ bool Q_INTERNAL_WIN_NO_THROW QPNGImageWriter::writeImage(const QImage& image_in,
png_set_swap_alpha(png_ptr);
}
- // Qt==ARGB==Big(ARGB)==Little(BGRA)
- if (QSysInfo::ByteOrder == QSysInfo::LittleEndian) {
+ // Qt==ARGB==Big(ARGB)==Little(BGRA). But RGB888 is RGB regardless
+ if (QSysInfo::ByteOrder == QSysInfo::LittleEndian
+ && image.format() != QImage::Format_RGB888) {
png_set_bgr(png_ptr);
}
@@ -820,7 +804,7 @@ bool Q_INTERNAL_WIN_NO_THROW QPNGImageWriter::writeImage(const QImage& image_in,
if (image.depth() != 1)
png_set_packing(png_ptr);
- if (image.format() == QImage::Format_RGB32)
+ if (color_type == PNG_COLOR_TYPE_RGB && image.format() != QImage::Format_RGB888)
png_set_filler(png_ptr, 0,
QSysInfo::ByteOrder == QSysInfo::BigEndian ?
PNG_FILLER_BEFORE : PNG_FILLER_AFTER);
@@ -841,22 +825,36 @@ bool Q_INTERNAL_WIN_NO_THROW QPNGImageWriter::writeImage(const QImage& image_in,
png_write_chunk(png_ptr, (png_byte*)"gIFg", data, 4);
}
- png_uint_32 width;
- png_uint_32 height;
- int bit_depth;
- int color_type;
- png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type,
- 0, 0, 0);
-
- const uchar *data = (static_cast<const QImage *>(&image))->bits();
- int bpl = image.bytesPerLine();
- row_pointers = new png_bytep[height];
- uint y;
- for (y=0; y<height; y++) {
- row_pointers[y] = (png_bytep)(data + y * bpl);
+ int height = image.height();
+ int width = image.width();
+ switch (image.format()) {
+ case QImage::Format_Mono:
+ case QImage::Format_MonoLSB:
+ case QImage::Format_Indexed8:
+ case QImage::Format_RGB32:
+ case QImage::Format_ARGB32:
+ case QImage::Format_RGB888:
+ {
+ png_bytep* row_pointers = new png_bytep[height];
+ for (int y=0; y<height; y++)
+ row_pointers[y] = (png_bytep)image.constScanLine(y);
+ png_write_image(png_ptr, row_pointers);
+ delete [] row_pointers;
+ }
+ break;
+ default:
+ {
+ QImage::Format fmt = image.hasAlphaChannel() ? QImage::Format_ARGB32 : QImage::Format_RGB32;
+ QImage row;
+ png_bytep row_pointers[1];
+ for (int y=0; y<height; y++) {
+ row = image.copy(0, y, width, 1).convertToFormat(fmt);
+ row_pointers[0] = png_bytep(row.constScanLine(0));
+ png_write_rows(png_ptr, row_pointers, 1);
+ }
+ }
+ break;
}
- png_write_image(png_ptr, row_pointers);
- delete [] row_pointers;
png_write_end(png_ptr, info_ptr);
frames_written++;
diff --git a/src/gui/painting/qgrayraster.c b/src/gui/painting/qgrayraster.c
index d0e25a9..ec9ebeb 100644
--- a/src/gui/painting/qgrayraster.c
+++ b/src/gui/painting/qgrayraster.c
@@ -325,6 +325,7 @@
{
void* buffer;
long buffer_size;
+ long buffer_allocated_size;
int band_size;
void* memory;
PWorker worker;
@@ -1791,7 +1792,7 @@
// If raster object and raster buffer are allocated, but
// raster size isn't of the minimum size, indicate out of
// memory.
- if (raster && raster->buffer && raster->buffer_size < MINIMUM_POOL_SIZE )
+ if (raster->buffer_allocated_size < MINIMUM_POOL_SIZE )
return ErrRaster_OutOfMemory;
/* return immediately if the outline is empty */
@@ -1930,6 +1931,7 @@
rast->buffer_size = 0;
rast->worker = NULL;
}
+ rast->buffer_allocated_size = pool_size;
}
}
diff --git a/src/gui/painting/qpaintengineex.cpp b/src/gui/painting/qpaintengineex.cpp
index 1e857e4..c1e3d66 100644
--- a/src/gui/painting/qpaintengineex.cpp
+++ b/src/gui/painting/qpaintengineex.cpp
@@ -517,7 +517,7 @@ void QPaintEngineEx::stroke(const QVectorPath &path, const QPen &pen)
QPainterPath painterPath = state()->matrix.map(path.convertToPainterPath());
d->activeStroker->strokePath(painterPath, d->strokeHandler, QTransform());
} else {
- d->activeStroker->setCurveThresholdFromTransform(state()->matrix);
+ d->activeStroker->setCurveThresholdFromTransform(QTransform());
d->activeStroker->begin(d->strokeHandler);
if (types) {
while (points < lastPoint) {
diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp
index 1402b44..b0ca6ed 100644
--- a/src/gui/painting/qpainter.cpp
+++ b/src/gui/painting/qpainter.cpp
@@ -6311,7 +6311,7 @@ void QPainter::drawText(const QRectF &r, int flags, const QString &str, QRectF *
By default, QPainter draws text anti-aliased.
- \note The y-position is used as the baseline of the font.
+ \note The y-position is used as the top of the font.
\sa Qt::AlignmentFlag, Qt::TextFlag
*/
diff --git a/src/gui/painting/qrasterdefs_p.h b/src/gui/painting/qrasterdefs_p.h
index 4131e4b..f6339ed 100644
--- a/src/gui/painting/qrasterdefs_p.h
+++ b/src/gui/painting/qrasterdefs_p.h
@@ -100,7 +100,7 @@ QT_FT_BEGIN_HEADER
/* distances in integer font units, or 16,16, or 26.6 fixed float */
/* pixel coordinates. */
/* */
- typedef signed long QT_FT_Pos;
+ typedef signed int QT_FT_Pos;
/*************************************************************************/
diff --git a/src/gui/painting/qstroker.cpp b/src/gui/painting/qstroker.cpp
index 9cff339..9decf41 100644
--- a/src/gui/painting/qstroker.cpp
+++ b/src/gui/painting/qstroker.cpp
@@ -190,6 +190,7 @@ static inline qreal adapted_angle_on_x(const QLineF &line)
QStrokerOps::QStrokerOps()
: m_elements(0)
, m_curveThreshold(qt_real_to_fixed(0.25))
+ , m_dashThreshold(qt_real_to_fixed(0.25))
, m_customData(0)
, m_moveTo(0)
, m_lineTo(0)
@@ -243,7 +244,7 @@ void QStrokerOps::strokePath(const QPainterPath &path, void *customData, const Q
if (path.isEmpty())
return;
- setCurveThresholdFromTransform(matrix);
+ setCurveThresholdFromTransform(QTransform());
begin(customData);
int count = path.elementCount();
if (matrix.isIdentity()) {
@@ -315,7 +316,7 @@ void QStrokerOps::strokePolygon(const QPointF *points, int pointCount, bool impl
if (!pointCount)
return;
- setCurveThresholdFromTransform(matrix);
+ setCurveThresholdFromTransform(QTransform());
begin(data);
if (matrix.isIdentity()) {
moveTo(qt_real_to_fixed(points[0].x()), qt_real_to_fixed(points[0].y()));
@@ -356,7 +357,7 @@ void QStrokerOps::strokeEllipse(const QRectF &rect, void *data, const QTransform
}
}
- setCurveThresholdFromTransform(matrix);
+ setCurveThresholdFromTransform(QTransform());
begin(data);
moveTo(qt_real_to_fixed(start.x()), qt_real_to_fixed(start.y()));
for (int i=0; i<12; i+=3) {
@@ -1142,7 +1143,7 @@ void QDashStroker::processCurrentSubpath()
QPainterPath dashPath;
- QSubpathFlatIterator it(&m_elements, m_curveThreshold);
+ QSubpathFlatIterator it(&m_elements, m_dashThreshold);
qfixed2d prev = it.next();
bool clipping = !m_clip_rect.isEmpty();
diff --git a/src/gui/painting/qstroker_p.h b/src/gui/painting/qstroker_p.h
index d646135..5607a8e 100644
--- a/src/gui/painting/qstroker_p.h
+++ b/src/gui/painting/qstroker_p.h
@@ -168,7 +168,7 @@ public:
{
qreal scale;
qt_scaleForTransform(transform, &scale);
- setCurveThreshold(scale == 0 ? qreal(0.5) : (qreal(0.5) / scale));
+ m_dashThreshold = scale == 0 ? qreal(0.5) : (qreal(0.5) / scale);
}
void setCurveThreshold(qfixed threshold) { m_curveThreshold = threshold; }
@@ -184,6 +184,7 @@ protected:
QRectF m_clip_rect;
qfixed m_curveThreshold;
+ qfixed m_dashThreshold;
void *m_customData;
qStrokerMoveToHook m_moveTo;
diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp
index 5c2d948..cb31491 100644
--- a/src/opengl/qgl.cpp
+++ b/src/opengl/qgl.cpp
@@ -515,6 +515,9 @@ QGLFormat::~QGLFormat()
exchange the screen contents with the buffer. The result is
flicker-free drawing and often better performance.
+ Note that single buffered contexts are currently not supported
+ with EGL.
+
\sa doubleBuffer(), QGLContext::swapBuffers(),
QGLWidget::swapBuffers()
*/
@@ -1696,6 +1699,9 @@ void QGLContextPrivate::init(QPaintDevice *dev, const QGLFormat &format)
workaround_brokenFBOReadBack = false;
workaroundsCached = false;
+ workaround_brokenTextureFromPixmap = false;
+ workaround_brokenTextureFromPixmap_init = false;
+
for (int i = 0; i < QT_GL_VERTEX_ARRAY_TRACKED_COUNT; ++i)
vertexAttributeArraysEnabledState[i] = false;
}
@@ -2578,19 +2584,35 @@ QGLTexture *QGLContextPrivate::bindTexture(const QPixmap &pixmap, GLenum target,
}
}
-#if defined(Q_WS_X11) && !defined(QT_NO_EGL)
- // Only try to use texture_from_pixmap under X11/EGL
+#if defined(Q_WS_X11)
+ // Try to use texture_from_pixmap
const QX11Info *xinfo = qt_x11Info(paintDevice);
if (pd->classId() == QPixmapData::X11Class && pd->pixelType() == QPixmapData::PixmapType
&& xinfo && xinfo->screen() == pixmap.x11Info().screen()
&& target == GL_TEXTURE_2D
&& QApplication::instance()->thread() == QThread::currentThread())
{
- texture = bindTextureFromNativePixmap(const_cast<QPixmap*>(&pixmap), key, options);
- if (texture) {
- texture->options |= QGLContext::MemoryManagedBindOption;
- texture->boundPixmap = pd;
- boundPixmaps.insert(pd, QPixmap(pixmap));
+ if (!workaround_brokenTextureFromPixmap_init) {
+ workaround_brokenTextureFromPixmap_init = true;
+
+ const QByteArray versionString(reinterpret_cast<const char*>(glGetString(GL_VERSION)));
+ const int pos = versionString.indexOf("NVIDIA ");
+
+ if (pos >= 0) {
+ const QByteArray nvidiaVersionString = versionString.mid(pos + strlen("NVIDIA "));
+
+ if (nvidiaVersionString.startsWith("195") || nvidiaVersionString.startsWith("256"))
+ workaround_brokenTextureFromPixmap = true;
+ }
+ }
+
+ if (!workaround_brokenTextureFromPixmap) {
+ texture = bindTextureFromNativePixmap(const_cast<QPixmap*>(&pixmap), key, options);
+ if (texture) {
+ texture->options |= QGLContext::MemoryManagedBindOption;
+ texture->boundPixmap = pd;
+ boundPixmaps.insert(pd, QPixmap(pixmap));
+ }
}
}
#endif
diff --git a/src/opengl/qgl_egl.cpp b/src/opengl/qgl_egl.cpp
index ebd1169..c79c4cd 100644
--- a/src/opengl/qgl_egl.cpp
+++ b/src/opengl/qgl_egl.cpp
@@ -143,6 +143,7 @@ void qt_glformat_from_eglconfig(QGLFormat& format, const EGLConfig config)
format.setRgba(true); // EGL doesn't support colour index rendering
format.setStereo(false); // EGL doesn't support stereo buffers
format.setAccumBufferSize(0); // EGL doesn't support accululation buffers
+ format.setDoubleBuffer(true); // We don't support single buffered EGL contexts
// Clear the EGL error state because some of the above may
// have errored out because the attribute is not applicable
diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h
index 73c0d65..78f888a 100644
--- a/src/opengl/qgl_p.h
+++ b/src/opengl/qgl_p.h
@@ -402,6 +402,9 @@ public:
uint workaround_brokenFBOReadBack : 1;
uint workaroundsCached : 1;
+ uint workaround_brokenTextureFromPixmap : 1;
+ uint workaround_brokenTextureFromPixmap_init : 1;
+
QPaintDevice *paintDevice;
QColor transpColor;
QGLContext *q_ptr;
diff --git a/src/opengl/qglpixelbuffer_win.cpp b/src/opengl/qglpixelbuffer_win.cpp
index 1da0aad..c61d9bf 100644
--- a/src/opengl/qglpixelbuffer_win.cpp
+++ b/src/opengl/qglpixelbuffer_win.cpp
@@ -172,6 +172,10 @@ typedef BOOL (WINAPI * PFNWGLSETPBUFFERATTRIBARBPROC) (HPBUFFERARB hPbuffer, con
#define WGL_SAMPLES_ARB 0x2042
#endif
+#ifndef GL_SAMPLES_ARB
+#define GL_SAMPLES_ARB 0x80A9
+#endif
+
QGLFormat pfiToQGLFormat(HDC hdc, int pfi);
static void qt_format_to_attrib_list(bool has_render_texture, const QGLFormat &f, int attribs[])
@@ -258,11 +262,10 @@ bool QGLPixelBufferPrivate::init(const QSize &size, const QGLFormat &f, QGLWidge
dc = wglGetCurrentDC();
Q_ASSERT(dc);
+ has_render_texture = false;
// sample buffers doesn't work in conjunction with the render_texture extension
- if (f.sampleBuffers()) {
- has_render_texture = false;
- } else {
+ if (!f.sampleBuffers()) {
PFNWGLGETEXTENSIONSSTRINGARBPROC wglGetExtensionsStringARB =
(PFNWGLGETEXTENSIONSSTRINGARBPROC) wglGetProcAddress("wglGetExtensionsStringARB");
@@ -303,7 +306,7 @@ bool QGLPixelBufferPrivate::init(const QSize &size, const QGLFormat &f, QGLWidge
pbuf = wglCreatePbufferARB(dc, pixel_format, size.width(), size.height(),
has_render_texture ? pb_attribs : 0);
- if(!pbuf) {
+ if (!pbuf) {
// try again without the render_texture extension
pbuf = wglCreatePbufferARB(dc, pixel_format, size.width(), size.height(), 0);
has_render_texture = false;
@@ -315,12 +318,20 @@ bool QGLPixelBufferPrivate::init(const QSize &size, const QGLFormat &f, QGLWidge
dc = wglGetPbufferDCARB(pbuf);
ctx = wglCreateContext(dc);
-
if (!dc || !ctx) {
qWarning("QGLPixelBuffer: Unable to create pbuffer context - giving up.");
return false;
}
+ // Explicitly disable the render_texture extension if we have a
+ // multi-sampled pbuffer context. This seems to be a problem only with
+ // ATI cards if multi-sampling is forced globally in the driver.
+ wglMakeCurrent(dc, ctx);
+ GLint samples = 0;
+ glGetIntegerv(GL_SAMPLES_ARB, &samples);
+ if (has_render_texture && samples != 0)
+ has_render_texture = false;
+
HGLRC share_ctx = shareWidget ? shareWidget->d_func()->glcx->d_func()->rc : 0;
if (share_ctx && !wglShareLists(share_ctx, ctx))
qWarning("QGLPixelBuffer: Unable to share display lists - with share widget.");
diff --git a/src/opengl/qpaintengine_opengl.cpp b/src/opengl/qpaintengine_opengl.cpp
index 58778ea..2f17aa6 100644
--- a/src/opengl/qpaintengine_opengl.cpp
+++ b/src/opengl/qpaintengine_opengl.cpp
@@ -506,12 +506,12 @@ struct QDrawQueueItem
////////// GL program cache: start
-typedef struct {
+struct GLProgram {
int brush; // brush index or mask index
int mode; // composition mode index
bool mask;
GLuint program;
-} GLProgram;
+};
typedef QMultiHash<const QGLContext *, GLProgram> QGLProgramHash;