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

Function PocoBitmapDraw

modules/commodetto/commodettoPocoBlit.c:516–587  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

514}
515
516void PocoBitmapDraw(Poco poco, PocoBitmap bits, PocoCoordinate x, PocoCoordinate y, PocoDimension sx, PocoDimension sy, PocoDimension sw, PocoDimension sh)
517{
518 const PocoPixel *pixels;
519 int16_t d;
520 PocoCommand pc = poco->next;
521
522 if (kCommodettoBitmapMonochrome == bits->format) {
523 PocoMonochromeBitmapDraw(poco, bits, kPocoMonochromeForeAndBackground, 0, ~0, x, y, sx, sy, sw, sh);
524 return;
525 }
526 if (kCommodettoBitmapFormat != bits->format)
527 return;
528
529 PocoReturnIfNoSpace(pc, sizeof(RenderMonochromeBitsRecord));
530
531 rotateCoordinates(poco->width, poco->height, x, y, sw, sh);
532#if (0 == kPocoRotation) || (180 == kPocoRotation)
533 rotateCoordinatesAndDimensions(bits->width, bits->height, sx, sy, sw, sh);
534#elif (90 == kPocoRotation) || (270 == kPocoRotation)
535 rotateCoordinatesAndDimensions(bits->height, bits->width, sx, sy, sw, sh);
536#endif
537
538 if ((x >= poco->xMax) || (y >= poco->yMax))
539 return;
540
541 if (x < poco->x) {
542 d = poco->x - x;
543 if (sw <= d)
544 return;
545 sx += d;
546 sw -= d;
547 x = poco->x;
548 }
549
550 if (y < poco->y) {
551 d = poco->y - y;
552 if (sh <= d)
553 return;
554 sy += d;
555 sh -= d;
556 y = poco->y;
557 }
558
559 if ((x + sw) > poco->xMax)
560 sw = poco->xMax - x;
561
562 if ((y + sh) > poco->yMax)
563 sh = poco->yMax - y;
564
565 if ((sx >= bits->width) || (sy >= bits->height) || ((sx + sw) > bits->width) || ((sy + sh) > bits->height) || !sw || !sh)
566 return;
567
568 pixels = bits->pixels;
569
570 pc->x = x, pc->y = y, pc->w = sw, pc->h = sh;
571
572 pc->command = kPocoCommandBitmapDraw;
573 PocoCommandSetLength(pc, sizeof(RenderBitsRecord));

Callers 5

xs_poco_drawBitmapFunction · 0.85
xs_poco_drawTextFunction · 0.85
PiuViewDrawStringAuxFunction · 0.85
PiuViewDrawTextureAuxFunction · 0.85
PiuImageBufferDrawAuxFunction · 0.85

Calls 2

PocoMonochromeBitmapDrawFunction · 0.85
buildColorMapFunction · 0.85

Tested by

no test coverage detected