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

Function PiuTextDraw

modules/piu/All/piuText.c:542–666  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

540}
541
542void PiuTextDraw(void* it, PiuView* view, PiuRectangle area)
543{
544 PiuText* self = it;
545 xsMachine *the = (*self)->the;
546 PiuTextBuffer* lineBuffer = (*self)->lineBuffer;
547 PiuTextOffset lineOffset = sizeof(PiuTextBufferRecord);
548 PiuTextOffset lineLimit = (PiuTextOffset)(*lineBuffer)->current;
549 PiuTextBuffer* nodeBuffer = (*self)->nodeBuffer;
550 PiuTextOffset nodeOffset = sizeof(PiuTextBufferRecord);
551 PiuTextOffset nodeLimit = (PiuTextOffset)(*nodeBuffer)->current;
552 PiuStyle* style = C_NULL;
553 PiuTextOffset fromOffset, toOffset;
554 PiuCoordinate x, base, y;
555 xsIntegerValue portion;
556 xsIntegerValue slop;
557 xsIntegerValue step;
558 PiuCoordinate clipTop = area->y;
559 PiuCoordinate clipBottom = clipTop + area->height;
560 PiuTextLink* link = NULL;
561 PiuTextLine previousLine, line = NULL, nextLine = LINE(lineOffset);
562 xsIntegerValue top, bottom;
563
564 PiuContentDraw(it, view, area);
565 while (lineOffset < lineLimit) {
566 previousLine = line;
567 line = nextLine;
568 lineOffset += sizeof(PiuTextLineRecord);
569 nextLine = (lineOffset < lineLimit) ? LINE(lineOffset) : NULL;
570
571 top = (previousLine) ? previousLine->top : line->top;
572 bottom = (nextLine) ? nextLine->bottom : line->bottom;
573
574 if (top >= clipBottom)
575 break;
576
577 if (bottom <= clipTop)
578 continue;
579
580 fromOffset = line->textOffset;
581 toOffset = (nextLine) ? nextLine->textOffset : (*self)->textOffset;
582
583 base = line->base;
584
585 x = line->x;
586 portion = line->portion;
587 if (portion) {
588 slop = 0;
589 step = line->slop << 16;
590 step /= portion;
591 }
592 else
593 toOffset += line->slop;
594
595 while ((fromOffset < toOffset) && (nodeOffset < nodeLimit)) {
596 switch (KIND(nodeOffset)) {
597 case piuTextNodeBeginBlockKind:
598 case piuTextNodeBeginSpanKind: {
599 PiuTextNodeBegin nodeBegin = NODE(nodeOffset);

Callers

nothing calls this directly

Calls 8

PiuContentDrawFunction · 0.85
PiuColorsBlendFunction · 0.85
PiuTextAdvanceFunction · 0.85
PiuViewPushColorFunction · 0.50
PiuFontGetAscentFunction · 0.50
PiuViewDrawStringFunction · 0.50
PiuFontGetWidthFunction · 0.50
PiuViewPopColorFunction · 0.50

Tested by

no test coverage detected