summaryrefslogtreecommitdiff
path: root/debian/patches/0274-shm-native-image-fix.diff
blob: 05e414beed030fd3dec9ebbc8c143415e2643064 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
From 8731ab999b849dac4716e3d29f5f55ed8e56438e Mon Sep 17 00:00:00 2001
From: Thiago Macieira <thiago.macieira@nokia.com>
Date: Thu, 25 Jun 2009 13:50:29 +0200
Subject: [PATCH 12/16] This patch makes the raster graphics system use shared images instead
 of shared pixmaps.

Shared memory pixmaps are deprecated since they are slower than shared
images with modern graphics hardware. They are also not supported by EXA
drivers and can be disabled in the latest version of the NVidia driver.

qt-bugs@ issue : none
Qt Software task ID : none
bugs.kde.org number : none
---
 src/gui/image/qnativeimage.cpp             |   10 ----------
 src/gui/image/qnativeimage_p.h             |    1 -
 src/gui/painting/qwindowsurface_raster.cpp |   13 ++++++++++---
 3 files changed, 10 insertions(+), 14 deletions(-)

--- a/src/gui/image/qnativeimage.cpp
+++ b/src/gui/image/qnativeimage.cpp
@@ -144,7 +144,7 @@ QImage::Format QNativeImage::systemForma
 #elif defined(Q_WS_X11) && !defined(QT_NO_MITSHM)
 
 QNativeImage::QNativeImage(int width, int height, QImage::Format format,bool /* isTextBuffer */, QWidget *widget)
-    : xshmimg(0), xshmpm(0)
+    : xshmimg(0)
 {
     if (!X11->use_mitshm) {
         image = QImage(width, height, format);
@@ -195,11 +195,6 @@ QNativeImage::QNativeImage(int width, in
             shmctl(xshminfo.shmid, IPC_RMID, 0);
         return;
     }
-    xshmpm = XShmCreatePixmap(X11->display, DefaultRootWindow(X11->display), xshmimg->data,
-                              &xshminfo, width, height, dd);
-    if (!xshmpm) {
-        qWarning() << "QNativeImage: Unable to create shared Pixmap.";
-    }
 }
 
 
@@ -208,10 +203,6 @@ QNativeImage::~QNativeImage()
     if (!xshmimg)
         return;
 
-    if (xshmpm) {
-        XFreePixmap(X11->display, xshmpm);
-        xshmpm = 0;
-    }
     XShmDetach(X11->display, &xshminfo);
     xshmimg->data = 0;
     XDestroyImage(xshmimg);
--- a/src/gui/image/qnativeimage_p.h
+++ b/src/gui/image/qnativeimage_p.h
@@ -90,7 +90,6 @@ public:
 
 #elif defined(Q_WS_X11) && !defined(QT_NO_MITSHM)
     XImage *xshmimg;
-    Pixmap xshmpm;
     XShmSegmentInfo xshminfo;
 
 #elif defined(Q_WS_MAC)
--- a/src/gui/painting/qwindowsurface_raster.cpp
+++ b/src/gui/painting/qwindowsurface_raster.cpp
@@ -220,9 +220,16 @@ void QRasterWindowSurface::flush(QWidget
 
     QRect br = rgn.boundingRect().translated(offset);
 #ifndef QT_NO_MITSHM
-    if (d_ptr->image->xshmpm) {
-        XCopyArea(X11->display, d_ptr->image->xshmpm, widget->handle(), d_ptr->gc,
-                  br.x(), br.y(), br.width(), br.height(), wbr.x(), wbr.y());
+    if (d_ptr->image->xshmimg && (br.width() * br.height() > 65536)) {
+        const QImage &src = d->image->image;
+        br = br.intersected(src.rect());
+        // Hack to make sure we satisify the PutImage() constraints in the X server,
+        // since the doShmPutImage() route currently forces a migration to system ram.
+        wbr.setX(wbr.x() - br.x());
+        br.setX(0);
+        br.setWidth(src.width());
+        XShmPutImage(X11->display, widget->handle(), d_ptr->gc, d_ptr->image->xshmimg,
+                     br.x(), br.y(), wbr.x(), wbr.y(), br.width(), br.height(), False);
         XSync(X11->display, False);
     } else
 #endif