/* Initialize a native display for use with WSEGL */ static WSEGLError wseglInitializeDisplay (NativeDisplayType nativeDisplay, WSEGLDisplayHandle *display, const WSEGLCaps **caps, WSEGLConfig **configs) { WSEGLPixelFormat pixelFormat; /* Bail out if the native display is incorrect */ if (nativeDisplay != WSEGL_DEFAULT_DISPLAY) return WSEGL_CANNOT_INITIALISE; /* Open the PVR/QWS display, which will initialize the framebuffer */ if (!pvrQwsDisplayOpen()) return WSEGL_CANNOT_INITIALISE; /* Convert the PVR2D pixel format into a WSEGL pixel format */ switch (pvrQwsDisplay.screens[0].pixelFormat) { case PVR2D_RGB565: pixelFormat = WSEGL_PIXELFORMAT_565; break; case PVR2D_ARGB4444: pixelFormat = WSEGL_PIXELFORMAT_4444; break; case PVR2D_ARGB8888: pixelFormat = WSEGL_PIXELFORMAT_8888; break; default: pvrQwsDisplayClose(); return WSEGL_CANNOT_INITIALISE; } wseglDisplayConfigs[0].ePixelFormat = pixelFormat; wseglDisplayConfigs[1].ePixelFormat = pixelFormat; /* The display has been initialized */ *display = (WSEGLDisplayHandle)&pvrQwsDisplay; *caps = wseglDisplayCaps; *configs = wseglDisplayConfigs; return WSEGL_SUCCESS; }
bool PvrEglScreen::connect(const QString &displaySpec) { if (!pvrQwsDisplayOpen()) return false; // Initialize the QScreen properties. data = (uchar *)(pvrQwsDisplay.screens[0].mapped); w = pvrQwsDisplay.screens[0].screenRect.width; h = pvrQwsDisplay.screens[0].screenRect.height; lstep = pvrQwsDisplay.screens[0].screenStride; dw = w; dh = h; size = h * lstep; mapsize = size; switch (pvrQwsDisplay.screens[0].pixelFormat) { case PVR2D_RGB565: d = 16; setPixelFormat(QImage::Format_RGB16); break; case PVR2D_ARGB4444: d = 16; setPixelFormat(QImage::Format_ARGB4444_Premultiplied); break; case PVR2D_ARGB8888: d = 32; setPixelFormat(QImage::Format_ARGB32_Premultiplied); break; default: pvrQwsDisplayClose(); qWarning("PvrEglScreen::connect: unsupported pixel format %d", (int)(pvrQwsDisplay.screens[0].pixelFormat)); return false; } // Handle display physical size spec. QStringList displayArgs = displaySpec.split(QLatin1Char(':')); QRegExp mmWidthRx(QLatin1String("mmWidth=?(\\d+)")); int dimIdxW = displayArgs.indexOf(mmWidthRx); QRegExp mmHeightRx(QLatin1String("mmHeight=?(\\d+)")); int dimIdxH = displayArgs.indexOf(mmHeightRx); if (dimIdxW >= 0) { mmWidthRx.exactMatch(displayArgs.at(dimIdxW)); physWidth = mmWidthRx.cap(1).toInt(); if (dimIdxH < 0) physHeight = dh*physWidth/dw; } if (dimIdxH >= 0) { mmHeightRx.exactMatch(displayArgs.at(dimIdxH)); physHeight = mmHeightRx.cap(1).toInt(); if (dimIdxW < 0) physWidth = dw*physHeight/dh; } if (dimIdxW < 0 && dimIdxH < 0) { const int dpi = 72; physWidth = qRound(dw * 25.4 / dpi); physHeight = qRound(dh * 25.4 / dpi); } // Find the name of the tty device to use. QRegExp ttyRegExp(QLatin1String("tty=(.*)")); if (displayArgs.indexOf(ttyRegExp) != -1) ttyDevice = ttyRegExp.cap(1); if (displayArgs.contains(QLatin1String("nographicsmodeswitch"))) doGraphicsMode = false; // The screen is ready. return true; }