MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / xs_poco_drawMasked

Function xs_poco_drawMasked

modules/commodetto/commodettoPocoCore.c:821–875  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

819}
820
821void xs_poco_drawMasked(xsMachine *the)
822{
823 Poco poco = xsmcGetHostDataPoco(xsThis);
824 int argc = xsmcArgc;
825 PocoBitmapRecord bits, mask;
826 PocoCoordinate x, y;
827 PocoDimension sx, sy, sw, sh, mask_sx, mask_sy;
828 CommodettoBitmap cb;
829
830 cb = xsmcGetHostChunk(xsArg(0));
831 bits.width = cb->w;
832 bits.height = cb->h;
833 bits.format = cb->format;
834#if COMMODETTO_BITMAP_ID
835 bits.id = cb->id;
836 bits.byteLength = 0;
837#endif
838 bits.pixels = pocoGetBitmapPixels(the, poco, cb, 0);
839
840 x = (PocoCoordinate)xsmcToInteger(xsArg(1)) + poco->xOrigin;
841 y = (PocoCoordinate)xsmcToInteger(xsArg(2)) + poco->yOrigin;
842 sx = (PocoDimension)xsmcToInteger(xsArg(3));
843 sy = (PocoDimension)xsmcToInteger(xsArg(4));
844 sw = (PocoDimension)xsmcToInteger(xsArg(5));
845 sh = (PocoDimension)xsmcToInteger(xsArg(6));
846
847#if (0 == kPocoRotation) || (180 == kPocoRotation)
848 if ((sx >= bits.width) || (sy >= bits.height) || ((sx + sw) > bits.width) || ((sy + sh) > bits.height))
849#else
850 if ((sx >= bits.height) || (sy >= bits.width) || ((sx + sw) > bits.height) || ((sy + sh) > bits.width))
851#endif
852 xsRangeError("invalid src");
853
854 cb = xsmcGetHostChunk(xsArg(7));
855 mask.width = cb->w;
856 mask.height = cb->h;
857 mask.format = cb->format;
858#if COMMODETTO_BITMAP_ID
859 mask.id = cb->id;
860 mask.byteLength = 0;
861#endif
862 mask.pixels = pocoGetBitmapPixels(the, poco, cb, 7);
863
864 mask_sx = (PocoDimension)xsmcToInteger(xsArg(8));
865 mask_sy = (PocoDimension)xsmcToInteger(xsArg(9));
866 if ((mask_sx >= mask.width) || (mask_sy >= mask.height) || ((mask_sx + sw) > mask.width) || ((mask_sy + sh) > mask.height))
867 xsRangeError("invalid mask src");
868
869 if (argc > 10) {
870 uint8_t blend = (uint8_t)xsmcToInteger(xsArg(10));
871 PocoBitmapDrawMasked(poco, blend, &bits, x, y, sx, sy, sw, sh, &mask, mask_sx, mask_sy);
872 }
873 else
874 PocoBitmapDrawMasked(poco, kPocoOpaque, &bits, x, y, sx, sy, sw, sh, &mask, mask_sx, mask_sy);
875}
876
877void xs_poco_fillPattern(xsMachine *the)
878{

Callers

nothing calls this directly

Calls 2

pocoGetBitmapPixelsFunction · 0.85
PocoBitmapDrawMaskedFunction · 0.85

Tested by

no test coverage detected