patches/qt3-0003-qpixmap_mitshm.patch
author jurikm
Sun, 12 Feb 2012 14:04:10 +0000
changeset 8245 383896da4129
parent 782 a013313b88b4
permissions -rw-r--r--
SFEsauerbraten.spec: add IPS package name
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
782
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
     1
--- qt-x11-free-3.3.8/src/kernel/qpixmap_x11.cpp.orig	2007-02-02 19:31:11.000000000 +0530
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
     2
+++ qt-x11-free-3.3.8/src/kernel/qpixmap_x11.cpp	2008-01-08 20:53:54.083245433 +0530
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
     3
@@ -37,7 +37,19 @@
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
     4
 
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
     5
 // NOT REVISED
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
     6
 
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
     7
+#include "qplatformdefs.h"
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
     8
+
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
     9
+#if defined(Q_OS_WIN32) && defined(QT_MITSHM)
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    10
+#undef QT_MITSHM
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    11
+#endif
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    12
+
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    13
+#ifdef QT_MITSHM
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    14
+
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    15
+// Use the MIT Shared Memory extension for pixmap<->image conversions
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    16
+#define QT_MITSHM_CONVERSIONS
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    17
+
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    18
 // Uncomment the next line to enable the MIT Shared Memory extension
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    19
+// for QPixmap::xForm()
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    20
 //
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    21
 // WARNING:  This has some problems:
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    22
 //
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    23
@@ -45,14 +57,13 @@
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    24
 //    2. Qt does not handle the ShmCompletion message, so you will
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    25
 //        get strange effects if you xForm() repeatedly.
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    26
 //
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    27
-// #define QT_MITSHM
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    28
+// #define QT_MITSHM_XFORM
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    29
 
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    30
-#if defined(Q_OS_WIN32) && defined(QT_MITSHM)
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    31
-#undef QT_MITSHM
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    32
+#else
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    33
+#undef QT_MITSHM_CONVERSIONS
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    34
+#undef QT_MITSHM_XFORM
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    35
 #endif
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    36
 
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    37
-#include "qplatformdefs.h"
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    38
-
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    39
 #include "qbitmap.h"
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    40
 #include "qpaintdevicemetrics.h"
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    41
 #include "qimage.h"
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    42
@@ -91,7 +102,7 @@
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    43
   MIT Shared Memory Extension support: makes xForm noticeably (~20%) faster.
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    44
  *****************************************************************************/
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    45
 
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    46
-#if defined(QT_MITSHM)
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    47
+#if defined(QT_MITSHM_XFORM)
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    48
 
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    49
 static bool	       xshminit = FALSE;
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    50
 static XShmSegmentInfo xshminfo;
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    51
@@ -173,8 +184,100 @@
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    52
 //     return FALSE;
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    53
 // }
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    54
 
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    55
-#endif // QT_MITSHM
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    56
+#endif // QT_MITSHM_XFORM
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    57
+
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    58
+#ifdef QT_MITSHM_CONVERSIONS
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    59
 
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    60
+static bool qt_mitshm_error = false;
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    61
+static int qt_mitshm_errorhandler( Display*, XErrorEvent* )
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    62
+{
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    63
+    qt_mitshm_error = true;
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    64
+    return 0;
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    65
+}
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    66
+
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    67
+static XImage* qt_XShmCreateImage( Display* dpy, Visual* visual, unsigned int depth,
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    68
+    int format, int /*offset*/, char* /*data*/, unsigned int width, unsigned int height,
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    69
+    int /*bitmap_pad*/, int /*bytes_per_line*/, XShmSegmentInfo* shminfo )
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    70
+{
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    71
+    if( width * height * depth < 100*100*32 )
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    72
+        return NULL;
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    73
+    static int shm_inited = -1;
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    74
+    if( shm_inited == -1 ) {
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    75
+        if( XShmQueryExtension( dpy ))
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    76
+            shm_inited = 1;
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    77
+        else
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    78
+            shm_inited = 0;
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    79
+    }
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    80
+    if( shm_inited == 0 )
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    81
+        return NULL;
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    82
+    XImage* xi = XShmCreateImage( dpy, visual, depth, format, NULL, shminfo, width,
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    83
+        height );
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    84
+    if( xi == NULL )
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    85
+        return NULL;
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    86
+    shminfo->shmid = shmget( IPC_PRIVATE, xi->bytes_per_line * xi->height,
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    87
+        IPC_CREAT|0600);
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    88
+    if( shminfo->shmid < 0 ) {
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    89
+        XDestroyImage( xi );
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    90
+        return NULL;
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    91
+    }
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    92
+    shminfo->readOnly = False;
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    93
+    shminfo->shmaddr = (char*)shmat( shminfo->shmid, 0, 0 );
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    94
+    if( shminfo->shmaddr == (char*)-1 ) {
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    95
+        XDestroyImage( xi );
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    96
+        shmctl( shminfo->shmid, IPC_RMID, 0 );
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    97
+        return NULL;
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    98
+    }
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
    99
+    xi->data = shminfo->shmaddr;
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   100
+#ifndef QT_MITSHM_RMID_IGNORES_REFCOUNT
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   101
+    // mark as deleted to automatically free the memory in case
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   102
+    // of a crash (but this doesn't work e.g. on Solaris)
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   103
+    shmctl( shminfo->shmid, IPC_RMID, 0 );
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   104
+#endif
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   105
+    if( shm_inited == 1 ) { // first time
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   106
+        XErrorHandler old_h = XSetErrorHandler( qt_mitshm_errorhandler );
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   107
+        XShmAttach( dpy, shminfo );
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   108
+        shm_inited = 2;
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   109
+        XSync( dpy, False );
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   110
+        XSetErrorHandler( old_h );
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   111
+        if( qt_mitshm_error ) { // oops ... perhaps we are remote?
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   112
+            shm_inited = 0;
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   113
+            XDestroyImage( xi );
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   114
+            shmdt( shminfo->shmaddr );
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   115
+#ifdef QT_MITSHM_RMID_IGNORES_REFCOUNT
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   116
+            shmctl( shminfo->shmid, IPC_RMID, 0 );
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   117
+#endif    
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   118
+            return NULL;
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   119
+        }
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   120
+    } else
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   121
+        XShmAttach( dpy, shminfo );
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   122
+    return xi;
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   123
+}
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   124
+
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   125
+static void qt_XShmDestroyImage( XImage* xi, XShmSegmentInfo* shminfo )
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   126
+{
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   127
+    XShmDetach( QPaintDevice::x11AppDisplay(), shminfo );
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   128
+    XDestroyImage( xi );
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   129
+    shmdt( shminfo->shmaddr );
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   130
+#ifdef QT_MITSHM_RMID_IGNORES_REFCOUNT
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   131
+    shmctl( shminfo->shmid, IPC_RMID, 0 );
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   132
+#endif    
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   133
+}
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   134
+
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   135
+static XImage* qt_XShmGetImage( const QPixmap* pix, int format,
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   136
+    XShmSegmentInfo* shminfo )
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   137
+{
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   138
+    XImage* xi = qt_XShmCreateImage( pix->x11Display(), (Visual*)pix->x11Visual(),
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   139
+        pix->depth(), format, 0, 0, pix->width(), pix->height(), 32, 0, shminfo );
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   140
+    if( xi == NULL )
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   141
+        return NULL;
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   142
+    if( XShmGetImage( pix->x11Display(), pix->handle(), xi, 0, 0, AllPlanes ) == False ) {
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   143
+        qt_XShmDestroyImage( xi, shminfo );
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   144
+        return NULL;
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   145
+    }
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   146
+    return xi;
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   147
+}
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   148
+
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   149
+#endif // QT_MITSHM_CONVERSIONS
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   150
 
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   151
 /*****************************************************************************
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   152
   Internal functions
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   153
@@ -627,9 +730,20 @@
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   154
 	d = 32;					//   > 8  ==> 32
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   155
 
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   156
     XImage *xi = (XImage *)data->ximage;	// any cached ximage?
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   157
-    if ( !xi )					// fetch data from X server
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   158
-	xi = XGetImage( x11Display(), hd, 0, 0, w, h, AllPlanes,
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   159
+#ifdef QT_MITSHM_CONVERSIONS
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   160
+    bool mitshm_ximage = false;
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   161
+    XShmSegmentInfo shminfo;
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   162
+#endif
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   163
+    if ( !xi ) {				// fetch data from X server
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   164
+#ifdef QT_MITSHM_CONVERSIONS
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   165
+        xi = qt_XShmGetImage( this, mono ? XYPixmap : ZPixmap, &shminfo );
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   166
+        if( xi ) {
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   167
+            mitshm_ximage = true;
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   168
+        } else
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   169
+#endif
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   170
+	    xi = XGetImage( x11Display(), hd, 0, 0, w, h, AllPlanes,
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   171
 			mono ? XYPixmap : ZPixmap );
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   172
+    }
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   173
     Q_CHECK_PTR( xi );
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   174
     if (!xi)
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   175
         return image; // null image
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   176
@@ -640,15 +754,31 @@
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   177
 		   QImage::LittleEndian : QImage::BigEndian;
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   178
     }
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   179
     image.create( w, h, d, 0, bitOrder );
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   180
-    if ( image.isNull() )			// could not create image
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   181
+    if ( image.isNull() ) {			// could not create image
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   182
+#ifdef QT_MITSHM_CONVERSIONS
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   183
+        if( mitshm_ximage )
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   184
+            qt_XShmDestroyImage( xi, &shminfo );
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   185
+        else
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   186
+#endif
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   187
+        qSafeXDestroyImage( xi );
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   188
 	return image;
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   189
+    }
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   190
 
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   191
     const QPixmap* msk = mask();
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   192
     const QPixmap *alf = data->alphapm;
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   193
 
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   194
     QImage alpha;
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   195
     if (alf) {
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   196
-	XImage *axi = XGetImage(x11Display(), alf->hd, 0, 0, w, h, AllPlanes, ZPixmap);
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   197
+        XImage* axi;
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   198
+#ifdef QT_MITSHM_CONVERSIONS
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   199
+        bool mitshm_aximage = false;
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   200
+        XShmSegmentInfo ashminfo;
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   201
+        axi = qt_XShmGetImage( alf, ZPixmap, &ashminfo );
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   202
+        if( axi ) {
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   203
+            mitshm_aximage = true;
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   204
+        } else
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   205
+#endif
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   206
+            axi = XGetImage(x11Display(), alf->hd, 0, 0, w, h, AllPlanes, ZPixmap);
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   207
 
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   208
 	if (axi) {
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   209
 	    image.setAlphaBuffer( TRUE );
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   210
@@ -662,7 +792,12 @@
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   211
 		src += axi->bytes_per_line;
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   212
 	    }
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   213
 
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   214
-	    qSafeXDestroyImage( axi );
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   215
+#ifdef QT_MITSHM_CONVERSIONS
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   216
+            if( mitshm_aximage )
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   217
+                qt_XShmDestroyImage( axi, &ashminfo );
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   218
+            else
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   219
+#endif
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   220
+    	        qSafeXDestroyImage( axi );
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   221
 	}
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   222
     } else if (msk) {
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   223
 	image.setAlphaBuffer( TRUE );
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   224
@@ -804,6 +939,12 @@
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   225
 		  xi->bits_per_pixel );
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   226
 #endif
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   227
 	image.reset();
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   228
+#ifdef QT_MITSHM_CONVERSIONS
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   229
+        if( mitshm_ximage )
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   230
+            qt_XShmDestroyImage( xi, &shminfo );
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   231
+        else
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   232
+#endif
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   233
+            qSafeXDestroyImage( xi );
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   234
 	return image;
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   235
     }
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   236
 
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   237
@@ -909,10 +1050,22 @@
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   238
 	delete [] carr;
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   239
     }
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   240
     if ( data->optim != BestOptim ) {		// throw away image data
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   241
-	qSafeXDestroyImage( xi );
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   242
+#ifdef QT_MITSHM_CONVERSIONS
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   243
+        if( mitshm_ximage )
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   244
+            qt_XShmDestroyImage( xi, &shminfo );
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   245
+        else
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   246
+#endif
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   247
+            qSafeXDestroyImage( xi );
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   248
 	((QPixmap*)this)->data->ximage = 0;
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   249
-    } else					// keep ximage data
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   250
+    } else {					// keep ximage data
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   251
+#ifdef QT_MITSHM_CONVERSIONS
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   252
+        if( mitshm_ximage ) { // copy the XImage?
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   253
+            qt_XShmDestroyImage( xi, &shminfo );
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   254
+            xi = 0;
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   255
+        }
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   256
+#endif
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   257
 	((QPixmap*)this)->data->ximage = xi;
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   258
+    }
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   259
 
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   260
     return image;
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   261
 }
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   262
@@ -1085,6 +1238,11 @@
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   263
     bool    trucol = (visual->c_class == TrueColor || visual->c_class == DirectColor);
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   264
     int	    nbytes = image.numBytes();
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   265
     uchar  *newbits= 0;
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   266
+    int newbits_size = 0;
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   267
+#ifdef QT_MITSHM_CONVERSIONS
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   268
+    bool mitshm_ximage = false;
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   269
+    XShmSegmentInfo shminfo;
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   270
+#endif
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   271
 
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   272
     if ( trucol ) {				// truecolor display
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   273
 	QRgb  pix[256];				// pixel translation table
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   274
@@ -1113,11 +1271,20 @@
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   275
 	    }
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   276
 	}
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   277
 
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   278
-	xi = XCreateImage( dpy, visual, dd, ZPixmap, 0, 0, w, h, 32, 0 );
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   279
+#ifdef QT_MITSHM_CONVERSIONS
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   280
+        xi = qt_XShmCreateImage( dpy, visual, dd, ZPixmap, 0, 0, w, h, 32, 0, &shminfo );
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   281
+        if( xi != NULL ) {
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   282
+            mitshm_ximage = true;
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   283
+            newbits = (uchar*)xi->data;
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   284
+        }
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   285
+        else
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   286
+#endif
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   287
+	    xi = XCreateImage( dpy, visual, dd, ZPixmap, 0, 0, w, h, 32, 0 );
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   288
 	Q_CHECK_PTR( xi );
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   289
         if (!xi)
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   290
             return false;
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   291
-	newbits = (uchar *)malloc( xi->bytes_per_line*h );
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   292
+	if( newbits == NULL )
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   293
+	    newbits = (uchar *)malloc( xi->bytes_per_line*h );
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   294
 	Q_CHECK_PTR( newbits );
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   295
 	if ( !newbits )				// no memory
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   296
 	    return FALSE;
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   297
@@ -1323,6 +1490,7 @@
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   298
 	}
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   299
 
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   300
 	newbits = (uchar *)malloc( nbytes );	// copy image into newbits
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   301
+        newbits_size = nbytes;
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   302
 	Q_CHECK_PTR( newbits );
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   303
 	if ( !newbits )				// no memory
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   304
 	    return FALSE;
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   305
@@ -1440,11 +1608,18 @@
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   306
     }
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   307
 
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   308
     if ( !xi ) {				// X image not created
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   309
-	xi = XCreateImage( dpy, visual, dd, ZPixmap, 0, 0, w, h, 32, 0 );
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   310
+#ifdef QT_MITSHM_CONVERSIONS
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   311
+        xi = qt_XShmCreateImage( dpy, visual, dd, ZPixmap, 0, 0, w, h, 32, 0, &shminfo );
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   312
+        if( xi != NULL )
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   313
+            mitshm_ximage = true;
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   314
+        else
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   315
+#endif
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   316
+	    xi = XCreateImage( dpy, visual, dd, ZPixmap, 0, 0, w, h, 32, 0 );
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   317
 	if ( xi->bits_per_pixel == 16 ) {	// convert 8 bpp ==> 16 bpp
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   318
 	    ushort *p2;
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   319
 	    int	    p2inc = xi->bytes_per_line/sizeof(ushort);
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   320
 	    ushort *newerbits = (ushort *)malloc( xi->bytes_per_line * h );
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   321
+            newbits_size = xi->bytes_per_line * h;
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   322
 	    Q_CHECK_PTR( newerbits );
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   323
 	    if ( !newerbits )				// no memory
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   324
 		return FALSE;
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   325
@@ -1462,7 +1637,15 @@
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   326
 		      "(bpp=%d)", xi->bits_per_pixel );
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   327
 #endif
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   328
 	}
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   329
-	xi->data = (char *)newbits;
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   330
+#ifdef QT_MITSHM_CONVERSIONS
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   331
+        if( newbits_size > 0 && mitshm_ximage ) { // need to copy to shared memory
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   332
+            memcpy( xi->data, newbits, newbits_size );
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   333
+            free( newbits );
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   334
+            newbits = (uchar*)xi->data;
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   335
+        }
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   336
+        else
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   337
+#endif
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   338
+            xi->data = (char *)newbits;
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   339
     }
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   340
 
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   341
     if ( hd && (width() != (int)w || height() != (int)h || this->depth() != dd) ) {
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   342
@@ -1495,19 +1678,24 @@
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   343
 
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   344
     }
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   345
 
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   346
-    XPutImage( dpy, hd, qt_xget_readonly_gc( x11Screen(), FALSE  ),
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   347
-	       xi, 0, 0, 0, 0, w, h );
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   348
+#ifdef QT_MITSHM_CONVERSIONS
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   349
+    if( mitshm_ximage )
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   350
+        XShmPutImage( dpy, hd, qt_xget_readonly_gc( x11Screen(), FALSE ),
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   351
+                      xi, 0, 0, 0, 0, w, h, False );
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   352
+    else
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   353
+#endif
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   354
+        XPutImage( dpy, hd, qt_xget_readonly_gc( x11Screen(), FALSE  ),
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   355
+                   xi, 0, 0, 0, 0, w, h );
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   356
 
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   357
-    if ( data->optim != BestOptim ) {		// throw away image
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   358
-	qSafeXDestroyImage( xi );
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   359
-	data->ximage = 0;
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   360
-    } else {					// keep ximage that we created
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   361
-	data->ximage = xi;
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   362
-    }
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   363
     data->w = w;
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   364
     data->h = h;
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   365
     data->d = dd;
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   366
 
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   367
+    XImage* axi = NULL;
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   368
+#ifdef QT_MITSHM_CONVERSIONS
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   369
+    bool mitshm_aximage = false;
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   370
+    XShmSegmentInfo ashminfo;
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   371
+#endif
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   372
     if ( image.hasAlphaBuffer() ) {
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   373
 	QBitmap m;
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   374
 	m = image.createAlphaMask( conversion_flags );
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   375
@@ -1543,13 +1731,22 @@
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   376
 	    data->alphapm->rendhd =
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   377
 		(HANDLE) XftDrawCreateAlpha( x11Display(), data->alphapm->hd, 8 );
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   378
 
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   379
-	    XImage *axi = XCreateImage(x11Display(), (Visual *) x11Visual(),
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   380
+#ifdef QT_MITSHM_CONVERSIONS
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   381
+            axi = qt_XShmCreateImage( x11Display(), (Visual*)x11Visual(),
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   382
+                                      8, ZPixmap, 0, 0, w, h, 8, 0, &ashminfo );
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   383
+            if( axi != NULL )
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   384
+                mitshm_aximage = true;
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   385
+            else
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   386
+#endif
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   387
+	        axi = XCreateImage(x11Display(), (Visual *) x11Visual(),
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   388
 				       8, ZPixmap, 0, 0, w, h, 8, 0);
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   389
 
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   390
 	    if (axi) {
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   391
-		// the data is deleted by qSafeXDestroyImage
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   392
-                axi->data = (char *) malloc(h * axi->bytes_per_line);
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   393
-		Q_CHECK_PTR( axi->data );
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   394
+		if( axi->data==NULL ) {
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   395
+		    // the data is deleted by qSafeXDestroyImage
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   396
+                    axi->data = (char *) malloc(h * axi->bytes_per_line);
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   397
+		    Q_CHECK_PTR( axi->data );
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   398
+		}
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   399
                 char *aptr = axi->data;
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   400
 
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   401
                 if (image.depth() == 32) {
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   402
@@ -1567,7 +1764,12 @@
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   403
                 }
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   404
 
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   405
                 GC gc = XCreateGC(x11Display(), data->alphapm->hd, 0, 0);
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   406
-                XPutImage(dpy, data->alphapm->hd, gc, axi, 0, 0, 0, 0, w, h);
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   407
+#ifdef QT_MITSHM_CONVERSIONS
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   408
+                if( mitshm_aximage )
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   409
+                    XShmPutImage( dpy, data->alphapm->hd, gc, axi, 0, 0, 0, 0, w, h, False );
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   410
+                else
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   411
+#endif
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   412
+                    XPutImage(dpy, data->alphapm->hd, gc, axi, 0, 0, 0, 0, w, h);
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   413
                 XFreeGC(x11Display(), gc);
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   414
 		qSafeXDestroyImage(axi);
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   415
 	    }
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   416
@@ -1737,7 +1939,7 @@
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   417
 	return pm;
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   418
     }
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   419
 
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   420
-#if defined(QT_MITSHM)
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   421
+#if defined(QT_MITSHM_XFORM)
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   422
     static bool try_once = TRUE;
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   423
     if (try_once) {
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   424
 	try_once = FALSE;
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   425
@@ -1770,7 +1972,7 @@
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   426
 	dbpl = ((w*bpp+31)/32)*4;
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   427
     dbytes = dbpl*h;
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   428
 
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   429
-#if defined(QT_MITSHM)
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   430
+#if defined(QT_MITSHM_XFORM)
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   431
     if ( use_mitshm ) {
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   432
 	dptr = (uchar *)xshmimg->data;
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   433
 	uchar fillbyte = bpp == 8 ? white.pixel() : 0xff;
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   434
@@ -1786,7 +1988,7 @@
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   435
 	    memset( dptr, Qt::white.pixel( x11Screen() ), dbytes );
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   436
 	else
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   437
 	    memset( dptr, 0xff, dbytes );
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   438
-#if defined(QT_MITSHM)
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   439
+#if defined(QT_MITSHM_XFORM)
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   440
     }
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   441
 #endif
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   442
 
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   443
@@ -1817,7 +2019,7 @@
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   444
     } else {
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   445
 	xbpl  = (w*bpp)/8;
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   446
 	p_inc = dbpl - xbpl;
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   447
-#if defined(QT_MITSHM)
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   448
+#if defined(QT_MITSHM_XFORM)
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   449
 	if ( use_mitshm )
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   450
 	    p_inc = xshmimg->bytes_per_line - xbpl;
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   451
 #endif
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   452
@@ -1854,7 +2056,7 @@
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   453
 	QPixmap pm( w, h );
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   454
 	pm.data->uninit = FALSE;
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   455
 	pm.x11SetScreen( x11Screen() );
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   456
-#if defined(QT_MITSHM)
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   457
+#if defined(QT_MITSHM_XFORM)
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   458
 	if ( use_mitshm ) {
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   459
 	    XCopyArea( dpy, xshmpm, pm.handle(), gc, 0, 0, w, h, 0, 0 );
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   460
 	} else {
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   461
@@ -1863,7 +2065,7 @@
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   462
 			       ZPixmap, 0, (char *)dptr, w, h, 32, 0 );
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   463
 	    XPutImage( dpy, pm.handle(), gc, xi, 0, 0, 0, 0, w, h);
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   464
 	    qSafeXDestroyImage( xi );
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   465
-#if defined(QT_MITSHM)
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   466
+#if defined(QT_MITSHM_XFORM)
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   467
 	}
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   468
 #endif
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   469
 
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   470
--- qt-x11-free-3.3.8/mkspecs/linux-g++/qplatformdefs.h.orig	2008-01-08 20:53:20.515026849 +0530
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   471
+++ qt-x11-free-3.3.8/mkspecs/linux-g++/qplatformdefs.h	2008-01-08 20:53:32.448225016 +0530
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   472
@@ -102,5 +102,6 @@
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   473
 #define QT_VSNPRINTF		::vsnprintf
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   474
 #endif
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   475
 
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   476
+#define QT_MITSHM
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   477
 
a013313b88b4 QT3 Spec file and patches, initial revision.
moinakg
parents:
diff changeset
   478
 #endif // QPLATFORMDEFS_H