22 QImage::Format format = QImage::Format_Invalid;
24 switch (fbinfo->BitsPerPixel) {
26 if (fbinfo->Alpha.Bits)
27 format = QImage::Format_ARGB32;
29 format = QImage::Format_RGB32;
32 format = QImage::Format_RGB888;
35 format = QImage::Format_RGB666;
38 format = QImage::Format_RGB16;
41 format = QImage::Format_RGB555;
44 format = QImage::Format_RGB444;
49 format = QImage::Format_Mono;
78 QRegularExpression fbRx(
"fb=(.*)"_L1);
79 QRegularExpression sizeRx(
"size=(\\d+)x(\\d+)"_L1);
80 QRegularExpression offsetRx(
"offset=(\\d+)x(\\d+)"_L1);
86 foreach (
const QString &arg, mArgs) {
87 QRegularExpressionMatch match;
88 if (arg.contains(sizeRx, &match))
89 userGeometry.setSize(QSize(match.captured(1).toInt(), match.captured(2).toInt()));
90 else if (arg.contains(offsetRx, &match))
91 userGeometry.setTopLeft(QPoint(match.captured(1).toInt(), match.captured(2).toInt()));
92 else if (arg.contains(fbRx, &match))
93 fbDevice = match.captured(1);
96 if (fbDevice.isEmpty()) {
98 err = gh_FB_get_driver_by_name(NULL, &mFbd);
100 uintptr_t context = 0;
102 err = gh_FB_get_next_driver(&context, &mFbd);
105 err = gh_FB_get_driver_by_name(qPrintable(fbDevice), &mFbd);
107 if (err != Success) {
108 qErrnoWarning(
"Failed to open framebuffer %s: %d", qPrintable(fbDevice), err);
112 memset(&mFbinfo, 0,
sizeof(FBInfo));
113 CheckSuccess(gh_FB_check_info(mFbd, &mFbinfo));
114 if (userGeometry.width() && userGeometry.height()) {
115 mFbinfo.Width = userGeometry.width();
116 mFbinfo.Height = userGeometry.height();
117 err = gh_FB_check_info(mFbd, &mFbinfo);
118 if (err != Success) {
119 qErrnoWarning(
"Unsupported resolution %dx%d for %s: %d",
120 userGeometry.width(), userGeometry.height(),
121 qPrintable(fbDevice), err);
126 if (mFbinfo.MMapSize) {
127 err = AllocateAnyMemoryRegionWithCookie(__ghs_VirtualMemoryRegionPool,
128 mFbinfo.MMapSize, &mVMR, &mVMRCookie);
129 if (err != Success) {
130 qErrnoWarning(
"Could not mmap: %d", err);
134 err = gh_FB_open_mmap(mFbd, &mFbinfo, mVMR, &mFbh);
136 err = gh_FB_open(mFbd, &mFbinfo, &mFbh);
138 if (err != Success) {
139 qErrnoWarning(
"Could not open framebuffer: %d", err);
143 CheckSuccess(gh_FB_get_info(mFbh, &mFbinfo));
145 mDepth = mFbinfo.BitsPerPixel;
146 mGeometry = QRect(0, 0, mFbinfo.Width, mFbinfo.Height);
147 mFormat = determineFormat(&mFbinfo);
150 int mmWidth = qRound((mFbinfo.Width * 25.4) / dpi);
151 int mmHeight = qRound((mFbinfo.Height * 25.4) / dpi);
152 mPhysicalSize = QSizeF(mmWidth, mmHeight);
154 QFbScreen::initializeCompositor();
155 mFbScreenImage = QImage((uchar *)mFbinfo.Start, mFbinfo.Width, mFbinfo.Height,
156 mFbinfo.BytesPerLine, mFormat);
158 mCursor =
new QFbCursor(
this);
192 width = mFbScreenImage.width() - x;
194 height = mFbScreenImage.height() - y;
195 return QPixmap::fromImage(mFbScreenImage).copy(x, y, width, height);
198 QFbWindow *window = windowForId(wid);
200 const QRect geom = window->geometry();
202 width = geom.width() - x;
204 height = geom.height() - y;
205 QRect rect(geom.topLeft() + QPoint(x, y), QSize(width, height));
206 rect &= window->geometry();
207 return QPixmap::fromImage(mFbScreenImage).copy(rect);