summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/cocoa/qcocoabackingstore.mm
Commit message (Collapse)AuthorAgeFilesLines
* Revert "Update commercial license headers"v6.2.5-lts-lgplTarja Sundqvist2022-11-241-21/+21
| | | | | | | | | | | This reverts commit 90c32995096ae90eb3c6f2da407488c5c063657f. Revert of commercial license headers is required for the Qt 6.2.x opensource releases, Qt 6.2.5 onwards. Task-number: QTBUG-107760 Change-Id: I80c7825f97af6eab576916514c2179840eb41fd3 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Update commercial license headersTarja Sundqvist2022-06-211-21/+21
| | | | | | | | | | | | | | | Updated header.COMM to the files in tqtc-qtbase. Examples, tests, or documentation files are not updated. The commercial license header may contain some additional lines so that its line count equals with the earlier license header. Reason for this is that some autotests use hard coded line numbers and a change in the line count causes failures in tests. Task-number: QTQAINFRA-4934 Change-Id: Ie60b1b5f64c28ddcc77462abadbcf66af7c6d73b Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* macOS: Don't scroll individual rects of a region when inline scrollingTor Arne Vestbø2022-04-011-8/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The QPlatformBackingStore::scroll() API takes a QRegion as input, and we kept this data type in the implementation of QCALayerBackingStore::scroll for the logic of figuring out whether we could use the existing back buffer as source of the scroll or if we needed to pull data from the front buffer. We then iterated the rects of the resulting in-line region, and called qt_scrollRectInImage for each of them. This will unfortunately not work whenever the scroll of one of these rects ends up overwriting parts of the back buffer that later rects of the region use as their source rect. This could be reproduced by moving the cursor within a text document, which would dirty a small area around the cursor, making the subsequent scroll of the viewport result in garbled text. This issue exists in the other platform backingstore implementations too, but since the QWidgetRepaintManager never calls scroll() with anything but a single rect they would not have any issues. The problem could potentially be solved by sorting the rects before blitting them, but now this quick fix solves the regression on macOS. Fixes: QTBUG-102181 Change-Id: I80f6d26117321e3c09e068cdb03eb320e244a5de Reviewed-by: Eike Ziller <eike.ziller@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> (cherry picked from commit 919f514f29f33d653e492b0dbf9fc95d7cd93287) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* macOS: Implement QCALayerBackingStore::scroll for improved performanceTor Arne Vestbø2022-01-171-0/+55
| | | | | | | | | | | | | | | | | | | The CALayer backingstore never had a scroll implementation because we were relying on the QRasterBackingStore implementation, but as it turned out that implementation was not applicable for the CALayer backingstore. We now implement scroll() by determining which part of the back buffer can be scrolled directly in-place, and then scrolling the rest by copying from the front buffer. We have to handle both cases, as clients may scroll multiple times before flushing, and the scrolled area may overlap both valid back-buffer content and content that needs to be pulled from the front-buffer. Change-Id: Icc09c9488386925116779c9024669a4329b38247 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> (cherry picked from commit 996061a1c0d5cd8413ffb6a97cb25b8da9ed811b) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* macOS: Add QCALayerBackingStore::preserveFromFrontBuffer helper functionTor Arne Vestbø2021-11-091-10/+20
| | | | | | | Change-Id: Iadd4791907564b8b82437643c54696ffa778d882 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> (cherry picked from commit ecfbc918d7f3042ecff5490a103a06cc1b195977) Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* macOS: Rename QCALayerBackingStore::prepareForFlush()Tor Arne Vestbø2021-11-081-38/+49
| | | | | | | | | The need to finalize the back buffer isn't limited to flushing. Change-Id: I98b04ab49ec27ea536e99462deab8d48a8e40e82 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> (cherry picked from commit 4ffdf2270a1341a703b591eb79f40dcc6033a3f1) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* macOS: Track painted area of backingstore buffer via its dirty regionTor Arne Vestbø2021-11-081-16/+24
| | | | | | | | | | When introducing support for scrolling the backingstore it doesn't make sense to track the painted region explicitly. Change-Id: I370932f02490ac526fb049908f99af678884e807 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> (cherry picked from commit 5190e77d87d743a75362ecf933adb466199e8958) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* macOS: Don't defer back/front-buffer swap in CALayer backingstoreTor Arne Vestbø2021-11-081-25/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | CoreAnimation doesn't immediately mark a surface as in use the moment we assign it to a layer, but defers it until the surface has bee picked up by the window server. In theory this would allow us to defer the swap until the next beginPaint(), which would allow painting to the back buffer again before Core Animation has time to flush the transaction and persist the layer changes to the window server, and would also automatically deal with requests to flush without painting anything. But, since a client may do several rounds of beginPaint/endPaint before flushing, we might end up in a situation where we detect that a surface is in use in the middle of several paint rounds, and end up swapping in a new back buffer without copying over the previously painted content, like we do in prepareForFlush. To be on the safe side we swap the back and front buffer straight away. We also need to mark the surface in use, to prevent the same problem from appearing when the window server doesn't pick up the surface in between two rounds of flushes. Change-Id: Ib418852424773c399df710da33a388e8d2c2e92c Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Doris Verria <doris.verria@qt.io> (cherry picked from commit 38130406ca806799ba812af1dbc849f57af1f64c) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* macOS: Don't pretend like our backing store is a QRasterBackingStoreTor Arne Vestbø2021-09-241-1/+1
| | | | | | | | | | | We're not using the internal m_image of QRasterBackingStore, nor its m_requestedSize, so inheriting it was just causing confusion when we ended up in QRasterBackingStore::scroll(), operating on those members. Change-Id: I26561209c0a19777577724728f0ad62e07673577 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit 8da42e1af631ffefc29fb2ef0e289dd11da376c5) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* macOS: Remove support for surface-backed viewsTor Arne Vestbø2020-08-181-270/+0
| | | | | | | | | | | | | Our deployment target is 10.14, which enables layer-backing by default, and our layer-backing support nowadays is stable enough that we don't need to maintain any of the old code paths for compatibility. The wantsBestResolutionOpenGLSurface property on NSView is only relevant for surface-backed views, so we no longer need to deal with it. Change-Id: I8aef4ac99371113d463ac35eee648a8a2fd1ea72 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* macOS: Handle platform window destroy and create in backingstoreTor Arne Vestbø2020-08-071-16/+33
| | | | | | | | | | | | | | | We observe changes to the NSWindow to pick up color space changes, so we need to track when the platform window is destroyed and created to match our observer with the recreated NSWindow. This does not handle the fact that we're internally recreating the NSWindow if certain window flag changes requires so, without letting clients know via surface events. Task-number: QTBUG-85915 Pick-to: 5.15 Change-Id: I7a7d728c742def79adebaadc985cedd86ea0d581 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* macOS: Fix crash when re-using backingstore for re-created QWindowTor Arne Vestbø2020-08-071-0/+8
| | | | | | | | | | | | | | | | | | | The observer we add for the NSWindow of the backingstore window will not be valid once that window is destroyed, but we may get last minute notifications for it still, in which case our platform window is gone. This patch fixes the immediate crash, but reveals a more fundamental problem of assuming the platform window that's alive during construction is the one that will always be used with the backingstore. This is not the case when for example QtWidgets opens a combo box, and reuses the backingstore for the widget each time the combobox popup is shown. Fixes: QTBUG-85915 Pick-to: 5.15 Pick-to: 5.12 Change-Id: Ia66a45d003882602ac29476aabf2d58b0ac33c1e Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* macOS: Clean up headersTor Arne Vestbø2020-06-051-0/+2
| | | | | | | | | | | | | | The headers are now C++ clean and can be used outside of Objective-C code. All includes of Objective-C frameworks have been moved to the implementation files. Header guards have been added in the few places they were missing. All includes are now done via #include, instead of sometimes using the #import variant. Change-Id: Ibb0a9c0bcfefbda4347737212e40e300a3184982 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Merge remote-tracking branch 'origin/5.15' into devQt Forward Merge Bot2020-04-271-2/+4
|\ | | | | | | | | | | | | Conflicts: src/corelib/text/qstringliteral.h Change-Id: I1665af3ce537471b249def5e080b39bd4105189e
| * macOS: Don't optimize out aggressive backingstore flushes when single-bufferedTor Arne Vestbø2020-04-221-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Comparing the layer contents to the backingstore surface doesn't make sense when we're single buffered since we're always using the same surface. And once Core Animation has picked up on the surface it's not enough to just keep drawing to it, we also need to tell Core Animation that the contents has changed. Change-Id: I517a0b7a3ba7e9d96033465c9bd5a192985643ac Fixes: QTBUG-81071 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* | Merge remote-tracking branch 'origin/5.15' into devQt Forward Merge Bot2020-04-221-0/+1
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/widgets/widgets/qabstractbutton.cpp src/widgets/widgets/qbuttongroup.cpp src/widgets/widgets/qbuttongroup.h src/widgets/widgets/qsplashscreen.cpp tests/auto/widgets/widgets/qbuttongroup/tst_qbuttongroup.cpp tests/benchmarks/opengl/main.cpp Needed update: src/plugins/platforms/cocoa/CMakeLists.txt Change-Id: I7be4baebb63844ec2b3e0de859ca9de1bc730bb5
| * macOS: Remove a bunch of dead (forward) declarationsTor Arne Vestbø2020-04-151-0/+1
| | | | | | | | | | Change-Id: I402668a17b48c164658f775bacd832615a6d2587 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Merge remote-tracking branch 'origin/5.15' into devQt Forward Merge Bot2020-04-081-24/+59
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: examples/opengl/doc/src/cube.qdoc src/corelib/global/qlibraryinfo.cpp src/corelib/text/qbytearray_p.h src/corelib/text/qlocale_data_p.h src/corelib/time/qhijricalendar_data_p.h src/corelib/time/qjalalicalendar_data_p.h src/corelib/time/qromancalendar_data_p.h src/network/ssl/qsslcertificate.h src/widgets/doc/src/graphicsview.qdoc src/widgets/widgets/qcombobox.cpp src/widgets/widgets/qcombobox.h tests/auto/corelib/tools/qscopeguard/tst_qscopeguard.cpp tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp tests/benchmarks/corelib/io/qdiriterator/qdiriterator.pro tests/manual/diaglib/debugproxystyle.cpp tests/manual/diaglib/qwidgetdump.cpp tests/manual/diaglib/qwindowdump.cpp tests/manual/diaglib/textdump.cpp util/locale_database/cldr2qlocalexml.py util/locale_database/qlocalexml.py util/locale_database/qlocalexml2cpp.py Resolution of util/locale_database/ are based on: https://codereview.qt-project.org/c/qt/qtbase/+/294250 and src/corelib/{text,time}/*_data_p.h were then regenerated by running those scripts. Updated CMakeLists.txt in each of tests/auto/corelib/serialization/qcborstreamreader/ tests/auto/corelib/serialization/qcborvalue/ tests/auto/gui/kernel/ and generated new ones in each of tests/auto/gui/kernel/qaddpostroutine/ tests/auto/gui/kernel/qhighdpiscaling/ tests/libfuzzer/corelib/text/qregularexpression/optimize/ tests/libfuzzer/gui/painting/qcolorspace/fromiccprofile/ tests/libfuzzer/gui/text/qtextdocument/sethtml/ tests/libfuzzer/gui/text/qtextdocument/setmarkdown/ tests/libfuzzer/gui/text/qtextlayout/beginlayout/ by running util/cmake/pro2cmake.py on their changed .pro files. Changed target name in tests/auto/gui/kernel/qaction/qaction.pro tests/auto/gui/kernel/qaction/qactiongroup.pro tests/auto/gui/kernel/qshortcut/qshortcut.pro to ensure unique target names for CMake Changed tst_QComboBox::currentIndex to not test the currentIndexChanged(QString), as that one does not exist in Qt 6 anymore. Change-Id: I9a85705484855ae1dc874a81f49d27a50b0dcff7
| * macOS: Flush sublayers via separate IOSurface backingstoresTor Arne Vestbø2020-03-251-24/+59
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Flushing sublayers via QImage copies of the root IOSurface was causing performance regressions due to the constant allocations of new images each frame. We now re-use the QCALayerBackingStore implementation for sublayers, which gives a dynamic swap-chain. We're still paying the CPU cost of the copy from the root backingstore to the layered backingstores, as well as the memory cost, but at least improves the situation. We do not try to be smart and paint directly into the sublayers, as that would leave the root backingstore stale, potentially causing glitches when views are repositioned. Investigating this is left for future work. Fixes: QTBUG-82986 Change-Id: I758a3d8e1e40e2ed4fe6bc590a4a5a988d87a3a7 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> (cherry picked from commit ce2d68ebe1aefeae78ff2fd8ec5ff7e20790ef69)
* | macOS: Fix or ignore deprecated API in 10.14Tor Arne Vestbø2020-03-271-4/+3
|/ | | | | | | Fixes: QTBUG-82128 Change-Id: I11abfcf7f245a7a25733625b50e207b07abba289 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* macOS: Tag sub-layer images with color space on flushTor Arne Vestbø2020-02-111-1/+2
| | | | | | | | Failing to tag the image results in costly CPU-based color-space conversions. Change-Id: Ib65547f4b99b83e10d3603c27388f50eb4d3840c Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* macOS: Skip uninitialized buffers in IOSurface backingstoreTor Arne Vestbø2020-01-031-2/+4
| | | | | | Task-number: QTBUG-80972 Change-Id: Ifb8eb84d6b802556ccd52ac129a91e142e265a81 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* macOS Don't throw away backingstore buffers when backing properties changeTor Arne Vestbø2019-12-231-19/+17
| | | | | | | | | | | | | | | | | | Clients such as QtWidgets that do their own dirty tracking will assume they can just flush in response to the expose event, without repainting anything. Since we have no way at the moment to inform these clients that the backingstore content might be invalid we can't just throw it away. It turns out that to pick up changes in color spaces we can just tag the existing buffers with the new color space, so we don't need to throw it away. And for the older surface-backed mode we tag the color space on flush, so we didn't need to invalidate anything in the first place. Fixes: QTBUG-80844 Task-number: QTBUG-77749 Change-Id: Icb1ceb178894bb43887cdf03fb855d2d614b5ab0 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* macOS: Optionally flush sub-layers via sub-image copies of the backingstoreTor Arne Vestbø2019-10-111-10/+19
| | | | | | | | | | | | | | | When we're flushing the backingstore to sub-views with their own layers we don't want to pay the cost of uploading the whole backingstore to the GPU in the case where we're dealing with a discrete GPU. To work around this we make a copy of the appropriate part of the surfcace. This results in additional copies of the data, and will need further investigation to limit these. Task-number: QTBUG-77447 Change-Id: I318ae80e433dd7b0a55fd5a598b19f114d8bd28e Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Merge remote-tracking branch 'origin/5.13' into 5.14Liang Qi2019-09-041-3/+53
|\ | | | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/codecs/qicucodec.cpp src/dbus/qdbusserver.cpp src/gui/painting/qbezier.cpp src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp src/plugins/printsupport/cups/qppdprintdevice.cpp Change-Id: I2703128bb64baf5580fbc2c2061b55b0f0611d2a
| * Merge remote-tracking branch 'origin/5.12' into 5.13Allan Sandfeld Jensen2019-08-271-0/+31
| |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/gui/painting/qdrawhelper.cpp src/gui/painting/qdrawhelper_p.h src/gui/painting/qdrawhelper_sse2.cpp src/gui/painting/qdrawhelper_x86_p.h Change-Id: I83256bb38ab3a705776e353bc0629315b6c59a0f
| | * macOS: Choose appropriate NSWindow depth based on surface formatTor Arne Vestbø2019-08-241-0/+31
| | | | | | | | | | | | | | | | | | Change-Id: I67e63412096ca11a8f056f5755525311756906ef Reviewed-by: Andy Nichols <andy.nichols@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
| * | Merge remote-tracking branch 'origin/5.12' into 5.13Qt Forward Merge Bot2019-08-241-3/+22
| |\| | | | | | | | | | Change-Id: I60bb714ef11bced075d94addb74d23c3a3975519
| | * macOS: Invalidate backingstore and trigger expose on color space changesTor Arne Vestbø2019-08-221-0/+22
| | | | | | | | | | | | | | | | | | | | | Fixes: QTBUG-77749 Change-Id: I677a71152e4a218c08d8863d4f886d158a79e809 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
| | * macOS: Don't ask for a NSWindow background unless we need oneTor Arne Vestbø2019-08-221-3/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This allow halfway transparent windows, even with a border, which is a bit of a weird use-case, but matches what we do on other platforms. We don't need the explicit call to NSDrawWindowBackground in the QNSWindowBackingStore implementation, as the NSThemeFrame will draw this background on our behalf. Fixes: QTBUG-77637 Change-Id: I012d845fa957c40aa713adaecbb1601a848e3534 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* | | Rename QWidgetBackingStore to QWidgetRepaintManagerTor Arne Vestbø2019-08-201-1/+1
|/ / | | | | | | | | | | | | | | | | | | | | | | | | Quoting a blog from 2009, "this class is responsible for figuring out which parts of the window surface needs to be updated prior to showing it to screen, so it's really a repaint manager." https://blog.qt.io/blog/2009/12/16/qt-graphics-and-performance-an-overview/ What better time to do the rename than 10 years later! Change-Id: Ibf3c3bc8c7df64ac03d72e1f71d296b62d832fee Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* | Merge remote-tracking branch 'origin/5.12' into 5.13Qt Forward Merge Bot2019-07-291-11/+19
|\| | | | | | | | | | | | | Conflicts: src/corelib/io/qresource.cpp Change-Id: I54917f72444a621bd08aeaa15f5d17415993144d
| * macOS: Respect color space set on NSWindow when flushing backingstoreTor Arne Vestbø2019-07-261-11/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | By default Qt tries to avoid potentially costly color matching by not assigning an sRGB color space to our backingstore, even if that's what we in practice fill it with. We used to do this by assigning the display's color space, which effectively opts out of color matching, similar to the old behavior of the device RGB color space (which nowadays implies sRGB). By picking up the color space from the NSWindow instead, we allow the user to override the color space to trigger color matching, for example by explicitly setting it to NSColorSpace.sRGBColorSpace. NSWindow will fall back to the screen's color space if the window doesn't have one set. Task-number: QTBUG-47660 Change-Id: Iac8177e85e86fe9044a41eb2c93fbf26bb83c248 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Merge remote-tracking branch 'origin/5.12' into 5.13Liang Qi2019-06-201-2/+22
|\| | | | | | | | | | | | | | | | | | | Conflicts: .qmake.conf src/gui/painting/qdrawhelper.cpp src/network/ssl/qsslsocket_openssl.cpp src/widgets/styles/qstylesheetstyle.cpp Change-Id: Ibe1cd40f46a823c9e5edbe0a3cd16be1e1686b17
| * macOS: prevent duplicate backing store scalingMorten Johan Sørvig2019-06-191-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | m_requestedSize is already scaled by the QtGui scale factor (e.g. as set by QT_SCALE_FACTOR). Multiplying by QWindow::devicePixelRatio() then applies this factor again. Use QPlatformWindow::devicePixelRatio() instead, which returns the platform scale factor. Change-Id: I133e99d84f4718215fda9ef0cf81a113b51db2c7 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
| * macOS: Invalidate window shadow after QNSWindowBackingStore resizeTor Arne Vestbø2019-06-181-0/+19
| | | | | | | | | | | | | | | | | | | | | | The window shadow rendered by AppKit is based on the shape/content of the NSWindow surface. If the backingstore is partially transparent, we need to invalidate the window shadow after each resize (and subsequent flush) of the backingstore. Change-Id: I451370af5a8c0c25faea26beb3faa2483a33a5cf Fixes: QTBUG-74560 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* | Merge "Merge remote-tracking branch 'origin/5.12' into 5.13" into ↵Liang Qi2019-05-131-0/+15
|\| | | | | | | refs/staging/5.13
| * macOS: Implement QCALayerBackingStore::toImage()Tor Arne Vestbø2019-05-101-0/+15
| | | | | | | | | | | | | | | | | | | | | | It's not part of the QBackingStore API, but clients such as the Qt Quick software renderer access it through the platform backingstore, to grab the window. Change-Id: I203484ce13a5f8fb6815d27ab07f874fa9d16b8c Fixes: QTBUG-75467 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* | macOS: Track screens via Quartz Display Services instead of NSScreenTor Arne Vestbø2019-05-131-12/+0
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | Using NSScreen as the basis for tracking screens is not recommended, as the list of screens can be added, removed, or dynamically reconfigured at any time, and the NSScreen instance, or index in the NSScreen.screens array may not be stable. Quartz Display Services on the other hand tracks displays via a unique display ID, which typically remains constant until the machine is restarted. The lower level API also gives us earlier callbacks about screen changes than the corresponding NSApplicationDidChangeScreenParametersNotification does. By reacting to screen changes _before_ AppKit does, we can remove workarounds for receiving window move and screen change notifications before the screen was actually visibly reconfigured. The new approach also handles changes to the primary screen, which can happen if the user moves the menu bar in the macOS display arrangement pane. The device pixel ratio of the screen has been made into a cached property, like all the other properties of QCocoaScreen. This is more consistent, and allows us to qDebug the screen even when it has been removed and we no longer have access to resolve the properties from the associated Quarts display. Change-Id: I2d86c7629ed3bf5fb8c77f174712633752ae4079 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* macOS: Guard backingstore composeAndFlush with QT_NO_OPENGLTor Arne Vestbø2019-05-071-0/+2
| | | | | | | Fixes: QTBUG-75612 Change-Id: I0e90a84697c1eb055c4150f2519829977fce7244 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* macOS: Gracefully handle devicePixelRatio mismatch in QCALayerBackingStoreTor Arne Vestbø2019-04-191-3/+20
| | | | | | | | | | | | If the client of the backingstore fails to pick up dpr changes, and tries to flush the backingstore without a repaint, we will end up flushing a back-buffer with a stale dpr. Detect when this happens, warn the user, and smooth out the situation by adjusting the layer accordingly. Change-Id: If4596a8976a3902252c81d8e28c7aeb9fdd908bf Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io> Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* macOS: Add IOSurface based backingstore for layer-backed viewsTor Arne Vestbø2019-03-141-108/+435
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The naïve approach used for layer-backing in the past caused a detach of the backingstore QImage on each beginPaint, since the image was assigned to the layer via a CGImageRef that participated in the QImage implicit sharing (and had to, so we couldn't get around that). We now use IOSurfaces, wrapped in a QPlatformGraphicsBuffer abstraction. The surfaces can be assigned to the layer's content the same way images could, but allows us to reason more closely about whether or a buffer is in use, and increases the chance that we will have a zero-copy path to the screen. Unless the window has requested a surface format with single buffering we use a dynamic swap chain of buffers. In most situations there will be two buffers in play, one assigned to the layer and one ready to paint to, but during resize and some other situations the buffers will grow temporarily to accommodate the increased back-pressure. Since QBackingStore is documented as having single-buffer behavior, we take care to persist content between the buffers before every swap. By doing this before swapping, instead of before each paint, we can avoid preserving areas that will be painted to anyways, and will in many situations (such as blinking cursors e.g.) end up not persisting anything. The RasterGL surface case is handled by reading out the buffer data and doing a manual texture upload. In the future we can support direct texture access via CGLTexImageIOSurface2D, but this requires QPlatformBackingStore::composeAndFlush to learn how to support other targets than GL_TEXTURE_2D, as CGLTexImageIOSurface2D only works with GL_TEXTURE_RECTANGLE_ARB targets. Fixes: QTBUG-48763 Fixes: QTBUG-72360 Fixes: QTBUG-71162 Change-Id: Ica12f69b244e54d0fd31c929730d15657c286af8 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Remove codepaths and checks for unsupported Apple platformsTor Arne Vestbø2018-08-311-5/+0
| | | | | | | We no longer support macOS 10.11, iOS/tvOS 10, or watchOS 3. Change-Id: Ide03d8fac06185ef4162ba75ee54a0adf6916905 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Merge remote-tracking branch 'origin/5.11' into devQt Forward Merge Bot2018-08-081-5/+5
|\ | | | | | | | | | | | | | | Conflicts: src/plugins/platforms/cocoa/qcocoabackingstore.mm src/plugins/platforms/cocoa/qcocoascreen.mm Change-Id: Iac965aea4867059dbf7bc401b71e8e8b5b259afb
| * macOS: Don't blend the backingstore unless the window has a backgroundTor Arne Vestbø2018-08-071-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | If there's no background, we should copy the backingstore, so that the backingstore is not blended with the result of the previous flush. The unified toolbar case is covered by the window having a textured background. Task-number: QTBUG-69773 Change-Id: I2f4eed9f44a60ebe7495ce68cf5a54d3d2424b0c Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io> Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* | Add logging for QPlatformBackingStore::composeAndFlushTor Arne Vestbø2018-08-071-2/+0
| | | | | | | | | | Change-Id: I96778296480d2aaad5e01ed15353106bc90d4d2b Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* | macOS: Correctly scale CALayer contentsRect for child NSViewsTor Arne Vestbø2018-07-201-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When flushing parts of a QBackingStore onto child QWindows, and we're in layer-backed mode, we need to set the contentsRect of the layer so that the layer will only show the part of the top-level-owned backingstore image that's relevant for the child window. Since the contentsRect is in unit coordinate system, we need to apply a transform, but this must be based on the top level view's size, not the image size, as the latter will be twice as big on a retina screen, giving the wrong unit rect. Change-Id: I7d6f378ed46a98272efb13406a2878ec1efe734e Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* | macOS: Invalidate window shadow after flushing backingstore to CALayerTor Arne Vestbø2018-07-191-82/+83
| | | | | | | | | | | | | | | | | | | | The macOS bug preventing us from doing this has now been fixed: http://openradar.appspot.com/radar?id=4976602949615616 Change-Id: I3bfa75d6bf982a051a9b274f530529f4ec4351a0 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* | Merge remote-tracking branch 'origin/5.11' into devQt Forward Merge Bot2018-04-051-3/+5
|\| | | | | | | Change-Id: I954bd6418bc862a04691240c0f1766f6ce033640
| * Cocoa: Make QMacNativeWidget paint correctlyMorten Johan Sørvig2018-04-031-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | QWindows with transparent pixels (of which QMacNativeWidget is an example) must be composited, even if they are content views. This will display the NSWindow background instead of solid black for the areas where the Qt backingstore has transparent pixels. Change-Id: Ibee1327e11bc64975900b4c5d632dd5f103da4c8 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>