1 /****************************************************************************
2 **
3 ** Copyright (C) 2015 The Qt Company Ltd.
4 ** Contact: http://www.qt.io/licensing/
5 **
6 ** This file is part of the plugins of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and The Qt Company. For licensing terms
14 ** and conditions see http://www.qt.io/terms-conditions. For further
15 ** information use the contact form at http://www.qt.io/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 or version 3 as published by the Free
20 ** Software Foundation and appearing in the file LICENSE.LGPLv21 and
21 ** LICENSE.LGPLv3 included in the packaging of this file. Please review the
22 ** following information to ensure the GNU Lesser General Public License
23 ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
24 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25 **
26 ** As a special exception, The Qt Company gives you certain additional
27 ** rights. These rights are described in The Qt Company LGPL Exception
28 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29 **
30 ** GNU General Public License Usage
31 ** Alternatively, this file may be used under the terms of the GNU
32 ** General Public License version 3.0 as published by the Free Software
33 ** Foundation and appearing in the file LICENSE.GPL included in the
34 ** packaging of this file.  Please review the following information to
35 ** ensure the GNU General Public License version 3.0 requirements will be
36 ** met: http://www.gnu.org/copyleft/gpl.html.
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #ifndef QGRAPHICSSYSTEM_LINUXFB_H
43 #define QGRAPHICSSYSTEM_LINUXFB_H
44 
45 #include <QPlatformIntegration>
46 #include "../fb_base/fb_base.h"
47 
48 QT_BEGIN_NAMESPACE
49 
50 class QLinuxFbScreen : public QFbScreen
51 {
52     Q_OBJECT
53 public:
54     QLinuxFbScreen(uchar * d, int w, int h, int lstep, QImage::Format screenFormat);
55     void setGeometry(QRect rect);
56     void setFormat(QImage::Format format);
57 
58 public slots:
59     QRegion doRedraw();
60 
61 private:
62     QImage * mFbScreenImage;
63     uchar * data;
64     int bytesPerLine;
65 
66     QPainter *compositePainter;
67 };
68 
69 class QLinuxFbIntegrationPrivate;
70 struct fb_cmap;
71 struct fb_var_screeninfo;
72 struct fb_fix_screeninfo;
73 
74 class QLinuxFbIntegration : public QPlatformIntegration
75 {
76 public:
77     QLinuxFbIntegration();
78     ~QLinuxFbIntegration();
79 
80     bool hasCapability(QPlatformIntegration::Capability cap) const;
81 
82     QPixmapData *createPixmapData(QPixmapData::PixelType type) const;
83     QPlatformWindow *createPlatformWindow(QWidget *widget, WId WinId) const;
84     QWindowSurface *createWindowSurface(QWidget *widget, WId WinId) const;
85 
screens()86     QList<QPlatformScreen *> screens() const { return mScreens; }
87 
88     QPlatformFontDatabase *fontDatabase() const;
89 
90 private:
91     QLinuxFbScreen *mPrimaryScreen;
92     QList<QPlatformScreen *> mScreens;
93     QLinuxFbIntegrationPrivate *d_ptr;
94 
95     enum PixelType { NormalPixel, BGRPixel };
96 
97     QRgb screenclut[256];
98     int screencols;
99 
100     uchar * data;
101 
102     QImage::Format screenFormat;
103     int w;
104     int lstep;
105     int h;
106     int d;
107     PixelType pixeltype;
108     bool grayscale;
109 
110     int dw;
111     int dh;
112 
113     int size;               // Screen size
114     int mapsize;       // Total mapped memory
115 
116     int displayId;
117 
118     int physWidth;
119     int physHeight;
120 
121     bool canaccel;
122     int dataoffset;
123     int cacheStart;
124 
125     bool connect(const QString &displaySpec);
126     bool initDevice();
127     void setPixelFormat(struct fb_var_screeninfo);
128     void createPalette(fb_cmap &cmap, fb_var_screeninfo &vinfo, fb_fix_screeninfo &finfo);
129     void blank(bool on);
130     QPlatformFontDatabase *fontDb;
131 };
132 
133 QT_END_NAMESPACE
134 
135 #endif
136