1 /***************************************************************************
3 ** Copyright (C) 2011 - 2012 Research In Motion
4 ** Contact: http://www.qt-project.org/
6 ** This file is part of the plugins of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
45 #include <qpa/qplatformwindow.h>
47 #include "qqnxbuffer.h"
49 #include <QtGui/QImage>
50 #include <QtCore/QMutex>
56 #include <screen/screen.h>
60 // all surfaces double buffered
61 #define MAX_BUFFER_COUNT 2
70 class QQnxWindow : public QPlatformWindow
72 friend class QQnxScreen;
74 QQnxWindow(QWindow *window, screen_context_t context);
75 virtual ~QQnxWindow();
77 void setGeometry(const QRect &rect);
78 void setVisible(bool visible);
79 void setOpacity(qreal level);
81 bool isExposed() const;
83 WId winId() const { return (WId)m_window; }
84 screen_window_t nativeHandle() const { return m_window; }
86 // Called by QQnxGLContext::createSurface()
87 QSize requestedBufferSize() const;
89 void setBufferSize(const QSize &size);
90 QSize bufferSize() const { return m_bufferSize; }
91 bool hasBuffers() const { return !m_bufferSize.isEmpty(); }
93 QQnxBuffer &renderBuffer();
94 void scroll(const QRegion ®ion, int dx, int dy, bool flush=false);
95 void post(const QRegion &dirty);
97 void setScreen(QQnxScreen *platformScreen);
99 void setParent(const QPlatformWindow *window);
102 void requestActivateWindow();
103 Qt::WindowState setWindowState(Qt::WindowState state);
107 QQnxScreen *screen() const { return m_screen; }
108 const QList<QQnxWindow*>& children() const { return m_childWindows; }
111 void setPlatformOpenGLContext(QQnxGLContext *platformOpenGLContext);
112 QQnxGLContext *platformOpenGLContext() const { return m_platformOpenGLContext; }
115 QQnxWindow *findWindow(screen_window_t windowHandle);
118 void removeFromParent();
119 void setOffset(const QPoint &setOffset);
120 void updateVisibility(bool parentVisible);
121 void updateZorder(int &topZorder);
125 void copyBack(const QRegion ®ion, int dx, int dy, bool flush=false);
127 static int platformWindowFormatToNativeFormat(const QSurfaceFormat &format);
129 screen_context_t m_screenContext;
130 screen_window_t m_window;
132 QQnxBuffer m_buffers[MAX_BUFFER_COUNT];
133 int m_currentBufferIndex;
134 int m_previousBufferIndex;
135 QRegion m_previousDirty;
139 QQnxGLContext *m_platformOpenGLContext;
141 QQnxScreen *m_screen;
142 QList<QQnxWindow*> m_childWindows;
143 QQnxWindow *m_parentWindow;
145 QRect m_unmaximizedGeometry;
146 Qt::WindowState m_windowState;
148 // This mutex is used to protect access to the m_requestedBufferSize
149 // member. This member is used in conjunction with QQnxGLContext::requestNewSurface()
150 // to coordinate recreating the EGL surface which involves destroying any
151 // existing EGL surface; resizing the native window buffers; and creating a new
152 // EGL surface. All of this has to be done from the thread that is calling
153 // QQnxGLContext::makeCurrent()
154 mutable QMutex m_mutex;
155 QSize m_requestedBufferSize;
160 #endif // QQNXWINDOW_H