MCPcopy Create free account
hub / github.com/KLayout/klayout / render_scanline_cross

Function render_scanline_cross

src/laybasic/laybasic/layBitmapsToImage.cc:305–431  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

303}
304
305static void
306render_scanline_cross (const uint32_t *dp, unsigned int ds, const lay::Bitmap *pbitmap,
307 unsigned int y, unsigned int w, unsigned int h, uint32_t *data,
308 unsigned int pixels)
309{
310 if (pixels < 1) {
311 return;
312 }
313
314 // NOTE: hardcoded bar/width ratio for crosses.
315 unsigned int lw = std::max (std::min ((unsigned int) 6, pixels / 9), (unsigned int) 1);
316
317 const int max_pixels = 31;
318 if (pixels > max_pixels) {
319 pixels = max_pixels;
320 }
321
322 const uint32_t *dm = dp;
323 unsigned int px1 = (pixels - 1) / 2;
324 unsigned int px2 = (pixels - 1) - px1;
325
326 unsigned int spx1 = (lw - 1) / 2;
327 unsigned int spx2 = (lw - 1) - spx1;
328
329 const uint32_t *ps[max_pixels + 1];
330 for (unsigned int p = 0; p < pixels; ++p) {
331 if (y + p < px1) {
332 ps[p] = pbitmap->scanline (0);
333 } else if ((y + p - px1) >= h) {
334 ps[p] = pbitmap->scanline (h - 1);
335 } else {
336 ps[p] = pbitmap->scanline (y + p - px1);
337 }
338 }
339
340 uint32_t *dpp = data;
341 for (unsigned int i = (w + lay::wordlen - 1) / lay::wordlen; i > 0; --i) {
342 *dpp++ = 0;
343 }
344
345 for (unsigned int o = 0; o < pixels; ++o) {
346
347 dpp = data;
348
349 unsigned int bpx1 = 0, bpx2 = 0;
350 if (o >= px1 - spx1 && o <= px1 + spx2) {
351 bpx1 = px1;
352 bpx2 = px2;
353 } else {
354 bpx1 = spx1;
355 bpx2 = spx2;
356 }
357
358 if (bpx1 > 0 || bpx2 > 0) {
359
360 uint32_t d, dd = 0, dn;
361 dn = *(ps[o]++);
362

Callers 2

bitmaps_to_imageFunction · 0.85
bitmap_to_bitmapFunction · 0.85

Calls 3

maxFunction · 0.85
minFunction · 0.85
scanlineMethod · 0.60

Tested by

no test coverage detected