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

Function render_scanline_px

src/laybasic/laybasic/layBitmapsToImage.cc:234–303  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

232}
233
234static void
235render_scanline_px (const uint32_t *dp, unsigned int ds, const lay::Bitmap *pbitmap,
236 unsigned int y, unsigned int w, unsigned int h, uint32_t *data,
237 unsigned int pixels)
238{
239 if (pixels < 1) {
240 return;
241 }
242
243 if (pixels > 15) {
244 pixels = 15;
245 }
246
247 const uint32_t *dm = dp;
248
249 unsigned int px1 = (pixels - 1) / 2;
250 unsigned int px2 = (pixels - 1) - px1;
251
252 const uint32_t *ps[16];
253 for (unsigned int p = 0; p < pixels; ++p) {
254 if (y + p < px1) {
255 ps[p] = pbitmap->scanline (0);
256 } else if ((y + p - px1) >= h) {
257 ps[p] = pbitmap->scanline (h - 1);
258 } else {
259 ps[p] = pbitmap->scanline (y + p - px1);
260 }
261 }
262
263 uint32_t d, dd = 0, dn = 0;
264 for (unsigned int p = 0; p < pixels; ++p) {
265 dn |= *(ps[p]++);
266 }
267
268 unsigned int x = w;
269 while (true) {
270
271 d = dn;
272
273 dn = 0;
274 if (x > lay::wordlen) {
275 for (unsigned int p = 0; p < pixels; ++p) {
276 dn |= *(ps[p]++);
277 }
278 }
279
280 uint32_t d0 = d;
281 for (unsigned int p = 1; p <= px1; ++p) {
282 d |= (d0 >> p) | (dn << (32 - p));
283 }
284 for (unsigned int p = 1; p <= px2; ++p) {
285 d |= (d0 << p) | (dd >> (32 - p));
286 }
287
288 dd = d0;
289
290 *data++ = d & *dm++;
291 if (dm == dp + ds) {

Callers 2

bitmaps_to_imageFunction · 0.85
bitmap_to_bitmapFunction · 0.85

Calls 1

scanlineMethod · 0.60

Tested by

no test coverage detected