summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamuel Rødal <sroedal@trolltech.com>2009-05-19 07:55:08 (GMT)
committerSamuel Rødal <sroedal@trolltech.com>2009-05-25 08:43:48 (GMT)
commit943b709a71b1ffc9abdf459269c79dd1b731d781 (patch)
tree1a89188429b0e8f3a28c27a59a3db1066395dacb
parentf8d4c07981e556bf416ccd75e7c460a0b84e4e98 (diff)
downloadQt-943b709a71b1ffc9abdf459269c79dd1b731d781.zip
Qt-943b709a71b1ffc9abdf459269c79dd1b731d781.tar.gz
Qt-943b709a71b1ffc9abdf459269c79dd1b731d781.tar.bz2
Made PixelBuffer/FramebufferObject report correct DPI based metrics.
We need to use both qt_defaultDpiX and qt_defaultDpiY, and round the resulting metric values. Reviewed-by: Trond
-rw-r--r--src/opengl/qglframebufferobject.cpp15
-rw-r--r--src/opengl/qglpixelbuffer.cpp15
2 files changed, 16 insertions, 14 deletions
diff --git a/src/opengl/qglframebufferobject.cpp b/src/opengl/qglframebufferobject.cpp
index f6857ac..8af9f63 100644
--- a/src/opengl/qglframebufferobject.cpp
+++ b/src/opengl/qglframebufferobject.cpp
@@ -985,15 +985,16 @@ void QGLFramebufferObject::drawTexture(const QPointF &point, QMacCompatGLuint te
}
#endif
-extern int qt_defaultDpi();
+extern int qt_defaultDpiX();
+extern int qt_defaultDpiY();
/*! \reimp */
int QGLFramebufferObject::metric(PaintDeviceMetric metric) const
{
Q_D(const QGLFramebufferObject);
- float dpmx = qt_defaultDpi()*100./2.54;
- float dpmy = qt_defaultDpi()*100./2.54;
+ float dpmx = qt_defaultDpiX()*100./2.54;
+ float dpmy = qt_defaultDpiY()*100./2.54;
int w = d->size.width();
int h = d->size.height();
switch (metric) {
@@ -1016,16 +1017,16 @@ int QGLFramebufferObject::metric(PaintDeviceMetric metric) const
return 32;//d->depth;
case PdmDpiX:
- return (int)(dpmx * 0.0254);
+ return qRound(dpmx * 0.0254);
case PdmDpiY:
- return (int)(dpmy * 0.0254);
+ return qRound(dpmy * 0.0254);
case PdmPhysicalDpiX:
- return (int)(dpmx * 0.0254);
+ return qRound(dpmx * 0.0254);
case PdmPhysicalDpiY:
- return (int)(dpmy * 0.0254);
+ return qRound(dpmy * 0.0254);
default:
qWarning("QGLFramebufferObject::metric(), Unhandled metric type: %d.\n", metric);
diff --git a/src/opengl/qglpixelbuffer.cpp b/src/opengl/qglpixelbuffer.cpp
index ce7e9bd..efc58f2 100644
--- a/src/opengl/qglpixelbuffer.cpp
+++ b/src/opengl/qglpixelbuffer.cpp
@@ -388,15 +388,16 @@ QPaintEngine *QGLPixelBuffer::paintEngine() const
#endif
}
-extern int qt_defaultDpi();
+extern int qt_defaultDpiX();
+extern int qt_defaultDpiY();
/*! \reimp */
int QGLPixelBuffer::metric(PaintDeviceMetric metric) const
{
Q_D(const QGLPixelBuffer);
- float dpmx = qt_defaultDpi()*100./2.54;
- float dpmy = qt_defaultDpi()*100./2.54;
+ float dpmx = qt_defaultDpiX()*100./2.54;
+ float dpmy = qt_defaultDpiY()*100./2.54;
int w = d->req_size.width();
int h = d->req_size.height();
switch (metric) {
@@ -419,16 +420,16 @@ int QGLPixelBuffer::metric(PaintDeviceMetric metric) const
return 32;//d->depth;
case PdmDpiX:
- return (int)(dpmx * 0.0254);
+ return qRound(dpmx * 0.0254);
case PdmDpiY:
- return (int)(dpmy * 0.0254);
+ return qRound(dpmy * 0.0254);
case PdmPhysicalDpiX:
- return (int)(dpmx * 0.0254);
+ return qRound(dpmx * 0.0254);
case PdmPhysicalDpiY:
- return (int)(dpmy * 0.0254);
+ return qRound(dpmy * 0.0254);
default:
qWarning("QGLPixelBuffer::metric(), Unhandled metric type: %d\n", metric);