Skip to content

Commit

Permalink
Get rid of qsgthreadobject
Browse files Browse the repository at this point in the history
  • Loading branch information
tmeshkova committed Aug 17, 2014
1 parent eb1af3b commit 064fdac
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 103 deletions.
39 changes: 0 additions & 39 deletions src/qsgthreadobject.cpp

This file was deleted.

33 changes: 0 additions & 33 deletions src/qsgthreadobject.h

This file was deleted.

47 changes: 19 additions & 28 deletions src/quickmozview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
#include "qmozscrolldecorator.h"
#include "qmoztexturenode.h"
#include "qmozextmaterialnode.h"
#include "qsgthreadobject.h"
#include "assert.h"
#include <QtOpenGLExtensions>

using namespace mozilla;
using namespace mozilla::embedlite;
Expand All @@ -41,8 +41,6 @@ using namespace mozilla::embedlite;
#define MOZVIEW_FLICK_STOP_TIMEOUT 500
#endif

static QSGThreadObject* gSGRenderer = NULL;

QuickMozView::QuickMozView(QQuickItem *parent)
: QQuickItem(parent)
, d(new QGraphicsMozViewPrivate(new IMozQView<QuickMozView>(*this)))
Expand Down Expand Up @@ -183,7 +181,6 @@ void QuickMozView::itemChange(ItemChange change, const ItemChangeData &)
return;
// All of these signals are emitted from scene graph rendering thread.
connect(win, SIGNAL(beforeRendering()), this, SLOT(refreshNodeTexture()), Qt::DirectConnection);
connect(win, SIGNAL(beforeSynchronizing()), this, SLOT(createThreadRenderObject()), Qt::DirectConnection);
connect(win, SIGNAL(sceneGraphInvalidated()), this, SLOT(clearThreadRenderObject()), Qt::DirectConnection);
win->setClearBeforeRendering(false);
}
Expand All @@ -208,32 +205,14 @@ void QuickMozView::geometryChanged(const QRectF &newGeometry, const QRectF &oldG
}
}

void QuickMozView::createThreadRenderObject()
{
updateGLContextInfo(QOpenGLContext::currentContext());
if (!gSGRenderer) {
gSGRenderer = new QSGThreadObject();
if (d->mView) {
d->mView->ResumeRendering();
}
}
disconnect(window(), SIGNAL(beforeSynchronizing()), this, 0);
}

void QuickMozView::clearThreadRenderObject()
{
QOpenGLContext* ctx = QOpenGLContext::currentContext();
Q_ASSERT(ctx != NULL && ctx->makeCurrent(ctx->surface()));
if (gSGRenderer != NULL) {
if (d->mView) {
d->mView->SuspendRendering(gSGRenderer->getTargetContextWrapper());
}
delete gSGRenderer;
gSGRenderer = NULL;
if (mConsTex) {
glDeleteTextures(1, &mConsTex);
mConsTex = 0;
}
QQuickWindow *win = window();
if (!win) return;
connect(win, SIGNAL(beforeSynchronizing()), this, SLOT(createThreadRenderObject()), Qt::DirectConnection);
}

void QuickMozView::createView()
Expand Down Expand Up @@ -268,9 +247,21 @@ void QuickMozView::refreshNodeTexture()
if (!d->mViewInitialized)
return;

int texId = 0, width = 0, height = 0;
if (gSGRenderer && d && d->mView && d->mView->GetPendingTexture(gSGRenderer->getTargetContextWrapper(), &texId, &width, &height)) {
Q_EMIT textureReady(texId, QSize(width, height));
if (d && d->mView && d->mView)
{
int width = 0, height = 0;
static QOpenGLExtension_OES_EGL_image* extension = nullptr;
if (!extension) {
extension = new QOpenGLExtension_OES_EGL_image();
extension->initializeOpenGLFunctions();
}
if (!mConsTex) {
glGenTextures(1, &mConsTex);
}
glBindTexture(GL_TEXTURE_EXTERNAL_OES, mConsTex);
void* image = d->mView->GetPlatformImage(&width, &height);
extension->glEGLImageTargetTexture2DOES(GL_TEXTURE_EXTERNAL_OES, image);
Q_EMIT textureReady(mConsTex, QSize(width, height));
}
}

Expand Down
1 change: 1 addition & 0 deletions src/quickmozview.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ private Q_SLOTS:
qreal mOffsetY;
bool mPreedit;
bool mActive;
GLuint mConsTex;
};

#endif // QuickMozView_H
6 changes: 3 additions & 3 deletions src/src.pro
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
CONFIG += qt thread debug ordered create_pc create_prl no_install_prl

QT += opengl openglextensions
TARGET = qt5embedwidget
TEMPLATE = lib

Expand Down Expand Up @@ -33,8 +33,8 @@ HEADERS += qmozcontext.h \
qmozview_defined_wrapper.h \
qmozview_templated_wrapper.h

SOURCES += quickmozview.cpp qmoztexturenode.cpp qsgthreadobject.cpp qmozextmaterialnode.cpp
HEADERS += quickmozview.h qmoztexturenode.h qsgthreadobject.h qmozextmaterialnode.h
SOURCES += quickmozview.cpp qmoztexturenode.cpp qmozextmaterialnode.cpp
HEADERS += quickmozview.h qmoztexturenode.h qmozextmaterialnode.h

!isEmpty(BUILD_QT5QUICK1) {
SOURCES += qdeclarativemozview.cpp qgraphicsmozview.cpp
Expand Down

0 comments on commit 064fdac

Please sign in to comment.