MCPcopy Create free account
hub / github.com/EasyRPG/Player / CreateMask

Function CreateMask

src/bitmap.cpp:587–611  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

585
586namespace {
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
614void Bitmap::Blit(int x, int y, Bitmap const& src, Rect const& src_rect, Opacity const& opacity, Bitmap::BlendMode blend_mode) {

Callers 6

BlitMethod · 0.85
TiledBlitMethod · 0.85
StretchBlitMethod · 0.85
WaverBlitMethod · 0.85
RotateZoomOpacityBlitMethod · 0.85
EdgeMirrorBlitMethod · 0.85

Calls 5

TranslationClass · 0.85
IsOpaqueMethod · 0.80
IsSplitMethod · 0.80
ValueMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected