/* droid VNC server - a vnc server for android Copyright (C) 2011 Jose Pereira This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #define OUT_T CONCAT3E(uint,OUT,_t) #define FUNCTION CONCAT2E(update_screen_,OUT) void FUNCTION(void) { int i,j; int offset=0,pixelToVirtual; OUT_T* a; OUT_T* b=0; if (method==FRAMEBUFFER) update_fb_info();//important for doubleframebuffing_* else if (method==ADB) updateADBFrame(); else if (method==GRALLOC) readfb_gralloc(); #ifndef ANDROID_FROYO else if (method==GINGERBREAD) updateScreen(); #endif a = (OUT_T*)cmpbuf; if (method==FRAMEBUFFER) b = (OUT_T*)fbmmap; else if (method==ADB) b = (OUT_T*)adbbuf; else if (method==GRALLOC) b = (OUT_T*)grallocfb; #ifndef ANDROID_FROYO else if (method==GINGERBREAD) b = (OUT_T*)gingerbuf; #endif int max_x=-1,max_y=-1, min_x=99999, min_y=99999; idle=1; if (rotation==0) { for (j = 0; j < vncscr->height; j++) { for (i = 0; i < vncscr->width; i++) { offset = j * vncscr->width; if (method==FRAMEBUFFER) pixelToVirtual = PIXEL_TO_VIRTUALPIXEL_FB(i,j); else pixelToVirtual = PIXEL_TO_VIRTUALPIXEL(i,j); if (a[i + offset]!=b[pixelToVirtual]) { a[i + offset]=b[pixelToVirtual]; if (i>max_x) max_x=i; if (imax_y) max_y=j; if (jwidth*vncscr->height*scrinfo.bits_per_pixel/CHAR_BIT); } else if (rotation==90) { for (j = 0; j < vncscr->width; j++) { for (i = 0; i < vncscr->height; i++) { offset = i * vncscr->width; if (method==FRAMEBUFFER) pixelToVirtual = PIXEL_TO_VIRTUALPIXEL_FB(i,j); else pixelToVirtual = PIXEL_TO_VIRTUALPIXEL(i,j); if (a[(vncscr->width - 1 - j + offset)] != b[pixelToVirtual]) { a[(vncscr->width - 1 - j + offset)] = b[pixelToVirtual]; if (i>max_y) max_y=i; if (iwidth-j; if (h < min_x) min_x=vncscr->width-j; if (h > max_x) max_x=vncscr->width-j; idle=0; } } } } else if (rotation==180) { for (j = 0; j < vncscr->height; j++) { for (i = 0; i < vncscr->width; i++) { offset = (vncscr->height - 1 - j) * vncscr->width; if (method==FRAMEBUFFER) pixelToVirtual = PIXEL_TO_VIRTUALPIXEL_FB(i,j); else pixelToVirtual = PIXEL_TO_VIRTUALPIXEL(i,j); if (a[((vncscr->width - 1 - i) + offset )]!=b[pixelToVirtual]) { a[((vncscr->width - 1 - i) + offset )]=b[pixelToVirtual]; if (i>max_x) max_x=i; if (iheight-j; if (h < min_y) min_y=vncscr->height-j; if (h > max_y) max_y=vncscr->height-j; idle=0; } } } } else if (rotation==270) { for (j = 0; j < vncscr->width; j++) { for (i = 0; i < vncscr->height; i++) { offset = (vncscr->height - 1 - i) * vncscr->width; if (method==FRAMEBUFFER) pixelToVirtual = PIXEL_TO_VIRTUALPIXEL_FB(i,j); else pixelToVirtual = PIXEL_TO_VIRTUALPIXEL(i,j); if(a[j + offset] != b[pixelToVirtual]) { a[j + offset] = b[pixelToVirtual]; if (i>max_y) max_y=i; if (i max_x) max_x=j; idle=0; } } } } if (!idle) { memcpy(vncbuf,a,displayInfo.width*displayInfo.height*displayInfo.bpp/CHAR_BIT); min_x--; min_x--; max_x++; max_y++; // L("Changed x(%d-%d) y(%d-%d)\n",min_x,max_x,min_y,max_y); rfbMarkRectAsModified(vncscr, min_x, min_y, max_x, max_y); } }