From dd3121a4d724ab91c0562657eb7e8f811dd796c5 Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Fri, 10 Jul 2020 18:24:18 -0700 Subject: 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. --- recordmydesktop/src/rmd_rectinsert.c | 56 +++++++++++++----------------------- 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