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

Function PocoClipPush

modules/commodetto/commodettoPocoBlit.c:3721–3778  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3719#endif
3720
3721int PocoClipPush(Poco poco, PocoCoordinate x, PocoCoordinate y, PocoDimension w, PocoDimension h)
3722{
3723 PocoCoordinate xMax, yMax;
3724 PocoRectangle clip = (PocoRectangle)(poco->displayListEnd - sizeof(PocoRectangleRecord));
3725 if ((char *)clip < (char *)poco->next) {
3726 poco->flags |= kPocoFlagErrorStackProblem;
3727 pocoInstrumentationMax(PocoDisplayListUsed, (char *)poco->next - (char *)poco->displayList);
3728 return 0;
3729 }
3730
3731 rotateCoordinatesAndDimensions(poco->width, poco->height, x, y, w, h);
3732
3733 poco->stackDepth++;
3734 poco->displayListEnd = (char *)clip;
3735
3736 // save current clip
3737 clip->x = poco->x;
3738 clip->y = poco->y;
3739 clip->w = poco->w;
3740 clip->h = poco->h;
3741
3742 // intersect new clip with current clip
3743 xMax = x + w;
3744 yMax = y + h;
3745
3746 if (x < poco->x)
3747 x = poco->x;
3748
3749 if (xMax > poco->xMax)
3750 xMax = poco->xMax;
3751
3752 if (y < poco->y)
3753 y = poco->y;
3754
3755 if (yMax > poco->yMax)
3756 yMax = poco->yMax;
3757
3758 if ((x >= xMax) || (y >= yMax)) {
3759 // clipped out
3760 poco->x = 0;
3761 poco->y = 0;
3762 poco->w = 0;
3763 poco->h = 0;
3764 poco->xMax = 0;
3765 poco->yMax = 0;
3766 return 0;
3767 }
3768
3769 // apply new clip
3770 poco->x = x;
3771 poco->y = y;
3772 poco->w = xMax - x;
3773 poco->h = yMax - y;
3774 poco->xMax = xMax;
3775 poco->yMax = yMax;
3776
3777 return 1;
3778}

Callers 4

xs_poco_clipFunction · 0.85
PiuViewPushClipFunction · 0.85
piuView.cFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected