ref: c0bcff65ed63e42976a699e01a63eecb7682fe1c
parent: e3b8f25509de4ce8991f7610db8a7938765f4170
author: Yaroslav Kolomiiets <yarikos@gmail.com>
date: Mon Sep 12 18:35:53 EDT 2016
group draw.h code together
--- a/dat.h
+++ b/dat.h
@@ -35,7 +35,6 @@
int xsz; /* rfb dimensions */
int ysz; /* rfb dimensions */
int depth; /* rfb color depth */
- ulong chan; /* remote graphics channel descriptor */
int hupreason; /* hangup reason as server explains */
int mcsuid; /* MCS [T.122] userId */
int userchan; /* MCS user channelId */
--- a/draw.c
+++ b/draw.c
@@ -15,7 +15,34 @@
int loadbmp(Image*,Rectangle,uchar*,int,uchar*);
int loadrle(Image*,Rectangle,uchar*,int,uchar*);
+static int
+depth2chan(int depth)
+{
+ int chan;
+
+ switch(depth){
+ default: sysfatal("Unsupported remote color depth: %uhd\n", depth);
+ case 8: chan = CMAP8; break;
+ case 15: chan = RGB15; break;
+ case 16: chan = RGB16; break;
+ case 24: chan = RGB24; break;
+ case 32: chan = XRGB32; break;
+ }
+ return chan;
+}
+
void
+initscreen(Rdp* c)
+{
+ if(initdraw(drawerror, nil, c->label) < 0)
+ sysfatal("initdraw: %r");
+ display->locking = 1;
+ unlockdisplay(display);
+ c->ysz = Dy(screen->r);
+ c->xsz = (Dx(screen->r) +3) & ~3;
+}
+
+void
drawimgupdate(Rdp *c, Share* s)
{
int (*getupd)(Imgupd*, uchar*, uint);
@@ -51,11 +78,13 @@
padresize(Rdp* c)
{
Rectangle rs;
+ int chan;
rs = rectaddpt(Rpt(ZP, Pt(c->xsz+4, c->ysz+4)), screen->r.min);
if(pad==nil || eqrect(pad->r, rs) == 0){
+ chan = depth2chan(c->depth);
freeimage(pad);
- pad = allocimage(display, rs, c->chan, 0, DNofill);
+ pad = allocimage(display, rs, chan, 0, DNofill);
if(pad==nil)
sysfatal("drawimgupdate: %r");
}
@@ -132,6 +161,7 @@
cacheimage2(Rdp* c, Imgupd* up)
{
int (*loadfn)(Image*,Rectangle,uchar*,int,uchar*);
+ int chan;
Image* img;
Rectangle r;
@@ -146,8 +176,9 @@
img = icache[up->cid][up->coff];
if(img==nil || eqrect(img->r, r)==0){
+ chan = depth2chan(c->depth);
freeimage(img);
- img = allocimage(display, r, c->chan, 0, DNofill);
+ img = allocimage(display, r, chan, 0, DNofill);
if(img == nil)
sysfatal("cacheimage2: %r");
icache[up->cid][up->coff] = img;
--- a/egdi.c
+++ b/egdi.c
@@ -4,7 +4,7 @@
*/
#include <u.h>
#include <libc.h>
-#include <draw.h>
+#include <draw.h> /* for geometry */
#include "dat.h"
#include "fns.h"
--- a/mkfile
+++ b/mkfile
@@ -1,4 +1,3 @@
-
</$objtype/mkfile
<$PLAN9/src/mkhdr
--- a/mouse.c
+++ b/mouse.c
@@ -1,7 +1,7 @@
#include <u.h>
#include <libc.h>
#include <draw.h>
-#include <mouse.h>
+#include <mouse.h> /* for screen->r and geometry */
#include "dat.h"
#include "fns.h"
--- a/rd-thread.c
+++ b/rd-thread.c
@@ -142,17 +142,6 @@
sysfatal("hangup");
}
-void
-initscreen(Rdp* c)
-{
- if(initdraw(drawerror, nil, c->label) < 0)
- sysfatal("initdraw: %r");
- display->locking = 1;
- unlockdisplay(display);
- c->ysz = Dy(screen->r);
- c->xsz = (Dx(screen->r) +3) & ~3;
-}
-
static void
keyboardthread(void* v)
{
--- a/rd.c
+++ b/rd.c
@@ -7,7 +7,6 @@
#include "fns.h"
Rdp conn = {
- .fd = -1,
.depth = 16,
.windom = "",
.passwd = "",
@@ -83,18 +82,6 @@
pollsnarf(c);
exits("snarf eof");
return 0;
-}
-
-void
-initscreen(Rdp* c)
-{
- if(initdraw(drawerror, nil, c->label) < 0)
- sysfatal("initdraw: %r");
- display->locking = 1;
- unlockdisplay(display);
-
- c->ysz = Dy(screen->r);
- c->xsz = Dx(screen->r);
}
static int killpid[32];
--- a/rpc.c
+++ b/rpc.c
@@ -1,6 +1,5 @@
#include <u.h>
#include <libc.h>
-#include <draw.h>
#include "dat.h"
#include "fns.h"
@@ -198,15 +197,6 @@
sysfatal("server can not Suppress Output PDU");
if(!rcaps.bitmap)
sysfatal("server concealed their Bitmap Capabilities");
-
- switch(rcaps.depth){
- default: sysfatal("Unsupported server color depth: %uhd\n", rcaps.depth);
- case 8: c->chan = CMAP8; break;
- case 15: c->chan = RGB15; break;
- case 16: c->chan = RGB16; break;
- case 24: c->chan = RGB24; break;
- case 32: c->chan = XRGB32; break;
- }
c->depth = rcaps.depth;
c->xsz = rcaps.xsz;
c->ysz = rcaps.ysz;
--- a/wsys.c
+++ b/wsys.c
@@ -1,6 +1,6 @@
#include <u.h>
#include <libc.h>
-#include <draw.h>
+#include <draw.h> /* for geometry */
#include "dat.h"
#include "fns.h"