Line | Source Code | Coverage |
---|
1 | | - |
2 | | - |
3 | | - |
4 | class QColormapPrivate | - |
5 | { | - |
6 | public: | - |
7 | inline QColormapPrivate() | - |
8 | : ref(1), mode(QColormap::Direct), depth(0), numcolors(0) | - |
9 | { } executed: } Execution Count:215 | 215 |
10 | | - |
11 | QAtomicInt ref; | - |
12 | | - |
13 | QColormap::Mode mode; | - |
14 | int depth; | - |
15 | int numcolors; | - |
16 | }; | - |
17 | | - |
18 | static QColormapPrivate *screenMap = 0; | - |
19 | | - |
20 | void QColormap::initialize() | - |
21 | { | - |
22 | screenMap = new QColormapPrivate; | - |
23 | | - |
24 | screenMap->depth = QGuiApplication::primaryScreen()->depth(); | - |
25 | if (screenMap->depth < 8) { partially evaluated: screenMap->depth < 8 no Evaluation Count:0 | yes Evaluation Count:215 |
| 0-215 |
26 | screenMap->mode = QColormap::Indexed; | - |
27 | screenMap->numcolors = 256; | - |
28 | } else { | 0 |
29 | screenMap->mode = QColormap::Direct; | - |
30 | screenMap->numcolors = -1; | - |
31 | } executed: } Execution Count:215 | 215 |
32 | } | - |
33 | | - |
34 | void QColormap::cleanup() | - |
35 | { | - |
36 | delete screenMap; | - |
37 | screenMap = 0; | - |
38 | } executed: } Execution Count:213 | 213 |
39 | | - |
40 | QColormap QColormap::instance(int ) | - |
41 | { | - |
42 | return QColormap(); executed: return QColormap(); Execution Count:79 | 79 |
43 | } | - |
44 | | - |
45 | QColormap::QColormap() | - |
46 | : d(screenMap) | - |
47 | { d->ref.ref(); } executed: } Execution Count:79 | 79 |
48 | | - |
49 | QColormap::QColormap(const QColormap &colormap) | - |
50 | :d (colormap.d) | - |
51 | { d->ref.ref(); } | 0 |
52 | | - |
53 | QColormap::~QColormap() | - |
54 | { | - |
55 | if (!d->ref.deref()) partially evaluated: !d->ref.deref() no Evaluation Count:0 | yes Evaluation Count:79 |
| 0-79 |
56 | delete d; never executed: delete d; | 0 |
57 | } executed: } Execution Count:79 | 79 |
58 | | - |
59 | QColormap::Mode QColormap::mode() const | - |
60 | { return d->mode; } never executed: return d->mode; | 0 |
61 | | - |
62 | | - |
63 | int QColormap::depth() const | - |
64 | { return d->depth; } executed: return d->depth; Execution Count:79 | 79 |
65 | | - |
66 | | - |
67 | int QColormap::size() const | - |
68 | { | - |
69 | return d->numcolors; never executed: return d->numcolors; | 0 |
70 | } | - |
71 | | - |
72 | | - |
73 | | - |
74 | | - |
75 | static const int qt_rbits = (565/100); | - |
76 | static const int qt_gbits = (565/10%10); | - |
77 | static const int qt_bbits = (565%10); | - |
78 | static const int qt_red_shift = qt_bbits+qt_gbits-(8-qt_rbits); | - |
79 | static const int qt_green_shift = qt_bbits-(8-qt_gbits); | - |
80 | static const int qt_neg_blue_shift = 8-qt_bbits; | - |
81 | static const int qt_blue_mask = (1<<qt_bbits)-1; | - |
82 | static const int qt_green_mask = (1<<(qt_gbits+qt_bbits))-(1<<qt_bbits); | - |
83 | static const int qt_red_mask = (1<<(qt_rbits+qt_gbits+qt_bbits))-(1<<(qt_gbits+qt_bbits)); | - |
84 | | - |
85 | static const int qt_red_rounding_shift = qt_red_shift + qt_rbits; | - |
86 | static const int qt_green_rounding_shift = qt_green_shift + qt_gbits; | - |
87 | static const int qt_blue_rounding_shift = qt_bbits - qt_neg_blue_shift; | - |
88 | | - |
89 | inline ushort qt_convRgbTo16(QRgb c) | - |
90 | { | - |
91 | const int tr = qRed(c) << qt_red_shift; | - |
92 | const int tg = qGreen(c) << qt_green_shift; | - |
93 | const int tb = qBlue(c) >> qt_neg_blue_shift; | - |
94 | | - |
95 | return (tb & qt_blue_mask) | (tg & qt_green_mask) | (tr & qt_red_mask); never executed: return (tb & qt_blue_mask) | (tg & qt_green_mask) | (tr & qt_red_mask); | 0 |
96 | } | - |
97 | | - |
98 | inline QRgb qt_conv16ToRgb(ushort c) | - |
99 | { | - |
100 | const int r=(c & qt_red_mask); | - |
101 | const int g=(c & qt_green_mask); | - |
102 | const int b=(c & qt_blue_mask); | - |
103 | const int tr = r >> qt_red_shift | r >> qt_red_rounding_shift; | - |
104 | const int tg = g >> qt_green_shift | g >> qt_green_rounding_shift; | - |
105 | const int tb = b << qt_neg_blue_shift | b >> qt_blue_rounding_shift; | - |
106 | | - |
107 | return qRgb(tr,tg,tb); never executed: return qRgb(tr,tg,tb); | 0 |
108 | } | - |
109 | | - |
110 | uint QColormap::pixel(const QColor &color) const | - |
111 | { | - |
112 | QRgb rgb = color.rgba(); | - |
113 | if (d->mode == QColormap::Direct) { never evaluated: d->mode == QColormap::Direct | 0 |
114 | switch(d->depth) { | - |
115 | case 16: | - |
116 | return qt_convRgbTo16(rgb); never executed: return qt_convRgbTo16(rgb); | 0 |
117 | case 24: | - |
118 | case 32: | - |
119 | { | - |
120 | const int r = qRed(rgb); | - |
121 | const int g = qGreen(rgb); | - |
122 | const int b = qBlue(rgb); | - |
123 | const int red_shift = 16; | - |
124 | const int green_shift = 8; | - |
125 | const int red_mask = 0xff0000; | - |
126 | const int green_mask = 0x00ff00; | - |
127 | const int blue_mask = 0x0000ff; | - |
128 | const int tg = g << green_shift; | - |
129 | | - |
130 | | - |
131 | | - |
132 | | - |
133 | | - |
134 | | - |
135 | const int tr = r << red_shift; | - |
136 | return 0xff000000 | (b & blue_mask) | (tg & green_mask) | (tr & red_mask); never executed: return 0xff000000 | (b & blue_mask) | (tg & green_mask) | (tr & red_mask); | 0 |
137 | } | - |
138 | } | - |
139 | } | 0 |
140 | | - |
141 | | - |
142 | return 0; never executed: return 0; | 0 |
143 | } | - |
144 | | - |
145 | const QColor QColormap::colorAt(uint pixel) const | - |
146 | { | - |
147 | if (d->mode == Direct) { never evaluated: d->mode == Direct | 0 |
148 | if (d->depth == 16) { never evaluated: d->depth == 16 | 0 |
149 | pixel = qt_conv16ToRgb(pixel); | - |
150 | } | 0 |
151 | const int red_shift = 16; | - |
152 | const int green_shift = 8; | - |
153 | const int red_mask = 0xff0000; | - |
154 | const int green_mask = 0x00ff00; | - |
155 | const int blue_mask = 0x0000ff; | - |
156 | | - |
157 | | - |
158 | | - |
159 | | - |
160 | | - |
161 | | - |
162 | | - |
163 | return QColor((pixel & red_mask) >> red_shift, | 0 |
164 | (pixel & green_mask) >> green_shift, | 0 |
165 | (pixel & blue_mask)); never executed: return QColor((pixel & red_mask) >> red_shift, (pixel & green_mask) >> green_shift, (pixel & blue_mask)); | 0 |
166 | } | - |
167 | | - |
168 | | - |
169 | | - |
170 | | - |
171 | return QColor(); never executed: return QColor(); | 0 |
172 | } | - |
173 | | - |
174 | const QVector<QColor> QColormap::colormap() const | - |
175 | { | - |
176 | return QVector<QColor>(); never executed: return QVector<QColor>(); | 0 |
177 | } | - |
178 | | - |
179 | QColormap &QColormap::operator=(const QColormap &colormap) | - |
180 | { qAtomicAssign(d, colormap.d); return *this; } never executed: return *this; | 0 |
181 | | - |
182 | | - |
183 | | - |
| | |