summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRafael Roquetto <rafael.roquetto.qnx@kdab.com>2012-10-29 20:09:18 (GMT)
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-10-30 16:51:52 (GMT)
commit4457a36cfba4e9ce8efba82bad7f4c62abf117fc (patch)
tree211a99a25677c8644d2241bb48bf4b98359270ed /src
parent7301665b57745a0b6d7b551834d603c6aa275b8c (diff)
downloadQt-4457a36cfba4e9ce8efba82bad7f4c62abf117fc.zip
Qt-4457a36cfba4e9ce8efba82bad7f4c62abf117fc.tar.gz
Qt-4457a36cfba4e9ce8efba82bad7f4c62abf117fc.tar.bz2
Blackberry: Fixes QWindowSurface::grabWidget
We are reading from the back buffer instead of the front buffer when grabWidget is called. This adds an override so that we query the front buffer (the last rendered frame). This change is not needed in Qt5 - the api there is different and grabWidget() no longer exists. Change-Id: I691ee589d56b60eab339de536b52fd90cee5ff85 Reviewed-by: Thomas McGuire <thomas.mcguire@kdab.com> Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/platforms/blackberry/qbbrasterwindowsurface.cpp21
-rw-r--r--src/plugins/platforms/blackberry/qbbrasterwindowsurface.h4
-rw-r--r--src/plugins/platforms/blackberry/qbbwindow.cpp32
-rw-r--r--src/plugins/platforms/blackberry/qbbwindow.h14
4 files changed, 66 insertions, 5 deletions
diff --git a/src/plugins/platforms/blackberry/qbbrasterwindowsurface.cpp b/src/plugins/platforms/blackberry/qbbrasterwindowsurface.cpp
index bab2aca..005cca7 100644
--- a/src/plugins/platforms/blackberry/qbbrasterwindowsurface.cpp
+++ b/src/plugins/platforms/blackberry/qbbrasterwindowsurface.cpp
@@ -53,7 +53,8 @@
QT_BEGIN_NAMESPACE
QBBRasterWindowSurface::QBBRasterWindowSurface(QWidget *window)
- : QWindowSurface(window)
+ : QWindowSurface(window),
+ mUseFrontBuffer(false)
{
#if defined(QBBRASTERWINDOWSURFACE_DEBUG)
qDebug() << "QBBRasterWindowSurface::QBBRasterWindowSurface - w=" << window;
@@ -73,7 +74,8 @@ QBBRasterWindowSurface::~QBBRasterWindowSurface()
QPaintDevice *QBBRasterWindowSurface::paintDevice()
{
if (mPlatformWindow->hasBuffers())
- return mPlatformWindow->renderBuffer().image();
+ return (mUseFrontBuffer) ? mPlatformWindow->frontBuffer().image()
+ : mPlatformWindow->renderBuffer().image();
return 0;
}
@@ -171,4 +173,19 @@ void QBBRasterWindowSurface::endPaint(const QRegion &region)
#endif
}
+QPixmap QBBRasterWindowSurface::grabWidget(const QWidget *widget, const QRect &rectangle) const
+{
+ // mUseFrontBuffer is used as a workaround to tell
+ // QBBRasterWindowSurface::paintDevice() to return the
+ // front buffer instead of the renderBuffer. grabWidget()
+ // is the only use case.
+ mUseFrontBuffer = true;
+
+ QPixmap pixmap = QWindowSurface::grabWidget(widget, rectangle);
+
+ mUseFrontBuffer = false;
+
+ return pixmap;
+}
+
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/blackberry/qbbrasterwindowsurface.h b/src/plugins/platforms/blackberry/qbbrasterwindowsurface.h
index 65de3ea..6077113 100644
--- a/src/plugins/platforms/blackberry/qbbrasterwindowsurface.h
+++ b/src/plugins/platforms/blackberry/qbbrasterwindowsurface.h
@@ -63,6 +63,8 @@ public:
virtual void beginPaint(const QRegion &region);
virtual void endPaint(const QRegion &region);
+ virtual QPixmap grabWidget(const QWidget *widget, const QRect &rectangle) const;
+
private:
class ScrollOp {
public:
@@ -72,6 +74,8 @@ private:
int dy;
};
+ mutable bool mUseFrontBuffer;
+
QBBWindow *mPlatformWindow;
QList<ScrollOp> mScrollOpList;
};
diff --git a/src/plugins/platforms/blackberry/qbbwindow.cpp b/src/plugins/platforms/blackberry/qbbwindow.cpp
index 650601d..284aabf 100644
--- a/src/plugins/platforms/blackberry/qbbwindow.cpp
+++ b/src/plugins/platforms/blackberry/qbbwindow.cpp
@@ -336,6 +336,24 @@ QBBBuffer &QBBWindow::renderBuffer()
qDebug() << "QBBWindow::renderBuffer - w=" << widget();
#endif
+ return buffer(BACK_BUFFER);
+}
+
+QBBBuffer &QBBWindow::frontBuffer()
+{
+#if defined(QBBWINDOW_DEBUG)
+ qDebug() << "QBBWindow::frontBuffer - w=" << widget();
+#endif
+
+ return buffer(FRONT_BUFFER);
+}
+
+QBBBuffer &QBBWindow::buffer(QBBWindow::Buffer bufferIndex)
+{
+#if defined(QBBWINDOW_DEBUG)
+ qDebug() << "QBBWindow::buffer - w=" << widget();
+#endif
+
// check if render buffer is invalid
if (mCurrentBufferIndex == -1) {
// check if there are any buffers available
@@ -368,6 +386,20 @@ QBBBuffer &QBBWindow::renderBuffer()
mPreviousBufferIndex = -1;
}
+ if (bufferIndex == BACK_BUFFER) {
+ return mBuffers[mCurrentBufferIndex];
+ } else if (bufferIndex == FRONT_BUFFER) {
+ int buf = mCurrentBufferIndex - 1;
+
+ if (buf < 0)
+ buf = MAX_BUFFER_COUNT - 1;
+
+ return mBuffers[buf];
+ }
+
+ qFatal("QBBWindow::buffer() - invalid buffer index. Aborting");
+
+ // never happens
return mBuffers[mCurrentBufferIndex];
}
diff --git a/src/plugins/platforms/blackberry/qbbwindow.h b/src/plugins/platforms/blackberry/qbbwindow.h
index cdd3e67..8d5f58f 100644
--- a/src/plugins/platforms/blackberry/qbbwindow.h
+++ b/src/plugins/platforms/blackberry/qbbwindow.h
@@ -52,9 +52,6 @@
QT_BEGIN_NAMESPACE
-// all surfaces double buffered
-#define MAX_BUFFER_COUNT 2
-
class QPlatformWindowFormat;
class QBBGLContext;
class QBBScreen;
@@ -77,6 +74,8 @@ public:
bool hasBuffers() const { return !mBufferSize.isEmpty(); }
QBBBuffer &renderBuffer();
+ QBBBuffer &frontBuffer();
+
void scroll(const QRegion &region, int dx, int dy, bool flush=false);
void post(const QRegion &dirty);
@@ -97,6 +96,15 @@ public:
QBBWindow *findWindow(screen_window_t windowHandle);
private:
+
+ enum Buffer {
+ BACK_BUFFER,
+ FRONT_BUFFER,
+ MAX_BUFFER_COUNT
+ };
+
+ QBBBuffer &buffer(QBBWindow::Buffer bufferIndex);
+
screen_context_t mContext;
screen_window_t mWindow;
QSize mBufferSize;