| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/opengl/qglcolormap.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||
| 2 | - | |||||||||||||
| 3 | - | |||||||||||||
| 4 | QGLColormap::QGLColormapData QGLColormap::shared_null = { { 1 }, 0, 0 }; | - | ||||||||||||
| 5 | - | |||||||||||||
| 6 | - | |||||||||||||
| 7 | - | |||||||||||||
| 8 | - | |||||||||||||
| 9 | QGLColormap::QGLColormap() | - | ||||||||||||
| 10 | : d(&shared_null) | - | ||||||||||||
| 11 | { | - | ||||||||||||
| 12 | d->ref.ref(); | - | ||||||||||||
| 13 | } executed 12 times by 3 tests: end of blockExecuted by:
| 12 | ||||||||||||
| 14 | - | |||||||||||||
| 15 | - | |||||||||||||
| 16 | - | |||||||||||||
| 17 | - | |||||||||||||
| 18 | - | |||||||||||||
| 19 | QGLColormap::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 | - | |||||||||||||
| 29 | QGLColormap::~QGLColormap() | - | ||||||||||||
| 30 | { | - | ||||||||||||
| 31 | if (!d->ref.deref()
| 0-12 | ||||||||||||
| 32 | cleanup(d); never executed: cleanup(d); | 0 | ||||||||||||
| 33 | } executed 12 times by 3 tests: end of blockExecuted by:
| 12 | ||||||||||||
| 34 | - | |||||||||||||
| 35 | void 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 | - | |||||||||||||
| 45 | QGLColormap & QGLColormap::operator=(const QGLColormap &map) | - | ||||||||||||
| 46 | { | - | ||||||||||||
| 47 | map.d->ref.ref(); | - | ||||||||||||
| 48 | if (!d->ref.deref()
| 0 | ||||||||||||
| 49 | cleanup(d); never executed: cleanup(d); | 0 | ||||||||||||
| 50 | d = map.d; | - | ||||||||||||
| 51 | return never executed: *this;return *this;never executed: return *this; | 0 | ||||||||||||
| 52 | } | - | ||||||||||||
| 53 | void 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
| 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()
| 0 | ||||||||||||
| 64 | cleanup(d); never executed: cleanup(d); | 0 | ||||||||||||
| 65 | d = x; | - | ||||||||||||
| 66 | } never executed: end of block | 0 | ||||||||||||
| 67 | - | |||||||||||||
| 68 | - | |||||||||||||
| 69 | - | |||||||||||||
| 70 | - | |||||||||||||
| 71 | void QGLColormap::setEntry(int idx, QRgb color) | - | ||||||||||||
| 72 | { | - | ||||||||||||
| 73 | detach(); | - | ||||||||||||
| 74 | if (!d->cells
| 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 | - | |||||||||||||
| 85 | void QGLColormap::setEntries(int count, const QRgb *colors, int base) | - | ||||||||||||
| 86 | { | - | ||||||||||||
| 87 | detach(); | - | ||||||||||||
| 88 | if (!d->cells
| 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
| 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 | - | |||||||||||||
| 104 | QRgb QGLColormap::entryRgb(int idx) const | - | ||||||||||||
| 105 | { | - | ||||||||||||
| 106 | if (d == &shared_null
| 0 | ||||||||||||
| 107 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 108 | else | - | ||||||||||||
| 109 | return never executed: d->cells->at(idx);return d->cells->at(idx);never executed: return d->cells->at(idx); | 0 | ||||||||||||
| 110 | } | - | ||||||||||||
| 111 | - | |||||||||||||
| 112 | - | |||||||||||||
| 113 | - | |||||||||||||
| 114 | - | |||||||||||||
| 115 | - | |||||||||||||
| 116 | - | |||||||||||||
| 117 | void QGLColormap::setEntry(int idx, const QColor &color) | - | ||||||||||||
| 118 | { | - | ||||||||||||
| 119 | setEntry(idx, color.rgb()); | - | ||||||||||||
| 120 | } never executed: end of block | 0 | ||||||||||||
| 121 | - | |||||||||||||
| 122 | - | |||||||||||||
| 123 | - | |||||||||||||
| 124 | - | |||||||||||||
| 125 | QColor QGLColormap::entryColor(int idx) const | - | ||||||||||||
| 126 | { | - | ||||||||||||
| 127 | if (d == &shared_null
| 0 | ||||||||||||
| 128 | return never executed: QColor();return QColor();never executed: return QColor(); | 0 | ||||||||||||
| 129 | else | - | ||||||||||||
| 130 | return never executed: QColor(d->cells->at(idx));return QColor(d->cells->at(idx));never executed: return QColor(d->cells->at(idx)); | 0 | ||||||||||||
| 131 | } | - | ||||||||||||
| 132 | bool QGLColormap::isEmpty() const | - | ||||||||||||
| 133 | { | - | ||||||||||||
| 134 | return never executed: d == &shared_null || d->cells == 0 || d->cells->size() == 0 || d->cmapHandle == 0;return 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 | - | |||||||||||||
| 141 | int QGLColormap::size() const | - | ||||||||||||
| 142 | { | - | ||||||||||||
| 143 | return never executed: d->cells ? d->cells->size() : 0;return d->cells ? d->cells->size() : 0;never executed: return d->cells ? d->cells->size() : 0; | 0 | ||||||||||||
| 144 | } | - | ||||||||||||
| 145 | - | |||||||||||||
| 146 | - | |||||||||||||
| 147 | - | |||||||||||||
| 148 | - | |||||||||||||
| 149 | - | |||||||||||||
| 150 | int QGLColormap::find(QRgb color) const | - | ||||||||||||
| 151 | { | - | ||||||||||||
| 152 | if (d->cells
| 0 | ||||||||||||
| 153 | return never executed: d->cells->indexOf(color);return d->cells->indexOf(color);never executed: return d->cells->indexOf(color); | 0 | ||||||||||||
| 154 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||
| 155 | } | - | ||||||||||||
| 156 | - | |||||||||||||
| 157 | - | |||||||||||||
| 158 | - | |||||||||||||
| 159 | - | |||||||||||||
| 160 | - | |||||||||||||
| 161 | int QGLColormap::findNearest(QRgb color) const | - | ||||||||||||
| 162 | { | - | ||||||||||||
| 163 | int idx = find(color); | - | ||||||||||||
| 164 | if (idx >= 0
| 0 | ||||||||||||
| 165 | return never executed: idx;return 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
| 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
| 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: idx;return idx;never executed: return idx; | 0 | ||||||||||||
| 184 | } | - | ||||||||||||
| 185 | - | |||||||||||||
| 186 | - | |||||||||||||
| Switch to Source code | Preprocessed file |