| 1 | static void ut_CalcScanBufferSize(UT_FONT_TASK* task) |
|---|
| 2 | { |
|---|
| 3 | int horiEdgeCount = 0; |
|---|
| 4 | int vertEdgeCount = 0; |
|---|
| 5 | UT_COORD* x, px, cx; |
|---|
| 6 | UT_COORD* y, py, cy; |
|---|
| 7 | UT_COORD* stop; |
|---|
| 8 | int iPath, iStartPoint, iEndPoint; |
|---|
| 9 | UT_TRACE1("ut_CalcScanBufferSize()"); |
|---|
| 10 | UT_TRACE_TAB_INC(); |
|---|
| 11 | for (iPath=0; iPath<task->rootGlyph.nPath; iPath++) |
|---|
| 12 | { |
|---|
| 13 | iStartPoint = task->rootGlyph.startPointIndex[iPath]; |
|---|
| 14 | iEndPoint = task->rootGlyph.endPointIndex[iPath]; |
|---|
| 15 | if (iStartPoint == iEndPoint) continue; |
|---|
| 16 | x = &task->rootGlyph.x[iStartPoint]; |
|---|
| 17 | y = &task->rootGlyph.y[iStartPoint]; |
|---|
| 18 | stop = &task->rootGlyph.x[iEndPoint]; |
|---|
| 19 | px = *x++; |
|---|
| 20 | py = *y++; |
|---|
| 21 | while (x <= stop) |
|---|
| 22 | { |
|---|
| 23 | cx = *x++; |
|---|
| 24 | cy = *y++; |
|---|
| 25 | if (py > cy) |
|---|
| 26 | { |
|---|
| 27 | horiEdgeCount += ((py+_UT_ONE_PIXEL-1) >> _UT_PIXEL_SHIFT) - (cy >> _UT_PIXEL_SHIFT); |
|---|
| 28 | } |
|---|
| 29 | else |
|---|
| 30 | { |
|---|
| 31 | horiEdgeCount += ((cy+_UT_ONE_PIXEL-1) >> _UT_PIXEL_SHIFT) - (py >> _UT_PIXEL_SHIFT); |
|---|
| 32 | } |
|---|
| 33 | if (px > cx) |
|---|
| 34 | { |
|---|
| 35 | vertEdgeCount += ((px+_UT_ONE_PIXEL-1) >> _UT_PIXEL_SHIFT) - (cx >> _UT_PIXEL_SHIFT); |
|---|
| 36 | } |
|---|
| 37 | else |
|---|
| 38 | { |
|---|
| 39 | vertEdgeCount += ((cx+_UT_ONE_PIXEL-1) >> _UT_PIXEL_SHIFT) - (px >> _UT_PIXEL_SHIFT); |
|---|
| 40 | } |
|---|
| 41 | px = cx; |
|---|
| 42 | py = cy; |
|---|
| 43 | } |
|---|
| 44 | cx = task->rootGlyph.x[iStartPoint]; |
|---|
| 45 | cy = task->rootGlyph.y[iStartPoint]; |
|---|
| 46 | if (py > cy) |
|---|
| 47 | { |
|---|
| 48 | horiEdgeCount += ((py+_UT_ONE_PIXEL-1) >> _UT_PIXEL_SHIFT) - (cy >> _UT_PIXEL_SHIFT); |
|---|
| 49 | } |
|---|
| 50 | else |
|---|
| 51 | { |
|---|
| 52 | horiEdgeCount += ((cy+_UT_ONE_PIXEL-1) >> _UT_PIXEL_SHIFT) - (py >> _UT_PIXEL_SHIFT); |
|---|
| 53 | } |
|---|
| 54 | if (px > cx) |
|---|
| 55 | { |
|---|
| 56 | vertEdgeCount += ((px+_UT_ONE_PIXEL-1) >> _UT_PIXEL_SHIFT) - (cx >> _UT_PIXEL_SHIFT); |
|---|
| 57 | } |
|---|
| 58 | else |
|---|
| 59 | { |
|---|
| 60 | vertEdgeCount += ((cx+_UT_ONE_PIXEL-1) >> _UT_PIXEL_SHIFT) - (px >> _UT_PIXEL_SHIFT); |
|---|
| 61 | } |
|---|
| 62 | } |
|---|
| 63 | task->horiScanBufferSize = sizeof(US_EDGE1) * (task->i_ySize+horiEdgeCount); |
|---|
| 64 | if (task->isDropout) |
|---|
| 65 | { |
|---|
| 66 | task->vertScanBufferSize = sizeof(US_EDGE1) * (task->i_xSize+vertEdgeCount); |
|---|
| 67 | } |
|---|
| 68 | else |
|---|
| 69 | { |
|---|
| 70 | task->vertScanBufferSize = 0; |
|---|
| 71 | } |
|---|
| 72 | #ifdef _UT_DEBUG |
|---|
| 73 | task->horiEdgeCount = 0; |
|---|
| 74 | task->vertEdgeCount = 0; |
|---|
| 75 | task->horiEdgeTotalCount = horiEdgeCount; |
|---|
| 76 | if (task->isDropout) |
|---|
| 77 | { |
|---|
| 78 | task->vertEdgeTotalCount = vertEdgeCount; |
|---|
| 79 | } |
|---|
| 80 | #endif |
|---|
| 81 | UT_TRACE_TAB_DEC(); |
|---|
| 82 | } |
|---|
| 83 | |
|---|
| 84 | static void ut_PrepareScan(UT_FONT_TASK* task) |
|---|
| 85 | { |
|---|
| 86 | int line; |
|---|
| 87 | US_EDGE1* edge = (US_EDGE1*)task->edge; |
|---|
| 88 | UT_TRACE1("ut_PrepareScan()"); |
|---|
| 89 | UT_TRACE_TAB_INC(); |
|---|
| 90 | task->horiScanLine1 = edge; |
|---|
| 91 | line = task->i_ySize; |
|---|
| 92 | for (line--; line>=0; line--,edge++) |
|---|
| 93 | { |
|---|
| 94 | edge->pos = 0; |
|---|
| 95 | edge->dir = 0; |
|---|
| 96 | edge->next = 0; |
|---|
| 97 | } |
|---|
| 98 | if (task->isDropout) |
|---|
| 99 | { |
|---|
| 100 | task->vertScanLine1 = edge; |
|---|
| 101 | line = task->i_xSize; |
|---|
| 102 | for (line--; line>=0; line--,edge++) |
|---|
| 103 | { |
|---|
| 104 | edge->pos = 0; |
|---|
| 105 | edge->dir = 0; |
|---|
| 106 | edge->next = 0; |
|---|
| 107 | } |
|---|
| 108 | } |
|---|
| 109 | task->emptyEdge = edge; |
|---|
| 110 | UT_TRACE_TAB_DEC(); |
|---|
| 111 | } |
|---|
| 112 | |
|---|
| 113 | static void ut_AddHoriEdge(UT_FONT_TASK* task, int line, int pos, int dir) |
|---|
| 114 | { |
|---|
| 115 | int i = task->horiScanLine1[line].pos; |
|---|
| 116 | US_EDGE1* curr = &task->horiScanLine1[line]; |
|---|
| 117 | UT_TRACE2("ut_AddHoriEdge() line = %d", line); |
|---|
| 118 | UT_TRACE2(" pos = %d", pos); |
|---|
| 119 | UT_TRACE2(" dir = %d", dir); |
|---|
| 120 | #ifdef _UT_DEBUG |
|---|
| 121 | if ((line < 0) || (line >= task->i_ySize)) |
|---|
| 122 | { |
|---|
| 123 | UT_FATAL_ERROR("Horizontal line overflow !!!"); |
|---|
| 124 | return; |
|---|
| 125 | } |
|---|
| 126 | if (task->horiEdgeCount >= task->horiEdgeTotalCount) |
|---|
| 127 | { |
|---|
| 128 | UT_FATAL_ERROR("Horizontal edge overflow !!!"); |
|---|
| 129 | return; |
|---|
| 130 | } |
|---|
| 131 | task->horiEdgeCount++; |
|---|
| 132 | #endif |
|---|
| 133 | for (; i; i--) |
|---|
| 134 | { |
|---|
| 135 | if (curr->next->pos <= pos) break; |
|---|
| 136 | curr = curr->next; |
|---|
| 137 | } |
|---|
| 138 | task->emptyEdge->next = curr->next; |
|---|
| 139 | task->emptyEdge->pos = pos; |
|---|
| 140 | task->emptyEdge->dir = dir; |
|---|
| 141 | curr->next = task->emptyEdge++; |
|---|
| 142 | task->horiScanLine1[line].pos++; |
|---|
| 143 | } |
|---|
| 144 | |
|---|
| 145 | static void ut_AddVertEdge(UT_FONT_TASK* task, int line, int pos, int dir) |
|---|
| 146 | { |
|---|
| 147 | int i = task->vertScanLine1[line].pos; |
|---|
| 148 | US_EDGE1* curr = &task->vertScanLine1[line]; |
|---|
| 149 | UT_TRACE2("ut_AddVertEdge() line = %d", line); |
|---|
| 150 | UT_TRACE2(" pos = %d", pos); |
|---|
| 151 | UT_TRACE2(" dir = %d", dir); |
|---|
| 152 | #ifdef _UT_DEBUG |
|---|
| 153 | if ((line < 0) || (line >= task->i_xSize)) |
|---|
| 154 | { |
|---|
| 155 | UT_FATAL_ERROR("Vertical line overflow !!!"); |
|---|
| 156 | return; |
|---|
| 157 | } |
|---|
| 158 | if (task->vertEdgeCount >= task->vertEdgeTotalCount) |
|---|
| 159 | { |
|---|
| 160 | UT_FATAL_ERROR("Vertical edge overflow !!!"); |
|---|
| 161 | return; |
|---|
| 162 | } |
|---|
| 163 | task->vertEdgeCount++; |
|---|
| 164 | #endif |
|---|
| 165 | for (; i; i--) |
|---|
| 166 | { |
|---|
| 167 | if (curr->next->pos <= pos) break; |
|---|
| 168 | curr = curr->next; |
|---|
| 169 | } |
|---|
| 170 | task->emptyEdge->next = curr->next; |
|---|
| 171 | task->emptyEdge->pos = pos; |
|---|
| 172 | task->emptyEdge->dir = dir; |
|---|
| 173 | curr->next = task->emptyEdge++; |
|---|
| 174 | task->vertScanLine1[line].pos++; |
|---|
| 175 | } |
|---|
| 176 | |
|---|
| 177 | #define ut_AddHoriEdgeP(task, x, y) ut_AddHoriEdge(task, y, x, +1) |
|---|
| 178 | #define ut_AddHoriEdgeN(task, x, y) ut_AddHoriEdge(task, y, x, -1) |
|---|
| 179 | #define ut_AddVertEdgeP(task, x, y) ut_AddVertEdge(task, x, y, +1) |
|---|
| 180 | #define ut_AddVertEdgeN(task, x, y) ut_AddVertEdge(task, x, y, -1) |
|---|
| 181 | |
|---|
| 182 | static void ut_CheckLastPoint(UT_FONT_TASK* task, UT_COORD o_x2, UT_COORD o_y2) |
|---|
| 183 | { |
|---|
| 184 | UT_TRACE1("ut_CheckLastPoint()"); |
|---|
| 185 | UT_TRACE_TAB_INC(); |
|---|
| 186 | if (ut_IsOnScanLine(task->o_cy)) |
|---|
| 187 | { |
|---|
| 188 | if (task->o_cy < o_y2) |
|---|
| 189 | { |
|---|
| 190 | if (task->o_py > task->o_cy) |
|---|
| 191 | ut_AddHoriEdgeN(task, ut_AbovePixel(task->o_cx), task->o_cy>>_UT_PIXEL_SHIFT); |
|---|
| 192 | if ((task->o_py != task->o_cy) || (task->o_px > task->o_cx)) |
|---|
| 193 | ut_AddHoriEdgeP(task, ut_ExceptionAbovePixel(task->o_cx), task->o_cy>>_UT_PIXEL_SHIFT); |
|---|
| 194 | } |
|---|
| 195 | else if (task->o_cy > o_y2) |
|---|
| 196 | { |
|---|
| 197 | if (task->o_py < task->o_cy) |
|---|
| 198 | ut_AddHoriEdgeP(task, ut_ExceptionAbovePixel(task->o_cx), task->o_cy>>_UT_PIXEL_SHIFT); |
|---|
| 199 | if ((task->o_py != task->o_cy) || (task->o_px < task->o_cx)) |
|---|
| 200 | ut_AddHoriEdgeN(task, ut_AbovePixel(task->o_cx), task->o_cy>>_UT_PIXEL_SHIFT); |
|---|
| 201 | } |
|---|
| 202 | else if (task->o_cx < o_x2) |
|---|
| 203 | { |
|---|
| 204 | if (task->o_py < task->o_cy) |
|---|
| 205 | ut_AddHoriEdgeP(task, ut_ExceptionAbovePixel(task->o_cx), task->o_cy>>_UT_PIXEL_SHIFT); |
|---|
| 206 | else if ((task->o_py == task->o_cy) && (task->o_px > task->o_cx)) |
|---|
| 207 | ut_AddHoriEdgeP(task, ut_ExceptionAbovePixel(task->o_cx), task->o_cy>>_UT_PIXEL_SHIFT); |
|---|
| 208 | } |
|---|
| 209 | else /*if (task->o_cx > o_x2)*/ |
|---|
| 210 | { |
|---|
| 211 | if (task->o_py > task->o_cy) |
|---|
| 212 | ut_AddHoriEdgeN(task, ut_AbovePixel(task->o_cx), task->o_cy>>_UT_PIXEL_SHIFT); |
|---|
| 213 | else if ((task->o_py == task->o_cy) && (task->o_px < task->o_cx)) |
|---|
| 214 | ut_AddHoriEdgeN(task, ut_AbovePixel(task->o_cx), task->o_cy>>_UT_PIXEL_SHIFT); |
|---|
| 215 | } |
|---|
| 216 | } |
|---|
| 217 | #ifdef _USE_DROPOUT_COLTROL |
|---|
| 218 | if (!task->isDropout) |
|---|
| 219 | { |
|---|
| 220 | UT_TRACE_TAB_DEC(); |
|---|
| 221 | return; |
|---|
| 222 | } |
|---|
| 223 | if (ut_IsOnScanLine(task->o_cx)) |
|---|
| 224 | { |
|---|
| 225 | if (task->o_cx < o_x2) |
|---|
| 226 | { |
|---|
| 227 | if (task->o_px > task->o_cx) |
|---|
| 228 | ut_AddVertEdgeN(task, task->o_cx>>_UT_PIXEL_SHIFT, ut_ExceptionAbovePixel(task->o_cy)); |
|---|
| 229 | if ((task->o_px != task->o_cx) || (task->o_py < task->o_cy)) |
|---|
| 230 | ut_AddVertEdgeP(task, task->o_cx>>_UT_PIXEL_SHIFT, ut_AbovePixel(task->o_cy)); |
|---|
| 231 | } |
|---|
| 232 | else if (task->o_cx > o_x2) |
|---|
| 233 | { |
|---|
| 234 | if (task->o_px < task->o_cx) |
|---|
| 235 | ut_AddVertEdgeP(task, task->o_cx>>_UT_PIXEL_SHIFT, ut_AbovePixel(task->o_cy)); |
|---|
| 236 | if ((task->o_px != task->o_cx) || (task->o_py > task->o_cy)) |
|---|
| 237 | ut_AddVertEdgeN(task, task->o_cx>>_UT_PIXEL_SHIFT, ut_ExceptionAbovePixel(task->o_cy)); |
|---|
| 238 | } |
|---|
| 239 | else if (task->o_cy < o_y2) |
|---|
| 240 | { |
|---|
| 241 | if (task->o_px > task->o_cx) |
|---|
| 242 | ut_AddVertEdgeN(task, task->o_cx>>_UT_PIXEL_SHIFT, ut_ExceptionAbovePixel(task->o_cy)); |
|---|
| 243 | else if ((task->o_px != task->o_cx) && (task->o_py > task->o_cy)) |
|---|
| 244 | ut_AddVertEdgeN(task, task->o_cx>>_UT_PIXEL_SHIFT, ut_ExceptionAbovePixel(task->o_cy)); |
|---|
| 245 | } |
|---|
| 246 | else /*if (task->o_cy > o_y2)*/ |
|---|
| 247 | { |
|---|
| 248 | if (task->o_px < task->o_cx) |
|---|
| 249 | ut_AddVertEdgeP(task, task->o_cx>>_UT_PIXEL_SHIFT, ut_AbovePixel(task->o_cy)); |
|---|
| 250 | else if ((task->o_px != task->o_cx) && (task->o_py < task->o_cy)) |
|---|
| 251 | ut_AddVertEdgeP(task, task->o_cx>>_UT_PIXEL_SHIFT, ut_AbovePixel(task->o_cy)); |
|---|
| 252 | } |
|---|
| 253 | } |
|---|
| 254 | #endif |
|---|
| 255 | UT_TRACE_TAB_DEC(); |
|---|
| 256 | } |
|---|
| 257 | |
|---|
| 258 | static void ut_LineTo_Standard(UT_FONT_TASK* task, UT_COORD o_x1, UT_COORD o_y1, UT_COORD o_x2, UT_COORD o_y2) |
|---|
| 259 | { |
|---|
| 260 | UT_TRACE2("ut_LineTo_Standard() o_x1 = %d", o_x1); |
|---|
| 261 | UT_TRACE2(" o_y1 = %d", o_y1); |
|---|
| 262 | UT_TRACE2(" o_x2 = %d", o_x2); |
|---|
| 263 | UT_TRACE2(" o_y3 = %d", o_y2); |
|---|
| 264 | UT_TRACE_TAB_INC(); |
|---|
| 265 | if ((task->o_cx == o_x2) && (task->o_cy == o_y2)) |
|---|
| 266 | { |
|---|
| 267 | UT_TRACE_TAB_DEC(); |
|---|
| 268 | return; |
|---|
| 269 | } |
|---|
| 270 | if (task->emptyLastPoint) |
|---|
| 271 | { |
|---|
| 272 | task->emptyLastPoint = 0; |
|---|
| 273 | task->o_lx = o_x2; |
|---|
| 274 | task->o_ly = o_y2; |
|---|
| 275 | } |
|---|
| 276 | else |
|---|
| 277 | { |
|---|
| 278 | ut_CheckLastPoint(task, o_x2, o_y2); |
|---|
| 279 | } |
|---|
| 280 | task->o_px = task->o_cx; |
|---|
| 281 | task->o_py = task->o_cy; |
|---|
| 282 | task->o_cx = o_x2; |
|---|
| 283 | task->o_cy = o_y2; |
|---|
| 284 | if (o_x1 == o_x2) |
|---|
| 285 | { |
|---|
| 286 | if (o_y1 < o_y2) |
|---|
| 287 | { |
|---|
| 288 | int xx = ut_ExceptionAbovePixel(o_x1); |
|---|
| 289 | int yy = ut_AbovePixel(o_y1); |
|---|
| 290 | int i = ut_BelowPixel(o_y2) - yy + 1; |
|---|
| 291 | for (; i; i--) |
|---|
| 292 | { |
|---|
| 293 | ut_AddHoriEdgeP(task, xx, yy); |
|---|
| 294 | yy++; |
|---|
| 295 | } |
|---|
| 296 | } |
|---|
| 297 | else /*if (o_y1 > o_y2)*/ |
|---|
| 298 | { |
|---|
| 299 | int xx = ut_AbovePixel(o_x1); |
|---|
| 300 | int yy = ut_BelowPixel(o_y1); |
|---|
| 301 | int i = yy - ut_AbovePixel(o_y2) + 1; |
|---|
| 302 | for (; i; i--) |
|---|
| 303 | { |
|---|
| 304 | ut_AddHoriEdgeN(task, xx, yy); |
|---|
| 305 | yy--; |
|---|
| 306 | } |
|---|
| 307 | } |
|---|
| 308 | } |
|---|
| 309 | else if (o_y1 == o_y2) |
|---|
| 310 | { |
|---|
| 311 | } |
|---|
| 312 | else if (o_x1 < o_x2) |
|---|
| 313 | { |
|---|
| 314 | if (o_y1 < o_y2) |
|---|
| 315 | { |
|---|
| 316 | int dx = (o_x2-o_x1) << _UT_PIXEL_SHIFT; |
|---|
| 317 | int dy = (o_y2-o_y1) << _UT_PIXEL_SHIFT; |
|---|
| 318 | int xx = ut_AbovePixel(o_x1); |
|---|
| 319 | int yy = ut_AbovePixel(o_y1); |
|---|
| 320 | int i = ut_BelowPixel(o_x2) - xx + 1 |
|---|
| 321 | + ut_BelowPixel(o_y2) - yy + 1; |
|---|
| 322 | int q = ((o_x2-o_x1) * ut_AboveScanDelta(o_y1)) |
|---|
| 323 | - ((o_y2-o_y1) * ut_AboveScanDelta(o_x1)); |
|---|
| 324 | for (; i; i--) |
|---|
| 325 | { |
|---|
| 326 | if (q > 0) |
|---|
| 327 | { |
|---|
| 328 | xx++; |
|---|
| 329 | q -= dy; |
|---|
| 330 | } |
|---|
| 331 | else |
|---|
| 332 | { |
|---|
| 333 | ut_AddHoriEdgeP(task, xx, yy); |
|---|
| 334 | yy++; |
|---|
| 335 | q += dx; |
|---|
| 336 | } |
|---|
| 337 | } |
|---|
| 338 | } |
|---|
| 339 | else /*if (o_y1 > o_y2)*/ |
|---|
| 340 | { |
|---|
| 341 | int dx = (o_x2-o_x1) << _UT_PIXEL_SHIFT; |
|---|
| 342 | int dy = (o_y1-o_y2) << _UT_PIXEL_SHIFT; |
|---|
| 343 | int xx = ut_AbovePixel(o_x1); |
|---|
| 344 | int yy = ut_BelowPixel(o_y1); |
|---|
| 345 | int i = ut_BelowPixel(o_x2) - xx + 1 |
|---|
| 346 | + yy - ut_AbovePixel(o_y2) + 1; |
|---|
| 347 | int q = ((o_x2-o_x1) * ut_BelowScanDelta(o_y1)) |
|---|
| 348 | - ((o_y1-o_y2) * ut_AboveScanDelta(o_x1)) + 1; |
|---|
| 349 | for (; i; i--) |
|---|
| 350 | { |
|---|
| 351 | if (q > 0) |
|---|
| 352 | { |
|---|
| 353 | xx++; |
|---|
| 354 | q -= dy; |
|---|
| 355 | } |
|---|
| 356 | else |
|---|
| 357 | { |
|---|
| 358 | ut_AddHoriEdgeN(task, xx, yy); |
|---|
| 359 | yy--; |
|---|
| 360 | q += dx; |
|---|
| 361 | } |
|---|
| 362 | } |
|---|
| 363 | } |
|---|
| 364 | } |
|---|
| 365 | else /*if (o_x1 > o_x2)*/ |
|---|
| 366 | { |
|---|
| 367 | if (o_y1 < o_y2) |
|---|
| 368 | { |
|---|
| 369 | int dx = (o_x1-o_x2) << _UT_PIXEL_SHIFT; |
|---|
| 370 | int dy = (o_y2-o_y1) << _UT_PIXEL_SHIFT; |
|---|
| 371 | int xx = ut_BelowPixel(o_x1); |
|---|
| 372 | int yy = ut_AbovePixel(o_y1); |
|---|
| 373 | int i = xx - ut_AbovePixel(o_x2) + 1 |
|---|
| 374 | + ut_BelowPixel(o_y2) - yy + 1; |
|---|
| 375 | int q = ((o_x1-o_x2) * ut_AboveScanDelta(o_y1)) |
|---|
| 376 | - ((o_y2-o_y1) * ut_BelowScanDelta(o_x1)) + 1; |
|---|
| 377 | for (; i; i--) |
|---|
| 378 | { |
|---|
| 379 | if (q > 0) |
|---|
| 380 | { |
|---|
| 381 | xx--; |
|---|
| 382 | q -= dy; |
|---|
| 383 | } |
|---|
| 384 | else |
|---|
| 385 | { |
|---|
| 386 | ut_AddHoriEdgeP(task, xx+1, yy); |
|---|
| 387 | yy++; |
|---|
| 388 | q += dx; |
|---|
| 389 | } |
|---|
| 390 | } |
|---|
| 391 | } |
|---|
| 392 | else /*if (o_y1 > o_y2)*/ |
|---|
| 393 | { |
|---|
| 394 | int dx = (o_x1-o_x2) << _UT_PIXEL_SHIFT; |
|---|
| 395 | int dy = (o_y1-o_y2) << _UT_PIXEL_SHIFT; |
|---|
| 396 | int yy = ut_BelowPixel(o_y1); |
|---|
| 397 | int xx = ut_BelowPixel(o_x1); |
|---|
| 398 | int i = yy - ut_AbovePixel(o_y2) + 1 |
|---|
| 399 | + xx - ut_AbovePixel(o_x2) + 1; |
|---|
| 400 | int q = ((o_x1-o_x2) * ut_BelowScanDelta(o_y1)) |
|---|
| 401 | - ((o_y1-o_y2) * ut_BelowScanDelta(o_x1)) + 1; |
|---|
| 402 | for (; i; i--) |
|---|
| 403 | { |
|---|
| 404 | if (q > 0) |
|---|
| 405 | { |
|---|
| 406 | xx--; |
|---|
| 407 | q -= dy; |
|---|
| 408 | } |
|---|
| 409 | else |
|---|
| 410 | { |
|---|
| 411 | ut_AddHoriEdgeN(task, xx+1, yy); |
|---|
| 412 | yy--; |
|---|
| 413 | q += dx; |
|---|
| 414 | } |
|---|
| 415 | } |
|---|
| 416 | } |
|---|
| 417 | } |
|---|
| 418 | UT_TRACE_TAB_DEC(); |
|---|
| 419 | } |
|---|
| 420 | |
|---|
| 421 | #ifdef _USE_DROPOUT_COLTROL |
|---|
| 422 | |
|---|
| 423 | #if 0 |
|---|
| 424 | |
|---|
| 425 | static void ut_LineTo_Dropout(UT_FONT_TASK* task, UT_COORD o_x1, UT_COORD o_y1, UT_COORD o_x2, UT_COORD o_y2) |
|---|
| 426 | { |
|---|
| 427 | UT_TRACE2("ut_LineTo_Dropout() o_x1 = %d", o_x1); |
|---|
| 428 | UT_TRACE2(" o_y1 = %d", o_y1); |
|---|
| 429 | UT_TRACE2(" o_x2 = %d", o_x2); |
|---|
| 430 | UT_TRACE2(" o_y3 = %d", o_y2); |
|---|
| 431 | UT_TRACE_TAB_INC(); |
|---|
| 432 | if ((task->o_cx == o_x2) && (task->o_cy == o_y2)) |
|---|
| 433 | { |
|---|
| 434 | UT_TRACE_TAB_DEC(); |
|---|
| 435 | return; |
|---|
| 436 | } |
|---|
| 437 | if (task->emptyLastPoint) |
|---|
| 438 | { |
|---|
| 439 | task->emptyLastPoint = 0; |
|---|
| 440 | task->o_lx = o_x2; |
|---|
| 441 | task->o_ly = o_y2; |
|---|
| 442 | } |
|---|
| 443 | else |
|---|
| 444 | { |
|---|
| 445 | ut_CheckLastPoint(task, o_x2, o_y2); |
|---|
| 446 | } |
|---|
| 447 | task->o_px = task->o_cx; |
|---|
| 448 | task->o_py = task->o_cy; |
|---|
| 449 | task->o_cx = o_x2; |
|---|
| 450 | task->o_cy = o_y2; |
|---|
| 451 | if (o_x1 == o_x2) |
|---|
| 452 | { |
|---|
| 453 | if (o_y1 < o_y2) |
|---|
| 454 | { |
|---|
| 455 | int sx = ut_ExceptionAbovePixel(o_x1); |
|---|
| 456 | int sy = ut_AbovePixel(o_y1); |
|---|
| 457 | int ii = ut_BelowPixel(o_y2) - sy + 1; |
|---|
| 458 | for (; ii; ii--) |
|---|
| 459 | { |
|---|
| 460 | ut_AddHoriEdgeP(task, sx, sy); |
|---|
| 461 | sy++; |
|---|
| 462 | } |
|---|
| 463 | } |
|---|
| 464 | else /*if (o_y1 > o_y2)*/ |
|---|
| 465 | { |
|---|
| 466 | int sx = ut_AbovePixel(o_x1); |
|---|
| 467 | int sy = ut_BelowPixel(o_y1); |
|---|
| 468 | int ii = sy - ut_AbovePixel(o_y2) + 1; |
|---|
| 469 | for (; ii; ii--) |
|---|
| 470 | { |
|---|
| 471 | ut_AddHoriEdgeN(task, sx, sy); |
|---|
| 472 | sy--; |
|---|
| 473 | } |
|---|
| 474 | } |
|---|
| 475 | } |
|---|
| 476 | else if (o_y1 == o_y2) |
|---|
| 477 | { |
|---|
| 478 | if (o_x1 < o_x2) |
|---|
| 479 | { |
|---|
| 480 | int sx = ut_AbovePixel(o_x1); |
|---|
| 481 | int sy = ut_AbovePixel(o_y1); |
|---|
| 482 | int ii = ut_BelowPixel(o_x2) - sx + 1; |
|---|
| 483 | for (; ii; ii--) |
|---|
| 484 | { |
|---|
| 485 | ut_AddVertEdgeP(task, sx, sy); |
|---|
| 486 | sx++; |
|---|
| 487 | } |
|---|
| 488 | } |
|---|
| 489 | else /*if (o_x1 > o_x2)*/ |
|---|
| 490 | { |
|---|
| 491 | int sx = ut_BelowPixel(o_x1); |
|---|
| 492 | int sy = ut_ExceptionAbovePixel(o_y1); |
|---|
| 493 | int ii = sx - ut_AbovePixel(o_x2) + 1; |
|---|
| 494 | for (; ii; ii--) |
|---|
| 495 | { |
|---|
| 496 | ut_AddVertEdgeN(task, sx, sy); |
|---|
| 497 | sx--; |
|---|
| 498 | } |
|---|
| 499 | } |
|---|
| 500 | } |
|---|
| 501 | else if (o_x1 < o_x2) |
|---|
| 502 | { |
|---|
| 503 | if (o_y1 < o_y2) |
|---|
| 504 | { |
|---|
| 505 | int dx = (o_x2-o_x1) << _UT_PIXEL_SHIFT; |
|---|
| 506 | int dy = (o_y2-o_y1) << _UT_PIXEL_SHIFT; |
|---|
| 507 | int sx = ut_AbovePixel(o_x1); |
|---|
| 508 | int sy = ut_AbovePixel(o_y1); |
|---|
| 509 | int ex = ut_BelowPixel(o_x2); |
|---|
| 510 | int ey = ut_BelowPixel(o_y2); |
|---|
| 511 | int ox = ut_AboveScanLine(o_x1)-o_x1; |
|---|
| 512 | int oy = ut_AboveScanLine(o_y1)-o_y1; |
|---|
| 513 | if (dx > dy) |
|---|
| 514 | { |
|---|
| 515 | int dd = (((o_y2-o_y1)*ox - (o_x2-o_x1)*oy + dy) << 1) - dx; |
|---|
| 516 | int ii = ex - sx + 1; |
|---|
| 517 | int ee = dy << 1; |
|---|
| 518 | int nn = (dy-dx) << 1; |
|---|
| 519 | for (; ii; ii--,sx++) |
|---|
| 520 | { |
|---|
| 521 | ut_AddVertEdgeP(task, sx, sy); |
|---|
| 522 | if (dd <= 0) dd += ee; |
|---|
| 523 | else |
|---|
| 524 | { |
|---|
| 525 | ut_AddHoriEdgeP(task, sx, sy); |
|---|
| 526 | dd += nn; |
|---|
| 527 | sy++; |
|---|
| 528 | } |
|---|
| 529 | } |
|---|
| 530 | } |
|---|
| 531 | else |
|---|
| 532 | { |
|---|
| 533 | int dd = (((o_x2-o_x1)*oy - (o_y2-o_y1)*ox + dx) << 1) - dy; |
|---|
| 534 | int ii = ey - sy + 1; |
|---|
| 535 | int ee = dx << 1; |
|---|
| 536 | int nn = (dx-dy) << 1; |
|---|
| 537 | for (; ii; ii--,sy++) |
|---|
| 538 | { |
|---|
| 539 | ut_AddHoriEdgeP(task, sx, sy); |
|---|
| 540 | if (dd <= 0) dd += ee; |
|---|
| 541 | else |
|---|
| 542 | { |
|---|
| 543 | ut_AddVertEdgeP(task, sx, sy); |
|---|
| 544 | dd += nn; |
|---|
| 545 | sx++; |
|---|
| 546 | } |
|---|
| 547 | } |
|---|
| 548 | } |
|---|
| 549 | } |
|---|
| 550 | else /*if (o_y1 > o_y2)*/ |
|---|
| 551 | { |
|---|
| 552 | int dx = (o_x2-o_x1) << _UT_PIXEL_SHIFT; |
|---|
| 553 | int dy = (o_y1-o_y2) << _UT_PIXEL_SHIFT; |
|---|
| 554 | int sx = ut_AbovePixel(o_x1); |
|---|
| 555 | int sy = ut_BelowPixel(o_y1); |
|---|
| 556 | int ex = ut_BelowPixel(o_x2); |
|---|
| 557 | int ey = ut_AbovePixel(o_y2); |
|---|
| 558 | int ox = ut_AboveScanDelta(o_x1); |
|---|
| 559 | int oy = ut_BelowScanDelta(o_y1); |
|---|
| 560 | if (dx > dy) |
|---|
| 561 | { |
|---|
| 562 | int dd = (((o_y1-o_y2)*ox - (o_x2-o_x1)*oy + dy) << 1) - dx; |
|---|
| 563 | int ii = ex - sx + 1; |
|---|
| 564 | int ee = dy << 1; |
|---|
| 565 | int nn = (dy-dx) << 1; |
|---|
| 566 | for (; ii; ii--,sx++) |
|---|
| 567 | { |
|---|
| 568 | ut_AddVertEdgeP(task, sx, sy); |
|---|
| 569 | if (dd <= 0) dd += ee; |
|---|
| 570 | else |
|---|
| 571 | { |
|---|
| 572 | ut_AddHoriEdgeN(task, sx, sy); |
|---|
| 573 | dd += nn; |
|---|
| 574 | sy--; |
|---|
| 575 | } |
|---|
| 576 | } |
|---|
| 577 | } |
|---|
| 578 | else |
|---|
| 579 | { |
|---|
| 580 | int dd = (((o_x2-o_x1)*oy - (o_y1-o_y2)*ox + dx) << 1) - dy; |
|---|
| 581 | int ii = sy - ey + 1; |
|---|
| 582 | int ee = dx << 1; |
|---|
| 583 | int nn = (dx-dy) << 1; |
|---|
| 584 | for (; ii; ii--,sy--) |
|---|
| 585 | { |
|---|
| 586 | ut_AddHoriEdgeN(task, sx, sy); |
|---|
| 587 | if (dd <= 0) dd += ee; |
|---|
| 588 | else |
|---|
| 589 | { |
|---|
| 590 | ut_AddVertEdgeP(task, sx, sy); |
|---|
| 591 | dd += nn; |
|---|
| 592 | sx++; |
|---|
| 593 | } |
|---|
| 594 | } |
|---|
| 595 | } |
|---|
| 596 | } |
|---|
| 597 | } |
|---|
| 598 | else /*if (o_x1 > o_x2)*/ |
|---|
| 599 | { |
|---|
| 600 | if (o_y1 < o_y2) |
|---|
| 601 | { |
|---|
| 602 | int dx = (o_x1-o_x2) << _UT_PIXEL_SHIFT; |
|---|
| 603 | int dy = (o_y2-o_y1) << _UT_PIXEL_SHIFT; |
|---|
| 604 | int sx = ut_BelowPixel(o_x1); |
|---|
| 605 | int sy = ut_AbovePixel(o_y1); |
|---|
| 606 | int ex = ut_AbovePixel(o_x2); |
|---|
| 607 | int ey = ut_BelowPixel(o_y2); |
|---|
| 608 | int ox = ut_BelowScanDelta(o_x1); |
|---|
| 609 | int oy = ut_AboveScanDelta(o_y1); |
|---|
| 610 | if (dx > dy) |
|---|
| 611 | { |
|---|
| 612 | int dd = (((o_y2-o_y1)*ox - (o_x1-o_x2)*oy + dy) << 1) - dx; |
|---|
| 613 | int ii = sx - ex + 1; |
|---|
| 614 | int ee = dy << 1; |
|---|
| 615 | int nn = (dy-dx) << 1; |
|---|
| 616 | for (; ii; ii--,sx--) |
|---|
| 617 | { |
|---|
| 618 | ut_AddVertEdgeN(task, sx, sy); |
|---|
| 619 | if (dd <= 0) dd += ee; |
|---|
| 620 | else |
|---|
| 621 | { |
|---|
| 622 | ut_AddHoriEdgeP(task, sx, sy); |
|---|
| 623 | dd += nn; |
|---|
| 624 | sy++; |
|---|
| 625 | } |
|---|
| 626 | } |
|---|
| 627 | } |
|---|
| 628 | else |
|---|
| 629 | { |
|---|
| 630 | int dd = (((o_x1-o_x2)*oy - (o_y2-o_y1)*ox + dx) << 1) - dy; |
|---|
| 631 | int ii = ey - sy + 1; |
|---|
| 632 | int ee = dx << 1; |
|---|
| 633 | int nn = (dx-dy) << 1; |
|---|
| 634 | for (; ii; ii--,sy++) |
|---|
| 635 | { |
|---|
| 636 | ut_AddHoriEdgeP(task, sx, sy); |
|---|
| 637 | if (dd <= 0) dd += ee; |
|---|
| 638 | else |
|---|
| 639 | { |
|---|
| 640 | ut_AddVertEdgeN(task, sx, sy); |
|---|
| 641 | dd += nn; |
|---|
| 642 | sx--; |
|---|
| 643 | } |
|---|
| 644 | } |
|---|
| 645 | } |
|---|
| 646 | } |
|---|
| 647 | else /*if (o_y1 > o_y2)*/ |
|---|
| 648 | { |
|---|
| 649 | int dx = (o_x1-o_x2) << _UT_PIXEL_SHIFT; |
|---|
| 650 | int dy = (o_y1-o_y2) << _UT_PIXEL_SHIFT; |
|---|
| 651 | int sy = ut_BelowPixel(o_y1); |
|---|
| 652 | int sx = ut_BelowPixel(o_x1); |
|---|
| 653 | int ex = ut_AbovePixel(o_x2); |
|---|
| 654 | int ey = ut_AbovePixel(o_y2); |
|---|
| 655 | int ox = ut_BelowScanDelta(o_x1); |
|---|
| 656 | int oy = ut_BelowScanDelta(o_y1); |
|---|
| 657 | if (dx > dy) |
|---|
| 658 | { |
|---|
| 659 | int dd = (((o_y1-o_y2)*ox - (o_x1-o_x2)*oy + dy) << 1) - dx; |
|---|
| 660 | int ii = sx - ex + 1; |
|---|
| 661 | int ee = dy << 1; |
|---|
| 662 | int nn = (dy-dx) << 1; |
|---|
| 663 | for (; ii; ii--,sx--) |
|---|
| 664 | { |
|---|
| 665 | ut_AddVertEdgeN(task, sx, sy); |
|---|
| 666 | if (dd <= 0) dd += ee; |
|---|
| 667 | else |
|---|
| 668 | { |
|---|
| 669 | ut_AddHoriEdgeN(task, sx, sy); |
|---|
| 670 | dd += nn; |
|---|
| 671 | sy--; |
|---|
| 672 | } |
|---|
| 673 | } |
|---|
| 674 | } |
|---|
| 675 | else |
|---|
| 676 | { |
|---|
| 677 | int dd = (((o_x1-o_x2)*oy - (o_y1-o_y2)*ox + dx) << 1) - dy; |
|---|
| 678 | int ii = sy - ey + 1; |
|---|
| 679 | int ee = dx << 1; |
|---|
| 680 | int nn = (dx-dy) << 1; |
|---|
| 681 | for (; ii; ii--,sy--) |
|---|
| 682 | { |
|---|
| 683 | ut_AddHoriEdgeN(task, sx, sy); |
|---|
| 684 | if (dd <= 0) dd += ee; |
|---|
| 685 | else |
|---|
| 686 | { |
|---|
| 687 | ut_AddVertEdgeN(task, sx, sy); |
|---|
| 688 | dd += nn; |
|---|
| 689 | sx--; |
|---|
| 690 | } |
|---|
| 691 | } |
|---|
| 692 | } |
|---|
| 693 | } |
|---|
| 694 | } |
|---|
| 695 | UT_TRACE_TAB_DEC(); |
|---|
| 696 | } |
|---|
| 697 | |
|---|
| 698 | #else |
|---|
| 699 | |
|---|
| 700 | static void ut_LineTo_Dropout(UT_FONT_TASK* task, UT_COORD o_x1, UT_COORD o_y1, UT_COORD o_x2, UT_COORD o_y2) |
|---|
| 701 | { |
|---|
| 702 | UT_TRACE2("ut_LineTo_Dropout() o_x1 = %d", o_x1); |
|---|
| 703 | UT_TRACE2(" o_y1 = %d", o_y1); |
|---|
| 704 | UT_TRACE2(" o_x2 = %d", o_x2); |
|---|
| 705 | UT_TRACE2(" o_y3 = %d", o_y2); |
|---|
| 706 | UT_TRACE_TAB_INC(); |
|---|
| 707 | if ((task->o_cx == o_x2) && (task->o_cy == o_y2)) |
|---|
| 708 | { |
|---|
| 709 | UT_TRACE_TAB_DEC(); |
|---|
| 710 | return; |
|---|
| 711 | } |
|---|
| 712 | if (task->emptyLastPoint) |
|---|
| 713 | { |
|---|
| 714 | task->emptyLastPoint = 0; |
|---|
| 715 | task->o_lx = o_x2; |
|---|
| 716 | task->o_ly = o_y2; |
|---|
| 717 | } |
|---|
| 718 | else |
|---|
| 719 | { |
|---|
| 720 | ut_CheckLastPoint(task, o_x2, o_y2); |
|---|
| 721 | } |
|---|
| 722 | task->o_px = task->o_cx; |
|---|
| 723 | task->o_py = task->o_cy; |
|---|
| 724 | task->o_cx = o_x2; |
|---|
| 725 | task->o_cy = o_y2; |
|---|
| 726 | if (o_x1 == o_x2) |
|---|
| 727 | { |
|---|
| 728 | if (o_y1 < o_y2) |
|---|
| 729 | { |
|---|
| 730 | int sx = ut_ExceptionAbovePixel(o_x1); |
|---|
| 731 | int sy = ut_AbovePixel(o_y1); |
|---|
| 732 | int ii = ut_BelowPixel(o_y2) - sy + 1; |
|---|
| 733 | for (; ii; ii--) |
|---|
| 734 | { |
|---|
| 735 | ut_AddHoriEdgeP(task, sx, sy); |
|---|
| 736 | sy++; |
|---|
| 737 | } |
|---|
| 738 | } |
|---|
| 739 | else /*if (o_y1 > o_y2)*/ |
|---|
| 740 | { |
|---|
| 741 | int sx = ut_AbovePixel(o_x1); |
|---|
| 742 | int sy = ut_BelowPixel(o_y1); |
|---|
| 743 | int ii = sy - ut_AbovePixel(o_y2) + 1; |
|---|
| 744 | for (; ii; ii--) |
|---|
| 745 | { |
|---|
| 746 | ut_AddHoriEdgeN(task, sx, sy); |
|---|
| 747 | sy--; |
|---|
| 748 | } |
|---|
| 749 | } |
|---|
| 750 | } |
|---|
| 751 | else if (o_y1 == o_y2) |
|---|
| 752 | { |
|---|
| 753 | if (o_x1 < o_x2) |
|---|
| 754 | { |
|---|
| 755 | int sx = ut_AbovePixel(o_x1); |
|---|
| 756 | int sy = ut_AbovePixel(o_y1); |
|---|
| 757 | int ii = ut_BelowPixel(o_x2) - sx + 1; |
|---|
| 758 | for (; ii; ii--) |
|---|
| 759 | { |
|---|
| 760 | ut_AddVertEdgeP(task, sx, sy); |
|---|
| 761 | sx++; |
|---|
| 762 | } |
|---|
| 763 | } |
|---|
| 764 | else /*if (o_x1 > o_x2)*/ |
|---|
| 765 | { |
|---|
| 766 | int sx = ut_BelowPixel(o_x1); |
|---|
| 767 | int sy = ut_ExceptionAbovePixel(o_y1); |
|---|
| 768 | int ii = sx - ut_AbovePixel(o_x2) + 1; |
|---|
| 769 | for (; ii; ii--) |
|---|
| 770 | { |
|---|
| 771 | ut_AddVertEdgeN(task, sx, sy); |
|---|
| 772 | sx--; |
|---|
| 773 | } |
|---|
| 774 | } |
|---|
| 775 | } |
|---|
| 776 | else if (o_x1 < o_x2) |
|---|
| 777 | { |
|---|
| 778 | if (o_y1 < o_y2) |
|---|
| 779 | { |
|---|
| 780 | int dx = (o_x2-o_x1) << _UT_PIXEL_SHIFT; |
|---|
| 781 | int dy = (o_y2-o_y1) << _UT_PIXEL_SHIFT; |
|---|
| 782 | int sx = ut_AbovePixel(o_x1); |
|---|
| 783 | int sy = ut_AbovePixel(o_y1); |
|---|
| 784 | int ex = ut_BelowPixel(o_x2); |
|---|
| 785 | int ey = ut_BelowPixel(o_y2); |
|---|
| 786 | int ox = ut_AboveScanDelta(o_x1); |
|---|
| 787 | int oy = ut_AboveScanDelta(o_y1); |
|---|
| 788 | int ii = ex - sx + 1 + ey - sy + 1; |
|---|
| 789 | int dd = (o_x2-o_x1)*oy - (o_y2-o_y1)*ox; |
|---|
| 790 | for (; ii; ii--) |
|---|
| 791 | { |
|---|
| 792 | if (dd > 0) |
|---|
| 793 | { |
|---|
| 794 | ut_AddVertEdgeP(task, sx, sy); |
|---|
| 795 | sx++; |
|---|
| 796 | dd -= dy; |
|---|
| 797 | } |
|---|
| 798 | else |
|---|
| 799 | { |
|---|
| 800 | ut_AddHoriEdgeP(task, sx, sy); |
|---|
| 801 | sy++; |
|---|
| 802 | dd += dx; |
|---|
| 803 | } |
|---|
| 804 | } |
|---|
| 805 | } |
|---|
| 806 | else /*if (o_y1 > o_y2)*/ |
|---|
| 807 | { |
|---|
| 808 | int dx = (o_x2-o_x1) << _UT_PIXEL_SHIFT; |
|---|
| 809 | int dy = (o_y1-o_y2) << _UT_PIXEL_SHIFT; |
|---|
| 810 | int sx = ut_AbovePixel(o_x1); |
|---|
| 811 | int sy = ut_BelowPixel(o_y1); |
|---|
| 812 | int ex = ut_BelowPixel(o_x2); |
|---|
| 813 | int ey = ut_AbovePixel(o_y2); |
|---|
| 814 | int ox = ut_AboveScanDelta(o_x1); |
|---|
| 815 | int oy = ut_BelowScanDelta(o_y1); |
|---|
| 816 | int ii = ex - sx + 1 + sy - ey + 1; |
|---|
| 817 | int dd = (o_x2-o_x1)*oy - (o_y1-o_y2)*ox; |
|---|
| 818 | for (; ii; ii--) |
|---|
| 819 | { |
|---|
| 820 | if (dd > 0) |
|---|
| 821 | { |
|---|
| 822 | ut_AddVertEdgeP(task, sx, sy+1); |
|---|
| 823 | sx++; |
|---|
| 824 | dd -= dy; |
|---|
| 825 | } |
|---|
| 826 | else |
|---|
| 827 | { |
|---|
| 828 | ut_AddHoriEdgeN(task, sx, sy); |
|---|
| 829 | sy--; |
|---|
| 830 | dd += dx; |
|---|
| 831 | } |
|---|
| 832 | } |
|---|
| 833 | } |
|---|
| 834 | } |
|---|
| 835 | else /*if (o_x1 > o_x2)*/ |
|---|
| 836 | { |
|---|
| 837 | if (o_y1 < o_y2) |
|---|
| 838 | { |
|---|
| 839 | int dx = (o_x1-o_x2) << _UT_PIXEL_SHIFT; |
|---|
| 840 | int dy = (o_y2-o_y1) << _UT_PIXEL_SHIFT; |
|---|
| 841 | int sx = ut_BelowPixel(o_x1); |
|---|
| 842 | int sy = ut_AbovePixel(o_y1); |
|---|
| 843 | int ex = ut_AbovePixel(o_x2); |
|---|
| 844 | int ey = ut_BelowPixel(o_y2); |
|---|
| 845 | int ox = ut_BelowScanDelta(o_x1); |
|---|
| 846 | int oy = ut_AboveScanDelta(o_y1); |
|---|
| 847 | int ii = sx - ex + 1 + ey - sy + 1; |
|---|
| 848 | int dd = (o_x1-o_x2)*oy - (o_y2-o_y1)*ox; |
|---|
| 849 | for (; ii; ii--) |
|---|
| 850 | { |
|---|
| 851 | if (dd > 0) |
|---|
| 852 | { |
|---|
| 853 | ut_AddVertEdgeN(task, sx, sy); |
|---|
| 854 | sx--; |
|---|
| 855 | dd -= dy; |
|---|
| 856 | } |
|---|
| 857 | else |
|---|
| 858 | { |
|---|
| 859 | ut_AddHoriEdgeP(task, sx+1, sy); |
|---|
| 860 | sy++; |
|---|
| 861 | dd += dx; |
|---|
| 862 | } |
|---|
| 863 | } |
|---|
| 864 | } |
|---|
| 865 | else /*if (o_y1 > o_y2)*/ |
|---|
| 866 | { |
|---|
| 867 | int dx = (o_x1-o_x2) << _UT_PIXEL_SHIFT; |
|---|
| 868 | int dy = (o_y1-o_y2) << _UT_PIXEL_SHIFT; |
|---|
| 869 | int sy = ut_BelowPixel(o_y1); |
|---|
| 870 | int sx = ut_BelowPixel(o_x1); |
|---|
| 871 | int ex = ut_AbovePixel(o_x2); |
|---|
| 872 | int ey = ut_AbovePixel(o_y2); |
|---|
| 873 | int ox = ut_BelowScanDelta(o_x1); |
|---|
| 874 | int oy = ut_BelowScanDelta(o_y1); |
|---|
| 875 | int ii = sx - ex + 1 + sy - ey + 1; |
|---|
| 876 | int dd = (o_x1-o_x2)*oy - (o_y1-o_y2)*ox; |
|---|
| 877 | for (; ii; ii--) |
|---|
| 878 | { |
|---|
| 879 | if (dd > 0) |
|---|
| 880 | { |
|---|
| 881 | ut_AddVertEdgeN(task, sx, sy+1); |
|---|
| 882 | sx--; |
|---|
| 883 | dd -= dy; |
|---|
| 884 | } |
|---|
| 885 | else |
|---|
| 886 | { |
|---|
| 887 | ut_AddHoriEdgeN(task, sx + 1, sy); |
|---|
| 888 | sy--; |
|---|
| 889 | dd += dx; |
|---|
| 890 | } |
|---|
| 891 | } |
|---|
| 892 | } |
|---|
| 893 | } |
|---|
| 894 | UT_TRACE_TAB_DEC(); |
|---|
| 895 | } |
|---|
| 896 | |
|---|
| 897 | #endif |
|---|
| 898 | |
|---|
| 899 | #endif |
|---|
| 900 | |
|---|
| 901 | static void ut_RegulizeEdge(US_EDGE1* scanLine, int nLine) |
|---|
| 902 | { |
|---|
| 903 | US_EDGE1* curr; |
|---|
| 904 | US_EDGE1* from; |
|---|
| 905 | int sum; |
|---|
| 906 | UT_TRACE2("ut_RegulizeEdge() nLine = %d", nLine); |
|---|
| 907 | for (nLine--; nLine>=0; nLine--) |
|---|
| 908 | { |
|---|
| 909 | for (curr=scanLine[nLine].next; curr; curr=curr->next) |
|---|
| 910 | { |
|---|
| 911 | from = curr; |
|---|
| 912 | curr = curr->next; |
|---|
| 913 | if (!curr) break; |
|---|
| 914 | if (from->dir == curr->dir) |
|---|
| 915 | { |
|---|
| 916 | sum = from->dir << 1; |
|---|
| 917 | do |
|---|
| 918 | { |
|---|
| 919 | curr = curr->next; |
|---|
| 920 | sum += curr->dir; |
|---|
| 921 | } while (sum); |
|---|
| 922 | } |
|---|
| 923 | from->next = curr; |
|---|
| 924 | } |
|---|
| 925 | for (curr=scanLine[nLine].next; curr;) |
|---|
| 926 | { |
|---|
| 927 | if (!curr->next) break; |
|---|
| 928 | if (!curr->next->next) break; |
|---|
| 929 | if (curr->next->pos == curr->next->next->next->pos) |
|---|
| 930 | { |
|---|
| 931 | curr->next = curr->next->next->next; |
|---|
| 932 | } |
|---|
| 933 | else |
|---|
| 934 | { |
|---|
| 935 | curr = curr->next->next; |
|---|
| 936 | } |
|---|
| 937 | } |
|---|
| 938 | } |
|---|
| 939 | } |
|---|
| 940 | |
|---|
| 941 | static void ut_ScanFillMono(UT_FONT_TASK* task) |
|---|
| 942 | { |
|---|
| 943 | US_EDGE1* scanLine; |
|---|
| 944 | US_EDGE1* edge; |
|---|
| 945 | int nLine, line, s, e; |
|---|
| 946 | UT_U32* p; |
|---|
| 947 | UT_TRACE1("ut_ScanFillMono()"); |
|---|
| 948 | UT_TRACE_TAB_INC(); |
|---|
| 949 | #ifdef _USE_DROPOUT_COLTROL |
|---|
| 950 | if (task->isDropout) |
|---|
| 951 | { |
|---|
| 952 | ut_RegulizeEdge(task->horiScanLine1, task->i_ySize); |
|---|
| 953 | ut_RegulizeEdge(task->vertScanLine1, task->i_xSize); |
|---|
| 954 | scanLine = task->horiScanLine1; |
|---|
| 955 | nLine = task->i_ySize; |
|---|
| 956 | for (line=0,p=task->image; line<nLine; line++,p+=task->i_bSize) |
|---|
| 957 | { |
|---|
| 958 | for (edge=scanLine[line].next; edge; edge=edge->next->next) |
|---|
| 959 | { |
|---|
| 960 | e = edge->pos; |
|---|
| 961 | s = edge->next->pos; |
|---|
| 962 | if (s<e) ut_FillLineMono(s, e-1+task->emulBold, p); |
|---|
| 963 | } |
|---|
| 964 | } |
|---|
| 965 | scanLine = task->horiScanLine1; |
|---|
| 966 | nLine = task->i_ySize; |
|---|
| 967 | for (line=0; line<nLine; line++) |
|---|
| 968 | { |
|---|
| 969 | for (edge=scanLine[line].next; edge; edge=edge->next->next) |
|---|
| 970 | { |
|---|
| 971 | s = edge->pos; |
|---|
| 972 | if (s!=edge->next->pos) continue; |
|---|
| 973 | if (s > 0) if (ut_GetPixel(task, s-1, line)) continue; |
|---|
| 974 | if (s < task->i_xSize) if (ut_GetPixel(task, s, line)) continue; |
|---|
| 975 | if (s) s--; |
|---|
| 976 | ut_SetPixel(task, s, line); |
|---|
| 977 | } |
|---|
| 978 | } |
|---|
| 979 | /* |
|---|
| 980 | scanLine = task->vertScanLine1; |
|---|
| 981 | nLine = task->i_xSize; |
|---|
| 982 | for (line=0; line<nLine; line++) |
|---|
| 983 | { |
|---|
| 984 | for (edge=scanLine[line].next; edge; edge=edge->next->next) |
|---|
| 985 | { |
|---|
| 986 | s = edge->pos; |
|---|
| 987 | UT_TRACE2("HH() s = %d", edge->next->pos); |
|---|
| 988 | UT_TRACE2(" e = %d", s); |
|---|
| 989 | if (!edge->next) break; |
|---|
| 990 | if (s!=edge->next->pos) continue; |
|---|
| 991 | if (s > 0) if (ut_GetPixel(task, line, s-1)) continue; |
|---|
| 992 | if (s < task->i_ySize) if (ut_GetPixel(task, line, s)) continue; |
|---|
| 993 | if (s) s--; |
|---|
| 994 | ut_SetPixel(task, line, s); |
|---|
| 995 | } |
|---|
| 996 | } |
|---|
| 997 | */ |
|---|
| 998 | } |
|---|
| 999 | else |
|---|
| 1000 | #endif |
|---|
| 1001 | { |
|---|
| 1002 | for (line=0,p=task->image; line<task->i_ySize; line++,p+=task->i_bSize) |
|---|
| 1003 | { |
|---|
| 1004 | int sum = 0; |
|---|
| 1005 | edge = task->horiScanLine1[line].next; |
|---|
| 1006 | while (edge) |
|---|
| 1007 | { |
|---|
| 1008 | if (sum) |
|---|
| 1009 | { |
|---|
| 1010 | if (!(sum += edge->dir)) |
|---|
| 1011 | { |
|---|
| 1012 | s = edge->pos; |
|---|
| 1013 | if (s<e) ut_FillLineMono(s, e-1+task->emulBold, p); |
|---|
| 1014 | } |
|---|
| 1015 | } |
|---|
| 1016 | else |
|---|
| 1017 | { |
|---|
| 1018 | sum += edge->dir; |
|---|
| 1019 | e = edge->pos; |
|---|
| 1020 | } |
|---|
| 1021 | edge = edge->next; |
|---|
| 1022 | } |
|---|
| 1023 | } |
|---|
| 1024 | } |
|---|
| 1025 | task->emulBold = 0; |
|---|
| 1026 | UT_TRACE_TAB_DEC(); |
|---|
| 1027 | } |
|---|
| 1028 | |
|---|
| 1029 | static void ut_ScanFillGray(UT_FONT_TASK* task, unsigned char* image) |
|---|
| 1030 | { |
|---|
| 1031 | int shift = task->grayShift; |
|---|
| 1032 | int level = 1 << (3-shift); |
|---|
| 1033 | US_EDGE1* edge; |
|---|
| 1034 | int line, s, e; |
|---|
| 1035 | UT_TRACE1("ut_ScanFillMono()"); |
|---|
| 1036 | UT_TRACE_TAB_INC(); |
|---|
| 1037 | for (line=0; line<task->i_ySize; line++) |
|---|
| 1038 | { |
|---|
| 1039 | int sum = 0; |
|---|
| 1040 | edge = task->horiScanLine1[line].next; |
|---|
| 1041 | while (edge) |
|---|
| 1042 | { |
|---|
| 1043 | if (sum) |
|---|
| 1044 | { |
|---|
| 1045 | if (!(sum += edge->dir)) |
|---|
| 1046 | { |
|---|
| 1047 | s = edge->pos; |
|---|
| 1048 | if (s<e) ut_FillLineGray(s, e-1+task->emulBold, shift, level, image+(line>>shift)*task->i_bSize); |
|---|
| 1049 | } |
|---|
| 1050 | } |
|---|
| 1051 | else |
|---|
| 1052 | { |
|---|
| 1053 | sum += edge->dir; |
|---|
| 1054 | e = edge->pos; |
|---|
| 1055 | } |
|---|
| 1056 | edge = edge->next; |
|---|
| 1057 | } |
|---|
| 1058 | } |
|---|
| 1059 | task->emulBold = 0; |
|---|
| 1060 | UT_TRACE_TAB_DEC(); |
|---|
| 1061 | } |
|---|