diff options
Diffstat (limited to 'src/quick/items/context2d')
7 files changed, 65 insertions, 31 deletions
diff --git a/src/quick/items/context2d/qquickcanvasitem.cpp b/src/quick/items/context2d/qquickcanvasitem.cpp index 68f465cc5a..6603d8158d 100644 --- a/src/quick/items/context2d/qquickcanvasitem.cpp +++ b/src/quick/items/context2d/qquickcanvasitem.cpp @@ -795,11 +795,13 @@ QSGTextureProvider *QQuickCanvasItem::textureProvider() const return QQuickItem::textureProvider(); Q_D(const QQuickCanvasItem); +#ifndef QT_NO_OPENGL QQuickWindow *w = window(); if (!w || !w->openglContext() || QThread::currentThread() != w->openglContext()->thread()) { qWarning("QQuickCanvasItem::textureProvider: can only be queried on the rendering thread of an exposed window"); return 0; } +#endif if (!d->textureProvider) d->textureProvider = new QQuickCanvasTextureProvider; d->textureProvider->node = d->node; diff --git a/src/quick/items/context2d/qquickcontext2d.cpp b/src/quick/items/context2d/qquickcontext2d.cpp index bacdfad557..3e84a79445 100644 --- a/src/quick/items/context2d/qquickcontext2d.cpp +++ b/src/quick/items/context2d/qquickcontext2d.cpp @@ -72,6 +72,10 @@ #include <private/qguiapplication_p.h> #include <qpa/qplatformintegration.h> +#ifndef QT_NO_OPENGL +# include <private/qsgdefaultrendercontext_p.h> +#endif + #include <cmath> #if defined(Q_OS_QNX) || defined(Q_OS_ANDROID) #include <ctype.h> @@ -3977,10 +3981,12 @@ public: ~QQuickContext2DThreadCleanup() { +#ifndef QT_NO_OPENGL context->makeCurrent(surface); delete texture; context->doneCurrent(); delete context; +#endif surface->deleteLater(); } @@ -4016,6 +4022,7 @@ QQuickContext2D::~QQuickContext2D() delete m_buffer; if (m_renderTarget == QQuickCanvasItem::FramebufferObject) { +#ifndef QT_NO_OPENGL if (m_renderStrategy == QQuickCanvasItem::Immediate && m_glContext) { Q_ASSERT(QThread::currentThread() == m_glContext->thread()); m_glContext->makeCurrent(m_surface.data()); @@ -4036,6 +4043,7 @@ QQuickContext2D::~QQuickContext2D() m_texture->deleteLater(); } } +#endif } else { // Image based does not have GL resources, but must still be deleted // on its designated thread after it has completed whatever it might @@ -4061,8 +4069,6 @@ void QQuickContext2D::init(QQuickCanvasItem *canvasItem, const QVariantMap &args m_canvas = canvasItem; m_renderTarget = canvasItem->renderTarget(); - - QQuickWindow *window = canvasItem->window(); m_renderStrategy = canvasItem->renderStrategy(); #ifdef Q_OS_WIN @@ -4085,9 +4091,12 @@ void QQuickContext2D::init(QQuickCanvasItem *canvasItem, const QVariantMap &args case QQuickCanvasItem::Image: m_texture = new QQuickContext2DImageTexture; break; +#ifndef QT_NO_OPENGL case QQuickCanvasItem::FramebufferObject: + m_texture = new QQuickContext2DFBOTexture; break; +#endif } m_texture->setItem(canvasItem); @@ -4100,18 +4109,26 @@ void QQuickContext2D::init(QQuickCanvasItem *canvasItem, const QVariantMap &args m_thread = QThread::currentThread(); QThread *renderThread = m_thread; +#ifndef QT_NO_OPENGL + QQuickWindow *window = canvasItem->window(); QThread *sceneGraphThread = window->openglContext() ? window->openglContext()->thread() : 0; if (m_renderStrategy == QQuickCanvasItem::Threaded) renderThread = QQuickContext2DRenderThread::instance(qmlEngine(canvasItem)); else if (m_renderStrategy == QQuickCanvasItem::Cooperative) renderThread = sceneGraphThread; +#else + if (m_renderStrategy == QQuickCanvasItem::Threaded) + renderThread = QQuickContext2DRenderThread::instance(qmlEngine(canvasItem)); +#endif + if (renderThread && renderThread != QThread::currentThread()) m_texture->moveToThread(renderThread); - +#ifndef QT_NO_OPENGL if (m_renderTarget == QQuickCanvasItem::FramebufferObject && renderThread != sceneGraphThread) { - QOpenGLContext *cc = QQuickWindowPrivate::get(window)->context->openglContext(); + auto openglRenderContext = static_cast<const QSGDefaultRenderContext *>(QQuickWindowPrivate::get(window)->context); + QOpenGLContext *cc = openglRenderContext->openglContext(); m_surface.reset(new QOffscreenSurface); m_surface->setFormat(window->format()); m_surface->create(); @@ -4122,7 +4139,7 @@ void QQuickContext2D::init(QQuickCanvasItem *canvasItem, const QVariantMap &args m_glContext->moveToThread(renderThread); m_texture->initializeOpenGL(m_glContext, m_surface.data()); } - +#endif connect(m_texture, SIGNAL(textureChanged()), SIGNAL(textureChanged())); reset(); @@ -4169,6 +4186,7 @@ QImage QQuickContext2D::toImage(const QRectF& bounds) flush(); m_texture->grabImage(bounds); } else { +#ifndef QT_NO_OPENGL QQuickWindow *window = m_canvas->window(); QOpenGLContext *ctx = window ? window->openglContext() : 0; if (ctx && ctx->isValid()) { @@ -4184,6 +4202,10 @@ QImage QQuickContext2D::toImage(const QRectF& bounds) qWarning() << "Cannot read pixels from canvas before opengl context is valid"; return QImage(); } +#else + flush(); + m_texture->grabImage(bounds); +#endif } } else if (m_renderStrategy == QQuickCanvasItem::Cooperative) { qWarning() << "Pixel readback is not supported in Cooperative mode, please try Threaded or Immediate mode"; diff --git a/src/quick/items/context2d/qquickcontext2dcommandbuffer.cpp b/src/quick/items/context2d/qquickcontext2dcommandbuffer.cpp index 58b374e696..8d659040b3 100644 --- a/src/quick/items/context2d/qquickcontext2dcommandbuffer.cpp +++ b/src/quick/items/context2d/qquickcontext2dcommandbuffer.cpp @@ -42,9 +42,11 @@ #include <qqml.h> #include <QtCore/QMutex> #include <QtQuick/qsgtexture.h> -#include <QtGui/QOpenGLContext> #include <QtGui/QPaintEngine> -#include <QtGui/private/qopenglpaintengine_p.h> +#ifndef QT_NO_OPENGL +# include <QtGui/QOpenGLContext> +# include <QtGui/private/qopenglpaintengine_p.h> +#endif #define HAS_SHADOW(offsetX, offsetY, blur, color) (color.isValid() && color.alpha() && (blur || offsetX || offsetY)) diff --git a/src/quick/items/context2d/qquickcontext2dtexture.cpp b/src/quick/items/context2d/qquickcontext2dtexture.cpp index f3513f447a..1bf5c333be 100644 --- a/src/quick/items/context2d/qquickcontext2dtexture.cpp +++ b/src/quick/items/context2d/qquickcontext2dtexture.cpp @@ -44,14 +44,15 @@ #include <QtQuick/private/qsgtexture_p.h> #include "qquickcontext2dcommandbuffer_p.h" #include <QOpenGLPaintDevice> - +#ifndef QT_NO_OPENGL #include <QOpenGLFramebufferObject> #include <QOpenGLFramebufferObjectFormat> +#endif #include <QtCore/QThread> #include <QtGui/QGuiApplication> QT_BEGIN_NAMESPACE - +#ifndef QT_NO_OPENGL #define QT_MINIMUM_FBO_SIZE 64 static inline int qt_next_power_of_two(int v) @@ -85,10 +86,12 @@ struct GLAcquireContext { } QOpenGLContext *ctx; }; - +#endif QQuickContext2DTexture::QQuickContext2DTexture() : m_context(0) +#ifndef QT_NO_OPENGL , m_gl(0) +#endif , m_surface(0) , m_item(0) , m_canvasWindowChanged(false) @@ -250,9 +253,9 @@ void QQuickContext2DTexture::paint(QQuickContext2DCommandBuffer *ccb) return; } QQuickContext2D::mutex.unlock(); - +#ifndef QT_NO_OPENGL GLAcquireContext currentContext(m_gl, m_surface); - +#endif if (!m_tiledCanvas) { paintWithoutTiles(ccb); delete ccb; @@ -379,7 +382,7 @@ bool QQuickContext2DTexture::event(QEvent *e) } return QObject::event(e); } - +#ifndef QT_NO_OPENGL static inline QSize npotAdjustedSize(const QSize &size) { static bool checked = false; @@ -646,6 +649,7 @@ void QQuickContext2DFBOTexture::endPainting() m_fbo->bindDefault(); } +#endif QQuickContext2DImageTexture::QQuickContext2DImageTexture() : QQuickContext2DTexture() diff --git a/src/quick/items/context2d/qquickcontext2dtexture_p.h b/src/quick/items/context2d/qquickcontext2dtexture_p.h index edc7283283..ed38382892 100644 --- a/src/quick/items/context2d/qquickcontext2dtexture_p.h +++ b/src/quick/items/context2d/qquickcontext2dtexture_p.h @@ -54,10 +54,10 @@ #include <QtQuick/qsgtexture.h> #include "qquickcanvasitem_p.h" #include "qquickcontext2d_p.h" - -#include <QOpenGLContext> -#include <QOpenGLFramebufferObject> - +#ifndef QT_NO_OPENGL +# include <QOpenGLContext> +# include <QOpenGLFramebufferObject> +#endif #include <QtCore/QMutex> #include <QtCore/QWaitCondition> #include <QtCore/QThread> @@ -121,11 +121,12 @@ public: // Called during sync() on the scene graph thread while GUI is blocked. virtual QSGTexture *textureForNextFrame(QSGTexture *lastFrame, QQuickWindow *window) = 0; bool event(QEvent *e); - +#ifndef QT_NO_OPENGL void initializeOpenGL(QOpenGLContext *gl, QOffscreenSurface *s) { m_gl = gl; m_surface = s; } +#endif Q_SIGNALS: void textureChanged(); @@ -152,8 +153,9 @@ protected: QList<QQuickContext2DTile*> m_tiles; QQuickContext2D *m_context; - +#ifndef QT_NO_OPENGL QOpenGLContext *m_gl; +#endif QSurface *m_surface; QQuickContext2D::State m_state; @@ -174,7 +176,7 @@ protected: uint m_painting : 1; uint m_onCustomThread : 1; // Not GUI and not SGRender }; - +#ifndef QT_NO_OPENGL class QQuickContext2DFBOTexture : public QQuickContext2DTexture { Q_OBJECT @@ -209,7 +211,7 @@ private: GLuint m_displayTextures[2]; int m_displayTexture; }; - +#endif class QSGPlainTexture; class QQuickContext2DImageTexture : public QQuickContext2DTexture { diff --git a/src/quick/items/context2d/qquickcontext2dtile.cpp b/src/quick/items/context2d/qquickcontext2dtile.cpp index a1503762de..95b6c9d961 100644 --- a/src/quick/items/context2d/qquickcontext2dtile.cpp +++ b/src/quick/items/context2d/qquickcontext2dtile.cpp @@ -38,10 +38,11 @@ ****************************************************************************/ #include "qquickcontext2dtile_p.h" - -#include <QOpenGLFramebufferObject> -#include <QOpenGLFramebufferObjectFormat> -#include <QOpenGLPaintDevice> +#ifndef QT_NO_OPENGL +# include <QOpenGLFramebufferObject> +# include <QOpenGLFramebufferObjectFormat> +# include <QOpenGLPaintDevice> +#endif QT_BEGIN_NAMESPACE @@ -96,7 +97,7 @@ QPainter* QQuickContext2DTile::createPainter(bool smooth, bool antialiasing) return 0; } - +#ifndef QT_NO_OPENGL QQuickContext2DFBOTile::QQuickContext2DFBOTile() : QQuickContext2DTile() , m_fbo(0) @@ -146,7 +147,7 @@ void QQuickContext2DFBOTile::setRect(const QRect& r) m_fbo = new QOpenGLFramebufferObject(r.size(), format); } } - +#endif QQuickContext2DImageTile::QQuickContext2DImageTile() : QQuickContext2DTile() diff --git a/src/quick/items/context2d/qquickcontext2dtile_p.h b/src/quick/items/context2d/qquickcontext2dtile_p.h index d9be2023c4..a87202daae 100644 --- a/src/quick/items/context2d/qquickcontext2dtile_p.h +++ b/src/quick/items/context2d/qquickcontext2dtile_p.h @@ -52,8 +52,9 @@ // #include "qquickcontext2d_p.h" -#include <QOpenGLFramebufferObject> - +#ifndef QT_NO_OPENGL +# include <QOpenGLFramebufferObject> +#endif QT_BEGIN_NAMESPACE class QQuickContext2DTexture; @@ -82,7 +83,7 @@ protected: QPainter m_painter; }; - +#ifndef QT_NO_OPENGL class QQuickContext2DFBOTile : public QQuickContext2DTile { public: @@ -99,7 +100,7 @@ private: QOpenGLFramebufferObject *m_fbo; }; - +#endif class QQuickContext2DImageTile : public QQuickContext2DTile { public: |
