author | treke <treke> | 2002-09-05 04:42:25 (UTC) |
---|---|---|
committer | treke <treke> | 2002-09-05 04:42:25 (UTC) |
commit | e2186a49cb5cbdf01b56f57818a15a760ff25b2e (patch) (unidiff) | |
tree | f22e7342c7a3adcccb6eed52a314fe8e301cc624 /noncore/comm/keypebble/krfbbuffer.cpp | |
parent | fd3239820e471044bf279a2964702573572859d6 (diff) | |
download | opie-e2186a49cb5cbdf01b56f57818a15a760ff25b2e.zip opie-e2186a49cb5cbdf01b56f57818a15a760ff25b2e.tar.gz opie-e2186a49cb5cbdf01b56f57818a15a760ff25b2e.tar.bz2 |
Added support for client side scaling of the screen. Slow, but sometimes usable.
Diffstat (limited to 'noncore/comm/keypebble/krfbbuffer.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/comm/keypebble/krfbbuffer.cpp | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/noncore/comm/keypebble/krfbbuffer.cpp b/noncore/comm/keypebble/krfbbuffer.cpp index 5a52f31..f1cb929 100644 --- a/noncore/comm/keypebble/krfbbuffer.cpp +++ b/noncore/comm/keypebble/krfbbuffer.cpp | |||
@@ -1,20 +1,22 @@ | |||
1 | #include <assert.h> | 1 | #include <assert.h> |
2 | #include <qpixmap.h> | 2 | #include <qpixmap.h> |
3 | #include <qbrush.h> | 3 | #include <qbrush.h> |
4 | #include <qimage.h> | 4 | #include <qimage.h> |
5 | #include <qpainter.h> | 5 | #include <qpainter.h> |
6 | #include <qapplication.h> | 6 | #include <qapplication.h> |
7 | #include "krfbdecoder.h" | 7 | #include "krfbdecoder.h" |
8 | #include "krfbbuffer.h" | 8 | #include "krfbbuffer.h" |
9 | #include "krfbconnection.h" | ||
10 | #include "krfbserver.h" | ||
9 | #include "krfbserverinfo.h" | 11 | #include "krfbserverinfo.h" |
10 | 12 | ||
11 | // | 13 | // |
12 | // Endian stuff | 14 | // Endian stuff |
13 | // | 15 | // |
14 | #ifndef KDE_USE_FINAL | 16 | #ifndef KDE_USE_FINAL |
15 | const int endianTest = 1; | 17 | const int endianTest = 1; |
16 | #endif | 18 | #endif |
17 | 19 | ||
18 | #define Swap16IfLE(s) \ | 20 | #define Swap16IfLE(s) \ |
19 | (*(char *)&endianTest ? ((((s) & 0xff) << 8) | (((s) >> 8) & 0xff)) : (s)) | 21 | (*(char *)&endianTest ? ((((s) & 0xff) << 8) | (((s) >> 8) & 0xff)) : (s)) |
20 | 22 | ||
@@ -77,36 +79,38 @@ void KRFBBuffer::copyRect( int srcX, int srcY, | |||
77 | { | 79 | { |
78 | // qWarning( "Got copy rect" ); | 80 | // qWarning( "Got copy rect" ); |
79 | bitBlt( pix, destX, destY, pix, srcX, srcY, w, h, CopyROP ); | 81 | bitBlt( pix, destX, destY, pix, srcX, srcY, w, h, CopyROP ); |
80 | 82 | ||
81 | emit updated( destX, destY, w, h ); | 83 | emit updated( destX, destY, w, h ); |
82 | } | 84 | } |
83 | 85 | ||
84 | void KRFBBuffer::drawRawRectChunk( void *data, | 86 | void KRFBBuffer::drawRawRectChunk( void *data, |
85 | int x, int y, int w, int h ) | 87 | int x, int y, int w, int h ) |
86 | { | 88 | { |
87 | QImage img( w, h, 32 ); | 89 | QImage img( w, h, 32 ); |
88 | 90 | ||
91 | int scaleFactor=decoder->con->options()->scaleFactor; | ||
89 | int redMax = Swap16IfLE( decoder->format->redMax ); | 92 | int redMax = Swap16IfLE( decoder->format->redMax ); |
90 | int greenMax = Swap16IfLE( decoder->format->greenMax ); | 93 | int greenMax = Swap16IfLE( decoder->format->greenMax ); |
91 | int blueMax = Swap16IfLE( decoder->format->blueMax ); | 94 | int blueMax = Swap16IfLE( decoder->format->blueMax ); |
92 | 95 | ||
93 | QPainter p( pix ); | 96 | QPainter p( pix ); |
94 | 97 | ||
95 | if ( decoder->format->bpp == 8 ) { | 98 | if ( decoder->format->bpp == 8 ) { |
96 | uchar *d = (unsigned char *) data; | 99 | uchar *d = (unsigned char *) data; |
97 | 100 | ||
98 | uint r,g,b; | 101 | uint r,g,b; |
99 | 102 | ||
100 | for ( int j = 0; j < h; j++ ) { | 103 | |
104 | for ( int j = 0; j < h; j++) { | ||
101 | for ( int i = 0; i < w ; i++ ) { | 105 | for ( int i = 0; i < w ; i++ ) { |
102 | r = d[ j * w + i ]; | 106 | r = d[ j * w + i ]; |
103 | r = r >> decoder->format->redShift; | 107 | r = r >> decoder->format->redShift; |
104 | r = r & redMax; | 108 | r = r & redMax; |
105 | 109 | ||
106 | g = d[ j * w + i ]; | 110 | g = d[ j * w + i ]; |
107 | g = g >> decoder->format->greenShift; | 111 | g = g >> decoder->format->greenShift; |
108 | g = g & greenMax; | 112 | g = g & greenMax; |
109 | 113 | ||
110 | b = d[ j * w + i ]; | 114 | b = d[ j * w + i ]; |
111 | b = b >> decoder->format->blueShift; | 115 | b = b >> decoder->format->blueShift; |
112 | b = b & blueMax; | 116 | b = b & blueMax; |
@@ -178,17 +182,22 @@ void KRFBBuffer::drawRawRectChunk( void *data, | |||
178 | b = ( b * 255 ) / blueMax; | 182 | b = ( b * 255 ) / blueMax; |
179 | 183 | ||
180 | ulong *p = ( ulong * ) img.scanLine( j ) + i; | 184 | ulong *p = ( ulong * ) img.scanLine( j ) + i; |
181 | *p = qRgb( r,g,b ); | 185 | *p = qRgb( r,g,b ); |
182 | } | 186 | } |
183 | } | 187 | } |
184 | } | 188 | } |
185 | else { | 189 | else { |
186 | p.setBrush( QBrush( Qt::black ) ); | 190 | p.setBrush( QBrush( Qt::black ) ); |
187 | p.drawRect( x, y, w, h ); | 191 | p.drawRect( x, y, w, h ); |
188 | } | 192 | } |
189 | 193 | ||
190 | p.drawImage( x, y, img ); | 194 | if (scaleFactor > 1) { |
191 | 195 | p.drawImage( x/scaleFactor, y/scaleFactor, img.smoothScale(w/scaleFactor,h/scaleFactor) ); | |
192 | emit updated( x, y, w, h ); | 196 | emit updated( x/scaleFactor, y/scaleFactor, w/scaleFactor, h/scaleFactor ); |
197 | } | ||
198 | else { | ||
199 | p.drawImage( x, y, img); | ||
200 | emit updated( x, y, w, h ); | ||
201 | } | ||
193 | } | 202 | } |
194 | 203 | ||