Line | Source Code | Coverage |
---|
1 | /**************************************************************************** | - |
2 | ** | - |
3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). | - |
4 | ** Contact: http://www.qt-project.org/legal | - |
5 | ** | - |
6 | ** This file is part of the QtGui module 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 Digia. For licensing terms and | - |
14 | ** conditions see http://qt.digia.com/licensing. For further information | - |
15 | ** use the contact form at http://qt.digia.com/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 2.1 as published by the Free Software | - |
20 | ** Foundation and appearing in the file LICENSE.LGPL included in the | - |
21 | ** packaging of this file. Please review the following information to | - |
22 | ** ensure the GNU Lesser General Public License version 2.1 requirements | - |
23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - |
24 | ** | - |
25 | ** In addition, as a special exception, Digia gives you certain additional | - |
26 | ** rights. These rights are described in the Digia Qt LGPL Exception | - |
27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - |
28 | ** | - |
29 | ** GNU General Public License Usage | - |
30 | ** Alternatively, this file may be used under the terms of the GNU | - |
31 | ** General Public License version 3.0 as published by the Free Software | - |
32 | ** Foundation and appearing in the file LICENSE.GPL included in the | - |
33 | ** packaging of this file. Please review the following information to | - |
34 | ** ensure the GNU General Public License version 3.0 requirements will be | - |
35 | ** met: http://www.gnu.org/copyleft/gpl.html. | - |
36 | ** | - |
37 | ** | - |
38 | ** $QT_END_LICENSE$ | - |
39 | ** | - |
40 | ****************************************************************************/ | - |
41 | | - |
42 | #include "qplatformpixmap.h" | - |
43 | #include <qpa/qplatformintegration.h> | - |
44 | #include <QtCore/qbuffer.h> | - |
45 | #include <QtGui/qbitmap.h> | - |
46 | #include <QtGui/qimagereader.h> | - |
47 | #include <private/qguiapplication_p.h> | - |
48 | #include <private/qimagepixmapcleanuphooks_p.h> | - |
49 | | - |
50 | QT_BEGIN_NAMESPACE | - |
51 | | - |
52 | /*! | - |
53 | \class QPlatformPixmap | - |
54 | \since 5.0 | - |
55 | \internal | - |
56 | \preliminary | - |
57 | \ingroup qpa | - |
58 | | - |
59 | \brief The QPlatformPixmap class provides an abstraction for native pixmaps. | - |
60 | */ | - |
61 | QPlatformPixmap *QPlatformPixmap::create(int w, int h, PixelType type) | - |
62 | { | - |
63 | QPlatformPixmap *data = QGuiApplicationPrivate::platformIntegration()->createPlatformPixmap(static_cast<QPlatformPixmap::PixelType>(type)); executed (the execution status of this line is deduced): QPlatformPixmap *data = QGuiApplicationPrivate::platformIntegration()->createPlatformPixmap(static_cast<QPlatformPixmap::PixelType>(type)); | - |
64 | data->resize(w, h); executed (the execution status of this line is deduced): data->resize(w, h); | - |
65 | return data; executed: return data; Execution Count:938 | 938 |
66 | } | - |
67 | | - |
68 | | - |
69 | QPlatformPixmap::QPlatformPixmap(PixelType pixelType, int objectId) | - |
70 | : w(0), | - |
71 | h(0), | - |
72 | d(0), | - |
73 | is_null(true), | - |
74 | ref(0), | - |
75 | detach_no(0), | - |
76 | type(pixelType), | - |
77 | id(objectId), | - |
78 | ser_no(0), | - |
79 | is_cached(false) | - |
80 | { | - |
81 | } executed: } Execution Count:5017 | 5017 |
82 | | - |
83 | QPlatformPixmap::~QPlatformPixmap() | - |
84 | { | - |
85 | // Sometimes the pixmap cleanup hooks will be called from derrived classes, which will | - |
86 | // then set is_cached to false. For example, on X11 Qt GUI needs to delete the GLXPixmap | - |
87 | // or EGL Pixmap Surface for a given pixmap _before_ the native X11 pixmap is deleted, | - |
88 | // otherwise some drivers will leak the GL surface. In this case, QX11PlatformPixmap will | - |
89 | // call the cleanup hooks itself before deleting the native pixmap and set is_cached to | - |
90 | // false. | - |
91 | if (is_cached) { partially evaluated: is_cached no Evaluation Count:0 | yes Evaluation Count:4995 |
| 0-4995 |
92 | QImagePixmapCleanupHooks::executePlatformPixmapDestructionHooks(this); never executed (the execution status of this line is deduced): QImagePixmapCleanupHooks::executePlatformPixmapDestructionHooks(this); | - |
93 | is_cached = false; never executed (the execution status of this line is deduced): is_cached = false; | - |
94 | } | 0 |
95 | } executed: } Execution Count:4995 | 4995 |
96 | | - |
97 | QPlatformPixmap *QPlatformPixmap::createCompatiblePlatformPixmap() const | - |
98 | { | - |
99 | QPlatformPixmap *d = QGuiApplicationPrivate::platformIntegration()->createPlatformPixmap(pixelType()); never executed (the execution status of this line is deduced): QPlatformPixmap *d = QGuiApplicationPrivate::platformIntegration()->createPlatformPixmap(pixelType()); | - |
100 | return d; never executed: return d; | 0 |
101 | } | - |
102 | | - |
103 | static QImage makeBitmapCompliantIfNeeded(QPlatformPixmap *d, const QImage &image, Qt::ImageConversionFlags flags) | - |
104 | { | - |
105 | if (d->pixelType() == QPlatformPixmap::BitmapType) { evaluated: d->pixelType() == QPlatformPixmap::BitmapType yes Evaluation Count:1 | yes Evaluation Count:121 |
| 1-121 |
106 | QImage img = image.convertToFormat(QImage::Format_MonoLSB, flags); executed (the execution status of this line is deduced): QImage img = image.convertToFormat(QImage::Format_MonoLSB, flags); | - |
107 | | - |
108 | // make sure image.color(0) == Qt::color0 (white) | - |
109 | // and image.color(1) == Qt::color1 (black) | - |
110 | const QRgb c0 = QColor(Qt::black).rgb(); executed (the execution status of this line is deduced): const QRgb c0 = QColor(Qt::black).rgb(); | - |
111 | const QRgb c1 = QColor(Qt::white).rgb(); executed (the execution status of this line is deduced): const QRgb c1 = QColor(Qt::white).rgb(); | - |
112 | if (img.color(0) == c0 && img.color(1) == c1) { partially evaluated: img.color(0) == c0 no Evaluation Count:0 | yes Evaluation Count:1 |
never evaluated: img.color(1) == c1 | 0-1 |
113 | img.invertPixels(); never executed (the execution status of this line is deduced): img.invertPixels(); | - |
114 | img.setColor(0, c1); never executed (the execution status of this line is deduced): img.setColor(0, c1); | - |
115 | img.setColor(1, c0); never executed (the execution status of this line is deduced): img.setColor(1, c0); | - |
116 | } | 0 |
117 | return img; executed: return img; Execution Count:1 | 1 |
118 | } | - |
119 | | - |
120 | return image; executed: return image; Execution Count:121 | 121 |
121 | } | - |
122 | | - |
123 | void QPlatformPixmap::fromImageReader(QImageReader *imageReader, | - |
124 | Qt::ImageConversionFlags flags) | - |
125 | { | - |
126 | const QImage image = imageReader->read(); never executed (the execution status of this line is deduced): const QImage image = imageReader->read(); | - |
127 | fromImage(image, flags); never executed (the execution status of this line is deduced): fromImage(image, flags); | - |
128 | } | 0 |
129 | | - |
130 | bool QPlatformPixmap::fromFile(const QString &fileName, const char *format, | - |
131 | Qt::ImageConversionFlags flags) | - |
132 | { | - |
133 | QImage image = QImageReader(fileName, format).read(); executed (the execution status of this line is deduced): QImage image = QImageReader(fileName, format).read(); | - |
134 | if (image.isNull()) evaluated: image.isNull() yes Evaluation Count:5 | yes Evaluation Count:122 |
| 5-122 |
135 | return false; executed: return false; Execution Count:5 | 5 |
136 | fromImage(makeBitmapCompliantIfNeeded(this, image, flags), flags); executed (the execution status of this line is deduced): fromImage(makeBitmapCompliantIfNeeded(this, image, flags), flags); | - |
137 | return !isNull(); executed: return !isNull(); Execution Count:122 | 122 |
138 | } | - |
139 | | - |
140 | bool QPlatformPixmap::fromData(const uchar *buf, uint len, const char *format, Qt::ImageConversionFlags flags) | - |
141 | { | - |
142 | QByteArray a = QByteArray::fromRawData(reinterpret_cast<const char *>(buf), len); never executed (the execution status of this line is deduced): QByteArray a = QByteArray::fromRawData(reinterpret_cast<const char *>(buf), len); | - |
143 | QBuffer b(&a); never executed (the execution status of this line is deduced): QBuffer b(&a); | - |
144 | b.open(QIODevice::ReadOnly); never executed (the execution status of this line is deduced): b.open(QIODevice::ReadOnly); | - |
145 | QImage image = QImageReader(&b, format).read(); never executed (the execution status of this line is deduced): QImage image = QImageReader(&b, format).read(); | - |
146 | if (image.isNull()) never evaluated: image.isNull() | 0 |
147 | return false; never executed: return false; | 0 |
148 | fromImage(makeBitmapCompliantIfNeeded(this, image, flags), flags); never executed (the execution status of this line is deduced): fromImage(makeBitmapCompliantIfNeeded(this, image, flags), flags); | - |
149 | return !isNull(); never executed: return !isNull(); | 0 |
150 | } | - |
151 | | - |
152 | void QPlatformPixmap::copy(const QPlatformPixmap *data, const QRect &rect) | - |
153 | { | - |
154 | fromImage(data->toImage(rect), Qt::NoOpaqueDetection); never executed (the execution status of this line is deduced): fromImage(data->toImage(rect), Qt::NoOpaqueDetection); | - |
155 | } | 0 |
156 | | - |
157 | bool QPlatformPixmap::scroll(int dx, int dy, const QRect &rect) | - |
158 | { | - |
159 | Q_UNUSED(dx); never executed (the execution status of this line is deduced): (void)dx;; | - |
160 | Q_UNUSED(dy); never executed (the execution status of this line is deduced): (void)dy;; | - |
161 | Q_UNUSED(rect); never executed (the execution status of this line is deduced): (void)rect;; | - |
162 | return false; never executed: return false; | 0 |
163 | } | - |
164 | | - |
165 | QPixmap QPlatformPixmap::transformed(const QTransform &matrix, | - |
166 | Qt::TransformationMode mode) const | - |
167 | { | - |
168 | return QPixmap::fromImage(toImage().transformed(matrix, mode)); executed: return QPixmap::fromImage(toImage().transformed(matrix, mode)); Execution Count:103 | 103 |
169 | } | - |
170 | | - |
171 | void QPlatformPixmap::setSerialNumber(int serNo) | - |
172 | { | - |
173 | ser_no = serNo; executed (the execution status of this line is deduced): ser_no = serNo; | - |
174 | } executed: } Execution Count:5219 | 5219 |
175 | | - |
176 | QImage QPlatformPixmap::toImage(const QRect &rect) const | - |
177 | { | - |
178 | if (rect.contains(QRect(0, 0, w, h))) never evaluated: rect.contains(QRect(0, 0, w, h)) | 0 |
179 | return toImage(); never executed: return toImage(); | 0 |
180 | else | - |
181 | return toImage().copy(rect); never executed: return toImage().copy(rect); | 0 |
182 | } | - |
183 | | - |
184 | QImage* QPlatformPixmap::buffer() | - |
185 | { | - |
186 | return 0; never executed: return 0; | 0 |
187 | } | - |
188 | | - |
189 | | - |
190 | QT_END_NAMESPACE | - |
191 | | - |
| | |