diff options
author | Vito Caputo <vcaputo@pengaru.com> | 2020-07-10 18:24:18 -0700 |
---|---|---|
committer | Vito Caputo <vcaputo@pengaru.com> | 2020-07-11 13:36:42 -0700 |
commit | dd3121a4d724ab91c0562657eb7e8f811dd796c5 (patch) | |
tree | 68e00b5069b737184864ac633c8ac74f79d1a9a9 /recordmydesktop/src | |
parent | c611da821a5d28063ffe79c26d27ae89e1784ba0 (diff) |
rectinsert: stop aligning rects on insert here
Assume rects that come in for insertion are already as aligned as
possible within the rrect bounds. If the rrect has odd dimensions,
then there's potential for edge case odd rects too - but the only
even-sensitive code is the YUV updating and that's been amended to
at least ignore those edge cases gracefully.
Also constify the supplied xrect while in here.
Diffstat (limited to 'recordmydesktop/src')
-rw-r--r-- | recordmydesktop/src/rmd_rectinsert.c | 56 | ||||
-rw-r--r-- | recordmydesktop/src/rmd_rectinsert.h | 2 |
2 files changed, 21 insertions, 37 deletions
diff --git a/recordmydesktop/src/rmd_rectinsert.c b/recordmydesktop/src/rmd_rectinsert.c index 1352047..2d2fd8c 100644 --- a/recordmydesktop/src/rmd_rectinsert.c +++ b/recordmydesktop/src/rmd_rectinsert.c @@ -277,49 +277,33 @@ static int rmdCollideRects( const XRectangle *xrect1, } } -int rmdRectInsert(RectArea **root,XRectangle *xrect) { +int rmdRectInsert(RectArea **root, const XRectangle *xrect) { - int total_insertions=0; - RectArea *temp=NULL,*newnode=(RectArea *)malloc(sizeof(RectArea)); - //align - //we do need to know boundaries - xrect->width+=(xrect->width%2)|(xrect->x%2); - xrect->height+=(xrect->height%2)|(xrect->y%2); - xrect->width+=(xrect->width%2); - xrect->height+=(xrect->height%2); - xrect->x-=xrect->x%2; - xrect->y-=xrect->y%2; -// fprintf(stderr," %d %d %d %d\n",xrect->x, + int total_insertions = 0; + RectArea *temp = NULL, *newnode = (RectArea *)malloc(sizeof(RectArea)); - newnode->rect.x=xrect->x; - newnode->rect.y=xrect->y; - newnode->rect.width=xrect->width; - newnode->rect.height=xrect->height; - newnode->prev=newnode->next=NULL; - if (*root==NULL) { - *root=newnode; - total_insertions=1; + newnode->rect.x = xrect->x; + newnode->rect.y = xrect->y; + newnode->rect.width = xrect->width; + newnode->rect.height = xrect->height; + newnode->prev = newnode->next = NULL; + + if (*root == NULL) { + *root = newnode; + total_insertions = 1; } else { - XRectangle xrect_return[2]; + XRectangle xrect_return[2]; + int nrects = 0, insert_ok = 1, i = 0; + + temp = *root; + + while (insert_ok) { //if something is broken list does not procceed + //(except on -1 collres case) - int nrects=0,insert_ok=1,i=0; - temp=*root; - while (insert_ok) { //if something is broken list does not procceed - //(except on -1 collres case) int collres = rmdCollideRects(&temp->rect, xrect, &xrect_return[0], &nrects); if ((!collres)) - insert_ok=1; + insert_ok = 1; else { - for(i=0;i<nrects;i++) { - xrect_return[i].width += (xrect_return[i].width % 2) | - (xrect_return[i].x % 2); - xrect_return[i].height += (xrect_return[i].height % 2) | - (xrect_return[i].y % 2); - xrect_return[i].width += (xrect_return[i].width % 2); - xrect_return[i].height += (xrect_return[i].height % 2); - xrect_return[i].x -= xrect_return[i].x % 2; - xrect_return[i].y -= xrect_return[i].y % 2; - } insert_ok=0; switch (collres) { case 1://remove current node,reinsert new one diff --git a/recordmydesktop/src/rmd_rectinsert.h b/recordmydesktop/src/rmd_rectinsert.h index 1f8b2c8..d9d0a9c 100644 --- a/recordmydesktop/src/rmd_rectinsert.h +++ b/recordmydesktop/src/rmd_rectinsert.h @@ -43,7 +43,7 @@ * \note This function is reentrant and recursive. The number * of insertions takes this into account. */ -int rmdRectInsert(RectArea **root, XRectangle *xrect); +int rmdRectInsert(RectArea **root, const XRectangle *xrect); /** * Clean up a list of areas marked for update. |