Skip to content

Commit

Permalink
clip draw region
Browse files Browse the repository at this point in the history
  • Loading branch information
GorgonMeducer committed Dec 19, 2024
1 parent 775a036 commit 0234f43
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
29 changes: 25 additions & 4 deletions examples/common/opcodes/arm_2d_user_opcode_draw_circle.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,19 +113,40 @@ arm_fsm_rt_t arm_2dp_rgb565_user_draw_circle(
this.chOpacity = chOpacity;
this.tForeground.hwColour = tColour.tValue;

arm_2d_region_t tTargetRegion = {0};
if (NULL == ptRegion) {
tTargetRegion.tSize = ptTarget->tRegion.tSize;
ptRegion = &tTargetRegion;
}

/* calculate the pivot */
do {
if (this.tParams.ptPivot) {
this.tPivot = *this.tParams.ptPivot;
} else if (NULL != ptRegion) {
} else {
this.tPivot.iX = ptRegion->tLocation.iX + (ptRegion->tSize.iWidth >> 1);
this.tPivot.iY = ptRegion->tLocation.iY + (ptRegion->tSize.iHeight >> 1);
} else {
this.tPivot.iX = (ptTarget->tRegion.tSize.iWidth >> 1);
this.tPivot.iY = (ptTarget->tRegion.tSize.iHeight >> 1);
}

this.tDrawRegion.tSize.iHeight = this.tParams.iRadius * 2 + 2;
this.tDrawRegion.tSize.iWidth = this.tDrawRegion.tSize.iHeight + 2;

this.tDrawRegion.tLocation.iX = this.tPivot.iX - this.tParams.iRadius - 1;
this.tDrawRegion.tLocation.iY = this.tPivot.iY - this.tParams.iRadius - 1;

if (!arm_2d_region_intersect(ptRegion, &this.tDrawRegion, &this.tDrawRegion)) {
/* nothing to draw */
return __arm_2d_op_depose((arm_2d_op_core_t *)ptThis, arm_fsm_rt_cpl);
}

OPCODE.Target.ptRegion = &this.tDrawRegion;

this.tPivot = arm_2d_get_absolute_location(ptTarget, this.tPivot, true );
} while(0);





return __arm_2d_op_invoke((arm_2d_op_core_t *)ptThis);
}
Expand Down
1 change: 1 addition & 0 deletions examples/common/opcodes/arm_2d_user_opcode_draw_circle.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ typedef struct arm_2d_user_draw_circle_descriptor_t {

arm_2d_user_draw_circle_api_params_t tParams;
arm_2d_location_t tPivot;
arm_2d_region_t tDrawRegion;

uint8_t chOpacity;
COLOUR_TYPE_T tForeground;
Expand Down

0 comments on commit 0234f43

Please sign in to comment.