From 8565f97ce37faef6c29fa80c1d3e70dac38d3396 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Fri, 15 Aug 2014 11:49:58 +0000 Subject: Delay querying for EGL extension string until we are live with GL Change-Id: I7317a5157d7692f6e3357479a5b4c0c7906c3f77 Reviewed-by: Giulio Camuffo --- customcontext/context.cpp | 33 ++++++++++++++++++++++----------- customcontext/context.h | 1 + 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/customcontext/context.cpp b/customcontext/context.cpp index aeffd41..0b8a756 100644 --- a/customcontext/context.cpp +++ b/customcontext/context.cpp @@ -159,6 +159,9 @@ Context::Context(QObject *parent) : QSGContext(parent) , m_sampleCount(0) , m_useMultisampling(false) +#ifdef CUSTOMCONTEXT_USE_HYBRISTEXTURE + , m_hybrisTexture(false) +#endif { m_useMultisampling = !qgetenv("CUSTOMCONTEXT_MULTISAMPLE").isEmpty(); if (m_useMultisampling) { @@ -192,14 +195,6 @@ Context::Context(QObject *parent) m_eglGrallocTexture = qEnvironmentVariableIsEmpty("CUSTOMCONTEXT_NO_EGLGRALLOCTEXTURE"); #endif -#ifdef CUSTOMCONTEXT_HYBRISTEXTURE - m_hybrisTexture = qEnvironmentVariableIsEmpty("CUSTOMCONTEXT_NO_HYBRISTEXTURE"); - if (m_hybrisTexture && strstr(eglQueryString(eglGetDisplay(EGL_DEFAULT_DISPLAY), EGL_EXTENSIONS), "EGL_HYBRIS_native_buffer") == 0) { - qDebug() << "EGL_HYBRIS_native_buffer is not available..."; - m_hybrisTexture = false; - } -#endif - #ifdef CUSTOMCONTEXT_THREADUPLOADTEXTURE m_threadUploadTexture = qgetenv("CUSTOMCONTEXT_NO_THREADUPLOADTEXTURE").isEmpty(); connect(this, SIGNAL(invalidated()), &m_threadUploadManager, SLOT(invalidated()), Qt::DirectConnection); @@ -254,9 +249,6 @@ Context::Context(QObject *parent) #ifdef CUSTOMCONTEXT_EGLGRALLOCTEXTURE qDebug(" - EGLImage/Gralloc based texture: %s", m_eglGrallocTexture ? "yes" : "no"); #endif -#ifdef CUSTOMCONTEXT_HYBRISTEXTURE - qDebug(" - EGL/Hybris based texture: %s", m_hybrisTexture ? "yes" : "no"); -#endif #ifdef CUSTOMCONTEXT_MACTEXTURE qDebug(" - mac textures: %s", m_macTexture ? "yes" : "no"); #endif @@ -289,6 +281,25 @@ Context::Context(QObject *parent) } +#ifdef CUSTOMCONTEXT_HYBRISTEXTURE +void Context::renderContextInitialized(QSGRenderContext *ctx) +{ + // This check is delayed until there is an EGL display present. + m_hybrisTexture = qEnvironmentVariableIsEmpty("CUSTOMCONTEXT_NO_HYBRISTEXTURE"); + if (m_hybrisTexture && strstr(eglQueryString(eglGetCurrentDisplay(), EGL_EXTENSIONS), "EGL_HYBRIS_native_buffer") == 0) { + qDebug() << "EGL_HYBRIS_native_buffer is not available..."; + m_hybrisTexture = false; + } +#if defined(CUSTOMCONTEXT_DEBUG) + qDebug(" - EGL/Hybris based texture: %s", m_hybrisTexture ? "yes" : "no"); +#endif + + QSGContext::renderContextInitialized(ctx); +} +#endif + + + void CONTEXT_CLASS::initialize(QOpenGLContext *context) diff --git a/customcontext/context.h b/customcontext/context.h index ab2b229..0b0e65f 100644 --- a/customcontext/context.h +++ b/customcontext/context.h @@ -112,6 +112,7 @@ public: #if QT_VERSION >= 0x050200 QSGRenderContext *createRenderContext() { return new RenderContext(this); } + void renderContextInitialized(QSGRenderContext *renderContext) Q_DECL_OVERRIDE; #else void initialize(QOpenGLContext *context); void invalidate(); -- cgit v1.2.3