48 #include <QtGui/QWidget> 50 #include <QtGui/QPlatformWindowFormat> 51 #include <QtGui/QWindowSystemInterface> 60 mCurrentBufferIndex(-1),
61 mPreviousBufferIndex(-1),
62 mPlatformGlContext(NULL),
67 #if defined(QBBWINDOW_DEBUG) 68 qDebug() <<
"QBBWindow::QBBWindow - w=" << window <<
", s=" << window->
size();
74 result = screen_create_window_type(&
mWindow,
mContext, SCREEN_CHILD_WINDOW);
76 qFatal(
"QBBWindow: failed to create window, errno=%d",
errno);
84 val = SCREEN_USAGE_NATIVE | SCREEN_USAGE_READ | SCREEN_USAGE_WRITE;
87 val = SCREEN_USAGE_OPENGL_ES2;
90 qFatal(
"QBBWindow: unsupported window API");
95 result = screen_set_window_property_iv(
mWindow, SCREEN_PROPERTY_USAGE, &val);
97 qFatal(
"QBBWindow: failed to set window buffer usage, errno=%d",
errno);
102 val = SCREEN_PRE_MULTIPLIED_ALPHA;
103 result = screen_set_window_property_iv(
mWindow, SCREEN_PROPERTY_ALPHA_MODE, &val);
105 qFatal(
"QBBWindow: failed to set window alpha mode, errno=%d",
errno);
110 val = SCREEN_TRANSPARENCY_NONE;
111 result = screen_set_window_property_iv(
mWindow, SCREEN_PROPERTY_TRANSPARENCY, &val);
113 qFatal(
"QBBWindow: failed to set window transparency, errno=%d",
errno);
119 result = screen_set_window_property_iv(
mWindow, SCREEN_PROPERTY_SWAP_INTERVAL, &val);
121 qFatal(
"QBBWindow: failed to set window swap interval, errno=%d",
errno);
137 #if defined(QBBWINDOW_DEBUG) 154 screen_destroy_window(
mWindow);
161 #if defined(QBBWINDOW_DEBUG) 162 qDebug() <<
"QBBWindow::setGeometry - w=" <<
widget() <<
", (" << rect.
x() <<
"," << rect.
y() <<
"," << rect.
width() <<
"," << rect.
height() <<
")";
174 int result = screen_set_window_property_iv(
mWindow, SCREEN_PROPERTY_POSITION, val);
176 qFatal(
"QBBWindow: failed to set window position, errno=%d",
errno);
180 val[0] = rect.
width();
182 result = screen_set_window_property_iv(
mWindow, SCREEN_PROPERTY_SIZE, val);
184 qFatal(
"QBBWindow: failed to set window size, errno=%d",
errno);
189 result = screen_set_window_property_iv(
mWindow, SCREEN_PROPERTY_SOURCE_SIZE, val);
191 qFatal(
"QBBWindow: failed to set window source size, errno=%d",
errno);
198 offset -= oldGeometry.
topLeft();
202 (*it)->offset(offset);
219 val[0] = newGeometry.
x();
220 val[1] = newGeometry.
y();
221 int result = screen_set_window_property_iv(
mWindow, SCREEN_PROPERTY_POSITION, val);
223 qFatal(
"QBBWindow: failed to set window position, errno=%d",
errno);
228 (*it)->offset(offset);
234 #if defined(QBBWINDOW_DEBUG) 235 qDebug() <<
"QBBWindow::setVisible - w=" <<
widget() <<
", v=" << visible;
258 int val = (
mVisible && parentVisible) ? 1 : 0;
259 int result = screen_set_window_property_iv(
mWindow, SCREEN_PROPERTY_VISIBLE, &val);
261 qFatal(
"QBBWindow: failed to set window visibility, errno=%d",
errno);
266 (*it)->updateVisibility(
mVisible && parentVisible);
272 #if defined(QBBWINDOW_DEBUG) 273 qDebug() <<
"QBBWindow::setOpacity - w=" <<
widget() <<
", o=" << level;
278 int val = (int)(level * 255);
279 int result = screen_set_window_property_iv(
mWindow, SCREEN_PROPERTY_GLOBAL_ALPHA, &val);
281 qFatal(
"QBBWindow: failed to set window global alpha, errno=%d",
errno);
290 #if defined(QBBWINDOW_DEBUG) 291 qDebug() <<
"QBBWindow::setBufferSize - w=" <<
widget() <<
", s=" << size;
297 int result = screen_set_window_property_iv(
mWindow, SCREEN_PROPERTY_BUFFER_SIZE, val);
299 qFatal(
"QBBWindow: failed to set window buffer size, errno=%d",
errno);
304 #if defined(QBBWINDOW_DEBUG) 305 qDebug() <<
"QBBWindow::setBufferSize - create buffers";
317 result = screen_set_window_property_iv(
mWindow, SCREEN_PROPERTY_FORMAT, val);
319 qFatal(
"QBBWindow: failed to set window pixel format, errno=%d",
errno);
325 qFatal(
"QBBWindow: failed to create window buffers, errno=%d",
errno);
330 result = screen_get_window_property_iv(
mWindow, SCREEN_PROPERTY_RENDER_BUFFER_COUNT, &bufferCount);
333 qFatal(
"QBBWindow: failed to query window buffer count, errno=%d",
errno);
352 #if defined(QBBWINDOW_DEBUG) 361 #if defined(QBBWINDOW_DEBUG) 370 #if defined(QBBWINDOW_DEBUG) 379 const int result = screen_get_window_property_pv(
mWindow, SCREEN_PROPERTY_RENDER_BUFFERS, (
void **)buffers);
381 qFatal(
"QBBWindow: failed to query window buffers, errno=%d",
errno);
405 qFatal(
"QBBWindow::buffer() - invalid buffer index. Aborting");
422 #if defined(QBBWINDOW_DEBUG) 435 int dirtyRect[4] = { rect.
x(), rect.
y(), rect.
x() + rect.
width(), rect.
y() + rect.
height() };
441 qFatal(
"QBBWindow: failed to post window buffer, errno=%d",
errno);
463 #if defined(QBBWINDOW_DEBUG) 476 #if defined(QBBWINDOW_DEBUG) 495 int result = screen_set_window_property_pv(
mWindow, SCREEN_PROPERTY_DISPLAY, (
void **)&display);
497 qFatal(
"QBBWindow: failed to set window display, errno=%d",
errno);
504 qFatal(
"QBBWindow: failed to join window group, errno=%d",
errno);
513 (*it)->setScreen(platformScreen);
526 qFatal(
"QBBWindow: Window Hierarchy broken; window has parent, but parent hasn't got child.");
534 #if defined(QBBWINDOW_DEBUG) 565 #if defined(QBBWINDOW_DEBUG) 581 #if defined(QBBWINDOW_DEBUG) 597 #if defined(QBBWINDOW_DEBUG) 598 qDebug() <<
"QBBWindow::requestActivateWindow - w=" <<
widget();
609 #if defined(QBBWINDOW_DEBUG) 634 int result = screen_set_window_property_iv(
mWindow, SCREEN_PROPERTY_ZORDER, &topZorder);
638 qFatal(
"QBBWindow: failed to set window z-order=%d, errno=%d, mWindow=0x%08x", topZorder,
errno,
mWindow);
643 (*it)->updateZorder(topZorder);
665 for (
int i = rects.
size() - 1; i >= 0; i--) {
668 QRect rect = rects[i].intersected( currentBuffer.
rect() );
674 int attribs[] = { SCREEN_BLIT_SOURCE_X, rect.
x(),
675 SCREEN_BLIT_SOURCE_Y, rect.
y(),
676 SCREEN_BLIT_SOURCE_WIDTH, rect.
width(),
677 SCREEN_BLIT_SOURCE_HEIGHT, rect.
height(),
678 SCREEN_BLIT_DESTINATION_X, rect.
x() + dx,
679 SCREEN_BLIT_DESTINATION_Y, rect.
y() + dy,
680 SCREEN_BLIT_DESTINATION_WIDTH, rect.
width(),
681 SCREEN_BLIT_DESTINATION_HEIGHT, rect.
height(),
688 qFatal(
"QBBWindow: failed to blit buffers, errno=%d",
errno);
697 result = screen_flush_blits(
mContext, SCREEN_WAIT_IDLE);
699 qFatal(
"QBBWindow: failed to flush blits, errno=%d",
errno);
712 qFatal(
"QBBWindow: red size not defined");
716 if (greenSize == -1) {
717 qFatal(
"QBBWindow: green size not defined");
721 if (blueSize == -1) {
722 qFatal(
"QBBWindow: blue size not defined");
726 if (redSize == 5 && greenSize == 6 && blueSize == 5) {
727 return SCREEN_FORMAT_RGB565;
728 }
else if (redSize == 8 && greenSize == 8 && blueSize == 8) {
729 return SCREEN_FORMAT_RGBA8888;
731 qFatal(
"QBBWindow: unsupported pixel format");
void push_front(const T &t)
This function is provided for STL compatibility.
void push_back(const T &t)
This function is provided for STL compatibility.
virtual QPlatformWindowFormat platformWindowFormat() const
QWidget has the function qplatformWindowFormat().
#define QT_END_NAMESPACE
This macro expands to.
void onWindowPost(QBBWindow *window)
void setScreen(QBBScreen *platformScreen)
virtual void lower()
Reimplement to be able to let Qt lower windows to the bottom of the desktop.
#define it(className, varName)
QBBWindow(QWidget *window, screen_context_t context, QBBScreen *screen)
virtual void requestActivateWindow()
Reimplement to let Qt be able to request activation/focus for a window.
virtual void setParent(const QPlatformWindow *window)
This function is called to enable native child widgets in QPA.
void offset(const QPoint &offset)
iterator begin()
Returns an STL-style iterator pointing to the first item in the list.
int width() const
Returns the width of the rectangle.
The QList::const_iterator class provides an STL-style const iterator for QList and QQueue...
void updateVisibility(bool parentVisible)
void ensureDisplayCreated()
void setBufferSize(const QSize &size)
QRect boundingRect() const
Returns the bounding rectangle of this region.
void lowerWindow(QBBWindow *window)
int height() const
Returns the height of the rectangle.
virtual void raise()
Reimplement to be able to let Qt rais windows to the top of the desktop.
Q_CORE_EXPORT void qDebug(const char *,...)
int width() const
Returns the width.
void addWindow(QBBWindow *child)
#define QT_BEGIN_NAMESPACE
This macro expands to.
Q_GUI_EXPORT EGLDisplay display()
void raiseWindow(QBBWindow *window)
const char * windowGroupName() const
QList< QBBWindow * > mChildren
static void handleWindowActivated(QWidget *w)
bool isEmpty() const
Returns true if the region is empty; otherwise returns false.
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the list...
QBBBuffer mBuffers[MAX_BUFFER_COUNT]
void post(const QRegion &dirty)
The QRegion class specifies a clip region for a painter.
static int platformWindowFormatToNativeFormat(const QPlatformWindowFormat &format)
virtual void setVisible(bool visible)
Reimplemented in subclasses to show the surface if visible is true, and hide it if visible is false...
QBBBuffer & renderBuffer()
virtual void setGeometry(const QRect &rect)
This function is called by Qt whenever a window is moved or the window is resized.
The QList::iterator class provides an STL-style non-const iterator for QList and QQueue.
bool isEmpty() const
Returns true if the rectangle is empty, otherwise returns false.
screen_display_t nativeDisplay() const
Q_CORE_EXPORT void qFatal(const char *,...)
The QPlatformGLContext class provides an abstraction for native GL contexts.
void scroll(const QRegion ®ion, int dx, int dy, bool flush=false)
void copyBack(const QRegion ®ion, int dx, int dy, bool flush=false)
QBBBuffer & buffer(QBBWindow::Buffer bufferIndex)
int y() const
Returns the y-coordinate of the rectangle's top edge.
virtual QPlatformGLContext * glContext() const
Reimplement to return the glContext associated with the window.
void removeWindow(QBBWindow *child)
int x() const
Returns the x-coordinate of the rectangle's left edge.
The QPoint class defines a point in the plane using integer precision.
QVector< QRect > rects() const
Returns an array of non-overlapping rectangles that make up the region.
int size() const
Returns the number of items in the list.
screen_context_t mContext
void updateZorder(int &topZorder)
int height() const
Returns the height.
The QRect class defines a rectangle in the plane using integer precision.
QBBBuffer & frontBuffer()
Q_CORE_EXPORT QTextStream & flush(QTextStream &s)
#define Q_FOREACH(variable, container)
Same as foreach(variable, container).
The QSize class defines the size of a two-dimensional object using integer point precision.
virtual void setOpacity(qreal level)
Reimplement to be able to let Qt set the opacity level of a window.
QBBWindow * findWindow(screen_window_t windowHandle)
screen_buffer_t nativeBuffer() const
void translate(int dx, int dy)
Moves the rectangle dx along the x axis and dy along the y axis, relative to the current position...
int size() const
Returns the number of items in the vector.
QBBGLContext * mPlatformGlContext
QPoint topLeft() const
Returns the position of the rectangle's top-left corner.
int removeAll(const T &t)
Removes all occurrences of value in the list and returns the number of entries removed.