1 /**************************************************************************** 2 ** 3 ** Copyright (C) 2011 - 2012 Research In Motion <blackberry-qt@qnx.com> 4 ** Contact: http://www.qt.io/licensing/ 5 ** 6 ** This file is part of the QtCore module 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 QBBWINDOW_H 43 #define QBBWINDOW_H 44 45 #include "qbbbuffer.h" 46 47 #include <QImage> 48 #include <QtGui/QPlatformWindow> 49 50 #include <screen/screen.h> 51 #include <EGL/egl.h> 52 53 QT_BEGIN_NAMESPACE 54 55 class QPlatformWindowFormat; 56 class QBBGLContext; 57 class QBBScreen; 58 59 class QBBWindow : public QPlatformWindow 60 { 61 friend class QBBScreen; 62 public: 63 QBBWindow(QWidget *window, screen_context_t context, QBBScreen *screen); 64 virtual ~QBBWindow(); 65 66 virtual void setGeometry(const QRect &rect); 67 virtual void setVisible(bool visible); 68 virtual void setOpacity(qreal level); 69 winId()70 virtual WId winId() const { return (WId)mWindow; } 71 72 void setBufferSize(const QSize &size); bufferSize()73 QSize bufferSize() const { return mBufferSize; } hasBuffers()74 bool hasBuffers() const { return !mBufferSize.isEmpty(); } 75 76 QBBBuffer &renderBuffer(); 77 QBBBuffer &frontBuffer(); 78 79 void scroll(const QRegion ®ion, int dx, int dy, bool flush=false); 80 void post(const QRegion &dirty); 81 82 void setScreen(QBBScreen *platformScreen); 83 84 virtual QPlatformGLContext *glContext() const; 85 86 virtual void setParent(const QPlatformWindow *window); 87 virtual void raise(); 88 virtual void lower(); 89 virtual void requestActivateWindow(); 90 91 void gainedFocus(); 92 screen()93 QBBScreen* screen() const { return mScreen; } children()94 const QList<QBBWindow*>& children() const { return mChildren; } 95 96 QBBWindow *findWindow(screen_window_t windowHandle); 97 98 private: 99 100 enum Buffer { 101 BACK_BUFFER, 102 FRONT_BUFFER, 103 MAX_BUFFER_COUNT 104 }; 105 106 QBBBuffer &buffer(QBBWindow::Buffer bufferIndex); 107 108 screen_context_t mContext; 109 screen_window_t mWindow; 110 QSize mBufferSize; 111 QBBBuffer mBuffers[MAX_BUFFER_COUNT]; 112 int mCurrentBufferIndex; 113 int mPreviousBufferIndex; 114 QRegion mPreviousDirty; 115 QRegion mScrolled; 116 117 mutable QBBGLContext* mPlatformGlContext; 118 QBBScreen* mScreen; 119 QList<QBBWindow*> mChildren; 120 QBBWindow *mParent; 121 bool mVisible; 122 123 void removeFromParent(); 124 void offset(const QPoint &offset); 125 void updateVisibility(bool parentVisible); 126 void updateZorder(int &topZorder); 127 128 void fetchBuffers(); 129 130 void copyBack(const QRegion ®ion, int dx, int dy, bool flush=false); 131 132 static int platformWindowFormatToNativeFormat(const QPlatformWindowFormat &format); 133 }; 134 135 QT_END_NAMESPACE 136 137 #endif // QBBWINDOW_H 138