summaryrefslogtreecommitdiffstats
path: root/src/opengl/qgl_mac.mm
diff options
context:
space:
mode:
authorMorten Johan Sørvig <morten.sorvig@nokia.com>2010-01-08 11:31:03 (GMT)
committerMorten Johan Sørvig <morten.sorvig@nokia.com>2010-01-08 11:31:03 (GMT)
commita54b606aef73f49dac451a35b29456bc1584a47e (patch)
tree02ae1bde2e69ea0b3206eb0344a072c5427fff08 /src/opengl/qgl_mac.mm
parentf90472009c928b3f599c182dfbab91390fdafdd9 (diff)
downloadQt-a54b606aef73f49dac451a35b29456bc1584a47e.zip
Qt-a54b606aef73f49dac451a35b29456bc1584a47e.tar.gz
Qt-a54b606aef73f49dac451a35b29456bc1584a47e.tar.bz2
Fix broken QGLWidget::renderPixmap on Mac/Carbon
Task: ed2a03b3bc85be056eca87928d18a746faa07bca Reviewed-by: Trond Commit ed2a03b3bc85be056eca87928d18a746faa07bca removed all QuickDraw code and made QPixmap::macQDHandle() return 0 in all cases. Unfortunately QGLWidget::renderPixmap() depended on macQDHandle returning a valid handle, causing it to break. Fix this by inserting the macQDHandle implementation were we would call macQDHandle before. This is the only place in Qt where macQDHandle is used.
Diffstat (limited to 'src/opengl/qgl_mac.mm')
-rw-r--r--src/opengl/qgl_mac.mm20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/opengl/qgl_mac.mm b/src/opengl/qgl_mac.mm
index ef2fa6c..6ed07e5 100644
--- a/src/opengl/qgl_mac.mm
+++ b/src/opengl/qgl_mac.mm
@@ -606,10 +606,22 @@ void QGLContext::updatePaintDevice()
}
}
} else if (d->paintDevice->devType() == QInternal::Pixmap) {
- QPixmap *pm = (QPixmap *)d->paintDevice;
- PixMapHandle mac_pm = GetGWorldPixMap((GWorldPtr)pm->macQDHandle());
- aglSetOffScreen((AGLContext)d->cx, pm->width(), pm->height(),
- GetPixRowBytes(mac_pm), GetPixBaseAddr(mac_pm));
+ QPixmap *pm = reinterpret_cast<QPixmap *>(d->paintDevice);
+
+ unsigned long qdformat = k32ARGBPixelFormat;
+ if (QSysInfo::ByteOrder == QSysInfo::LittleEndian)
+ qdformat = k32BGRAPixelFormat;
+ Rect rect;
+ SetRect(&rect, 0, 0, pm->width(), pm->height());
+
+ GWorldPtr gworld;
+ NewGWorldFromPtr(&gworld, qdformat, &rect, 0, 0, 0,
+ reinterpret_cast<char *>(qt_mac_pixmap_get_base(pm)),
+ qt_mac_pixmap_get_bytes_per_line(pm));
+
+ PixMapHandle pixmapHandle = GetGWorldPixMap(gworld);
+ aglSetOffScreen(reinterpret_cast<AGLContext>(d->cx), pm->width(), pm->height(),
+ GetPixRowBytes(pixmapHandle), GetPixBaseAddr(pixmapHandle));
} else {
qWarning("QGLContext::updatePaintDevice(): Not sure how to render OpenGL on this device!");
}