qglcolormap.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/opengl/qglcolormap.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4QGLColormap::QGLColormapData QGLColormap::shared_null = { { 1 }, 0, 0 };-
5-
6-
7-
8-
9QGLColormap::QGLColormap()-
10 : d(&shared_null)-
11{-
12 d->ref.ref();-
13}
executed 12 times by 3 tests: end of block
Executed by:
  • tst_qglbuffer - unknown status
  • tst_qglfunctions - unknown status
  • tst_qmdiarea - unknown status
12
14-
15-
16-
17-
18-
19QGLColormap::QGLColormap(const QGLColormap &map)-
20 : d(map.d)-
21{-
22 d->ref.ref();-
23}
never executed: end of block
0
24-
25-
26-
27-
28-
29QGLColormap::~QGLColormap()-
30{-
31 if (!d->ref.deref()
!d->ref.deref()Description
TRUEnever evaluated
FALSEevaluated 12 times by 3 tests
Evaluated by:
  • tst_qglbuffer - unknown status
  • tst_qglfunctions - unknown status
  • tst_qmdiarea - unknown status
)
0-12
32 cleanup(d);
never executed: cleanup(d);
0
33}
executed 12 times by 3 tests: end of block
Executed by:
  • tst_qglbuffer - unknown status
  • tst_qglfunctions - unknown status
  • tst_qmdiarea - unknown status
12
34-
35void QGLColormap::cleanup(QGLColormap::QGLColormapData *x)-
36{-
37 delete x->cells;-
38 x->cells = 0;-
39 delete x;-
40}
never executed: end of block
0
41-
42-
43-
44-
45QGLColormap & QGLColormap::operator=(const QGLColormap &map)-
46{-
47 map.d->ref.ref();-
48 if (!d->ref.deref()
!d->ref.deref()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
49 cleanup(d);
never executed: cleanup(d);
0
50 d = map.d;-
51 return
never executed: return *this;
*this;
never executed: return *this;
0
52}-
53void QGLColormap::detach_helper()-
54{-
55 QGLColormapData *x = new QGLColormapData;-
56 x->ref.store(1);-
57 x->cmapHandle = 0;-
58 x->cells = 0;-
59 if (d->cells
d->cellsDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
60 x->cells = new QVector<QRgb>(256);-
61 *x->cells = *d->cells;-
62 }
never executed: end of block
0
63 if (!d->ref.deref()
!d->ref.deref()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
64 cleanup(d);
never executed: cleanup(d);
0
65 d = x;-
66}
never executed: end of block
0
67-
68-
69-
70-
71void QGLColormap::setEntry(int idx, QRgb color)-
72{-
73 detach();-
74 if (!d->cells
!d->cellsDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
75 d->cells = new QVector<QRgb>(256);
never executed: d->cells = new QVector<QRgb>(256);
0
76 d->cells->replace(idx, color);-
77}
never executed: end of block
0
78-
79-
80-
81-
82-
83-
84-
85void QGLColormap::setEntries(int count, const QRgb *colors, int base)-
86{-
87 detach();-
88 if (!d->cells
!d->cellsDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
89 d->cells = new QVector<QRgb>(256);
never executed: d->cells = new QVector<QRgb>(256);
0
90-
91 ((!(colors && base >= 0 && (base + count) <= d->cells->size())) ? qt_assert_x("QGLColormap::setEntries", "preconditions not met",-
92 __FILE__-
93 ,-
94 192-
95 ) : qt_noop())-
96 ;-
97 for (int i = 0; i < count
i < countDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i)
0
98 setEntry(base + i, colors[i]);
never executed: setEntry(base + i, colors[i]);
0
99}
never executed: end of block
0
100-
101-
102-
103-
104QRgb QGLColormap::entryRgb(int idx) const-
105{-
106 if (d == &shared_null
d == &shared_nullDescription
TRUEnever evaluated
FALSEnever evaluated
|| !d->cells
!d->cellsDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
107 return
never executed: return 0;
0;
never executed: return 0;
0
108 else-
109 return
never executed: return d->cells->at(idx);
d->cells->at(idx);
never executed: return d->cells->at(idx);
0
110}-
111-
112-
113-
114-
115-
116-
117void QGLColormap::setEntry(int idx, const QColor &color)-
118{-
119 setEntry(idx, color.rgb());-
120}
never executed: end of block
0
121-
122-
123-
124-
125QColor QGLColormap::entryColor(int idx) const-
126{-
127 if (d == &shared_null
d == &shared_nullDescription
TRUEnever evaluated
FALSEnever evaluated
|| !d->cells
!d->cellsDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
128 return
never executed: return QColor();
QColor();
never executed: return QColor();
0
129 else-
130 return
never executed: return QColor(d->cells->at(idx));
QColor(d->cells->at(idx));
never executed: return QColor(d->cells->at(idx));
0
131}-
132bool QGLColormap::isEmpty() const-
133{-
134 return
never executed: return d == &shared_null || d->cells == 0 || d->cells->size() == 0 || d->cmapHandle == 0;
d == &shared_null || d->cells == 0 || d->cells->size() == 0 || d->cmapHandle == 0;
never executed: return d == &shared_null || d->cells == 0 || d->cells->size() == 0 || d->cmapHandle == 0;
0
135}-
136-
137-
138-
139-
140-
141int QGLColormap::size() const-
142{-
143 return
never executed: return d->cells ? d->cells->size() : 0;
d->cells ? d->cells->size() : 0;
never executed: return d->cells ? d->cells->size() : 0;
0
144}-
145-
146-
147-
148-
149-
150int QGLColormap::find(QRgb color) const-
151{-
152 if (d->cells
d->cellsDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
153 return
never executed: return d->cells->indexOf(color);
d->cells->indexOf(color);
never executed: return d->cells->indexOf(color);
0
154 return
never executed: return -1;
-1;
never executed: return -1;
0
155}-
156-
157-
158-
159-
160-
161int QGLColormap::findNearest(QRgb color) const-
162{-
163 int idx = find(color);-
164 if (idx >= 0
idx >= 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
165 return
never executed: return idx;
idx;
never executed: return idx;
0
166 int mapSize = size();-
167 int mindist = 200000;-
168 int r = qRed(color);-
169 int g = qGreen(color);-
170 int b = qBlue(color);-
171 int rx, gx, bx, dist;-
172 for (int i = 0; i < mapSize
i < mapSizeDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
173 QRgb ci = d->cells->at(i);-
174 rx = r - qRed(ci);-
175 gx = g - qGreen(ci);-
176 bx = b - qBlue(ci);-
177 dist = rx * rx + gx * gx + bx * bx;-
178 if (dist < mindist
dist < mindistDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
179 mindist = dist;-
180 idx = i;-
181 }
never executed: end of block
0
182 }
never executed: end of block
0
183 return
never executed: return idx;
idx;
never executed: return idx;
0
184}-
185-
186-
Switch to Source codePreprocessed file

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