diff options
author | axis <qt-info@nokia.com> | 2009-04-24 14:03:55 (GMT) |
---|---|---|
committer | axis <qt-info@nokia.com> | 2009-04-27 07:09:01 (GMT) |
commit | e74c8dc65e2feffb9a55d00aee5ca634fba41df8 (patch) | |
tree | 3a131f9235fb6a455793178d8313655e4fd0036e /src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp | |
parent | 8f427b2b914d5b575a4a7c0ed65d2fb8f45acc76 (diff) | |
parent | 211bea9838bcc2acd7f54b65468fe1be2d81b1e0 (diff) | |
download | Qt-e74c8dc65e2feffb9a55d00aee5ca634fba41df8.zip Qt-e74c8dc65e2feffb9a55d00aee5ca634fba41df8.tar.gz Qt-e74c8dc65e2feffb9a55d00aee5ca634fba41df8.tar.bz2 |
Merge branch '4.5' of git@scm.dev.nokia.troll.no:qt/qt
Configure.exe recompiled with MSVC6.
Conflicts:
configure.exe
examples/network/network.pro
src/gui/dialogs/qfiledialog_p.h
src/gui/dialogs/qfilesystemmodel_p.h
src/gui/kernel/qapplication.cpp
tests/auto/_Categories/qmake.txt
tests/auto/qfile/test/test.pro
tests/auto/qfile/tst_qfile.cpp
tests/auto/qlibrary/tst_qlibrary.cpp
tests/auto/qline/tst_qline.cpp
tests/auto/qstyle/tst_qstyle.cpp
tests/auto/qtextstream/tst_qtextstream.cpp
tests/auto/qtranslator/qtranslator.pro
tests/auto/qwaitcondition/tst_qwaitcondition.cpp
translations/qt_ja_JP.ts
Diffstat (limited to 'src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp')
-rw-r--r-- | src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp | 71 |
1 files changed, 20 insertions, 51 deletions
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp index 6a41a24..924090c 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp @@ -50,34 +50,22 @@ QDirectFBPaintDevice::~QDirectFBPaintDevice() } -IDirectFBSurface *QDirectFBPaintDevice::directFbSurface() const +IDirectFBSurface *QDirectFBPaintDevice::directFBSurface() const { return dfbSurface; } -// Locks the dfb surface and creates a QImage (lockedImage) from the pointer -void QDirectFBPaintDevice::lockDirectFB() { - +void QDirectFBPaintDevice::lockDirectFB() +{ if (lockedImage) return; // Already locked - void *mem; - int w, h; - int bpl; - DFBSurfacePixelFormat format; - - DFBResult result = dfbSurface->Lock(dfbSurface, DSLF_WRITE, &mem, &bpl); - if (result != DFB_OK || !mem) { - DirectFBError("QDirectFBPixmapData::buffer()", result); - return; + if (uchar *mem = QDirectFBScreen::lockSurface(dfbSurface, DSLF_WRITE, &bpl)) { + const QSize s = size(); + lockedImage = new QImage(mem, s.width(), s.height(), bpl, + QDirectFBScreen::getImageFormat(dfbSurface)); } - - dfbSurface->GetSize(dfbSurface, &w, &h); - dfbSurface->GetPixelFormat(dfbSurface, &format); - - lockedImage = new QImage(static_cast<uchar*>(mem), w, h, bpl, - QDirectFBScreen::getImageFormat(format)); } @@ -103,19 +91,20 @@ void* QDirectFBPaintDevice::memory() const QImage::Format QDirectFBPaintDevice::format() const { - DFBSurfacePixelFormat dfbFormat; - dfbSurface->GetPixelFormat(dfbSurface, &dfbFormat); - return QDirectFBScreen::getImageFormat(dfbFormat); + return QDirectFBScreen::getImageFormat(dfbSurface); } int QDirectFBPaintDevice::bytesPerLine() const { - // Can only get the stride when we lock the surface - QDirectFBPaintDevice* that = const_cast<QDirectFBPaintDevice*>(this); - that->lockDirectFB(); - Q_ASSERT(that->lockedImage); - return that->lockedImage->bytesPerLine(); + if (bpl == -1) { + // Can only get the stride when we lock the surface + Q_ASSERT(!lockedImage); + QDirectFBPaintDevice* that = const_cast<QDirectFBPaintDevice*>(this); + that->lockDirectFB(); + Q_ASSERT(bpl != -1); + } + return bpl; } @@ -126,7 +115,6 @@ QSize QDirectFBPaintDevice::size() const return QSize(w, h); } - int QDirectFBPaintDevice::metric(QPaintDevice::PaintDeviceMetric metric) const { if (!dfbSurface) @@ -135,40 +123,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); |