summaryrefslogtreecommitdiffstats
path: root/unix
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2014-01-20 15:05:21 +0100
committerPierre Ossman <ossman@cendio.se>2014-07-07 14:50:11 +0200
commitb6b4dc6487690e891ec2487c6cf765d36821fe3a (patch)
tree77d2e0f49461c7ff8fc78872c9763fe9b6f67adb /unix
parentbcc295e5a60954ff39b011d6a2cbdf052a0efafc (diff)
downloadtigervnc-b6b4dc6487690e891ec2487c6cf765d36821fe3a.tar.gz
tigervnc-b6b4dc6487690e891ec2487c6cf765d36821fe3a.zip
Remove full support for colour maps
Gets rid of a loooot of code and complexity. Colour map clients are still supported through an automatically generated map, but we lose the ability to develop a client or server that uses colour maps internally.
Diffstat (limited to 'unix')
-rw-r--r--unix/x0vncserver/XPixelBuffer.cxx3
-rw-r--r--unix/x0vncserver/XPixelBuffer.h3
-rw-r--r--unix/x0vncserver/x0vncserver.cxx18
-rw-r--r--unix/xserver/hw/vnc/XserverDesktop.cc136
-rw-r--r--unix/xserver/hw/vnc/XserverDesktop.h10
-rw-r--r--unix/xserver/hw/vnc/vncExtInit.cc9
-rw-r--r--unix/xserver/hw/vnc/vncHooks.cc38
7 files changed, 36 insertions, 181 deletions
diff --git a/unix/x0vncserver/XPixelBuffer.cxx b/unix/x0vncserver/XPixelBuffer.cxx
index aa52620a..f88eda49 100644
--- a/unix/x0vncserver/XPixelBuffer.cxx
+++ b/unix/x0vncserver/XPixelBuffer.cxx
@@ -29,7 +29,7 @@
using namespace rfb;
XPixelBuffer::XPixelBuffer(Display *dpy, ImageFactory &factory,
- const Rect &rect, ColourMap* cm)
+ const Rect &rect)
: FullFramePixelBuffer(),
m_poller(0),
m_dpy(dpy),
@@ -54,7 +54,6 @@ XPixelBuffer::XPixelBuffer(Display *dpy, ImageFactory &factory,
width_ = rect.width();
height_ = rect.height();
data = (rdr::U8 *)m_image->xim->data;
- colourmap = cm;
// Calculate the distance in pixels between two subsequent scan
// lines of the framebuffer. This may differ from image width.
diff --git a/unix/x0vncserver/XPixelBuffer.h b/unix/x0vncserver/XPixelBuffer.h
index 29ae94a8..ab4f88e5 100644
--- a/unix/x0vncserver/XPixelBuffer.h
+++ b/unix/x0vncserver/XPixelBuffer.h
@@ -37,8 +37,7 @@ using namespace rfb;
class XPixelBuffer : public FullFramePixelBuffer
{
public:
- XPixelBuffer(Display *dpy, ImageFactory &factory,
- const Rect &rect, ColourMap* cm);
+ XPixelBuffer(Display *dpy, ImageFactory &factory, const Rect &rect);
virtual ~XPixelBuffer();
// Provide access to the underlying Image object.
diff --git a/unix/x0vncserver/x0vncserver.cxx b/unix/x0vncserver/x0vncserver.cxx
index 165441fe..ee39fae1 100644
--- a/unix/x0vncserver/x0vncserver.cxx
+++ b/unix/x0vncserver/x0vncserver.cxx
@@ -135,7 +135,7 @@ private:
};
-class XDesktop : public SDesktop, public ColourMap, public TXGlobalEventHandler
+class XDesktop : public SDesktop, public TXGlobalEventHandler
{
public:
XDesktop(Display* dpy_, Geometry *geometry_)
@@ -199,7 +199,7 @@ public:
ImageFactory factory((bool)useShm, (bool)useOverlay);
// Create pixel buffer and provide it to the server object.
- pb = new XPixelBuffer(dpy, factory, geometry->getRect(), this);
+ pb = new XPixelBuffer(dpy, factory, geometry->getRect());
vlog.info("Allocated %s", pb->getImage()->classDesc());
server = (VNCServerST *)vs;
@@ -269,20 +269,6 @@ public:
return Point(pb->width(), pb->height());
}
- // -=- ColourMap callbacks
- virtual void lookup(int index, int* r, int* g, int* b) {
- XColor xc;
- xc.pixel = index;
- if (index < DisplayCells(dpy,DefaultScreen(dpy))) {
- XQueryColor(dpy, DefaultColormap(dpy,DefaultScreen(dpy)), &xc);
- } else {
- xc.red = xc.green = xc.blue = 0;
- }
- *r = xc.red;
- *g = xc.green;
- *b = xc.blue;
- }
-
// -=- TXGlobalEventHandler interface
virtual bool handleGlobalEvent(XEvent* ev) {
diff --git a/unix/xserver/hw/vnc/XserverDesktop.cc b/unix/xserver/hw/vnc/XserverDesktop.cc
index b0d4601e..e53dccde 100644
--- a/unix/xserver/hw/vnc/XserverDesktop.cc
+++ b/unix/xserver/hw/vnc/XserverDesktop.cc
@@ -51,7 +51,6 @@ extern "C" {
extern char *display;
-#include "colormapst.h"
#ifdef RANDR
#include "randrstr.h"
#endif
@@ -143,14 +142,11 @@ XserverDesktop::XserverDesktop(ScreenPtr pScreen_,
: pScreen(pScreen_),
server(0), httpServer(0),
listener(listener_), httpListener(httpListener_),
- cmap(0), deferredUpdateTimerSet(false),
+ deferredUpdateTimerSet(false),
grabbing(false), ignoreHooks_(false), directFbptr(true),
queryConnectId(0)
{
format = pf;
- colourmap = this;
-
- serverReset(pScreen);
server = new VNCServerST(name, this);
setFramebuffer(pScreen->width, pScreen->height, fbptr, stride);
@@ -171,24 +167,6 @@ XserverDesktop::~XserverDesktop()
delete server;
}
-void XserverDesktop::serverReset(ScreenPtr pScreen_)
-{
- pScreen = pScreen_;
- int i;
- pointer retval;
-
-#if XORG >= 17
-#define dixLookupResource dixLookupResourceByType
-#endif
- i = dixLookupResource(&retval, pScreen->defColormap, RT_COLORMAP, NullClient,
- DixReadAccess);
-
- /* Handle suspicious conditions */
- assert(i == Success);
-
- cmap = (ColormapPtr) retval;
-}
-
void XserverDesktop::blockUpdates()
{
server->blockUpdates();
@@ -379,44 +357,6 @@ XserverDesktop::queryConnection(network::Socket* sock,
return rfb::VNCServerST::PENDING;
}
-
-void XserverDesktop::setColormap(ColormapPtr cmap_)
-{
- if (cmap != cmap_) {
- cmap = cmap_;
- setColourMapEntries(0, 0);
- }
-}
-
-void XserverDesktop::setColourMapEntries(ColormapPtr pColormap, int ndef,
- xColorItem* pdef)
-{
- if (cmap != pColormap || ndef <= 0) return;
-
- unsigned int first = pdef[0].pixel;
- unsigned int n = 1;
-
- for (int i = 1; i < ndef; i++) {
- if (first + n == pdef[i].pixel) {
- n++;
- } else {
- setColourMapEntries(first, n);
- first = pdef[i].pixel;
- n = 1;
- }
- }
- setColourMapEntries(first, n);
-}
-
-void XserverDesktop::setColourMapEntries(int firstColour, int nColours)
-{
- try {
- server->setColourMapEntries(firstColour, nColours);
- } catch (rdr::Exception& e) {
- vlog.error("XserverDesktop::setColourMapEntries: %s",e.str());
- }
-}
-
void XserverDesktop::bell()
{
server->bell();
@@ -469,7 +409,7 @@ void XserverDesktop::setCursor(CursorPtr cursor)
rgb[1] = (*in >> 8) & 0xff;
rgb[2] = (*in >> 0) & 0xff;
- getPF().bufferFromRGB(out, rgb, 1, this);
+ getPF().bufferFromRGB(out, rgb, 1);
if (((*in >> 24) & 0xff) > 127)
cursorMask[y * rfbMaskBytesPerRow + x/8] |= 0x80>>(x%8);
@@ -480,42 +420,42 @@ void XserverDesktop::setCursor(CursorPtr cursor)
}
} else {
#endif
- xColorItem fg, bg;
- fg.red = cursor->foreRed;
- fg.green = cursor->foreGreen;
- fg.blue = cursor->foreBlue;
- FakeAllocColor(cmap, &fg);
- bg.red = cursor->backRed;
- bg.green = cursor->backGreen;
- bg.blue = cursor->backBlue;
- FakeAllocColor(cmap, &bg);
- FakeFreeColor(cmap, fg.pixel);
- FakeFreeColor(cmap, bg.pixel);
+ rdr::U8 rgb[3];
+ rdr::U8 fg[4], bg[4];
+
+ rdr::U8* buffer;
+
+ rgb[0] = cursor->foreRed;
+ rgb[1] = cursor->foreGreen;
+ rgb[2] = cursor->foreBlue;
+ getPF().bufferFromRGB(fg, rgb, 1);
+
+ rgb[0] = cursor->backRed;
+ rgb[1] = cursor->backGreen;
+ rgb[2] = cursor->backBlue;
+ getPF().bufferFromRGB(bg, rgb, 1);
int xMaskBytesPerRow = BitmapBytePad(w);
+ buffer = cursorData;
+
for (int y = 0; y < h; y++) {
for (int x = 0; x < w; x++) {
+ rdr::U8 *pixel;
int byte = y * xMaskBytesPerRow + x / 8;
#if (BITMAP_BIT_ORDER == MSBFirst)
int bit = 7 - x % 8;
#else
int bit = x % 8;
#endif
- switch (getPF().bpp) {
- case 8:
- ((rdr::U8*)cursorData)[y * w + x]
- = (cursor->bits->source[byte] & (1 << bit)) ? fg.pixel : bg.pixel;
- break;
- case 16:
- ((rdr::U16*)cursorData)[y * w + x]
- = (cursor->bits->source[byte] & (1 << bit)) ? fg.pixel : bg.pixel;
- break;
- case 32:
- ((rdr::U32*)cursorData)[y * w + x]
- = (cursor->bits->source[byte] & (1 << bit)) ? fg.pixel : bg.pixel;
- break;
- }
+
+ if (cursor->bits->source[byte] & (1 << bit))
+ pixel = fg;
+ else
+ pixel = bg;
+
+ memcpy(buffer, pixel, getPF().bpp/8);
+ buffer += getPF().bpp/8;
}
}
@@ -1109,28 +1049,6 @@ int XserverDesktop::getStride() const
return stride_;
}
-void XserverDesktop::lookup(int index, int* r, int* g, int* b)
-{
- if ((cmap->c_class | DynamicClass) == DirectColor) {
- VisualPtr v = cmap->pVisual;
- *r = cmap->red [(index & v->redMask ) >> v->offsetRed ].co.local.red;
- *g = cmap->green[(index & v->greenMask) >> v->offsetGreen].co.local.green;
- *b = cmap->blue [(index & v->blueMask ) >> v->offsetBlue ].co.local.blue;
- } else {
- EntryPtr pent;
- pent = (EntryPtr)&cmap->red[index];
- if (pent->fShared) {
- *r = pent->co.shco.red->color;
- *g = pent->co.shco.green->color;
- *b = pent->co.shco.blue->color;
- } else {
- *r = pent->co.local.red;
- *g = pent->co.local.green;
- *b = pent->co.local.blue;
- }
- }
-}
-
void XserverDesktop::keyEvent(rdr::U32 keysym, bool down)
{
if (down)
diff --git a/unix/xserver/hw/vnc/XserverDesktop.h b/unix/xserver/hw/vnc/XserverDesktop.h
index fb247b04..fa03d8ab 100644
--- a/unix/xserver/hw/vnc/XserverDesktop.h
+++ b/unix/xserver/hw/vnc/XserverDesktop.h
@@ -54,7 +54,7 @@ namespace rfb {
namespace network { class TcpListener; class Socket; }
class XserverDesktop : public rfb::SDesktop, public rfb::FullFramePixelBuffer,
- public rfb::ColourMap, public rdr::Substitutor,
+ public rdr::Substitutor,
public rfb::VNCServerST::QueryConnectionHandler {
public:
@@ -65,13 +65,10 @@ public:
virtual ~XserverDesktop();
// methods called from X server code
- void serverReset(ScreenPtr pScreen);
void blockUpdates();
void unblockUpdates();
void setFramebuffer(int w, int h, void* fbptr, int stride);
void refreshScreenLayout();
- void setColormap(ColormapPtr cmap);
- void setColourMapEntries(ColormapPtr pColormap, int ndef, xColorItem* pdef);
void bell();
void serverCutText(const char* str, int len);
void setDesktopName(const char* name);
@@ -114,9 +111,6 @@ public:
virtual void grabRegion(const rfb::Region& r);
virtual int getStride() const;
- // rfb::ColourMap callbacks
- virtual void lookup(int index, int* r, int* g, int* b);
-
// rdr::Substitutor callback
virtual char* substitute(const char* varName);
@@ -126,7 +120,6 @@ public:
char** reason);
private:
- void setColourMapEntries(int firstColour, int nColours);
rfb::ScreenSet computeScreenLayout();
#ifdef RANDR
RRModePtr findRandRMode(RROutputPtr output, int width, int height);
@@ -138,7 +131,6 @@ private:
rfb::HTTPServer* httpServer;
network::TcpListener* listener;
network::TcpListener* httpListener;
- ColormapPtr cmap;
int stride_;
bool deferredUpdateTimerSet;
bool grabbing;
diff --git a/unix/xserver/hw/vnc/vncExtInit.cc b/unix/xserver/hw/vnc/vncExtInit.cc
index a9fd0e9f..732fa69b 100644
--- a/unix/xserver/hw/vnc/vncExtInit.cc
+++ b/unix/xserver/hw/vnc/vncExtInit.cc
@@ -168,8 +168,10 @@ static PixelFormat vncGetPixelFormat(ScreenPtr pScreen)
trueColour = (vis->c_class == TrueColor);
- if (!trueColour && bpp != 8)
- throw rfb::Exception("X server uses unsupported visual");
+ if (!trueColour) {
+ fprintf(stderr,"pseudocolour not supported");
+ abort();
+ }
redShift = ffs(vis->redMask) - 1;
greenShift = ffs(vis->greenMask) - 1;
@@ -266,9 +268,6 @@ void vncExtensionInit()
desktop[scr]->addClient(sock, false);
vlog.info("added inetd sock");
}
-
- } else {
- desktop[scr]->serverReset(screenInfo.screens[scr]);
}
vncHooksInit(screenInfo.screens[scr], desktop[scr]);
diff --git a/unix/xserver/hw/vnc/vncHooks.cc b/unix/xserver/hw/vnc/vncHooks.cc
index 6756da7a..94693872 100644
--- a/unix/xserver/hw/vnc/vncHooks.cc
+++ b/unix/xserver/hw/vnc/vncHooks.cc
@@ -75,8 +75,6 @@ typedef struct {
#if XORG < 110
RestoreAreasProcPtr RestoreAreas;
#endif
- InstallColormapProcPtr InstallColormap;
- StoreColorsProcPtr StoreColors;
DisplayCursorProcPtr DisplayCursor;
ScreenBlockHandlerProcPtr BlockHandler;
#ifdef RENDER
@@ -132,9 +130,6 @@ static void vncHooksClearToBackground(WindowPtr pWin, int x, int y, int w,
#if XORG < 110
static RegionPtr vncHooksRestoreAreas(WindowPtr pWin, RegionPtr prgnExposed);
#endif
-static void vncHooksInstallColormap(ColormapPtr pColormap);
-static void vncHooksStoreColors(ColormapPtr pColormap, int ndef,
- xColorItem* pdef);
static Bool vncHooksDisplayCursor(
#if XORG >= 16
DeviceIntPtr pDev,
@@ -289,8 +284,6 @@ Bool vncHooksInit(ScreenPtr pScreen, XserverDesktop* desktop)
#if XORG < 110
vncHooksScreen->RestoreAreas = pScreen->RestoreAreas;
#endif
- vncHooksScreen->InstallColormap = pScreen->InstallColormap;
- vncHooksScreen->StoreColors = pScreen->StoreColors;
vncHooksScreen->DisplayCursor = pScreen->DisplayCursor;
vncHooksScreen->BlockHandler = pScreen->BlockHandler;
#ifdef RENDER
@@ -318,8 +311,6 @@ Bool vncHooksInit(ScreenPtr pScreen, XserverDesktop* desktop)
#if XORG < 110
pScreen->RestoreAreas = vncHooksRestoreAreas;
#endif
- pScreen->InstallColormap = vncHooksInstallColormap;
- pScreen->StoreColors = vncHooksStoreColors;
pScreen->DisplayCursor = vncHooksDisplayCursor;
pScreen->BlockHandler = vncHooksBlockHandler;
#ifdef RENDER
@@ -381,8 +372,6 @@ static Bool vncHooksCloseScreen(ScreenPtr pScreen_)
#if XORG < 110
pScreen->RestoreAreas = vncHooksScreen->RestoreAreas;
#endif
- pScreen->InstallColormap = vncHooksScreen->InstallColormap;
- pScreen->StoreColors = vncHooksScreen->StoreColors;
pScreen->DisplayCursor = vncHooksScreen->DisplayCursor;
pScreen->BlockHandler = vncHooksScreen->BlockHandler;
#ifdef RENDER
@@ -512,33 +501,6 @@ static RegionPtr vncHooksRestoreAreas(WindowPtr pWin, RegionPtr pRegion)
}
#endif
-// InstallColormap - get the new colormap
-
-static void vncHooksInstallColormap(ColormapPtr pColormap)
-{
- SCREEN_UNWRAP(pColormap->pScreen, InstallColormap);
-
- (*pScreen->InstallColormap) (pColormap);
-
- vncHooksScreen->desktop->setColormap(pColormap);
-
- SCREEN_REWRAP(InstallColormap);
-}
-
-// StoreColors - get the colormap changes
-
-static void vncHooksStoreColors(ColormapPtr pColormap, int ndef,
- xColorItem* pdef)
-{
- SCREEN_UNWRAP(pColormap->pScreen, StoreColors);
-
- (*pScreen->StoreColors) (pColormap, ndef, pdef);
-
- vncHooksScreen->desktop->setColourMapEntries(pColormap, ndef, pdef);
-
- SCREEN_REWRAP(StoreColors);
-}
-
// DisplayCursor - get the cursor shape
static Bool vncHooksDisplayCursor(