summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qopenglcontext_p.h
Commit message (Collapse)AuthorAgeFilesLines
* Refactor initialization/caching code for versioned opengl functionsLars Knoll2016-03-021-1/+1
| | | | | | | Saves around 80k in Qt Gui. Change-Id: I3f7068ae699136d0edf46a49694ade7e1df3c91d Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
* Use an enum for versioning the opengl function backendsLars Knoll2016-03-021-1/+1
| | | | | | | | Saves some code, is easier to maintain and will allow for some more nice refactoring. Change-Id: Ica7ae8e9d36acbe6586e488bc6aff114336c65bb Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
* Updated license headersJani Heikkinen2016-01-151-14/+20
| | | | | | | | | | | From Qt 5.7 -> LGPL v2.1 isn't an option anymore, see http://blog.qt.io/blog/2016/01/13/new-agreement-with-the-kde-free-qt-foundation/ Updated license headers to use new LGPL header instead of LGPL21 one (in those files which will be under LGPL v3) Change-Id: I046ec3e47b1876cd7b4b0353a576b352e3a946d9 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Null out QOpenGLContext::screen upon screen disconnectLaszlo Agocs2015-09-221-0/+2
| | | | | | | | | Returning a dangling pointer is no good. Do what QOffscreenSurface does: just null it out. Task-number: QTBUG-42803 Change-Id: I01a6db9ae8974a1c78157ebc67097c8dac3a6b6e Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
* Fix incorrect FBO bindings with QOpenGLWidgetLaszlo Agocs2015-03-301-0/+2
| | | | | | | | | | | | | | QOpenGLContext::defaultFramebufferObject() knows nothing about QOpenGLWidget and QQuickWidget. The problem is that this function (and others that rely on it) is expected to give the widget's backing FBO in paintGL() and friends. To overcome this, we have to provide a way for such widgets that indicate what is the expected "default fbo". Task-number: QTBUG-43269 Change-Id: I43f439f8609382b9f7004707ab0ef9f091952b4f Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
* Make versioned OpenGL functions working with the subclass patternLaszlo Agocs2015-03-271-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QOpenGLFunctions allows both deriving from it and getting an instance via QOpenGLContext::functions(). Unsurprisingly a large number of users attempt to use the versioned function wrappers in the same way. Unfortunately this approach was not that well supported. Besides some potential base class exporting issues the real blocker for QOpenGLWidget - or any versionfunction subclass whose associated context changes during its lifetime - is that the functions instances could only be initialized once. Unlike instances retrieved via QOpenGLContext::versionFunctions(), instances created "manually" were not deinitialized upon the destruction of the associated context because context did not know about them. A pattern like initializeOpenGLFunctions(); delete context; create new context and make it current initializeOpenGLFunctions(); is working fine in QOpenGLFunctions-derived classes but not with the versioned ones. To overcome this, start registering such instances to the context too. QOpenGLContext::destroy() can then reset the internal state so a subsequent initializeOpenGLFunctions() will reinitialize properly instead of bailing out mistakenly thinking that everything is ready to use. Task-number: QTBUG-45199 Change-Id: Ia1420bcccb33c51508698b7a1b036c7544a66e74 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* Update copyright headersJani Heikkinen2015-02-111-7/+7
| | | | | | | | | | | | | | | | | | Qt copyrights are now in The Qt Company, so we could update the source code headers accordingly. In the same go we should also fix the links to point to qt.io. Outdated header.LGPL removed (use header.LGPL21 instead) Old header.LGPL3 renamed to header.LGPL3-COMM to match actual licensing combination. New header.LGPL-COMM taken in the use file which were using old header.LGPL3 (src/plugins/platforms/android/extract.cpp) Added new header.LGPL3 containing Commercial + LGPLv3 + GPLv2 license combination Change-Id: I6f49b819a8a20cc4f88b794a8f6726d975e8ffbe Reviewed-by: Matti Paaso <matti.paaso@theqtcompany.com>
* Add Q_DECL_OVERRIDE in the src subdirectoryOlivier Goffart2014-12-031-2/+2
| | | | | | | | | | Done automatically with clang-modernize on linux (But does not add Q_DECL_OVERRIDE to the function that are marked as inline because it a compilation error with MSVC2010) Change-Id: I2196ee26e3e6fe20816834ecea5ea389eeab3171 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix for current_fbo getting out of sync in QtOpenGLSamuel Rødal2014-11-111-0/+3
| | | | | | | | | | | | | | | When using QGLWidget in combination with QOpenGLFramebufferObject from QtGui, instead of QGLFramebufferObject from QtOpenGL, the current_fbo variable doesn't get updated when framebuffer object bindings change. To ensure that the QGLWidget correctly releases the currently bound framebuffer object when using a QPainter, we keep track of whether QOpenGLFramebufferObject has modified the current FBO binding, and if that's the case we need to read the OpenGL state directly instead of relying on a cached value. Change-Id: If7e0bd936e202cad07365b5ce641ee01d2251930 Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
* Remove QOpenGLContextPrivate::globalShareContextJocelyn Turcotte2014-10-201-3/+0
| | | | | | | | This has previously been replaced with qt_gl_global_share_context and all using code has been ported to the new name at this point. Change-Id: I13832f583456891dd057a7b414f45ec3e83f5698 Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
* Update license headers and add new license filesMatti Paaso2014-09-241-19/+11
| | | | | | | | | - Renamed LICENSE.LGPL to LICENSE.LGPLv21 - Added LICENSE.LGPLv3 - Removed LICENSE.GPL Change-Id: Iec3406e3eb3f133be549092015cefe33d259a3f2 Reviewed-by: Iikka Eklund <iikka.eklund@digia.com>
* Merge remote-tracking branch 'origin/5.3' into 5.4Frederik Gladhorn2014-08-121-0/+1
|\ | | | | | | | | | | | | | | | | | | | | | | Manually included changes from 3a347a4e70e5a10ee92dd2578316c926a399e894 in src/opengl/qgl.cpp. Conflicts: src/opengl/qgl_qpa.cpp src/plugins/platforms/android/androidjnimain.cpp Change-Id: Ic26b58ee587d4884c9d0fba45c5a94b5a45ee929
| * Initialize member.Gunnar Sletta2014-08-081-0/+1
| | | | | | | | | | Change-Id: I9ed8d5a7aeb40886bafbd9eb2003e88e5d796cc9 Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
* | Add default format to QSurfaceFormatLaszlo Agocs2014-08-081-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add defaultFormat() and setDefaultFormat() statics to QSurfaceFormat. These define the default values for the requestedFormat members of QOpenGLContext, QWindow and QOpenGLWidget (and implicitly QOpenGLWindow, QQuickWindow, etc.) This replaces QQuickWindow::setDefaultFormat() which can now be removed. The main inspiration here is not the convenience (avoiding setFormat() calls for all windows/widgets), but robustness: by setting the format once at the start of the application, all windows and contexts, including the internal share context used by QOpenGLWidget and QQuickWidget, will use the same format, eliminating the possibility of failing due to trying to share between incompatible contexts. Furthermore, since such a functionality is anyway mandatory for QQuickWindow (due to the possibility of creating windows from QML code), extending it to QSurfaceFormat and QOpenGLContext/QWindow is the next logical step. Change-Id: Ie94486adc489d17fecfcebb7050fecedffd2688b Reviewed-by: Gunnar Sletta <gunnar.sletta@jollamobile.com>
* | Rename globalShareContext to qt_gl_global_share_contextJocelyn Turcotte2014-08-041-0/+3
| | | | | | | | | | | | | | | | | | | | This makes it easier to forward-declare the exported symbol from other Qt modules without having to include the private headers. This keeps the old API until dependent submodules are updated. Change-Id: I08310a684b79f2f612f2ce897a601ff74178bee6 Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
* | Remove tracking of the current fboLaszlo Agocs2014-06-021-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When binding an FBO directly via glBindFramebuffer, the QOpenGLContext's internal current_fbo, that is maintained by QOpenGLFramebufferObject, becomes out of sync. This will lead to QOpenGLFramebufferObjects thinking they are still bound. Such state tracking should be avoided since it is becoming increasingly difficult to keep it consistent between the various OpenGL API wrappers and will never be robust enough when the application changes the state by directly calling OpenGL functions. current_fbo is now removed in QtGui. QtOpenGL is not touched. Change-Id: Id809aab1306c9486d1e2ba3bb5aa93593659e920 Reviewed-by: Gunnar Sletta <gunnar.sletta@jollamobile.com>
* | Merge remote-tracking branch 'origin/stable' into devFrederik Gladhorn2014-05-131-1/+4
|\| | | | | | | | | | | | | Conflicts: src/gui/kernel/qguiapplication.cpp Change-Id: Ibe75603dc8a51769db6550ea3f07bc8d19b0be85
| * Avoid corruption in Q(Open)GLFunctions when used on multiple threadsLaszlo Agocs2014-05-091-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Using Q(Open)GLFunctions concurrently on multiple threads had some issues due to incorrect synchronization: The m_groups list in the QOpenGLMultiGroupSharedResource, in which the Q(Open)GLFunctions instance is stored, became corrupted under certain scenarios, for example in the tst_qglthreads autotest and any two threads that happen to enter an initializeOpenGLFunctions() or QOpenGLContext::functions() call concurrently. Locking in value() has been introduced in 666c25c089acf7fcc9e9a6b7665074c6286d604e to fix such issues, however using the context group's mutex is not enough: that still allows two threads using two contexts with a different context group to concurrently enter insert(). Instead, the MultiGroupSharedResource has to have its own mutex to protect its own member variables. Task-number: QTBUG-38771 Change-Id: If01c44c2084b95e487bc9146576ca180ed8044da Reviewed-by: Jørgen Lind <jorgen.lind@digia.com>
* | Merge remote-tracking branch 'origin/stable' into devFrederik Gladhorn2014-05-061-1/+1
|\| | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: mkspecs/qnx-x86-qcc/qplatformdefs.h src/corelib/global/qglobal.h src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp src/opengl/qgl.cpp src/opengl/qglpixelbuffer.cpp src/opengl/qglshaderprogram.cpp tests/auto/opengl/qglthreads/tst_qglthreads.cpp Change-Id: Iaba137884d3526a139000ca26fee02bb27b5cdb5
| * Remove unneeded ;Albert Astals Cid2014-04-241-1/+1
| | | | | | | | | | | | | | Warnings returned by pedantic Change-Id: I501621df6e9f39b18576625b321714a862dc971a Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
* | Add public and QPA APIs for adapting existing OpenGL contextsLaszlo Agocs2014-04-241-0/+2
|/ | | | | | | | | | | | | For now only xcb on GLX is supported. Other platforms will follow later. Add also some missing documentation for the platform OpenGL context factory functions. [ChangeLog] QOpenGLContext is now able to adopt existing native contexts. Task-number: QTBUG-37552 Change-Id: I5dd959f102df178f646b2df5989203b5dc6de376 Reviewed-by: Jørgen Lind <jorgen.lind@digia.com>
* Add a way to share context between QtQuick and QtWidgetsJocelyn Turcotte2014-04-021-0/+3
| | | | | | | | | | | | | This will replace QSGContext::setSharedOpenGLContext. To be able to allow sharing the Chromium GL context with both QWebEngineView and QQuickWebEngineView, we need some way of setting the sharing within QtWidgets and QtQuick. Since they don't depend on one another this patch allows the sharing context to be set through QtGui. Change-Id: I91b365dd06ec925b4c5a99ac82c222778781fe8e Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
* Fix race condition in QOpenGLMultiGroupSharedResourceLiang Jian2014-03-271-0/+1
| | | | | | | | | | | | | In QOpenGLMultiGroupSharedResource::value(), the m_resources memeber of opengl context group will be checked and may be inserted a new value. This function may be called from different threads with the same opengl context group object: Think about that OpenGL context A and B are shared, they live in different thread, and in each thread we call QOpenGLContext::functions() to the context, that may cause the race I mentioned above. So I put a QMutexLocker to prevent race condition. Change-Id: I101a28f46b2af72b3094a9945880efeb3563482a Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
* Long live QOpenGLTexture!Sean Harmer2013-09-221-0/+3
| | | | | | | Task-number: QTBUG-33274 Change-Id: I9259d947d11f8ba330a2cd7f5620d8f1af0a804b Reviewed-by: Sean Harmer <sean.harmer@kdab.com> Reviewed-by: Gunnar Sletta <gunnar.sletta@digia.com>
* Add workaround for GL on Android emulatorEskil Abrahamsen Blomfeldt2013-07-291-0/+7
| | | | | | | | | | | | On the Android Emulator, the shaders will be compiled by a desktop GL driver, since the GL driver in the emulator is just a thin wrapper. The GL driver does not necessarily support the precision qualifiers, which can cause applications to break. We detect this at runtime in the platform plugin and set a workaround flag to Task-number: QTBUG-32557 Change-Id: Ied00cfe8e804d1f7862697dd379a14f3bed3d980 Reviewed-by: Gunnar Sletta <gunnar.sletta@digia.com>
* Q_DISABLE_COPY doesn't need a ; at the endAlbert Astals Cid2013-06-101-1/+1
| | | | | | | | | Fixes warnings when -Wpedantic is enabled Change-Id: I8fcfbfa9bb3a5ab61c85f8cb74660f6f7e459fc0 Reviewed-by: Gunnar Sletta <gunnar.sletta@digia.com> Reviewed-by: Alejandro Exojo Piqueras <suy@badopi.org> Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* OpenGL: Add a set of version and context specific OpenGL classesSean Harmer2013-02-261-0/+3
| | | | | | | | | | | | | | | | | | This commit adds part of the output of utils/glgen and some simple modifications to QOpenGLContext to allow easy access to classes containing functions specific to a given OpenGL context and version. This allows compile-time detection of mis-use of OpenGL features. For example, trying to use glBegin(GL_TRIANGLES) with an OpenGL 3.2 Core Profile context will be detected by the compiler rather than at runtime. These capabilities make it much easier to add functionality to Qt and applications that relies upon core features of OpenGL from specific versions e.g. geometry shaders. Change-Id: Ieb584a489792595f831bc77dee84935c03bb5a64 Reviewed-by: Samuel Rødal <samuel.rodal@digia.com>
* Remove QT_{BEGIN,END}_HEADER macro usageSergio Ahumada2013-01-291-4/+0
| | | | | | | | | | | The macro was made empty in ba3dc5f3b56d1fab6fe37fe7ae08096d7dc68bcb and is no longer necessary or used. Discussed-on: http://lists.qt-project.org/pipermail/development/2013-January/009284.html Change-Id: Id2bb2e2cabde059305d4af5f12593344ba30f001 Reviewed-by: Laszlo Papp <lpapp@kde.org> Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com> Reviewed-by: hjk <hjk121@nokiamail.com>
* Update copyright year in Digia's license headersSergio Ahumada2013-01-181-1/+1
| | | | | Change-Id: Ic804938fc352291d011800d21e549c10acac66fb Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Added private header warnings in src/gui/kernelSamuel Rødal2012-11-091-0/+11
| | | | | Change-Id: If3ad9d1e18543639f9e6abb8899b72772bc70c83 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
* Return appropriate currentContext() in platform's makeCurrent().Samuel Rødal2012-11-081-1/+1
| | | | | | | | This way the platform plugin can use convenience classes such as QOpenGLFramebufferObject in the makeCurrent() implementation. Change-Id: I1fb5f6b8ec094ff39454adbeca9eb0d1a8f43ee6 Reviewed-by: Paul Olav Tvete <paul.tvete@digia.com>
* Change copyrights from Nokia to DigiaIikka Eklund2012-09-221-24/+24
| | | | | | | | Change copyrights and license headers from Nokia to Digia Change-Id: If1cc974286d29fd01ec6c19dd4719a67f4c3f00e Reviewed-by: Lars Knoll <lars.knoll@digia.com> Reviewed-by: Sergio Ahumada <sergio.ahumada@digia.com>
* gui/opengl: Fix missing or improper include guard in headersSergio Ahumada2012-09-151-3/+3
| | | | | | | | Use an include guard in headers to ensure the header is not included more than once. Make the header guard match its file name. Change-Id: I29b41e9d33e4ea17165f44c49de0a963574dd809 Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
* OpenGL: Allow querying OpenGL extensions via the QOpenGLContextSean Harmer2012-08-091-0/+3
| | | | | Change-Id: Ia88470554bbfd2a56738dadfcafafe42a990382d Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
* Properly detect the max texture size when using QOpenGLPaintDevice.Jocelyn Turcotte2012-07-041-1/+3
| | | | | | | | | | | The value is currently hard-coded to 1024, this is a problem since any image painted with a size higher that this will be scaled down before being uploaded. This patch copies the implementation from QGLContext which works correctly. Change-Id: Ia2bda60cf21d9adf13c91cea4854a2b20e4041f2 Reviewed-by: Kim M. Kalland <kim.kalland@nokia.com>
* Make qobject_p.h not need qvariant.h.Stephen Kelly2012-02-291-2/+0
| | | | | | | | | | Move definition of ExtraData to the implementation file. As a side effect, we need to include qhash.h in some other places. Change-Id: I8bb4ec0940ae51c7d6961c9a51adb80fd444e1e3 Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* Fix compile with QT_NO_OPENGL.Andreas Holzammer2012-02-091-0/+3
| | | | | | Change-Id: Icade54a6e3b43fdc9c151efbc25adcef6b7e41d6 Reviewed-by: Miikka Heikkinen <miikka.heikkinen@digia.com> Reviewed-by: Gunnar Sletta <gunnar.sletta@nokia.com>
* Remove "All rights reserved" line from license headers.Jason McDonald2012-01-301-1/+1
| | | | | | | | | | As in the past, to avoid rewriting various autotests that contain line-number information, an extra blank line has been inserted at the end of the license text to ensure that this commit does not change the total number of lines in the license header. Change-Id: I311e001373776812699d6efc045b5f742890c689 Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Introduced QOpenGLContext::defaultFramebufferObject().Samuel Rødal2012-01-271-2/+21
| | | | | | | | Also add some debugging helpers to make sure applications are correctly written even on less restrictive platforms. Change-Id: Ie92e497c32e07b2b83662f7ab5540d8f37777fd0 Reviewed-by: Jørgen Lind <jorgen.lind@nokia.com>
* Remove use of QT_MODULE from libraryGunnar Sletta2012-01-251-1/+0
| | | | | | | | | | These defines were there to aid in the commercial licensing scheme we used long ago, and are no longer needed. Keep a QT_MODULE(x) define so other modules continue compiling. Change-Id: I8fd76cd5270df8f14aee746b6cf32ebf7c23fec7 Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
* Update contact information in license headers.Jason McDonald2012-01-231-1/+1
| | | | | | | Replace Nokia contact email address with Qt Project website. Change-Id: I431bbbf76d7c27d8b502f87947675c116994c415 Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Update copyright year in license headers.Jason McDonald2012-01-051-1/+1
| | | | | Change-Id: I02f2c620296fcd91d4967d58767ea33fc4e1e7dc Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Call invalidateResource() on QOpenGLMultiGroupSharedResource-owned resourcesKent Hansen2011-11-171-0/+1
| | | | | | | | | Commit 202127f860208c21145e05685bc54219e1655dbd ensured that QOpenGLMultiGroupSharedResource-owned resources are deleted, but it was missing a call to invalidateResource(). Change-Id: I166ce8a7298772408081331fe1a91bd2cd88aebb Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
* Ensure that QOpenGLMultiGroupSharedResources are cleaned upKent Hansen2011-11-151-6/+1
| | | | | | | | | | | | | | | | | When a GL context group is destroyed, all multi-group shared resources associated with the group should be cleaned up. Otherwise we could get a double deletion in the resource's destructor, because it still retained a pointer to the deleted group. The missing cleanup resulted in a crash when the global static qt_gl_functions_resource was destroyed, first seen in the tst_examples autotest in qtdeclarative. It possibly didn't manifest before because it's event loop-dependent (the contexts are deleted via deleteLater()). Change-Id: I6b1e0bfdfbbb2bff8e795f545e680fcdfa094768 Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
* Implemented texture cache for GL paint engine in QtGui.Samuel Rødal2011-09-121-0/+2
| | | | | | | | | | | This is simpler than the existing texture cache in QtOpenGL, as it only serves the GL paint engine. There's one per context group, to simplify the design and to prevent performance degradations. Change-Id: I61e3c9a444d8e246a8b38da019a56f2c0a533c0c Reviewed-on: http://codereview.qt-project.org/4674 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Kim M. Kalland <kim.kalland@nokia.com>
* Clean up shared resources immediately as the last context is destroyed.Samuel Rødal2011-09-011-0/+2
| | | | | | | | | | | By not waiting until deleteLater() kicks in it's easier to auto-test. We can now add a test case for what happens when a shared resource is still valid while the last context is destroyed. Change-Id: I72963928e6a921e49ed59a79e2579b497ba37ccf Reviewed-on: http://codereview.qt.nokia.com/3732 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Gunnar Sletta <gunnar.sletta@nokia.com>
* Build on Windows/clean build on Linux.Friedemann Kleint2011-08-291-1/+1
| | | | | | | Change-Id: I26552e85a8e8c63002db93b7d9b645981620f0af Reviewed-on: http://codereview.qt.nokia.com/3738 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
* Copy core GL functionality to QtGui with QGL -> QOpenGL naming.Samuel Rødal2011-08-291-0/+230
Change-Id: Ibc989afa4a30dd184d41d1a1cd89f97196e48855 Reviewed-on: http://codereview.qt.nokia.com/3710 Reviewed-by: Gunnar Sletta <gunnar.sletta@nokia.com>