summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Cooksey <thomas.cooksey@nokia.com>2010-03-01 11:59:34 (GMT)
committerTom Cooksey <thomas.cooksey@nokia.com>2010-03-02 08:24:25 (GMT)
commitf936cc4e2a7b377981a626b1d45dbbb1c1df1cb8 (patch)
tree2947cac05c037279c92563d99f1362c141760e7a
parenta2eddea1432d6e558dcd620cd5100ce4531975e8 (diff)
downloadQt-f936cc4e2a7b377981a626b1d45dbbb1c1df1cb8.zip
Qt-f936cc4e2a7b377981a626b1d45dbbb1c1df1cb8.tar.gz
Qt-f936cc4e2a7b377981a626b1d45dbbb1c1df1cb8.tar.bz2
Move EGL surface type setting to new QEglProperties::setDeviceType
Also renamed qt_egl_set_format->qt_eglproperties_set_glformat Reviewed-By: TrustMe
-rw-r--r--src/gui/egl/qeglproperties.cpp11
-rw-r--r--src/gui/egl/qeglproperties_p.h4
-rw-r--r--src/opengl/qgl_egl.cpp62
-rw-r--r--src/opengl/qgl_egl_p.h2
-rw-r--r--src/opengl/qgl_qws.cpp3
-rw-r--r--src/opengl/qgl_wince.cpp3
-rw-r--r--src/opengl/qgl_x11egl.cpp3
-rw-r--r--src/opengl/qglpixelbuffer_egl.cpp6
8 files changed, 53 insertions, 41 deletions
diff --git a/src/gui/egl/qeglproperties.cpp b/src/gui/egl/qeglproperties.cpp
index e0e8481..636f469 100644
--- a/src/gui/egl/qeglproperties.cpp
+++ b/src/gui/egl/qeglproperties.cpp
@@ -167,6 +167,17 @@ bool QEglProperties::removeValue(int name)
return false;
}
+void QEglProperties::setDeviceType(int devType)
+{
+ if (devType == QInternal::Pixmap || devType == QInternal::Image)
+ setValue(EGL_SURFACE_TYPE, EGL_PIXMAP_BIT);
+ else if (devType == QInternal::Pbuffer)
+ setValue(EGL_SURFACE_TYPE, EGL_PBUFFER_BIT);
+ else
+ setValue(EGL_SURFACE_TYPE, EGL_WINDOW_BIT);
+}
+
+
// Sets the red, green, blue, and alpha sizes based on a pixel format.
// Normally used to match a configuration request to the screen format.
void QEglProperties::setPixelFormat(QImage::Format pixelFormat)
diff --git a/src/gui/egl/qeglproperties_p.h b/src/gui/egl/qeglproperties_p.h
index 496847b..eebcf72 100644
--- a/src/gui/egl/qeglproperties_p.h
+++ b/src/gui/egl/qeglproperties_p.h
@@ -82,9 +82,9 @@ public:
#ifdef Q_WS_X11
void setVisualFormat(const QX11Info *xinfo);
#endif
- void setRenderableType(QEgl::API api);
-
+ void setDeviceType(int devType);
void setPaintDeviceFormat(QPaintDevice *dev);
+ void setRenderableType(QEgl::API api);
bool reduceConfiguration();
diff --git a/src/opengl/qgl_egl.cpp b/src/opengl/qgl_egl.cpp
index 90fb2bb..f1abab8 100644
--- a/src/opengl/qgl_egl.cpp
+++ b/src/opengl/qgl_egl.cpp
@@ -45,44 +45,40 @@
QT_BEGIN_NAMESPACE
-// Set device configuration attributes from a QGLFormat instance.
-void qt_egl_set_format(QEglProperties& props, int deviceType, const QGLFormat& f)
+void qt_eglproperties_set_glformat(QEglProperties& eglProperties, const QGLFormat& glFormat)
{
- if (deviceType == QInternal::Pixmap || deviceType == QInternal::Image)
- props.setValue(EGL_SURFACE_TYPE, EGL_PIXMAP_BIT);
- else if (deviceType == QInternal::Pbuffer)
- props.setValue(EGL_SURFACE_TYPE, EGL_PBUFFER_BIT);
- else
- props.setValue(EGL_SURFACE_TYPE, EGL_WINDOW_BIT);
-
- // Set the pixel format to that contained in the QGLFormat
- // if the system hasn't already chosen a fixed format to
- // match the pixmap, widget, etc.
- if (props.value(EGL_RED_SIZE) == 0 || f.redBufferSize() != -1)
- props.setValue(EGL_RED_SIZE, f.redBufferSize() == -1 ? 1 : f.redBufferSize());
- if (props.value(EGL_GREEN_SIZE) == 0 || f.greenBufferSize() != -1)
- props.setValue(EGL_GREEN_SIZE, f.greenBufferSize() == -1 ? 1 : f.greenBufferSize());
- if (props.value(EGL_BLUE_SIZE) == 0 || f.blueBufferSize() != -1)
- props.setValue(EGL_BLUE_SIZE, f.blueBufferSize() == -1 ? 1 : f.blueBufferSize());
- if (f.alpha()) {
- if (props.value(EGL_ALPHA_SIZE) == 0 || f.alphaBufferSize() != -1)
- props.setValue(EGL_ALPHA_SIZE, f.alphaBufferSize() == -1 ? 1 : f.alphaBufferSize());
+ // NOTE: QGLFormat uses a magic value of -1 to indicate "don't care", even when a buffer of that
+ // type has been requested.
+ if (glFormat.depth()) {
+ int depthSize = glFormat.depthBufferSize();
+ eglProperties.setValue(EGL_DEPTH_SIZE, depthSize == -1 ? 1 : depthSize);
}
-
- if (f.depth())
- props.setValue(EGL_DEPTH_SIZE, f.depthBufferSize() == -1 ? 1 : f.depthBufferSize());
- if (f.stencil())
- props.setValue(EGL_STENCIL_SIZE, f.stencilBufferSize() == -1 ? 1 : f.stencilBufferSize());
- if (f.sampleBuffers()) {
- props.setValue(EGL_SAMPLE_BUFFERS, 1);
- props.setValue(EGL_SAMPLES, f.samples() == -1 ? 1 : f.samples());
- } else {
- props.setValue(EGL_SAMPLE_BUFFERS, 0);
+ if (glFormat.stencil()) {
+ int stencilSize = glFormat.stencilBufferSize();
+ eglProperties.setValue(EGL_STENCIL_SIZE, stencilSize == -1 ? 1 : stencilSize);
+ }
+ if (glFormat.sampleBuffers()) {
+ int sampleCount = glFormat.samples();
+ eglProperties.setValue(EGL_SAMPLES, sampleCount == -1 ? 1 : sampleCount);
+ eglProperties.setValue(EGL_SAMPLE_BUFFERS, 1);
+ }
+ if (glFormat.alpha()) {
+ int alphaSize = glFormat.alphaBufferSize();
+ eglProperties.setValue(EGL_ALPHA_SIZE, alphaSize == -1 ? 1 : alphaSize);
}
- if (deviceType == QInternal::Widget)
- props.setValue(EGL_LEVEL, f.plane());
+
+ int redSize = glFormat.redBufferSize();
+ int greenSize = glFormat.greenBufferSize();
+ int blueSize = glFormat.blueBufferSize();
+ int alphaSize = glFormat.alphaBufferSize();
+
+ eglProperties.setValue(EGL_RED_SIZE, redSize > 0 ? redSize : 1);
+ eglProperties.setValue(EGL_GREEN_SIZE, greenSize > 0 ? greenSize : 1);
+ eglProperties.setValue(EGL_BLUE_SIZE, blueSize > 0 ? blueSize : 1);
+ eglProperties.setValue(EGL_ALPHA_SIZE, alphaSize > 0 ? alphaSize : 0);
}
+
// Updates "format" with the parameters of the selected configuration.
void qt_egl_update_format(const QEglContext& context, QGLFormat& format)
{
diff --git a/src/opengl/qgl_egl_p.h b/src/opengl/qgl_egl_p.h
index 1d8cbf1..6b65227 100644
--- a/src/opengl/qgl_egl_p.h
+++ b/src/opengl/qgl_egl_p.h
@@ -60,7 +60,7 @@ QT_BEGIN_NAMESPACE
class QGLFormat;
-void qt_egl_set_format(QEglProperties& props, int deviceType, const QGLFormat& f);
+void qt_eglproperties_set_glformat(QEglProperties& props, const QGLFormat& format);
void qt_egl_update_format(const QEglContext& context, QGLFormat& format);
QT_END_NAMESPACE
diff --git a/src/opengl/qgl_qws.cpp b/src/opengl/qgl_qws.cpp
index c221134..f72f051 100644
--- a/src/opengl/qgl_qws.cpp
+++ b/src/opengl/qgl_qws.cpp
@@ -186,7 +186,8 @@ bool QGLContext::chooseContext(const QGLContext* shareContext)
// Construct the configuration we need for this surface.
QEglProperties configProps;
- qt_egl_set_format(configProps, devType, d->glFormat);
+ qt_eglproperties_set_glformat(configProps, d->glFormat);
+ configProps.setDeviceType(devType);
configProps.setPaintDeviceFormat(device());
configProps.setRenderableType(QEgl::OpenGL);
diff --git a/src/opengl/qgl_wince.cpp b/src/opengl/qgl_wince.cpp
index ed8b4f7..3bf7f3a 100644
--- a/src/opengl/qgl_wince.cpp
+++ b/src/opengl/qgl_wince.cpp
@@ -149,7 +149,8 @@ bool QGLContext::chooseContext(const QGLContext* shareContext)
// Construct the configuration we need for this surface.
QEglProperties configProps;
- qt_egl_set_format(configProps, devType, d->glFormat);
+ qt_eglproperties_set_glformat(configProps, d->glFormat);
+ configProps.setDeviceType(devType);
configProps.setPaintDeviceFormat(device());
configProps.setRenderableType(QEgl::OpenGL);
diff --git a/src/opengl/qgl_x11egl.cpp b/src/opengl/qgl_x11egl.cpp
index 21ddfe3..7be4973 100644
--- a/src/opengl/qgl_x11egl.cpp
+++ b/src/opengl/qgl_x11egl.cpp
@@ -171,7 +171,8 @@ bool QGLContext::chooseContext(const QGLContext* shareContext)
// Construct the configuration we need for this surface.
QEglProperties configProps;
- qt_egl_set_format(configProps, devType, d->glFormat);
+ qt_eglproperties_set_glformat(configProps, d->glFormat);
+ configProps.setDeviceType(devType);
configProps.setPaintDeviceFormat(device());
configProps.setRenderableType(QEgl::OpenGL);
diff --git a/src/opengl/qglpixelbuffer_egl.cpp b/src/opengl/qglpixelbuffer_egl.cpp
index cee5a1f..ee0714f 100644
--- a/src/opengl/qglpixelbuffer_egl.cpp
+++ b/src/opengl/qglpixelbuffer_egl.cpp
@@ -82,7 +82,8 @@ bool QGLPixelBufferPrivate::init(const QSize &size, const QGLFormat &f, QGLWidge
#endif
} else {
QEglProperties configProps;
- qt_egl_set_format(configProps, QInternal::Pbuffer, f);
+ qt_eglproperties_set_glformat(configProps, f);
+ configProps.setDeviceType(QInternal::Pbuffer);
configProps.setRenderableType(ctx->api());
bool ok = false;
#if QGL_RENDER_TEXTURE
@@ -208,7 +209,8 @@ bool QGLPixelBuffer::hasOpenGLPbuffers()
if (dpy == EGL_NO_DISPLAY)
return false;
QEglProperties configProps;
- qt_egl_set_format(configProps, QInternal::Pbuffer, QGLFormat::defaultFormat());
+ qt_eglproperties_set_glformat(configProps, QGLFormat::defaultFormat());
+ configProps.setDeviceType(QInternal::Pbuffer);
configProps.setRenderableType(QEgl::OpenGL);
do {
EGLConfig cfg = 0;