Mercurial > hg > svgui
comparison layer/Colour3DPlotLayer.cpp @ 470:26d1ddc0ce96
* another, rather trivial, optimisation
| author | Chris Cannam |
|---|---|
| date | Mon, 26 Jan 2009 10:49:31 +0000 |
| parents | 9863f9a36cc2 |
| children | 72a080272a4e |
comparison
equal
deleted
inserted
replaced
| 469:9863f9a36cc2 | 470:26d1ddc0ce96 |
|---|---|
| 1093 float srRatio = float(mmsr) / float(msr); | 1093 float srRatio = float(mmsr) / float(msr); |
| 1094 | 1094 |
| 1095 int x0 = rect.left(); | 1095 int x0 = rect.left(); |
| 1096 int x1 = rect.right() + 1; | 1096 int x1 = rect.right() + 1; |
| 1097 | 1097 |
| 1098 int w = x1 - x0; | 1098 const int w = x1 - x0; // const so it can be used as array size below |
| 1099 int h = v->height(); | 1099 int h = v->height(); |
| 1100 int sh = m_model->getHeight(); | 1100 int sh = m_model->getHeight(); |
| 1101 | 1101 |
| 1102 int symin = m_miny; | 1102 int symin = m_miny; |
| 1103 int symax = m_maxy; | 1103 int symax = m_maxy; |
| 1126 // std::cerr << "not using peaks cache" << std::endl; | 1126 // std::cerr << "not using peaks cache" << std::endl; |
| 1127 } | 1127 } |
| 1128 | 1128 |
| 1129 int psy1i = -1; | 1129 int psy1i = -1; |
| 1130 int sw = source->width(); | 1130 int sw = source->width(); |
| 1131 | |
| 1132 long xf = -1; | |
| 1133 long nxf = v->getFrameForX(x0); | |
| 1134 | |
| 1135 int sxa[w * 2]; | |
| 1136 for (int x = 0; x < w; ++x) { | |
| 1137 | |
| 1138 xf = nxf; | |
| 1139 nxf = xf + zoomLevel; | |
| 1140 | |
| 1141 float sx0 = (float(xf) / srRatio - modelStart) / modelResolution; | |
| 1142 float sx1 = (float(nxf) / srRatio - modelStart) / modelResolution; | |
| 1143 | |
| 1144 int sx0i = int(sx0 + 0.001); | |
| 1145 int sx1i = int(sx1); | |
| 1146 | |
| 1147 sxa[x*2] = sx0i; | |
| 1148 sxa[x*2 + 1] = sx1i; | |
| 1149 } | |
| 1131 | 1150 |
| 1132 for (int y = 0; y < h; ++y) { | 1151 for (int y = 0; y < h; ++y) { |
| 1133 | 1152 |
| 1134 float sy0 = symin + (float(h - y - 1) * (symax - symin)) / h; | 1153 float sy0 = symin + (float(h - y - 1) * (symax - symin)) / h; |
| 1135 float sy1 = symin + (float(h - y) * (symax - symin)) / h; | 1154 float sy1 = symin + (float(h - y) * (symax - symin)) / h; |
| 1149 | 1168 |
| 1150 if (sy < 0 || sy >= source->height()) continue; | 1169 if (sy < 0 || sy >= source->height()) continue; |
| 1151 | 1170 |
| 1152 uchar *sourceLine = source->scanLine(sy); | 1171 uchar *sourceLine = source->scanLine(sy); |
| 1153 | 1172 |
| 1154 long xf = -1; | |
| 1155 long nxf = v->getFrameForX(x0); | |
| 1156 | |
| 1157 int nsxi = -1; | |
| 1158 | |
| 1159 for (int x = 0; x < w; ++x) { | 1173 for (int x = 0; x < w; ++x) { |
| 1160 | 1174 |
| 1161 xf = nxf; | 1175 int sx0i = sxa[x*2]; |
| 1162 nxf = xf + zoomLevel; | 1176 int sx1i = sxa[x*2 + 1]; |
| 1163 | |
| 1164 if (xf < 0) { | |
| 1165 peaks[x] = 0; | |
| 1166 continue; | |
| 1167 } | |
| 1168 | |
| 1169 float sx0 = (float(xf) / srRatio - modelStart) / modelResolution; | |
| 1170 float sx1 = (float(nxf) / srRatio - modelStart) / modelResolution; | |
| 1171 | |
| 1172 int sx0i = int(sx0 + 0.001); | |
| 1173 int sx1i = int(sx1); | |
| 1174 | 1177 |
| 1175 uchar peak = 0; | 1178 uchar peak = 0; |
| 1176 for (int sx = sx0i; sx <= sx1i; ++sx) { | 1179 for (int sx = sx0i; sx <= sx1i; ++sx) { |
| 1177 if (sx < 0 || sx >= sw) continue; | 1180 if (sx < 0 || sx >= sw) continue; |
| 1178 if (sourceLine[sx] > peak) peak = sourceLine[sx]; | 1181 if (sourceLine[sx] > peak) peak = sourceLine[sx]; |
