From 73a9e0a7657112cac94107f771c33270467eff08 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Fri, 23 Sep 2011 16:24:06 +0200 Subject: [PATCH] Make surface format plugable from the scene graph plugin Also enable depth, stencil and samples by default as our default renderer requires both depth and stencil and our default rounded rectangles require multisampling The user should be able to override the default format, by getting the QSGCanvas::format(), modify it and set it back, but this is currently not supported in QWindow, so that will have to wait Change-Id: I1869003705709987ab2e9a3cebbeeec4d45a2021 Reviewed-on: http://codereview.qt-project.org/5464 Reviewed-by: Qt Sanity Bot Reviewed-by: Gunnar Sletta --- src/declarative/items/qsgcanvas.cpp | 3 ++- src/declarative/scenegraph/qsgcontext.cpp | 10 ++++++++++ src/declarative/scenegraph/qsgcontext_p.h | 10 +++++++--- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/declarative/items/qsgcanvas.cpp b/src/declarative/items/qsgcanvas.cpp index 749099c..8e5d1ec 100644 --- a/src/declarative/items/qsgcanvas.cpp +++ b/src/declarative/items/qsgcanvas.cpp @@ -459,6 +459,7 @@ void QSGCanvasPrivate::init(QSGCanvas *c) thread->moveContextToThread(context); q->setSurfaceType(QWindow::OpenGLSurface); + q->setFormat(context->defaultSurfaceFormat()); } void QSGCanvasPrivate::transformTouchPoints(QList &touchPoints, const QTransform &transform) @@ -1831,7 +1832,7 @@ QImage QSGCanvas::grabFrameBuffer() void QSGCanvasRenderLoop::createGLContext() { gl = new QOpenGLContext(); - gl->setFormat(renderer->format()); + gl->setFormat(d->context->defaultSurfaceFormat()); gl->create(); } diff --git a/src/declarative/scenegraph/qsgcontext.cpp b/src/declarative/scenegraph/qsgcontext.cpp index 7adbb32..9016b81 100644 --- a/src/declarative/scenegraph/qsgcontext.cpp +++ b/src/declarative/scenegraph/qsgcontext.cpp @@ -380,6 +380,16 @@ QSGTexture *QSGContext::decodeImageToTexture(QIODevice *dev, +QSurfaceFormat QSGContext::defaultSurfaceFormat() const +{ + QSurfaceFormat format; + format.setDepthBufferSize(24); + format.setStencilBufferSize(8); + format.setSamples(16); + return format; +} + + /*! Factory function for texture objects. diff --git a/src/declarative/scenegraph/qsgcontext_p.h b/src/declarative/scenegraph/qsgcontext_p.h index a05854e..6fdd4ae 100644 --- a/src/declarative/scenegraph/qsgcontext_p.h +++ b/src/declarative/scenegraph/qsgcontext_p.h @@ -42,9 +42,11 @@ #ifndef QSGCONTEXT_H #define QSGCONTEXT_H -#include -#include -#include +#include +#include + +#include +#include #include "qsgnode.h" @@ -105,6 +107,8 @@ public: virtual QSGTexture *createTexture(const QImage &image = QImage()) const; virtual QSize minimumFBOSize() const; + virtual QSurfaceFormat defaultSurfaceFormat() const; + static QSGContext *createDefaultContext(); void scheduleTextureForCleanup(QSGTexture *texture); -- 2.7.4