/*! Returns the bit depth of the display. \sa screenHeight(), screenWidth() */ int QDirectPainter::screenDepth() { QScreen *screen = getPrimaryScreen(); if (!screen) return 0; return screen->depth(); }
int QWidget::metric(PaintDeviceMetric m) const { Q_D(const QWidget); QScreen *screen = 0; if (QWidget *topLevel = window()) if (QWindow *topLevelWindow = topLevel->windowHandle()) { QPlatformScreen *platformScreen = QPlatformScreen::platformScreenForWindow(topLevelWindow); if (platformScreen) screen = platformScreen->screen(); } if (!screen && QGuiApplication::primaryScreen()) screen = QGuiApplication::primaryScreen(); if (!screen) { if (m == PdmDpiX || m == PdmDpiY) return 72; return QPaintDevice::metric(m); } int val; if (m == PdmWidth) { val = data->crect.width(); } else if (m == PdmWidthMM) { val = data->crect.width() * screen->physicalSize().width() / screen->geometry().width(); } else if (m == PdmHeight) { val = data->crect.height(); } else if (m == PdmHeightMM) { val = data->crect.height() * screen->physicalSize().height() / screen->geometry().height(); } else if (m == PdmDepth) { return screen->depth(); } else if (m == PdmDpiX) { if (d->extra && d->extra->customDpiX) return d->extra->customDpiX; else if (d->parent) return static_cast<QWidget *>(d->parent)->metric(m); return qRound(screen->logicalDotsPerInchX()); } else if (m == PdmDpiY) { if (d->extra && d->extra->customDpiY) return d->extra->customDpiY; else if (d->parent) return static_cast<QWidget *>(d->parent)->metric(m); return qRound(screen->logicalDotsPerInchY()); } else if (m == PdmPhysicalDpiX) { return qRound(screen->physicalDotsPerInchX()); } else if (m == PdmPhysicalDpiY) { return qRound(screen->physicalDotsPerInchY()); } else if (m == PdmDevicePixelRatio) { return screen->devicePixelRatio(); } else { val = QPaintDevice::metric(m);// XXX } return val; }
bool QMultiScreen::connect(const QString &displaySpec) { QString dSpec = displaySpec; if (dSpec.startsWith(QLatin1String("Multi:"), Qt::CaseInsensitive)) dSpec = dSpec.mid(QString::fromLatin1("Multi:").size()); const QString displayIdSpec = QString::fromLatin1(" :%1").arg(displayId); if (dSpec.endsWith(displayIdSpec)) dSpec = dSpec.left(dSpec.size() - displayIdSpec.size()); QStringList specs = dSpec.split(QLatin1Char(' '), QString::SkipEmptyParts); foreach (QString spec, specs) { const int id = getDisplayId(spec); if (spec.startsWith("vnc:", Qt::CaseInsensitive)) { spec.append(":noDisablePainting"); } const QPoint offset = filterDisplayOffset(spec); QScreen *s = qt_get_screen(id, spec.toLatin1().constData()); s->setOffset(offset); addSubScreen(s); } QScreen *firstScreen = d_ptr->screens.at(0); Q_ASSERT(firstScreen); // XXX QScreen::d = firstScreen->depth(); QScreen::lstep = 0; QScreen::data = 0; QScreen::size = 0; QScreen::w = d_ptr->region.boundingRect().width(); QScreen::h = d_ptr->region.boundingRect().height(); QScreen::dw = QScreen::w; QScreen::dh = QScreen::h; // XXX - Extend the physical size based on the first screen // to encompass all screens, so that code that uses the multi // screen to calculate dpi values will get the right numbers. QScreen::physWidth = firstScreen->physicalWidth() * w / firstScreen->width(); QScreen::physHeight = firstScreen->physicalHeight() * h / firstScreen->height(); // XXXXX qt_screen = this; return true; }
void GetScreenInfoFromNativeWindow(QWindow* window, blink::WebScreenInfo* results) { QScreen* screen = window->screen(); blink::WebScreenInfo r; r.deviceScaleFactor = screen->devicePixelRatio(); r.depthPerComponent = 8; r.depth = screen->depth(); r.isMonochrome = (r.depth == 1); QRect screenGeometry = screen->geometry(); r.rect = blink::WebRect(screenGeometry.x(), screenGeometry.y(), screenGeometry.width(), screenGeometry.height()); QRect available = screen->availableGeometry(); r.availableRect = blink::WebRect(available.x(), available.y(), available.width(), available.height()); *results = r; }
QImage::Format QWSMemorySurface::preferredImageFormat(const QWidget *widget) const { QScreen *screen = getScreen(widget); const int depth = screen->depth(); const bool opaque = isWidgetOpaque(widget); if (!opaque) { if (depth <= 12) return QImage::Format_ARGB4444_Premultiplied; else if (depth <= 15) return QImage::Format_ARGB8555_Premultiplied; else if (depth <= 16) return QImage::Format_ARGB8565_Premultiplied; else if (depth <= 18) return QImage::Format_ARGB6666_Premultiplied; else return QImage::Format_ARGB32_Premultiplied; } QImage::Format format = screen->pixelFormat(); if (format > QImage::Format_Indexed8) // ### assumes all new image formats supports a QPainter return format; if (depth <= 12) return QImage::Format_RGB444; else if (depth <= 15) return QImage::Format_RGB555; else if (depth <= 16) return QImage::Format_RGB16; else if (depth <= 18) return QImage::Format_RGB666; else if (depth <= 24) return QImage::Format_RGB888; else return QImage::Format_ARGB32_Premultiplied; }