From 5194817941985c766bbc7f80039a58e0cf504b55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Mon, 6 Nov 2017 15:08:37 +0100 Subject: Cocoa: optimize backingstore flush on 10-bit displays MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Qt draws the backing store to the window using CoreGrahics, which will trigger a slow RGB32 -> RGB64 conversion when the output display is a deep color display. Disable NSWindow dynamicDepthLimit and force the depthLimit to WindowDepthTwentyforBitRGB for the common case of 8-bit-per-component raster surfaces. This was benchmarked by resizing a simple QRasterWindow test case which fills the window area using QPainter::fillRect(). Before: 67.1% rgba64_image_mark_rgb32 10.8% __vImageCopyBuffer_block_invoke 6.0% madvise 5.0% _kernelrpc_mach_vm_deallocate_trap 4.1% qt_memfill32(unsigned int*, unsigned int, int) After: 30.7% __vImageCopyBuffer_block_invoke 20.3% madvise 12.3% __vOverwriteChannelsWithScalar_ARGB8888_block_invoke 12.2% qt_memfill32(unsigned int*, unsigned int, int) 4.6% _kernelrpc_mach_vm_deallocate_trap The test program now spends significantly more of its time allocating/deallocating the backing store (madvise), and running the Qt paint event (qt_memfill32). Task-number: QTBUG-47660 Change-Id: I878be7a0e6eee4ad798f7a53f7f9f79b7950af26 Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/cocoa/qcocoawindow.mm | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/plugins/platforms/cocoa') diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index c6fa6795c1..5cd4beb4f0 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -1887,6 +1887,21 @@ QCocoaNSWindow *QCocoaWindow::createNSWindow(bool shouldBeChildNSWindow, bool sh applyContentBorderThickness(window); + // Prevent CoreGraphics RGB32 -> RGB64 backing store conversions on deep color + // displays by forcing 8-bit components, unless a deep color format has been + // requested. This conversion uses significant CPU time. + QSurface::SurfaceType surfaceType = QPlatformWindow::window()->surfaceType(); + bool usesCoreGraphics = surfaceType == QSurface::RasterSurface || surfaceType == QSurface::RasterGLSurface; + QSurfaceFormat surfaceFormat = QPlatformWindow::window()->format(); + bool usesDeepColor = surfaceFormat.redBufferSize() > 8 || + surfaceFormat.greenBufferSize() > 8 || + surfaceFormat.blueBufferSize() > 8; + bool usesLayer = view().layer; + if (usesCoreGraphics && !usesDeepColor && !usesLayer) { + [window setDynamicDepthLimit:NO]; + [window setDepthLimit:NSWindowDepthTwentyfourBitRGB]; + } + return window; } -- cgit v1.2.3