summaryrefslogtreecommitdiffstats
path: root/src/opengl
diff options
context:
space:
mode:
Diffstat (limited to 'src/opengl')
-rw-r--r--src/opengl/qgraphicssystem_gl.cpp22
-rw-r--r--src/opengl/qgraphicssystem_gl_p.h2
-rw-r--r--src/opengl/qwindowsurface_gl.cpp70
-rw-r--r--src/opengl/qwindowsurface_gl_p.h10
4 files changed, 53 insertions, 51 deletions
diff --git a/src/opengl/qgraphicssystem_gl.cpp b/src/opengl/qgraphicssystem_gl.cpp
index 0aa3c2e6c7..662fa56cb5 100644
--- a/src/opengl/qgraphicssystem_gl.cpp
+++ b/src/opengl/qgraphicssystem_gl.cpp
@@ -70,28 +70,14 @@ QPixmapData *QGLGraphicsSystem::createPixmapData(QPixmapData::PixelType type) co
return new QGLPixmapData(type);
}
-QWindowSurface *QGLGraphicsSystem::createWindowSurface(QWidget *widget) const
+QWindowSurface *QGLGraphicsSystem::createWindowSurface(QWindow *window) const
{
#ifdef Q_WS_WIN
// On Windows the QGLWindowSurface class can't handle
// drop shadows and native effects, e.g. fading a menu in/out using
// top level window opacity.
- if (widget->windowType() == Qt::Popup)
- return new QRasterWindowSurface(widget);
-#endif
-
-#if defined(Q_WS_X11) && !defined(QT_NO_EGL)
- if (m_useX11GL && QX11GLPixmapData::hasX11GLPixmaps()) {
- // If the widget is a QGraphicsView which will be re-drawing the entire
- // scene each frame anyway, we should use QGLWindowSurface as this may
- // provide proper buffer flipping, which should be faster than QX11GL's
- // blitting approach:
- QGraphicsView* qgv = qobject_cast<QGraphicsView*>(widget);
- if (qgv && qgv->viewportUpdateMode() == QGraphicsView::FullViewportUpdate)
- return new QGLWindowSurface(widget);
- else
- return new QX11GLWindowSurface(widget);
- }
+ if (window->windowType() == Qt::Popup)
+ return new QRasterWindowSurface(window);
#endif
#if defined(Q_OS_SYMBIAN)
@@ -102,7 +88,7 @@ QWindowSurface *QGLGraphicsSystem::createWindowSurface(QWidget *widget) const
}
#endif
- return new QGLWindowSurface(widget);
+ return new QGLWindowSurface(window);
}
#ifdef QGL_USE_TEXTURE_POOL
void QGLGraphicsSystem::releaseCachedResources()
diff --git a/src/opengl/qgraphicssystem_gl_p.h b/src/opengl/qgraphicssystem_gl_p.h
index 5829dccea9..40c6013d14 100644
--- a/src/opengl/qgraphicssystem_gl_p.h
+++ b/src/opengl/qgraphicssystem_gl_p.h
@@ -65,7 +65,7 @@ public:
QGLGraphicsSystem(bool useX11GL);
QPixmapData *createPixmapData(QPixmapData::PixelType type) const;
- QWindowSurface *createWindowSurface(QWidget *widget) const;
+ QWindowSurface *createWindowSurface(QWindow *window) const;
#ifdef QGL_USE_TEXTURE_POOL
void releaseCachedResources();
diff --git a/src/opengl/qwindowsurface_gl.cpp b/src/opengl/qwindowsurface_gl.cpp
index 56e2c3b517..c73172784a 100644
--- a/src/opengl/qwindowsurface_gl.cpp
+++ b/src/opengl/qwindowsurface_gl.cpp
@@ -86,6 +86,10 @@
#include <private/qeglcontext_p.h>
#endif
+#ifdef Q_WS_QPA
+#include <qplatformscreen_qpa.h>
+#endif
+
QT_BEGIN_NAMESPACE
//
@@ -353,7 +357,31 @@ QGLContext* QGLWindowSurfaceGLPaintDevice::context() const
int QGLWindowSurfaceGLPaintDevice::metric(PaintDeviceMetric m) const
{
- return qt_paint_device_metric(d->q_ptr->window(), m);
+ QWindow *window = d->q_ptr->window();
+ QPlatformScreen *screen = QPlatformScreen::platformScreenForWindow(window);
+ if (!screen) {
+ if (m == PdmDpiX || m == PdmDpiY)
+ return 72;
+ }
+ int val;
+ if (m == PdmWidth) {
+ val = window->geometry().width();
+ } else if (m == PdmWidthMM) {
+ val = window->geometry().width() * screen->physicalSize().width() / screen->geometry().width();
+ } else if (m == PdmHeight) {
+ val = window->geometry().height();
+ } else if (m == PdmHeightMM) {
+ val = window->geometry().height() * screen->physicalSize().height() / screen->geometry().height();
+ } else if (m == PdmDepth) {
+ val = screen->depth();
+ } else if (m == PdmDpiX || m == PdmPhysicalDpiX) {
+ val = qRound(screen->geometry().width() / double(screen->physicalSize().width() / 25.4));
+ } else if (m == PdmDpiY || m == PdmPhysicalDpiY) {
+ val = qRound(screen->geometry().height() / double(screen->physicalSize().height() / 25.4));
+ } else {
+ val = 1 << qMax(24, screen->depth());
+ }
+ return val;
}
QPaintEngine *QGLWindowSurfaceGLPaintDevice::paintEngine() const
@@ -361,7 +389,7 @@ QPaintEngine *QGLWindowSurfaceGLPaintDevice::paintEngine() const
return qt_qgl_paint_engine();
}
-QGLWindowSurface::QGLWindowSurface(QWidget *window)
+QGLWindowSurface::QGLWindowSurface(QWindow *window)
: QWindowSurface(window), d_ptr(new QGLWindowSurfacePrivate)
{
// Q_ASSERT(window->isTopLevel());
@@ -422,6 +450,7 @@ QGLWindowSurface::~QGLWindowSurface()
void QGLWindowSurface::deleted(QObject *object)
{
+#if 0
QWidget *widget = qobject_cast<QWidget *>(object);
if (widget) {
if (widget == window()) {
@@ -444,10 +473,12 @@ void QGLWindowSurface::deleted(QObject *object)
}
#endif
}
+#endif
}
-void QGLWindowSurface::hijackWindow(QWidget *widget)
+void QGLWindowSurface::hijackWindow(QWindow *window)
{
+#if 0
QWidgetPrivate *widgetPrivate = widget->d_func();
widgetPrivate->createExtra();
if (widgetPrivate->extraData()->glContext)
@@ -505,6 +536,7 @@ void QGLWindowSurface::hijackWindow(QWidget *widget)
#ifndef Q_OS_SYMBIAN
qDebug() << "hijackWindow() context created for" << widget << d_ptr->contexts.size();
#endif
+#endif
}
QGLContext *QGLWindowSurface::context() const
@@ -522,8 +554,10 @@ QPaintDevice *QGLWindowSurface::paintDevice()
if (d_ptr->ctx)
return &d_ptr->glDevice;
+#if 0
QGLContext *ctx = reinterpret_cast<QGLContext *>(window()->d_func()->extraData()->glContext);
ctx->makeCurrent();
+#endif
Q_ASSERT(d_ptr->fbo);
return d_ptr->fbo;
@@ -594,8 +628,9 @@ static void blitTexture(QGLContext *ctx, GLuint texture, const QSize &viewport,
}
-void QGLWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoint &offset)
+void QGLWindowSurface::flush(QWindow *window, const QRegion &rgn, const QPoint &offset)
{
+#if 0
//### Find out why d_ptr->geometry_updated isn't always false.
// flush() should not be called when d_ptr->geometry_updated is true. It assumes that either
// d_ptr->fbo or d_ptr->pb is allocated and has the correct size.
@@ -847,7 +882,7 @@ void QGLWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoint &
ctx->swapBuffers();
else
glFlush();
-
+#endif
d_ptr->did_paint = false;
}
@@ -867,6 +902,7 @@ void QGLWindowSurface::resize(const QSize &size)
#endif
void QGLWindowSurface::updateGeometry() {
+#if 0
if (!d_ptr->geometry_updated)
return;
d_ptr->geometry_updated = false;
@@ -1001,6 +1037,7 @@ void QGLWindowSurface::updateGeometry() {
#endif
d_ptr->ctx = ctx;
d_ptr->ctx->d_ptr->internal_context = true;
+#endif
}
bool QGLWindowSurface::initializeOffscreenTexture(const QSize &size)
@@ -1022,6 +1059,7 @@ bool QGLWindowSurface::initializeOffscreenTexture(const QSize &size)
bool QGLWindowSurface::scroll(const QRegion &area, int dx, int dy)
{
+#if 0
// this code randomly fails currently for unknown reasons
return false;
@@ -1050,7 +1088,7 @@ bool QGLWindowSurface::scroll(const QRegion &area, int dx, int dy)
glBindTexture(target, 0);
drawTexture(br.translated(dx, dy), d_ptr->tex_id, window()->size());
-
+#endif
return true;
}
@@ -1115,26 +1153,6 @@ static void drawTexture(const QRectF &rect, GLuint tex_id, const QSize &texSize,
#endif
}
-QImage *QGLWindowSurface::buffer(const QWidget *widget)
-{
- QImage image;
-
- if (d_ptr->pb)
- image = d_ptr->pb->toImage();
- else if (d_ptr->fbo)
- image = d_ptr->fbo->toImage();
-
- if (image.isNull())
- return 0;
-
- QRect rect = widget->rect();
- rect.translate(widget->mapTo(widget->window(), QPoint()));
-
- QImage subImage = image.copy(rect);
- d_ptr->buffers << subImage;
- return &d_ptr->buffers.last();
-}
-
QWindowSurface::WindowSurfaceFeatures QGLWindowSurface::features() const
{
WindowSurfaceFeatures features = 0;
diff --git a/src/opengl/qwindowsurface_gl_p.h b/src/opengl/qwindowsurface_gl_p.h
index c71ce59c4d..8dc3a4583a 100644
--- a/src/opengl/qwindowsurface_gl_p.h
+++ b/src/opengl/qwindowsurface_gl_p.h
@@ -63,7 +63,7 @@ QT_BEGIN_NAMESPACE
class QPaintDevice;
class QPoint;
class QRegion;
-class QWidget;
+class QWindow;
struct QGLWindowSurfacePrivate;
Q_OPENGL_EXPORT QGLWidget* qt_gl_share_widget();
@@ -84,11 +84,11 @@ class Q_OPENGL_EXPORT QGLWindowSurface : public QObject, public QWindowSurface /
{
Q_OBJECT
public:
- QGLWindowSurface(QWidget *window);
+ QGLWindowSurface(QWindow *window);
~QGLWindowSurface();
QPaintDevice *paintDevice();
- void flush(QWidget *widget, const QRegion &region, const QPoint &offset);
+ void flush(QWindow *window, const QRegion &region, const QPoint &offset);
#if !defined(Q_WS_QPA)
void setGeometry(const QRect &rect);
@@ -102,8 +102,6 @@ public:
void beginPaint(const QRegion &region);
void endPaint(const QRegion &region);
- QImage *buffer(const QWidget *widget);
-
WindowSurfaceFeatures features() const;
QGLContext *context() const;
@@ -117,7 +115,7 @@ private slots:
void deleted(QObject *object);
private:
- void hijackWindow(QWidget *widget);
+ void hijackWindow(QWindow *window);
bool initializeOffscreenTexture(const QSize &size);
QGLWindowSurfacePrivate *d_ptr;