qxcbimage.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/plugins/platforms/xcb/qxcbimage.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5extern "C" {-
6}-
7-
8-
9-
10-
11-
12QImage::Format qt_xcb_imageFormatForVisual(QXcbConnection *connection, uint8_t depth,-
13 const xcb_visualtype_t *visual)-
14{-
15 const xcb_format_t *format = connection->formatForDepth(depth);-
16-
17 if (!visual
!visualDescription
TRUEnever evaluated
FALSEevaluated 72831 times by 105 tests
Evaluated by:
  • tst_QAbstractButton
  • tst_QAbstractItemView
  • tst_QAbstractScrollArea
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBoxLayout
  • tst_QBrush
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDataStream
  • tst_QDateTimeEdit
  • tst_QDialog
  • tst_QDialogButtonBox
  • tst_QDockWidget
  • tst_QDoubleSpinBox
  • tst_QErrorMessage
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • ...
|| !format
!formatDescription
TRUEnever evaluated
FALSEevaluated 72831 times by 105 tests
Evaluated by:
  • tst_QAbstractButton
  • tst_QAbstractItemView
  • tst_QAbstractScrollArea
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBoxLayout
  • tst_QBrush
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDataStream
  • tst_QDateTimeEdit
  • tst_QDialog
  • tst_QDialogButtonBox
  • tst_QDockWidget
  • tst_QDoubleSpinBox
  • tst_QErrorMessage
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • ...
)
0-72831
18 return
never executed: return QImage::Format_Invalid;
QImage::Format_Invalid;
never executed: return QImage::Format_Invalid;
0
19-
20 if (depth == 32
depth == 32Description
TRUEnever evaluated
FALSEevaluated 72831 times by 105 tests
Evaluated by:
  • tst_QAbstractButton
  • tst_QAbstractItemView
  • tst_QAbstractScrollArea
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBoxLayout
  • tst_QBrush
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDataStream
  • tst_QDateTimeEdit
  • tst_QDialog
  • tst_QDialogButtonBox
  • tst_QDockWidget
  • tst_QDoubleSpinBox
  • tst_QErrorMessage
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • ...
&& format->bits_per_pixel == 32
format->bits_per_pixel == 32Description
TRUEnever evaluated
FALSEnever evaluated
&& visual->red_mask == 0xff0000
visual->red_mask == 0xff0000Description
TRUEnever evaluated
FALSEnever evaluated
0-72831
21 && visual->green_mask == 0xff00
visual->green_mask == 0xff00Description
TRUEnever evaluated
FALSEnever evaluated
&& visual->blue_mask == 0xff
visual->blue_mask == 0xffDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
22 return
never executed: return QImage::Format_ARGB32_Premultiplied;
QImage::Format_ARGB32_Premultiplied;
never executed: return QImage::Format_ARGB32_Premultiplied;
0
23-
24 if (depth == 30
depth == 30Description
TRUEnever evaluated
FALSEevaluated 72831 times by 105 tests
Evaluated by:
  • tst_QAbstractButton
  • tst_QAbstractItemView
  • tst_QAbstractScrollArea
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBoxLayout
  • tst_QBrush
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDataStream
  • tst_QDateTimeEdit
  • tst_QDialog
  • tst_QDialogButtonBox
  • tst_QDockWidget
  • tst_QDoubleSpinBox
  • tst_QErrorMessage
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • ...
&& format->bits_per_pixel == 32
format->bits_per_pixel == 32Description
TRUEnever evaluated
FALSEnever evaluated
&& visual->red_mask == 0x3ff
visual->red_mask == 0x3ffDescription
TRUEnever evaluated
FALSEnever evaluated
0-72831
25 && visual->green_mask == 0x0ffc00
visual->green_mask == 0x0ffc00Description
TRUEnever evaluated
FALSEnever evaluated
&& visual->blue_mask == 0x3ff00000
visual->blue_m... == 0x3ff00000Description
TRUEnever evaluated
FALSEnever evaluated
)
0
26 return
never executed: return QImage::Format_BGR30;
QImage::Format_BGR30;
never executed: return QImage::Format_BGR30;
0
27-
28 if (depth == 30
depth == 30Description
TRUEnever evaluated
FALSEevaluated 72831 times by 105 tests
Evaluated by:
  • tst_QAbstractButton
  • tst_QAbstractItemView
  • tst_QAbstractScrollArea
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBoxLayout
  • tst_QBrush
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDataStream
  • tst_QDateTimeEdit
  • tst_QDialog
  • tst_QDialogButtonBox
  • tst_QDockWidget
  • tst_QDoubleSpinBox
  • tst_QErrorMessage
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • ...
&& format->bits_per_pixel == 32
format->bits_per_pixel == 32Description
TRUEnever evaluated
FALSEnever evaluated
&& visual->blue_mask == 0x3ff
visual->blue_mask == 0x3ffDescription
TRUEnever evaluated
FALSEnever evaluated
0-72831
29 && visual->green_mask == 0x0ffc00
visual->green_mask == 0x0ffc00Description
TRUEnever evaluated
FALSEnever evaluated
&& visual->red_mask == 0x3ff00000
visual->red_mask == 0x3ff00000Description
TRUEnever evaluated
FALSEnever evaluated
)
0
30 return
never executed: return QImage::Format_RGB30;
QImage::Format_RGB30;
never executed: return QImage::Format_RGB30;
0
31-
32 if (depth == 24
depth == 24Description
TRUEevaluated 72831 times by 105 tests
Evaluated by:
  • tst_QAbstractButton
  • tst_QAbstractItemView
  • tst_QAbstractScrollArea
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBoxLayout
  • tst_QBrush
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDataStream
  • tst_QDateTimeEdit
  • tst_QDialog
  • tst_QDialogButtonBox
  • tst_QDockWidget
  • tst_QDoubleSpinBox
  • tst_QErrorMessage
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • ...
FALSEnever evaluated
&& format->bits_per_pixel == 32
format->bits_per_pixel == 32Description
TRUEevaluated 72831 times by 105 tests
Evaluated by:
  • tst_QAbstractButton
  • tst_QAbstractItemView
  • tst_QAbstractScrollArea
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBoxLayout
  • tst_QBrush
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDataStream
  • tst_QDateTimeEdit
  • tst_QDialog
  • tst_QDialogButtonBox
  • tst_QDockWidget
  • tst_QDoubleSpinBox
  • tst_QErrorMessage
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • ...
FALSEnever evaluated
&& visual->red_mask == 0xff0000
visual->red_mask == 0xff0000Description
TRUEevaluated 72831 times by 105 tests
Evaluated by:
  • tst_QAbstractButton
  • tst_QAbstractItemView
  • tst_QAbstractScrollArea
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBoxLayout
  • tst_QBrush
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDataStream
  • tst_QDateTimeEdit
  • tst_QDialog
  • tst_QDialogButtonBox
  • tst_QDockWidget
  • tst_QDoubleSpinBox
  • tst_QErrorMessage
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • ...
FALSEnever evaluated
0-72831
33 && visual->green_mask == 0xff00
visual->green_mask == 0xff00Description
TRUEevaluated 72831 times by 105 tests
Evaluated by:
  • tst_QAbstractButton
  • tst_QAbstractItemView
  • tst_QAbstractScrollArea
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBoxLayout
  • tst_QBrush
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDataStream
  • tst_QDateTimeEdit
  • tst_QDialog
  • tst_QDialogButtonBox
  • tst_QDockWidget
  • tst_QDoubleSpinBox
  • tst_QErrorMessage
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • ...
FALSEnever evaluated
&& visual->blue_mask == 0xff
visual->blue_mask == 0xffDescription
TRUEevaluated 72831 times by 105 tests
Evaluated by:
  • tst_QAbstractButton
  • tst_QAbstractItemView
  • tst_QAbstractScrollArea
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBoxLayout
  • tst_QBrush
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDataStream
  • tst_QDateTimeEdit
  • tst_QDialog
  • tst_QDialogButtonBox
  • tst_QDockWidget
  • tst_QDoubleSpinBox
  • tst_QErrorMessage
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • ...
FALSEnever evaluated
)
0-72831
34 return
executed 72831 times by 105 tests: return QImage::Format_RGB32;
Executed by:
  • tst_QAbstractButton
  • tst_QAbstractItemView
  • tst_QAbstractScrollArea
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBoxLayout
  • tst_QBrush
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDataStream
  • tst_QDateTimeEdit
  • tst_QDialog
  • tst_QDialogButtonBox
  • tst_QDockWidget
  • tst_QDoubleSpinBox
  • tst_QErrorMessage
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • ...
QImage::Format_RGB32;
executed 72831 times by 105 tests: return QImage::Format_RGB32;
Executed by:
  • tst_QAbstractButton
  • tst_QAbstractItemView
  • tst_QAbstractScrollArea
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBoxLayout
  • tst_QBrush
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDataStream
  • tst_QDateTimeEdit
  • tst_QDialog
  • tst_QDialogButtonBox
  • tst_QDockWidget
  • tst_QDoubleSpinBox
  • tst_QErrorMessage
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • ...
72831
35-
36 if (depth == 16
depth == 16Description
TRUEnever evaluated
FALSEnever evaluated
&& format->bits_per_pixel == 16
format->bits_per_pixel == 16Description
TRUEnever evaluated
FALSEnever evaluated
&& visual->red_mask == 0xf800
visual->red_mask == 0xf800Description
TRUEnever evaluated
FALSEnever evaluated
0
37 && visual->green_mask == 0x7e0
visual->green_mask == 0x7e0Description
TRUEnever evaluated
FALSEnever evaluated
&& visual->blue_mask == 0x1f
visual->blue_mask == 0x1fDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
38 return
never executed: return QImage::Format_RGB16;
QImage::Format_RGB16;
never executed: return QImage::Format_RGB16;
0
39-
40 return
never executed: return QImage::Format_Invalid;
QImage::Format_Invalid;
never executed: return QImage::Format_Invalid;
0
41}-
42-
43QPixmap qt_xcb_pixmapFromXPixmap(QXcbConnection *connection, xcb_pixmap_t pixmap,-
44 int width, int height, int depth,-
45 const xcb_visualtype_t *visual)-
46{-
47 xcb_connection_t *conn = connection->xcb_connection();-
48-
49 xcb_get_image_cookie_t get_image_cookie =-
50 xcb_get_image_unchecked(conn, XCB_IMAGE_FORMAT_Z_PIXMAP, pixmap,-
51 0, 0, width, height, 0xffffffff);-
52-
53 xcb_get_image_reply_t *image_reply =-
54 xcb_get_image_reply(conn, get_image_cookie, __null);-
55-
56 if (!image_reply
!image_replyDescription
TRUEnever evaluated
FALSEevaluated 22 times by 3 tests
Evaluated by:
  • tst_QOpenGLWidget
  • tst_QToolTip
  • tst_QWidget
) {
0-22
57 return
never executed: return QPixmap();
QPixmap();
never executed: return QPixmap();
0
58 }-
59-
60 uint8_t *data = xcb_get_image_data(image_reply);-
61 uint32_t length = xcb_get_image_data_length(image_reply);-
62-
63 QPixmap result;-
64-
65 QImage::Format format = qt_xcb_imageFormatForVisual(connection, depth, visual);-
66 if (format != QImage::Format_Invalid
format != QIma...Format_InvalidDescription
TRUEevaluated 22 times by 3 tests
Evaluated by:
  • tst_QOpenGLWidget
  • tst_QToolTip
  • tst_QWidget
FALSEnever evaluated
) {
0-22
67 uint32_t bytes_per_line = length / height;-
68 QImage image(const_cast<uint8_t *>(data), width, height, bytes_per_line, format);-
69 uint8_t image_byte_order = connection->setup()->image_byte_order;-
70-
71-
72 if ((QSysInfo::ByteOrder == QSysInfo::LittleEndian
QSysInfo::Byte...::LittleEndianDescription
TRUEevaluated 22 times by 3 tests
Evaluated by:
  • tst_QOpenGLWidget
  • tst_QToolTip
  • tst_QWidget
FALSEnever evaluated
&& image_byte_order == XCB_IMAGE_ORDER_MSB_FIRST
image_byte_ord...RDER_MSB_FIRSTDescription
TRUEnever evaluated
FALSEevaluated 22 times by 3 tests
Evaluated by:
  • tst_QOpenGLWidget
  • tst_QToolTip
  • tst_QWidget
)
0-22
73 || (QSysInfo::ByteOrder == QSysInfo::BigEndian
QSysInfo::Byte...nfo::BigEndianDescription
TRUEnever evaluated
FALSEevaluated 22 times by 3 tests
Evaluated by:
  • tst_QOpenGLWidget
  • tst_QToolTip
  • tst_QWidget
&& image_byte_order == XCB_IMAGE_ORDER_LSB_FIRST
image_byte_ord...RDER_LSB_FIRSTDescription
TRUEnever evaluated
FALSEnever evaluated
))
0-22
74 {-
75 for (int i=0; i < image.height()
i < image.height()Description
TRUEnever evaluated
FALSEnever evaluated
; i++) {
0
76 switch (format) {-
77 case
never executed: case QImage::Format_RGB16:
QImage::Format_RGB16:
never executed: case QImage::Format_RGB16:
{
0
78 ushort *p = (ushort*)image.scanLine(i);-
79 ushort *end = p + image.width();-
80 while (p < end
p < endDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
81 *p = ((*p << 8) & 0xff00) | ((*p >> 8) & 0x00ff);-
82 p++;-
83 }
never executed: end of block
0
84 break;
never executed: break;
0
85 }-
86 case
never executed: case QImage::Format_RGB32:
QImage::Format_RGB32:
never executed: case QImage::Format_RGB32:
0
87 case
never executed: case QImage::Format_ARGB32_Premultiplied:
QImage::Format_ARGB32_Premultiplied:
never executed: case QImage::Format_ARGB32_Premultiplied:
{
0
88 uint *p = (uint*)image.scanLine(i);-
89 uint *end = p + image.width();-
90 while (p < end
p < endDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
91 *p = ((*p << 24) & 0xff000000) | ((*p << 8) & 0x00ff0000)-
92 | ((*p >> 8) & 0x0000ff00) | ((*p >> 24) & 0x000000ff);-
93 p++;-
94 }
never executed: end of block
0
95 break;
never executed: break;
0
96 }-
97 default
never executed: default:
:
never executed: default:
0
98 ((!(false)) ? qt_assert("false",__FILE__,143) : qt_noop());-
99 }
never executed: end of block
0
100 }-
101 }
never executed: end of block
0
102-
103-
104 if (format == QImage::Format_RGB32
format == QImage::Format_RGB32Description
TRUEevaluated 22 times by 3 tests
Evaluated by:
  • tst_QOpenGLWidget
  • tst_QToolTip
  • tst_QWidget
FALSEnever evaluated
) {
0-22
105 QRgb *p = (QRgb *)image.bits();-
106 for (int y = 0; y < height
y < heightDescription
TRUEevaluated 1856 times by 3 tests
Evaluated by:
  • tst_QOpenGLWidget
  • tst_QToolTip
  • tst_QWidget
FALSEevaluated 22 times by 3 tests
Evaluated by:
  • tst_QOpenGLWidget
  • tst_QToolTip
  • tst_QWidget
; ++y) {
22-1856
107 for (int x = 0; x < width
x < widthDescription
TRUEevaluated 487578 times by 3 tests
Evaluated by:
  • tst_QOpenGLWidget
  • tst_QToolTip
  • tst_QWidget
FALSEevaluated 1856 times by 3 tests
Evaluated by:
  • tst_QOpenGLWidget
  • tst_QToolTip
  • tst_QWidget
; ++x)
1856-487578
108 p[x] |= 0xff000000;
executed 487578 times by 3 tests: p[x] |= 0xff000000;
Executed by:
  • tst_QOpenGLWidget
  • tst_QToolTip
  • tst_QWidget
487578
109 p += bytes_per_line / 4;-
110 }
executed 1856 times by 3 tests: end of block
Executed by:
  • tst_QOpenGLWidget
  • tst_QToolTip
  • tst_QWidget
1856
111 }
executed 22 times by 3 tests: end of block
Executed by:
  • tst_QOpenGLWidget
  • tst_QToolTip
  • tst_QWidget
else if (format == QImage::Format_BGR30
format == QImage::Format_BGR30Description
TRUEnever evaluated
FALSEnever evaluated
|| format == QImage::Format_RGB30
format == QImage::Format_RGB30Description
TRUEnever evaluated
FALSEnever evaluated
) {
0-22
112 QRgb *p = (QRgb *)image.bits();-
113 for (int y = 0; y < height
y < heightDescription
TRUEnever evaluated
FALSEnever evaluated
; ++y) {
0
114 for (int x = 0; x < width
x < widthDescription
TRUEnever evaluated
FALSEnever evaluated
; ++x)
0
115 p[x] |= 0xc0000000;
never executed: p[x] |= 0xc0000000;
0
116 p += bytes_per_line / 4;-
117 }
never executed: end of block
0
118 }
never executed: end of block
0
119-
120 result = QPixmap::fromImage(image.copy());-
121 }
executed 22 times by 3 tests: end of block
Executed by:
  • tst_QOpenGLWidget
  • tst_QToolTip
  • tst_QWidget
22
122-
123 free(image_reply);-
124 return
executed 22 times by 3 tests: return result;
Executed by:
  • tst_QOpenGLWidget
  • tst_QToolTip
  • tst_QWidget
result;
executed 22 times by 3 tests: return result;
Executed by:
  • tst_QOpenGLWidget
  • tst_QToolTip
  • tst_QWidget
22
125}-
126-
127xcb_pixmap_t qt_xcb_XPixmapFromBitmap(QXcbScreen *screen, const QImage &image)-
128{-
129 xcb_connection_t *conn = screen->xcb_connection();-
130 QImage bitmap = image.convertToFormat(QImage::Format_MonoLSB);-
131 const QRgb c0 = QColor(Qt::black).rgb();-
132 const QRgb c1 = QColor(Qt::white).rgb();-
133 if (bitmap.color(0) == c0
bitmap.color(0) == c0Description
TRUEnever evaluated
FALSEnever evaluated
&& bitmap.color(1) == c1
bitmap.color(1) == c1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
134 bitmap.invertPixels();-
135 bitmap.setColor(0, c1);-
136 bitmap.setColor(1, c0);-
137 }
never executed: end of block
0
138 const int width = bitmap.width();-
139 const int height = bitmap.height();-
140 const int bytesPerLine = bitmap.bytesPerLine();-
141 int destLineSize = width / 8;-
142 if (width % 8
width % 8Description
TRUEnever evaluated
FALSEnever evaluated
)
0
143 ++
never executed: ++destLineSize;
destLineSize;
never executed: ++destLineSize;
0
144 const uchar *map = bitmap.bits();-
145 uint8_t *buf = new uint8_t[height * destLineSize];-
146 for (int i = 0; i < height
i < heightDescription
TRUEnever evaluated
FALSEnever evaluated
; i++)
0
147 memcpy(buf + (destLineSize * i), map + (bytesPerLine * i), destLineSize);
never executed: memcpy(buf + (destLineSize * i), map + (bytesPerLine * i), destLineSize);
0
148 xcb_pixmap_t pm = xcb_create_pixmap_from_bitmap_data(conn, screen->root(), buf,-
149 width, height, 1, 0, 0, 0);-
150 delete[] buf;-
151 return
never executed: return pm;
pm;
never executed: return pm;
0
152}-
153-
154xcb_cursor_t qt_xcb_createCursorXRender(QXcbScreen *screen, const QImage &image,-
155 const QPoint &spot)-
156{-
157-
158 xcb_connection_t *conn = screen->xcb_connection();-
159 const int w = image.width();-
160 const int h = image.height();-
161 xcb_generic_error_t *error = 0;-
162 xcb_render_query_pict_formats_cookie_t formatsCookie = xcb_render_query_pict_formats(conn);-
163 xcb_render_query_pict_formats_reply_t *formatsReply = xcb_render_query_pict_formats_reply(conn,-
164 formatsCookie,-
165 &error);-
166 if (!formatsReply
!formatsReplyDescription
TRUEnever evaluated
FALSEnever evaluated
|| error
errorDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
167 QMessageLogger(__FILE__, 212, __PRETTY_FUNCTION__).warning("qt_xcb_createCursorXRender: query_pict_formats failed");-
168 free(formatsReply);-
169 free(error);-
170 return
never executed: return 0L;
0L;
never executed: return 0L;
0
171 }-
172 xcb_render_pictforminfo_t *fmt = xcb_render_util_find_standard_format(formatsReply,-
173 XCB_PICT_STANDARD_ARGB_32);-
174 if (!fmt
!fmtDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
175 QMessageLogger(__FILE__, 220, __PRETTY_FUNCTION__).warning("qt_xcb_createCursorXRender: Failed to find format PICT_STANDARD_ARGB_32");-
176 free(formatsReply);-
177 return
never executed: return 0L;
0L;
never executed: return 0L;
0
178 }-
179-
180 QImage img = image.convertToFormat(QImage::Format_ARGB32_Premultiplied);-
181 xcb_image_t *xi = xcb_image_create(w, h, XCB_IMAGE_FORMAT_Z_PIXMAP,-
182 32, 32, 32, 32,-
183 QSysInfo::ByteOrder == QSysInfo::BigEndian ? XCB_IMAGE_ORDER_MSB_FIRST : XCB_IMAGE_ORDER_LSB_FIRST,-
184 XCB_IMAGE_ORDER_MSB_FIRST,-
185 0, 0, 0);-
186 if (!xi
!xiDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
187 QMessageLogger(__FILE__, 232, __PRETTY_FUNCTION__).warning("qt_xcb_createCursorXRender: xcb_image_create failed");-
188 free(formatsReply);-
189 return
never executed: return 0L;
0L;
never executed: return 0L;
0
190 }-
191 xi->data = (uint8_t *) malloc(xi->stride * h);-
192 if (!xi->data
!xi->dataDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
193 QMessageLogger(__FILE__, 238, __PRETTY_FUNCTION__).warning("qt_xcb_createCursorXRender: Failed to malloc() image data");-
194 xcb_image_destroy(xi);-
195 free(formatsReply);-
196 return
never executed: return 0L;
0L;
never executed: return 0L;
0
197 }-
198 memcpy(xi->data, img.constBits(), img.byteCount());-
199-
200 xcb_pixmap_t pix = xcb_generate_id(conn);-
201 xcb_create_pixmap(conn, 32, pix, screen->root(), w, h);-
202-
203 xcb_render_picture_t pic = xcb_generate_id(conn);-
204 xcb_render_create_picture(conn, pic, pix, fmt->id, 0, 0);-
205-
206 xcb_gcontext_t gc = xcb_generate_id(conn);-
207 xcb_create_gc(conn, gc, pix, 0, 0);-
208 xcb_image_put(conn, pix, gc, xi, 0, 0, 0);-
209 xcb_free_gc(conn, gc);-
210-
211 xcb_cursor_t cursor = xcb_generate_id(conn);-
212 xcb_render_create_cursor(conn, cursor, pic, spot.x(), spot.y());-
213-
214 free(xi->data);-
215 xcb_image_destroy(xi);-
216 xcb_render_free_picture(conn, pic);-
217 xcb_free_pixmap(conn, pix);-
218 free(formatsReply);-
219 return
never executed: return cursor;
cursor;
never executed: return cursor;
0
220-
221-
222-
223-
224-
225-
226-
227}-
228-
229-
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9