QGLWidget: Support retina framebuffer grabbing

And update the opengl/grabber example.

Task-number: QTBUG-31173
Change-Id: If09f1f3634b353d034f51240fc68be6ee7aabb48
Reviewed-by: Samuel Rødal <samuel.rodal@digia.com>
Reviewed-by: Gunnar Sletta <gunnar.sletta@digia.com>
This commit is contained in:
Gabriel de Dietrich 2013-05-21 18:22:27 +02:00 committed by The Qt Project
parent 602bd98737
commit 004f25df78
2 changed files with 5 additions and 4 deletions

View File

@ -175,7 +175,7 @@ QSlider *MainWindow::createSlider(const char *changedSignal,
void MainWindow::setPixmap(const QPixmap &pixmap)
{
pixmapLabel->setPixmap(pixmap);
QSize size = pixmap.size();
QSize size = pixmap.size() / pixmap.devicePixelRatio();
if (size - QSize(1, 0) == pixmapLabelArea->maximumViewportSize())
size -= QSize(1, 0);
pixmapLabel->resize(size);

View File

@ -4090,11 +4090,12 @@ QImage QGLWidget::grabFrameBuffer(bool withAlpha)
{
makeCurrent();
QImage res;
int w = width();
int h = height();
qreal pixelRatio = devicePixelRatio();
int w = pixelRatio * width();
int h = pixelRatio * height();
if (format().rgba())
res = qt_gl_read_frame_buffer(QSize(w, h), format().alpha(), withAlpha);
res.setDevicePixelRatio(pixelRatio);
return res;
}