OpenCoverage

qxcbimage.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/plugins/platforms/xcb/qxcbimage.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2016 The Qt Company Ltd.-
4** Contact: https://www.qt.io/licensing/-
5**-
6** This file is part of the plugins of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL$-
9** Commercial License Usage-
10** Licensees holding valid commercial Qt licenses may use this file in-
11** accordance with the commercial license agreement provided with the-
12** Software or, alternatively, in accordance with the terms contained in-
13** a written agreement between you and The Qt Company. For licensing terms-
14** and conditions see https://www.qt.io/terms-conditions. For further-
15** information use the contact form at https://www.qt.io/contact-us.-
16**-
17** GNU Lesser General Public License Usage-
18** Alternatively, this file may be used under the terms of the GNU Lesser-
19** General Public License version 3 as published by the Free Software-
20** Foundation and appearing in the file LICENSE.LGPL3 included in the-
21** packaging of this file. Please review the following information to-
22** ensure the GNU Lesser General Public License version 3 requirements-
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.-
24**-
25** GNU General Public License Usage-
26** Alternatively, this file may be used under the terms of the GNU-
27** General Public License version 2.0 or (at your option) the GNU General-
28** Public license version 3 or any later version approved by the KDE Free-
29** Qt Foundation. The licenses are as published by the Free Software-
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3-
31** included in the packaging of this file. Please review the following-
32** information to ensure the GNU General Public License requirements will-
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and-
34** https://www.gnu.org/licenses/gpl-3.0.html.-
35**-
36** $QT_END_LICENSE$-
37**-
38****************************************************************************/-
39-
40#include "qxcbimage.h"-
41#include <QtGui/QColor>-
42#include <QtGui/private/qimage_p.h>-
43#include <QtGui/private/qdrawhelper_p.h>-
44#ifdef XCB_USE_RENDER-
45#include <xcb/render.h>-
46// 'template' is used as a function argument name in xcb_renderutil.h-
47#define template template_param-
48// extern "C" is missing too-
49extern "C" {-
50#include <xcb/xcb_renderutil.h>-
51}-
52#undef template-
53#endif-
54-
55QT_BEGIN_NAMESPACE-
56-
57QImage::Format qt_xcb_imageFormatForVisual(QXcbConnection *connection, uint8_t depth,-
58 const xcb_visualtype_t *visual)-
59{-
60 const xcb_format_t *format = connection->formatForDepth(depth);-
61-
62 if (!visual || !format)
!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
  • ...
!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
63 return QImage::Format_Invalid;
never executed: return QImage::Format_Invalid;
0
64-
65 if (depth == 32 && format->bits_per_pixel == 32 && visual->red_mask == 0xff0000
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 == 32Description
TRUEnever evaluated
FALSEnever evaluated
visual->red_mask == 0xff0000Description
TRUEnever evaluated
FALSEnever evaluated
0-72831
66 && visual->green_mask == 0xff00 && visual->blue_mask == 0xff)
visual->green_mask == 0xff00Description
TRUEnever evaluated
FALSEnever evaluated
visual->blue_mask == 0xffDescription
TRUEnever evaluated
FALSEnever evaluated
0
67 return QImage::Format_ARGB32_Premultiplied;
never executed: return QImage::Format_ARGB32_Premultiplied;
0
68-
69 if (depth == 30 && format->bits_per_pixel == 32 && visual->red_mask == 0x3ff
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 == 32Description
TRUEnever evaluated
FALSEnever evaluated
visual->red_mask == 0x3ffDescription
TRUEnever evaluated
FALSEnever evaluated
0-72831
70 && visual->green_mask == 0x0ffc00 && visual->blue_mask == 0x3ff00000)
visual->green_mask == 0x0ffc00Description
TRUEnever evaluated
FALSEnever evaluated
visual->blue_m... == 0x3ff00000Description
TRUEnever evaluated
FALSEnever evaluated
0
71 return QImage::Format_BGR30;
never executed: return QImage::Format_BGR30;
0
72-
73 if (depth == 30 && format->bits_per_pixel == 32 && visual->blue_mask == 0x3ff
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 == 32Description
TRUEnever evaluated
FALSEnever evaluated
visual->blue_mask == 0x3ffDescription
TRUEnever evaluated
FALSEnever evaluated
0-72831
74 && visual->green_mask == 0x0ffc00 && visual->red_mask == 0x3ff00000)
visual->green_mask == 0x0ffc00Description
TRUEnever evaluated
FALSEnever evaluated
visual->red_mask == 0x3ff00000Description
TRUEnever evaluated
FALSEnever evaluated
0
75 return QImage::Format_RGB30;
never executed: return QImage::Format_RGB30;
0
76-
77 if (depth == 24 && format->bits_per_pixel == 32 && visual->red_mask == 0xff0000
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 == 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 == 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
78 && visual->green_mask == 0xff00 && visual->blue_mask == 0xff)
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 == 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
79 return 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
80-
81 if (depth == 16 && format->bits_per_pixel == 16 && visual->red_mask == 0xf800
depth == 16Description
TRUEnever evaluated
FALSEnever evaluated
format->bits_per_pixel == 16Description
TRUEnever evaluated
FALSEnever evaluated
visual->red_mask == 0xf800Description
TRUEnever evaluated
FALSEnever evaluated
0
82 && visual->green_mask == 0x7e0 && visual->blue_mask == 0x1f)
visual->green_mask == 0x7e0Description
TRUEnever evaluated
FALSEnever evaluated
visual->blue_mask == 0x1fDescription
TRUEnever evaluated
FALSEnever evaluated
0
83 return QImage::Format_RGB16;
never executed: return QImage::Format_RGB16;
0
84-
85 return QImage::Format_Invalid;
never executed: return QImage::Format_Invalid;
0
86}-
87-
88QPixmap qt_xcb_pixmapFromXPixmap(QXcbConnection *connection, xcb_pixmap_t pixmap,-
89 int width, int height, int depth,-
90 const xcb_visualtype_t *visual)-
91{-
92 xcb_connection_t *conn = connection->xcb_connection();-
93-
94 xcb_get_image_cookie_t get_image_cookie =-
95 xcb_get_image_unchecked(conn, XCB_IMAGE_FORMAT_Z_PIXMAP, pixmap,-
96 0, 0, width, height, 0xffffffff);-
97-
98 xcb_get_image_reply_t *image_reply =-
99 xcb_get_image_reply(conn, get_image_cookie, NULL);-
100-
101 if (!image_reply) {
!image_replyDescription
TRUEnever evaluated
FALSEevaluated 22 times by 3 tests
Evaluated by:
  • tst_QOpenGLWidget
  • tst_QToolTip
  • tst_QWidget
0-22
102 return QPixmap();
never executed: return QPixmap();
0
103 }-
104-
105 uint8_t *data = xcb_get_image_data(image_reply);-
106 uint32_t length = xcb_get_image_data_length(image_reply);-
107-
108 QPixmap result;-
109-
110 QImage::Format format = qt_xcb_imageFormatForVisual(connection, depth, visual);-
111 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
112 uint32_t bytes_per_line = length / height;-
113 QImage image(const_cast<uint8_t *>(data), width, height, bytes_per_line, format);-
114 uint8_t image_byte_order = connection->setup()->image_byte_order;-
115-
116 // we may have to swap the byte order-
117 if ((QSysInfo::ByteOrder == QSysInfo::LittleEndian && image_byte_order == XCB_IMAGE_ORDER_MSB_FIRST)
QSysInfo::Byte...::LittleEndianDescription
TRUEevaluated 22 times by 3 tests
Evaluated by:
  • tst_QOpenGLWidget
  • tst_QToolTip
  • tst_QWidget
FALSEnever evaluated
image_byte_ord...RDER_MSB_FIRSTDescription
TRUEnever evaluated
FALSEevaluated 22 times by 3 tests
Evaluated by:
  • tst_QOpenGLWidget
  • tst_QToolTip
  • tst_QWidget
0-22
118 || (QSysInfo::ByteOrder == QSysInfo::BigEndian && image_byte_order == XCB_IMAGE_ORDER_LSB_FIRST))
QSysInfo::Byte...nfo::BigEndianDescription
TRUEnever evaluated
FALSEevaluated 22 times by 3 tests
Evaluated by:
  • tst_QOpenGLWidget
  • tst_QToolTip
  • tst_QWidget
image_byte_ord...RDER_LSB_FIRSTDescription
TRUEnever evaluated
FALSEnever evaluated
0-22
119 {-
120 for (int i=0; i < image.height(); i++) {
i < image.height()Description
TRUEnever evaluated
FALSEnever evaluated
0
121 switch (format) {-
122 case QImage::Format_RGB16: {
never executed: case QImage::Format_RGB16:
0
123 ushort *p = (ushort*)image.scanLine(i);-
124 ushort *end = p + image.width();-
125 while (p < end) {
p < endDescription
TRUEnever evaluated
FALSEnever evaluated
0
126 *p = ((*p << 8) & 0xff00) | ((*p >> 8) & 0x00ff);-
127 p++;-
128 }
never executed: end of block
0
129 break;
never executed: break;
0
130 }-
131 case QImage::Format_RGB32: // fall-through
never executed: case QImage::Format_RGB32:
0
132 case QImage::Format_ARGB32_Premultiplied: {
never executed: case QImage::Format_ARGB32_Premultiplied:
0
133 uint *p = (uint*)image.scanLine(i);-
134 uint *end = p + image.width();-
135 while (p < end) {
p < endDescription
TRUEnever evaluated
FALSEnever evaluated
0
136 *p = ((*p << 24) & 0xff000000) | ((*p << 8) & 0x00ff0000)-
137 | ((*p >> 8) & 0x0000ff00) | ((*p >> 24) & 0x000000ff);-
138 p++;-
139 }
never executed: end of block
0
140 break;
never executed: break;
0
141 }-
142 default:
never executed: default:
0
143 Q_ASSERT(false);-
144 }
never executed: end of block
0
145 }-
146 }
never executed: end of block
0
147-
148 // fix-up alpha channel-
149 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
150 QRgb *p = (QRgb *)image.bits();-
151 for (int y = 0; y < height; ++y) {
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
22-1856
152 for (int x = 0; x < width; ++x)
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
1856-487578
153 p[x] |= 0xff000000;
executed 487578 times by 3 tests: p[x] |= 0xff000000;
Executed by:
  • tst_QOpenGLWidget
  • tst_QToolTip
  • tst_QWidget
487578
154 p += bytes_per_line / 4;-
155 }
executed 1856 times by 3 tests: end of block
Executed by:
  • tst_QOpenGLWidget
  • tst_QToolTip
  • tst_QWidget
1856
156 } else if (format == QImage::Format_BGR30 || format == QImage::Format_RGB30) {
executed 22 times by 3 tests: end of block
Executed by:
  • tst_QOpenGLWidget
  • tst_QToolTip
  • tst_QWidget
format == QImage::Format_BGR30Description
TRUEnever evaluated
FALSEnever evaluated
format == QImage::Format_RGB30Description
TRUEnever evaluated
FALSEnever evaluated
0-22
157 QRgb *p = (QRgb *)image.bits();-
158 for (int y = 0; y < height; ++y) {
y < heightDescription
TRUEnever evaluated
FALSEnever evaluated
0
159 for (int x = 0; x < width; ++x)
x < widthDescription
TRUEnever evaluated
FALSEnever evaluated
0
160 p[x] |= 0xc0000000;
never executed: p[x] |= 0xc0000000;
0
161 p += bytes_per_line / 4;-
162 }
never executed: end of block
0
163 }
never executed: end of block
0
164-
165 result = QPixmap::fromImage(image.copy());-
166 }
executed 22 times by 3 tests: end of block
Executed by:
  • tst_QOpenGLWidget
  • tst_QToolTip
  • tst_QWidget
22
167-
168 free(image_reply);-
169 return result;
executed 22 times by 3 tests: return result;
Executed by:
  • tst_QOpenGLWidget
  • tst_QToolTip
  • tst_QWidget
22
170}-
171-
172xcb_pixmap_t qt_xcb_XPixmapFromBitmap(QXcbScreen *screen, const QImage &image)-
173{-
174 xcb_connection_t *conn = screen->xcb_connection();-
175 QImage bitmap = image.convertToFormat(QImage::Format_MonoLSB);-
176 const QRgb c0 = QColor(Qt::black).rgb();-
177 const QRgb c1 = QColor(Qt::white).rgb();-
178 if (bitmap.color(0) == c0 && bitmap.color(1) == c1) {
bitmap.color(0) == c0Description
TRUEnever evaluated
FALSEnever evaluated
bitmap.color(1) == c1Description
TRUEnever evaluated
FALSEnever evaluated
0
179 bitmap.invertPixels();-
180 bitmap.setColor(0, c1);-
181 bitmap.setColor(1, c0);-
182 }
never executed: end of block
0
183 const int width = bitmap.width();-
184 const int height = bitmap.height();-
185 const int bytesPerLine = bitmap.bytesPerLine();-
186 int destLineSize = width / 8;-
187 if (width % 8)
width % 8Description
TRUEnever evaluated
FALSEnever evaluated
0
188 ++destLineSize;
never executed: ++destLineSize;
0
189 const uchar *map = bitmap.bits();-
190 uint8_t *buf = new uint8_t[height * destLineSize];-
191 for (int i = 0; i < height; i++)
i < heightDescription
TRUEnever evaluated
FALSEnever evaluated
0
192 memcpy(buf + (destLineSize * i), map + (bytesPerLine * i), destLineSize);
never executed: memcpy(buf + (destLineSize * i), map + (bytesPerLine * i), destLineSize);
0
193 xcb_pixmap_t pm = xcb_create_pixmap_from_bitmap_data(conn, screen->root(), buf,-
194 width, height, 1, 0, 0, 0);-
195 delete[] buf;-
196 return pm;
never executed: return pm;
0
197}-
198-
199xcb_cursor_t qt_xcb_createCursorXRender(QXcbScreen *screen, const QImage &image,-
200 const QPoint &spot)-
201{-
202#ifdef XCB_USE_RENDER-
203 xcb_connection_t *conn = screen->xcb_connection();-
204 const int w = image.width();-
205 const int h = image.height();-
206 xcb_generic_error_t *error = 0;-
207 xcb_render_query_pict_formats_cookie_t formatsCookie = xcb_render_query_pict_formats(conn);-
208 xcb_render_query_pict_formats_reply_t *formatsReply = xcb_render_query_pict_formats_reply(conn,-
209 formatsCookie,-
210 &error);-
211 if (!formatsReply || error) {
!formatsReplyDescription
TRUEnever evaluated
FALSEnever evaluated
errorDescription
TRUEnever evaluated
FALSEnever evaluated
0
212 qWarning("qt_xcb_createCursorXRender: query_pict_formats failed");-
213 free(formatsReply);-
214 free(error);-
215 return XCB_NONE;
never executed: return 0L;
0
216 }-
217 xcb_render_pictforminfo_t *fmt = xcb_render_util_find_standard_format(formatsReply,-
218 XCB_PICT_STANDARD_ARGB_32);-
219 if (!fmt) {
!fmtDescription
TRUEnever evaluated
FALSEnever evaluated
0
220 qWarning("qt_xcb_createCursorXRender: Failed to find format PICT_STANDARD_ARGB_32");-
221 free(formatsReply);-
222 return XCB_NONE;
never executed: return 0L;
0
223 }-
224-
225 QImage img = image.convertToFormat(QImage::Format_ARGB32_Premultiplied);-
226 xcb_image_t *xi = xcb_image_create(w, h, XCB_IMAGE_FORMAT_Z_PIXMAP,-
227 32, 32, 32, 32,-
228 QSysInfo::ByteOrder == QSysInfo::BigEndian ? XCB_IMAGE_ORDER_MSB_FIRST : XCB_IMAGE_ORDER_LSB_FIRST,-
229 XCB_IMAGE_ORDER_MSB_FIRST,-
230 0, 0, 0);-
231 if (!xi) {
!xiDescription
TRUEnever evaluated
FALSEnever evaluated
0
232 qWarning("qt_xcb_createCursorXRender: xcb_image_create failed");-
233 free(formatsReply);-
234 return XCB_NONE;
never executed: return 0L;
0
235 }-
236 xi->data = (uint8_t *) malloc(xi->stride * h);-
237 if (!xi->data) {
!xi->dataDescription
TRUEnever evaluated
FALSEnever evaluated
0
238 qWarning("qt_xcb_createCursorXRender: Failed to malloc() image data");-
239 xcb_image_destroy(xi);-
240 free(formatsReply);-
241 return XCB_NONE;
never executed: return 0L;
0
242 }-
243 memcpy(xi->data, img.constBits(), img.byteCount());-
244-
245 xcb_pixmap_t pix = xcb_generate_id(conn);-
246 xcb_create_pixmap(conn, 32, pix, screen->root(), w, h);-
247-
248 xcb_render_picture_t pic = xcb_generate_id(conn);-
249 xcb_render_create_picture(conn, pic, pix, fmt->id, 0, 0);-
250-
251 xcb_gcontext_t gc = xcb_generate_id(conn);-
252 xcb_create_gc(conn, gc, pix, 0, 0);-
253 xcb_image_put(conn, pix, gc, xi, 0, 0, 0);-
254 xcb_free_gc(conn, gc);-
255-
256 xcb_cursor_t cursor = xcb_generate_id(conn);-
257 xcb_render_create_cursor(conn, cursor, pic, spot.x(), spot.y());-
258-
259 free(xi->data);-
260 xcb_image_destroy(xi);-
261 xcb_render_free_picture(conn, pic);-
262 xcb_free_pixmap(conn, pix);-
263 free(formatsReply);-
264 return cursor;
never executed: return cursor;
0
265-
266#else-
267 Q_UNUSED(screen);-
268 Q_UNUSED(image);-
269 Q_UNUSED(spot);-
270 return XCB_NONE;-
271#endif-
272}-
273-
274QT_END_NAMESPACE-
Source codeSwitch to Preprocessed file

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