rotatetemplate.c

Go to the documentation of this file.
00001 void FUNCTIONNAME
00002              (rfbScreenInfoPtr rfbScreen, 
00003               unsigned short int* fbbuf,
00004               unsigned short int* cmpbuf) {
00005   
00006   unsigned short int
00007      *comparePointer = cmpbuf,
00008      *sourcePointer  = fbbuf, 
00009      *targetPointer  = (unsigned short int *) rfbScreen -> frameBuffer,
00010 /*
00011  * The main program has already adjusted/rotated the dimension of the
00012  * remote buffer if SWAP is defined. We have to swap x/y again to reflect the HW
00013  * screen dimensions
00014  */     
00015 #ifdef SWAP      
00016       x = rfbScreen -> height,
00017       y = rfbScreen -> width,
00018 #else
00019       x = rfbScreen -> width,   
00020       y = rfbScreen -> height,
00021 #endif 
00022       nCounterX = 0,
00023       nCounterY = 0;
00024   
00025   unsigned long int 
00026       changedPixels = 0;
00027       
00028   sraRect
00029       modifiedRegion;
00030 
00031   modifiedRegion.x1 = (rfbScreen -> width)  +1;
00032   modifiedRegion.y1 = (rfbScreen -> height) +1;  
00033   modifiedRegion.x2 =  -1;
00034   modifiedRegion.y2 =  -1;
00035   
00036 #define PIXELPOSITION nCounterX + nCounterY * x
00037   for (nCounterY = 0; nCounterY < y; nCounterY++) {   
00038     for (nCounterX = 0; nCounterX < x; nCounterX++) {
00039       if (comparePointer[PIXELPOSITION] != sourcePointer[PIXELPOSITION]) {  // only update changed pixels
00040         comparePointer[PIXELPOSITION] 
00041             = sourcePointer[PIXELPOSITION];     // update comparebuffer
00042         
00043         targetPointer[FUNCTION(nCounterX,nCounterY)] 
00044             = comparePointer[PIXELPOSITION];    // update remote framebuffer
00045         
00046         // extend the changed region to cover this pixel (if necessary)
00047         if ((FUNCTIONX) < modifiedRegion.x1) modifiedRegion.x1 = FUNCTIONX;
00048         if ((FUNCTIONX) > modifiedRegion.x2) modifiedRegion.x2 = FUNCTIONX;
00049         if ((FUNCTIONY) < modifiedRegion.y1) modifiedRegion.y1 = FUNCTIONY;
00050         if ((FUNCTIONY) > modifiedRegion.y2) modifiedRegion.y2 = FUNCTIONY;
00051         changedPixels++;        
00052       }; // end of [*cmpbuf != ...]
00053     }; // end of [for]       
00054   }; // end of [for]   
00055 #undef PIXELPOSITION
00056 
00057   if (changedPixels > 0) 
00058     rfbMarkRectAsModified(rfbScreen,
00059                           modifiedRegion.x1-1,
00060                           modifiedRegion.y1-1,
00061                           modifiedRegion.x2+1,
00062                           modifiedRegion.y2+1);
00063 }; // end of [FUNCTIONNAME]