~ubuntu-branches/debian/lenny/italc/lenny

« back to all changes in this revision

Viewing changes to ica/x11/libvncserver/draw.c

  • Committer: Bazaar Package Importer
  • Author(s): Patrick Winnertz
  • Date: 2008-06-17 13:46:54 UTC
  • mfrom: (1.2.1 upstream) (4.1.1 gutsy)
  • Revision ID: james.westby@ubuntu.com-20080617134654-cl0gi4u524cv1ici
Tags: 1:1.0.9~rc3-1
* Package new upstream version
  - upstream ported the code to qt4.4 (Closes: #481974)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <rfb/rfb.h>
 
2
 
 
3
void rfbFillRect(rfbScreenInfoPtr s,int x1,int y1,int x2,int y2,rfbPixel col)
 
4
{
 
5
  int rowstride = s->paddedWidthInBytes, bpp = s->bitsPerPixel>>3;
 
6
  int i,j;
 
7
  char* colour=(char*)&col;
 
8
 
 
9
   if(!rfbEndianTest)
 
10
    colour += 4-bpp;
 
11
  for(j=y1;j<y2;j++)
 
12
    for(i=x1;i<x2;i++)
 
13
      memcpy(s->frameBuffer+j*rowstride+i*bpp,colour,bpp);
 
14
  rfbMarkRectAsModified(s,x1,y1,x2,y2);
 
15
}
 
16
 
 
17
#define SETPIXEL(x,y) \
 
18
  memcpy(s->frameBuffer+(y)*rowstride+(x)*bpp,colour,bpp)
 
19
 
 
20
void rfbDrawPixel(rfbScreenInfoPtr s,int x,int y,rfbPixel col)
 
21
{
 
22
  int rowstride = s->paddedWidthInBytes, bpp = s->bitsPerPixel>>3;
 
23
  char* colour=(char*)&col;
 
24
 
 
25
  if(!rfbEndianTest)
 
26
    colour += 4-bpp;
 
27
  SETPIXEL(x,y);
 
28
  rfbMarkRectAsModified(s,x,y,x+1,y+1);
 
29
}
 
30
 
 
31
void rfbDrawLine(rfbScreenInfoPtr s,int x1,int y1,int x2,int y2,rfbPixel col)
 
32
{
 
33
  int rowstride = s->paddedWidthInBytes, bpp = s->bitsPerPixel>>3;
 
34
  int i;
 
35
  char* colour=(char*)&col;
 
36
 
 
37
  if(!rfbEndianTest)
 
38
    colour += 4-bpp;
 
39
 
 
40
#define SWAPPOINTS { i=x1; x1=x2; x2=i; i=y1; y1=y2; y2=i; }
 
41
  if(abs(x1-x2)<abs(y1-y2)) {
 
42
    if(y1>y2)
 
43
      SWAPPOINTS
 
44
    for(i=y1;i<=y2;i++)
 
45
      SETPIXEL(x1+(i-y1)*(x2-x1)/(y2-y1),i);
 
46
    /* TODO: Maybe make this more intelligently? */
 
47
    if(x2<x1) { i=x1; x1=x2; x2=i; }
 
48
    rfbMarkRectAsModified(s,x1,y1,x2+1,y2+1);
 
49
  } else {
 
50
    if(x1>x2)
 
51
      SWAPPOINTS
 
52
    else if(x1==x2) {
 
53
      rfbDrawPixel(s,x1,y1,col);
 
54
      return;
 
55
    }
 
56
    for(i=x1;i<=x2;i++)
 
57
      SETPIXEL(i,y1+(i-x1)*(y2-y1)/(x2-x1));
 
58
    if(y2<y1) { i=y1; y1=y2; y2=i; }
 
59
    rfbMarkRectAsModified(s,x1,y1,x2+1,y2+1);
 
60
  }
 
61
}