int QDirectFBPaintDevice::metric(QPaintDevice::PaintDeviceMetric metric) const { if (!dfbSurface) return 0; int w, h; dfbSurface->GetSize(dfbSurface, &w, &h); switch (metric) { case QPaintDevice::PdmWidth: return w; case QPaintDevice::PdmHeight: return h; case QPaintDevice::PdmWidthMM: return (w * 1000) / dotsPerMeterX(); case QPaintDevice::PdmHeightMM: return (h * 1000) / dotsPerMeterY(); case QPaintDevice::PdmPhysicalDpiX: case QPaintDevice::PdmDpiX: return (dotsPerMeterX() * 254) / 10000; // 0.0254 meters-per-inch case QPaintDevice::PdmPhysicalDpiY: case QPaintDevice::PdmDpiY: return (dotsPerMeterY() * 254) / 10000; // 0.0254 meters-per-inch case QPaintDevice::PdmDepth: DFBSurfacePixelFormat format; dfbSurface->GetPixelFormat(dfbSurface, &format); return QDirectFBScreen::depth(format); case QPaintDevice::PdmNumColors: { if (lockedImage) return lockedImage->numColors(); DFBResult result; IDirectFBPalette *palette = 0; unsigned int numColors = 0; result = dfbSurface->GetPalette(dfbSurface, &palette); if ((result != DFB_OK) || !palette) return 0; result = palette->GetSize(palette, &numColors); palette->Release(palette); if (result != DFB_OK) return 0; return numColors; } default: qCritical("QDirectFBPaintDevice::metric(): Unhandled metric!"); return 0; } }
int QDirectFBPaintDevice::metric(QPaintDevice::PaintDeviceMetric metric) const { if (!dfbSurface) return 0; switch (metric) { case QPaintDevice::PdmWidth: case QPaintDevice::PdmHeight: return (metric == PdmWidth ? size().width() : size().height()); case QPaintDevice::PdmWidthMM: return (size().width() * 1000) / dotsPerMeterX(); case QPaintDevice::PdmHeightMM: return (size().height() * 1000) / dotsPerMeterY(); case QPaintDevice::PdmPhysicalDpiX: case QPaintDevice::PdmDpiX: return (dotsPerMeterX() * 254) / 10000; // 0.0254 meters-per-inch case QPaintDevice::PdmPhysicalDpiY: case QPaintDevice::PdmDpiY: return (dotsPerMeterY() * 254) / 10000; // 0.0254 meters-per-inch case QPaintDevice::PdmDepth: return QDirectFBScreen::depth(imageFormat); case QPaintDevice::PdmNumColors: { if (!lockedImage.isNull()) return lockedImage.colorCount(); DFBResult result; IDirectFBPalette *palette = 0; unsigned int numColors = 0; result = dfbSurface->GetPalette(dfbSurface, &palette); if ((result != DFB_OK) || !palette) return 0; result = palette->GetSize(palette, &numColors); palette->Release(palette); if (result != DFB_OK) return 0; return numColors; } default: qCritical("QDirectFBPaintDevice::metric(): Unhandled metric!"); return 0; } }