summaryrefslogtreecommitdiffstats
path: root/src/opengl/qwindowsurface_gl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/opengl/qwindowsurface_gl.cpp')
-rw-r--r--src/opengl/qwindowsurface_gl.cpp168
1 files changed, 49 insertions, 119 deletions
diff --git a/src/opengl/qwindowsurface_gl.cpp b/src/opengl/qwindowsurface_gl.cpp
index ff551427ec..d3e7e5178e 100644
--- a/src/opengl/qwindowsurface_gl.cpp
+++ b/src/opengl/qwindowsurface_gl.cpp
@@ -39,11 +39,11 @@
**
****************************************************************************/
-#include <QtGui/QApplication>
+#include <QtWidgets/QApplication>
#include <QtGui/QColormap>
-#include <QtGui/QDesktopWidget>
+#include <QtWidgets/QDesktopWidget>
#include <QtGui/QPaintDevice>
-#include <QtGui/QWidget>
+#include <QtWidgets/QWidget>
#include <qglframebufferobject.h>
#include <qglpixelbuffer.h>
@@ -68,7 +68,6 @@
#include <private/qgl_p.h>
#include <private/qglpixelbuffer_p.h>
-#include <private/qgraphicssystem_gl_p.h>
#include <private/qpaintengineex_opengl2_p.h>
#include <private/qpixmapdata_gl_p.h>
@@ -86,97 +85,11 @@
#include <private/qeglcontext_p.h>
#endif
-QT_BEGIN_NAMESPACE
-
-//
-// QGLGraphicsSystem
-//
-#ifdef Q_WS_WIN
-extern Q_GUI_EXPORT bool qt_win_owndc_required;
+#ifdef Q_WS_QPA
+#include <qplatformscreen_qpa.h>
#endif
-QGLGraphicsSystem::QGLGraphicsSystem(bool useX11GL)
- : QGraphicsSystem(), m_useX11GL(useX11GL)
-{
-#if defined(Q_WS_X11) && !defined(QT_OPENGL_ES)
- // only override the system defaults if the user hasn't already
- // picked a visual
- if (X11->visual == 0 && X11->visual_id == -1 && X11->visual_class == -1) {
- // find a double buffered, RGBA visual that supports OpenGL
- // and set that as the default visual for windows in Qt
- int i = 0;
- int spec[16];
- spec[i++] = GLX_RGBA;
- spec[i++] = GLX_DOUBLEBUFFER;
-
- if (!qgetenv("QT_GL_SWAPBUFFER_PRESERVE").isNull()) {
- spec[i++] = GLX_DEPTH_SIZE;
- spec[i++] = 8;
- spec[i++] = GLX_STENCIL_SIZE;
- spec[i++] = 8;
- spec[i++] = GLX_SAMPLE_BUFFERS_ARB;
- spec[i++] = 1;
- spec[i++] = GLX_SAMPLES_ARB;
- spec[i++] = 4;
- }
-
- spec[i++] = XNone;
-
- XVisualInfo *vi = glXChooseVisual(X11->display, X11->defaultScreen, spec);
- if (vi) {
- X11->visual_id = vi->visualid;
- X11->visual_class = vi->c_class;
-
- QGLFormat format;
- int res;
- glXGetConfig(X11->display, vi, GLX_LEVEL, &res);
- format.setPlane(res);
- glXGetConfig(X11->display, vi, GLX_DOUBLEBUFFER, &res);
- format.setDoubleBuffer(res);
- glXGetConfig(X11->display, vi, GLX_DEPTH_SIZE, &res);
- format.setDepth(res);
- if (format.depth())
- format.setDepthBufferSize(res);
- glXGetConfig(X11->display, vi, GLX_RGBA, &res);
- format.setRgba(res);
- glXGetConfig(X11->display, vi, GLX_RED_SIZE, &res);
- format.setRedBufferSize(res);
- glXGetConfig(X11->display, vi, GLX_GREEN_SIZE, &res);
- format.setGreenBufferSize(res);
- glXGetConfig(X11->display, vi, GLX_BLUE_SIZE, &res);
- format.setBlueBufferSize(res);
- glXGetConfig(X11->display, vi, GLX_ALPHA_SIZE, &res);
- format.setAlpha(res);
- if (format.alpha())
- format.setAlphaBufferSize(res);
- glXGetConfig(X11->display, vi, GLX_ACCUM_RED_SIZE, &res);
- format.setAccum(res);
- if (format.accum())
- format.setAccumBufferSize(res);
- glXGetConfig(X11->display, vi, GLX_STENCIL_SIZE, &res);
- format.setStencil(res);
- if (format.stencil())
- format.setStencilBufferSize(res);
- glXGetConfig(X11->display, vi, GLX_STEREO, &res);
- format.setStereo(res);
- glXGetConfig(X11->display, vi, GLX_SAMPLE_BUFFERS_ARB, &res);
- format.setSampleBuffers(res);
- if (format.sampleBuffers()) {
- glXGetConfig(X11->display, vi, GLX_SAMPLES_ARB, &res);
- format.setSamples(res);
- }
-
- QGLWindowSurface::surfaceFormat = format;
- XFree(vi);
-
- printf("using visual class %x, id %x\n", X11->visual_class, X11->visual_id);
- }
- }
-#elif defined(Q_WS_WIN)
- QGLWindowSurface::surfaceFormat.setDoubleBuffer(true);
- qt_win_owndc_required = true;
-#endif
-}
+QT_BEGIN_NAMESPACE
//
// QGLWindowSurface
@@ -359,7 +272,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
@@ -367,7 +304,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());
@@ -428,6 +365,7 @@ QGLWindowSurface::~QGLWindowSurface()
void QGLWindowSurface::deleted(QObject *object)
{
+#if 0
QWidget *widget = qobject_cast<QWidget *>(object);
if (widget) {
if (widget == window()) {
@@ -450,10 +388,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)
@@ -511,6 +451,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
@@ -528,8 +469,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;
@@ -544,7 +487,10 @@ void QGLWindowSurface::beginPaint(const QRegion &)
int clearFlags = 0;
+#if 0
QGLContext *ctx = reinterpret_cast<QGLContext *>(window()->d_func()->extraData()->glContext);
+#endif
+ const QGLContext *ctx = QGLContext::currentContext();
if (!ctx)
return;
@@ -608,8 +554,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.
@@ -872,7 +819,7 @@ void QGLWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoint &
ctx->swapBuffers();
else
glFlush();
-
+#endif
d_ptr->did_paint = false;
}
@@ -892,6 +839,7 @@ void QGLWindowSurface::resize(const QSize &size)
#endif
void QGLWindowSurface::updateGeometry() {
+#if 0
if (!d_ptr->geometry_updated)
return;
d_ptr->geometry_updated = false;
@@ -1026,6 +974,7 @@ void QGLWindowSurface::updateGeometry() {
#endif
d_ptr->ctx = ctx;
d_ptr->ctx->d_ptr->internal_context = true;
+#endif
}
bool QGLWindowSurface::initializeOffscreenTexture(const QSize &size)
@@ -1047,6 +996,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;
@@ -1075,7 +1025,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;
}
@@ -1140,26 +1090,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;