summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/cocoa/qnsview_drawing.mm
Commit message (Collapse)AuthorAgeFilesLines
* macOS: Propagate [NSOpenGLContext setView:] failuresTor Arne Vestbø2018-08-031-30/+2
| | | | | | | | | | | | | | | | | Instead of trying to mask situations where [NSOpenGLContext setView:] will fail (such as calling it for a view that's not part of a window yet, or part of a window that hasn't been shown), we report the error up through the API, so that QOpenGLContext::makeCurrent() will return false. This is documented to occur e.g. when "the surface is not exposed, or the graphics hardware is not available due to e.g. the application being suspended." QGLWidget was taught how to deal with this situation in cc27a50e. Other Qt APIs seem to handle it fine, but if regressions occur they should be fixable though the same logic as in cc27a50e. Change-Id: I92775fc165444696b6c5b44fa0e28ce3c4ad2190 Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@qt.io>
* macOS: Remove dead updateRequest code based on setNeedsDisplayTor Arne Vestbø2018-07-091-35/+1
| | | | | | | We're no longer using this code path for QWindow::requestUpdate() Change-Id: I000304a4f1a6ea2c3a4e8268ae978dedd968e07c Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* macOS: Remove declarative override of -[NSView wantsLayer]Alexandru Croitor2018-07-051-8/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | The -[NSView setWantsLayer:] method may have side effects that extend beyond just setting an internal boolean property, so we need to ensure it gets called. This was observed on e.g. macOS 10.12.5, where the method ends up creating the internal backing layer. On later macOS versions the method just emits KVO notifications for wantsLayer, but these may in turn result in similar logic being triggered. The issue was masked somewhat by AppKit itself calling the method from e.g. -[NSWindow setContentView:], so we still got the backing layer created. The problem appeared when running binaries built against an older SDK (10.6 in this case), which triggered AppKit to not call -[NSView setWantsLayer:], due to __NSViewLayerBackWindowFrame() in that case returning false. This change removes the overridden -[NSView wantsLayer], and replaces it with an explicit call to -[NSView setWantsLayer] when creating a new QNSView, essentially revering c8c8cc790a315710b0dae2282dc32. Task-number: PYSIDE-724 Task-number: PYSIDE-734 Change-Id: Idaff4ed38838311b37da4925b1eec241e077dbcc Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* macOS: Make layer-backed mode the defaultTor Arne Vestbø2018-05-311-2/+2
| | | | | | | | | | | | | | | | | | QWindows are still backed by NSViews, but these views render to a CoreAnimation layer instead of directly to the top level NSWindow. This is the direction Apple is going (and is the only available option on iOS/tvOS), so we want to move away from the existing code path as soon as possible. The default can be reversed by setting QT_MAC_WANTS_LAYER=0, or the _q_mac_wantsLayer property on QWindow. [ChangeLog][macOS] Layer-backed mode is now the default for QWindow. Change-Id: Ibb9cc7541b179cad215d0daee14aeb1b54be614c Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* macOS: Minor metal support nits/cleanupsTor Arne Vestbø2018-05-301-3/+2
| | | | | | Change-Id: I840426ebf35b0fec64e92386fc3e1cabd91ced25 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* macOS: Add QSurfaceType::MetalSurfaceMorten Johan Sørvig2018-05-111-5/+9
| | | | | | | | | | | | | | | | | | | | Add API to activate previously added Metal layer implementation. This provides minimal support, and unlike VulkanSurface there is no separate QWindow subclass. What this does do is configure the QWindow to use a Metal layer, and to send expose/update events when the layer content should be redrawn. Qt will also update the layer’s drawableSize and contentsScale when needed. Application code can make use of this by accessing the QWindow layer, which will be a CAMetalLayer: CAMetalLayer *metalLayer = reinterpret_cast<CAMetalLayer *>( reinterpret_cast<NSView *>(window->winId()).layer); Change-Id: I514f5186133c3e610fd4e53ca91fe9c85c6d016e Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* macOS: Experimental Vulkan support via MoltenVKMorten Johan Sørvig2018-05-081-2/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add support for QSurface::VulkanSurface and QVulkanWindow. Usage: 1) Build MoltenVK according to instructions 2) Configure Qt: ./configure -I /path/to/MoltenVK/Package/Release/MoltenVK/include 3) export QT_VULKAN_LIB=/path/to/MoltenVK/Package/Release/MoltenVK/macOS/libMoltenVK. Implement support for QSurface::VulkanSurface by enabling layer mode for QNSView and then creating a CAMetalLayer, which the MoltenVK translation layer can run on. MoltenVK provides an implementation of the Vulcan API, which means that the platform integration is similar to other platforms: implement a QCocoaVulkanInstance where we pass the QNSView instance to the vkCreateMacOSSurfaceMVK Vulkan surface constructor function. Using Vulkan directly without QVulkanWindow is possible, but not tested. We currently load libMoltenVK at run-time and use the existing QT_VULKAN_LIB environment variable to set its path. For deployment purposes it would be better to link against MoltenVK.frameworkm, but this Task-number: QTBUG-66966 Change-Id: I04ec6289c40b199dca9fed32902b5d2ad4e9c030 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Merge remote-tracking branch 'origin/5.11' into devLiang Qi2018-05-031-1/+1
| | | | | | | | | | | | Conflicts: examples/widgets/graphicsview/elasticnodes/graphwidget.cpp examples/widgets/graphicsview/elasticnodes/node.cpp examples/widgets/graphicsview/elasticnodes/node.h src/plugins/platforms/cocoa/qnsview.mm src/plugins/platforms/cocoa/qnsview_drawing.mm src/widgets/kernel/qmacgesturerecognizer_p.h Change-Id: I13cf06bac75d48d779d8ee7b5c91bfc976f2a32c
* Provide QPlatformWindow::hasPendingUpdateRequest() helper functionTor Arne Vestbø2018-04-171-4/+2
| | | | | | | So that platform plugins don't need to dive into QWindowPrivate. Change-Id: Ia2d94b3e9236e4a68857e6afe7af063f1b0d0aeb Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* macOS: Add logging when delivering update requestsTor Arne Vestbø2018-04-171-1/+0
| | | | | Change-Id: I2144e39c69fe79c0a31d5fb708abe4b20169d27a Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Cocoa: Add QNSView Metal Layer supportMorten Johan Sørvig2018-04-121-2/+58
| | | | | | | | | | | | | | | | | Make sure the layer is updated on window resize and screen change. Add a support test and print a warning if we try to create a Metal layer without Metal system support. This test should ideally be done earlier, before configuring the QWindow to use Metal. Link against the Metal framework: The minimum deployment target is already 10.11 so this does not add additional deployment requirements. Change-Id: I0a38e824d0b6042bb52520dfaf0958ce21bb40b8 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Move delivery of update requests into QPlatformWindowTor Arne Vestbø2018-03-291-1/+1
| | | | | | | | | | | | Having deliverUpdateRequest in QWindowPrivate was a bit awkward and asymmetric to the QPlatformWindow::requestUpdate() API. Keeping them together follows the existing pattern of plumbing things through the platform window, and also allows us to move away from platform plugins relying on QWindowPrivate implementation details. Change-Id: Ib131ccdd1c2bdd6ff1c8d95facbc3f6f88a1abcf Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* macOS: Make [QNSView wantsLayer] declarativeTor Arne Vestbø2018-03-211-0/+12
| | | | | Change-Id: Ib5dc8178293d13542a54d51484181debd57580f5 Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@qt.io>
* macOS: Remove stray qDebug in [QNSView setNeedsDisplayInRect:]Tor Arne Vestbø2018-03-201-1/+0
| | | | | Change-Id: Ia253edf84bc0c890f291499ed2635d8287b18327 Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@qt.io>
* macOS: Do layer updates via the CALayerDelegate protocolTor Arne Vestbø2018-03-201-6/+3
| | | | | | | | | | | | | | | The updateLayer function is only called when the layer is a _NSViewBackingLayer instance, which is what the default implementation of [NSView makeBackingLayer] returns. Once we move to optionally returning a CAMetalLayer, we need to use the more generic displayLayer: API, so we do that now as a first step. This matches the way we draw and send expose events on iOS. Change-Id: I49721ff005ca9dfddebff645705f96b5ab46abb4 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* macOS: Move QNSView drawing related functionality to its own fileTor Arne Vestbø2018-03-201-0/+162
Change-Id: Iaeaa5c57368445a1fd67d110823c919aa7173a7a Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>