| 466 | } |
| 467 | |
| 468 | void |
| 469 | bitmaps_to_image (const std::vector<lay::ViewOp> &view_ops_in, |
| 470 | const std::vector<lay::Bitmap *> &pbitmaps_in, |
| 471 | const lay::DitherPattern &dp, |
| 472 | const lay::LineStyles &ls, |
| 473 | double dpr, |
| 474 | tl::PixelBuffer *pimage, unsigned int width, unsigned int height, |
| 475 | bool use_bitmap_index, |
| 476 | tl::Mutex *mutex) |
| 477 | { |
| 478 | bool transparent = pimage->transparent (); |
| 479 | |
| 480 | std::vector<unsigned int> bm_map; |
| 481 | std::vector<unsigned int> vo_map; |
| 482 | |
| 483 | vo_map.reserve (view_ops_in.size ()); |
| 484 | bm_map.reserve (view_ops_in.size ()); |
| 485 | unsigned int n_in = 0; |
| 486 | |
| 487 | // drop invisible and empty bitmaps, build bitmap mask |
| 488 | for (unsigned int i = 0; i < view_ops_in.size (); ++i) { |
| 489 | |
| 490 | const lay::ViewOp &vop = view_ops_in [i]; |
| 491 | |
| 492 | unsigned int bi = (use_bitmap_index && vop.bitmap_index () >= 0) ? (unsigned int) vop.bitmap_index () : i; |
| 493 | const lay::Bitmap *pb = bi < pbitmaps_in.size () ? pbitmaps_in [bi] : 0; |
| 494 | |
| 495 | if ((vop.ormask () | ~vop.andmask ()) != 0 && pb && ! pb->empty ()) { |
| 496 | vo_map.push_back (i); |
| 497 | bm_map.push_back (bi); |
| 498 | ++n_in; |
| 499 | } |
| 500 | |
| 501 | } |
| 502 | |
| 503 | // Styled lines with width > 1 are not rendered directly, but through an intermediate step. |
| 504 | // We prepare the necessary precursor bitmaps now |
| 505 | std::map<unsigned int, lay::Bitmap> precursors; |
| 506 | create_precursor_bitmaps (view_ops_in, vo_map, pbitmaps_in, bm_map, ls, width, height, precursors, mutex); |
| 507 | |
| 508 | std::vector<lay::ViewOp> view_ops; |
| 509 | std::vector<const lay::Bitmap *> pbitmaps; |
| 510 | std::vector<std::pair <tl::color_t, tl::color_t> > masks; |
| 511 | std::vector<uint32_t> non_empty_sls; |
| 512 | |
| 513 | view_ops.reserve (n_in); |
| 514 | pbitmaps.reserve (n_in); |
| 515 | masks.reserve (n_in); |
| 516 | non_empty_sls.reserve (n_in); |
| 517 | |
| 518 | // to optimize the bitmap generation, the bitmaps are checked |
| 519 | // for emptyness in slices of "slice" scanlines |
| 520 | unsigned int slice = 32; |
| 521 | |
| 522 | // allocate a pixel buffer large enough to hold a scanline for all |
| 523 | // planes. |
| 524 | unsigned int nwords = (width + 31) / 32; |
| 525 | uint32_t *buffer = new uint32_t [n_in * nwords]; |
no test coverage detected