| 585 | |
| 586 | namespace { |
| 587 | PixmanImagePtr CreateMask(Opacity const& opacity, Rect const& src_rect, Transform const* pxform = nullptr) { |
| 588 | if (opacity.IsOpaque()) { |
| 589 | return nullptr; |
| 590 | } |
| 591 | |
| 592 | if (!opacity.IsSplit()) { |
| 593 | pixman_color_t tcolor = {0, 0, 0, static_cast<uint16_t>(opacity.Value() << 8)}; |
| 594 | return PixmanImagePtr{ pixman_image_create_solid_fill(&tcolor) }; |
| 595 | } |
| 596 | |
| 597 | auto mask = PixmanImagePtr{pixman_image_create_bits(PIXMAN_a8, 1, 2, (uint32_t*) NULL, 4)}; |
| 598 | uint32_t* pixels = pixman_image_get_data(mask.get()); |
| 599 | *reinterpret_cast<uint8_t*>(&pixels[0]) = (opacity.top & 0xFF); |
| 600 | *reinterpret_cast<uint8_t*>(&pixels[1]) = (opacity.bottom & 0xFF); |
| 601 | |
| 602 | Transform xform = Transform::Scale(1.0 / src_rect.width, 1.0 / src_rect.height); |
| 603 | xform *= Transform::Translation(0, opacity.split); |
| 604 | |
| 605 | if (pxform) |
| 606 | xform *= *pxform; |
| 607 | |
| 608 | pixman_image_set_transform(mask.get(), &xform.matrix); |
| 609 | |
| 610 | return mask; |
| 611 | } |
| 612 | } // anonymous namespace |
| 613 | |
| 614 | void Bitmap::Blit(int x, int y, Bitmap const& src, Rect const& src_rect, Opacity const& opacity, Bitmap::BlendMode blend_mode) { |
no test coverage detected