diff options
author | Anders Bakken <anders.bakken@nokia.com> | 2009-04-03 23:16:38 (GMT) |
---|---|---|
committer | Anders Bakken <anders.bakken@nokia.com> | 2009-04-03 23:21:16 (GMT) |
commit | 4cdb847d93842df26859581906c943f0da78d775 (patch) | |
tree | 59745fda8635d82e6af3a4af01c34f9e303bd3b8 /src/plugins | |
parent | 2a8e39999cb3f5be9bb16ffb5ddfe118d18f9ef1 (diff) | |
download | Qt-4cdb847d93842df26859581906c943f0da78d775.zip Qt-4cdb847d93842df26859581906c943f0da78d775.tar.gz Qt-4cdb847d93842df26859581906c943f0da78d775.tar.bz2 |
Silence warning and beautify code
Even though these variables couldn't really be used uninitialized GCC
4.3.2 thinks it could. This is nicer, more readable and faster anyway.
Reviewed-by: Donald <qt-info@nokia.com>
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp | 28 | ||||
-rw-r--r-- | src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h | 9 |
2 files changed, 13 insertions, 24 deletions
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp index 5e71640..edbfa7d 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp @@ -123,7 +123,6 @@ QSize QDirectFBPaintDevice::size() const return QSize(w, h); } - int QDirectFBPaintDevice::metric(QPaintDevice::PaintDeviceMetric metric) const { if (!dfbSurface) @@ -132,40 +131,21 @@ int QDirectFBPaintDevice::metric(QPaintDevice::PaintDeviceMetric metric) const int w, h; dfbSurface->GetSize(dfbSurface, &w, &h); - int dpmX, dpmY; // Dots-per-meter ;-) - - // Do some common calculations: - switch (metric) { - case QPaintDevice::PdmWidthMM: - case QPaintDevice::PdmPhysicalDpiX: - case QPaintDevice::PdmDpiX: - dpmX = (screen->deviceWidth() * 1000) / screen->physicalWidth(); - break; - case QPaintDevice::PdmHeightMM: - case QPaintDevice::PdmPhysicalDpiY: - case QPaintDevice::PdmDpiY: - dpmY = (screen->deviceHeight() * 1000) / screen->physicalHeight(); - break; - default: - break; - } - - // Now use those calculations switch (metric) { case QPaintDevice::PdmWidth: return w; case QPaintDevice::PdmHeight: return h; case QPaintDevice::PdmWidthMM: - return (w * 1000) / dpmX; + return (w * 1000) / dotsPerMeterX(); case QPaintDevice::PdmHeightMM: - return (h * 1000) / dpmY; + return (h * 1000) / dotsPerMeterY(); case QPaintDevice::PdmPhysicalDpiX: case QPaintDevice::PdmDpiX: - return (dpmX * 254) / 10000; // 0.0254 meters-per-inch + return (dotsPerMeterX() * 254) / 10000; // 0.0254 meters-per-inch case QPaintDevice::PdmPhysicalDpiY: case QPaintDevice::PdmDpiY: - return (dpmY * 254) / 10000; // 0.0254 meters-per-inch + return (dotsPerMeterY() * 254) / 10000; // 0.0254 meters-per-inch case QPaintDevice::PdmDepth: DFBSurfacePixelFormat format; dfbSurface->GetPixelFormat(dfbSurface, &format); diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h index 89a3087..a11064b 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h @@ -78,6 +78,15 @@ protected: screen(scr), forceRaster(false) {} + inline int dotsPerMeterX() const + { + return (screen->deviceWidth() * 1000) / screen->physicalWidth(); + } + inline int dotsPerMeterY() const + { + return (screen->deviceHeight() * 1000) / screen->physicalHeight(); + } + IDirectFBSurface *dfbSurface; QImage *lockedImage; QDirectFBScreen *screen; |