Merge lp:~spacedout/qtubuntu/fix_opengl_sharing into lp:qtubuntu

Proposed by David Fries
Status: Work in progress
Proposed branch: lp:~spacedout/qtubuntu/fix_opengl_sharing
Merge into: lp:qtubuntu
Diff against target: 101 lines (+23/-13)
4 files modified
src/platforms/base/context.cc (+18/-4)
src/platforms/base/context.h (+3/-1)
src/platforms/base/integration.cc (+2/-7)
src/platforms/base/integration.h (+0/-1)
To merge this branch: bzr merge lp:~spacedout/qtubuntu/fix_opengl_sharing
Reviewer Review Type Date Requested Status
Gerry Boland (community) Needs Fixing
Loïc Molinari Pending
Francis Ginther why hasn't jenkins reviewed this yet? Pending
PS Jenkins bot continuous-integration Pending
Review via email: mp+163466@code.launchpad.net

Commit message

All of OpenGL, OpenGLES, and Qt5 support sharing a context, but the ubuntu-touch Qt5 abstraction does not, this adds that support, otherwise programs can't offload tasks to another thread to execute.

Description of the change

All of OpenGL, OpenGLES, and Qt5 support sharing a context, but the ubuntu-touch Qt5 abstraction does not, this adds that support, otherwise programs can't offload tasks to another thread to execute.

To post a comment you must log in.
Revision history for this message
Francis Ginther (fginther) wrote :

Jenkins will not perform a ci build on this until it is reviewed and top approved by a Canonical employee. Your best bet for finding a reviewer is through the #ubuntu-touch IRC channel on freenode.

If this is approved and still fails to be tested by jenkins, please ping me again.

Revision history for this message
Francis Ginther (fginther) wrote :

Oh, one more thing. You'll need to provide a commit message through launchpad as jenkins enforces this as part of this project's workflow. Copy-n-paste of the current Description should be suitable.

Revision history for this message
Loïc Molinari (loic.molinari) wrote :

The code looks good. I'll test on the device and approve if everything's fine.

Revision history for this message
David Fries (spacedout) wrote :

On Tue, May 21, 2013 at 05:10:37PM -0000, Loïc Molinari wrote:
> The code looks good. I'll test on the device and approve if everything's fine.

Depending on how you plan to test it I wanted to pass along a tip.

There is a related issue I'll mention that I've only worked around.
The problem is while I could create a new window for the new context,
it would be resized to the full screen, even though show() was never
called. While the hidden window was not visible (the main window
continued to be updated and displayed), all touch events were directed
to the hidden window. My hack was to turn around and deliver them in
my code to the main window object so things would continue to work.

The upcoming Qt 5.1 has an QOffscreenSurface that would be nice to
support directly, but that's independent of this.

--
David Fries <email address hidden> PGP pub CB1EE8F0
http://fries.net/~david/

Revision history for this message
Gerry Boland (gerboland) wrote :

Most of this seems implemented by now:
http://bazaar.launchpad.net/~phablet-team/qtubuntu/trunk/view/head:/src/platforms/base/context.cc

isSharing is not implemented in trunk though, yet these shared contexts are being used by the oxide browser. So not sure that needed either

review: Needs Fixing

Unmerged revisions

132. By David Fries

Enable sharing OpenGL contexts

Sharing OpenGL contexts are required to offload OpenGL tasks to another
thread such as uploading textues or drawing into a framebuffer to use
as a texture.

131. By David Fries

QUbuntuBaseIntegration allocate in const remove typecast

The base QPlatformIntegration doesn't have the non-const version of
createPlatformOpenGLContext and this routine doesn't require it,
so simplifying the code and removing a typecast along the way.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/platforms/base/context.cc'
--- src/platforms/base/context.cc 2013-02-14 16:31:33 +0000
+++ src/platforms/base/context.cc 2013-05-13 06:45:33 +0000
@@ -37,7 +37,10 @@
37}37}
38#endif38#endif
3939
40QUbuntuBaseContext::QUbuntuBaseContext(QUbuntuBaseScreen* screen) {40QUbuntuBaseContext::QUbuntuBaseContext(QUbuntuBaseScreen* screen,
41 QPlatformOpenGLContext *share) :
42 sharingContext_(false) {
43 DLOG("QUbuntuBaseContext::QUbuntuBaseContext (screen=%p, share=%p)", screen, share);
41 DASSERT(screen != NULL);44 DASSERT(screen != NULL);
42 eglDisplay_ = screen->eglDisplay();45 eglDisplay_ = screen->eglDisplay();
43 screen_ = screen;46 screen_ = screen;
@@ -48,10 +51,21 @@
48 attribs.append(2);51 attribs.append(2);
49 attribs.append(EGL_NONE);52 attribs.append(EGL_NONE);
50 ASSERT(eglBindAPI(EGL_OPENGL_ES_API) == EGL_TRUE);53 ASSERT(eglBindAPI(EGL_OPENGL_ES_API) == EGL_TRUE);
51 ASSERT((eglContext_ = eglCreateContext(54 EGLContext shareContext = EGL_NO_CONTEXT;
52 eglDisplay_, screen->eglConfig(), EGL_NO_CONTEXT, attribs.constData())) != EGL_NO_CONTEXT);55 if (share) {
56 shareContext = static_cast<QUbuntuBaseContext*>(share)->eglContext();
57 sharingContext_ = true;
58 }
5359
54 DLOG("QUbuntuBaseContext::QUbuntuBaseContext (this=%p, screen=%p)", this, screen);60 eglContext_ = eglCreateContext(eglDisplay_, screen->eglConfig(), shareContext, attribs.constData());
61 if (eglContext_ == EGL_NO_CONTEXT && sharingContext_) {
62 // re-try without a shared context
63 sharingContext_ = false;
64 DLOG("QUbuntuBaseContext::QUbuntuBaseContext sharing context failed");
65 eglContext_ = eglCreateContext(
66 eglDisplay_, screen->eglConfig(), EGL_NO_CONTEXT, attribs.constData());
67 }
68 ASSERT(eglContext_ != EGL_NO_CONTEXT);
55}69}
5670
57QUbuntuBaseContext::~QUbuntuBaseContext() {71QUbuntuBaseContext::~QUbuntuBaseContext() {
5872
=== modified file 'src/platforms/base/context.h'
--- src/platforms/base/context.h 2013-02-14 16:31:33 +0000
+++ src/platforms/base/context.h 2013-05-13 06:45:33 +0000
@@ -21,7 +21,7 @@
2121
22class QUbuntuBaseContext : public QPlatformOpenGLContext {22class QUbuntuBaseContext : public QPlatformOpenGLContext {
23 public:23 public:
24 QUbuntuBaseContext(QUbuntuBaseScreen* screen);24 QUbuntuBaseContext(QUbuntuBaseScreen* screen, QPlatformOpenGLContext *share);
25 ~QUbuntuBaseContext();25 ~QUbuntuBaseContext();
2626
27 // QPlatformOpenGLContext methods.27 // QPlatformOpenGLContext methods.
@@ -29,6 +29,7 @@
29 void swapBuffers(QPlatformSurface* surface);29 void swapBuffers(QPlatformSurface* surface);
30 bool makeCurrent(QPlatformSurface* surface);30 bool makeCurrent(QPlatformSurface* surface);
31 void doneCurrent();31 void doneCurrent();
32 bool isSharing() const { return sharingContext_; }
32 bool isValid() const { return eglContext_ != EGL_NO_CONTEXT; }33 bool isValid() const { return eglContext_ != EGL_NO_CONTEXT; }
33 void (*getProcAddress(const QByteArray& procName)) ();34 void (*getProcAddress(const QByteArray& procName)) ();
34 EGLContext eglContext() const { return eglContext_; }35 EGLContext eglContext() const { return eglContext_; }
@@ -37,6 +38,7 @@
37 QUbuntuBaseScreen* screen_;38 QUbuntuBaseScreen* screen_;
38 EGLContext eglContext_;39 EGLContext eglContext_;
39 EGLDisplay eglDisplay_;40 EGLDisplay eglDisplay_;
41 bool sharingContext_;
40};42};
4143
42#endif //QUBUNTUBASECONTEXT_H44#endif //QUBUNTUBASECONTEXT_H
4345
=== modified file 'src/platforms/base/integration.cc'
--- src/platforms/base/integration.cc 2013-02-14 16:31:33 +0000
+++ src/platforms/base/integration.cc 2013-05-13 06:45:33 +0000
@@ -70,13 +70,8 @@
70 QOpenGLContext* context) const {70 QOpenGLContext* context) const {
71 DLOG("QUbuntuBaseIntegration::createPlatformOpenGLContext const (this=%p, context=%p)", this,71 DLOG("QUbuntuBaseIntegration::createPlatformOpenGLContext const (this=%p, context=%p)", this,
72 context);72 context);
73 return const_cast<QUbuntuBaseIntegration*>(this)->createPlatformOpenGLContext(context);73 return new QUbuntuBaseContext(static_cast<QUbuntuBaseScreen*>(context->screen()->handle()),
74}74 context->shareHandle());
75
76QPlatformOpenGLContext* QUbuntuBaseIntegration::createPlatformOpenGLContext(
77 QOpenGLContext* context) {
78 DLOG("QUbuntuBaseIntegration::createPlatformOpenGLContext (this=%p, context=%p)", this, context);
79 return new QUbuntuBaseContext(static_cast<QUbuntuBaseScreen*>(context->screen()->handle()));
80}75}
8176
82QStringList QUbuntuBaseIntegration::themeNames() const {77QStringList QUbuntuBaseIntegration::themeNames() const {
8378
=== modified file 'src/platforms/base/integration.h'
--- src/platforms/base/integration.h 2013-02-14 16:31:33 +0000
+++ src/platforms/base/integration.h 2013-05-13 06:45:33 +0000
@@ -31,7 +31,6 @@
31 QPlatformNativeInterface* nativeInterface() const { return nativeInterface_; }31 QPlatformNativeInterface* nativeInterface() const { return nativeInterface_; }
32 QPlatformBackingStore* createPlatformBackingStore(QWindow* window) const;32 QPlatformBackingStore* createPlatformBackingStore(QWindow* window) const;
33 QPlatformOpenGLContext* createPlatformOpenGLContext(QOpenGLContext* context) const;33 QPlatformOpenGLContext* createPlatformOpenGLContext(QOpenGLContext* context) const;
34 QPlatformOpenGLContext* createPlatformOpenGLContext(QOpenGLContext* context);
35 QPlatformFontDatabase* fontDatabase() const { return fontDb_; }34 QPlatformFontDatabase* fontDatabase() const { return fontDb_; }
36 QStringList themeNames() const;35 QStringList themeNames() const;
37 QPlatformTheme* createPlatformTheme(const QString& name) const;36 QPlatformTheme* createPlatformTheme(const QString& name) const;

Subscribers

People subscribed via source and target branches