qcolormap.cpp

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

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