static sraSpan* sraNextSpan(sraRectangleIterator *i) { if(sraReverse(i)) return(i->sPtrs[i->ptrPos]->_prev); else return(i->sPtrs[i->ptrPos]->_next); }
rfbBool sraRgnIteratorNext(sraRectangleIterator* i,sraRect* r) { if ((!i) || (!r)) return(0); /* is the subspan finished? */ while(sraNextSpan(i) == i->sPtrs[i->ptrPos+1]) { i->ptrPos -= 2; if(i->ptrPos < 0) /* the end */ return(0); } i->sPtrs[i->ptrPos] = sraNextSpan(i); /* is this a new subspan? */ while((i->sPtrs[i->ptrPos]) && (i->sPtrs[i->ptrPos]->subspan)) { if(i->ptrPos+2 > i->ptrSize) /* array is too small */ { i->ptrSize += DEFSTEP; i->sPtrs = (sraSpan**)MemRealloc(i->sPtrs, sizeof(sraSpan*)*i->ptrSize); } i->ptrPos =+ 2; if(sraReverse(i)) { i->sPtrs[i->ptrPos] = i->sPtrs[i->ptrPos-2]->subspan->back._prev; i->sPtrs[i->ptrPos+1] = &(i->sPtrs[i->ptrPos-2]->subspan->front); } else { i->sPtrs[i->ptrPos] = i->sPtrs[i->ptrPos-2]->subspan->front._next; i->sPtrs[i->ptrPos+1] = &(i->sPtrs[i->ptrPos-2]->subspan->back); } } if((i->ptrPos%4)!=2) { ///rfbErr("sraRgnIteratorNext: offset is wrong (%d%%4!=2)\n",i->ptrPos); return FALSE; } r->y1 = i->sPtrs[i->ptrPos-2]->start; r->y2 = i->sPtrs[i->ptrPos-2]->end; r->x1 = i->sPtrs[i->ptrPos]->start; r->x2 = i->sPtrs[i->ptrPos]->end; return(-1); }