diff options
author | Pierre Ossman <ossman@cendio.se> | 2014-07-14 16:15:16 +0200 |
---|---|---|
committer | Pierre Ossman <ossman@cendio.se> | 2014-07-14 16:15:16 +0200 |
commit | ff7a923a61154b04d8202039651a66db195affa1 (patch) | |
tree | d9b3db2ac42beb09fe831e14317ac9689a68ae73 /unix | |
parent | 15bb3b07d86f073857bbeeadb9b1cb1a6db066e3 (diff) | |
parent | 2e5a10608394186fd1324c97b17d7f08e0c0aaf6 (diff) | |
download | tigervnc-ff7a923a61154b04d8202039651a66db195affa1.tar.gz tigervnc-ff7a923a61154b04d8202039651a66db195affa1.zip |
Merge branch 'nocolourmap' of https://github.com/CendioOssman/tigervnc
Diffstat (limited to 'unix')
-rw-r--r-- | unix/x0vncserver/XPixelBuffer.cxx | 8 | ||||
-rw-r--r-- | unix/x0vncserver/XPixelBuffer.h | 9 | ||||
-rw-r--r-- | unix/x0vncserver/x0vncserver.cxx | 18 | ||||
-rw-r--r-- | unix/xserver/hw/vnc/XserverDesktop.cc | 147 | ||||
-rw-r--r-- | unix/xserver/hw/vnc/XserverDesktop.h | 12 | ||||
-rw-r--r-- | unix/xserver/hw/vnc/vncExtInit.cc | 9 | ||||
-rw-r--r-- | unix/xserver/hw/vnc/vncHooks.cc | 38 |
7 files changed, 41 insertions, 200 deletions
diff --git a/unix/x0vncserver/XPixelBuffer.cxx b/unix/x0vncserver/XPixelBuffer.cxx index aa52620a..f4641825 100644 --- a/unix/x0vncserver/XPixelBuffer.cxx +++ b/unix/x0vncserver/XPixelBuffer.cxx @@ -29,14 +29,13 @@ using namespace rfb; XPixelBuffer::XPixelBuffer(Display *dpy, ImageFactory &factory, - const Rect &rect, ColourMap* cm) + const Rect &rect) : FullFramePixelBuffer(), m_poller(0), m_dpy(dpy), m_image(factory.newImage(dpy, rect.width(), rect.height())), m_offsetLeft(rect.tl.x), - m_offsetTop(rect.tl.y), - m_stride(0) + m_offsetTop(rect.tl.y) { // Fill in the PixelFormat structure of the parent class. format = PixelFormat(m_image->xim->bits_per_pixel, @@ -54,11 +53,10 @@ 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. - m_stride = m_image->xim->bytes_per_line * 8 / m_image->xim->bits_per_pixel; + stride = m_image->xim->bytes_per_line * 8 / m_image->xim->bits_per_pixel; // Get initial screen image from the X display. m_image->get(DefaultRootWindow(m_dpy), m_offsetLeft, m_offsetTop); diff --git a/unix/x0vncserver/XPixelBuffer.h b/unix/x0vncserver/XPixelBuffer.h index 29ae94a8..da031615 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. @@ -47,9 +46,6 @@ public: // Detect changed pixels, notify the server. inline void poll(VNCServer *server) { m_poller->poll(server); } - // Override PixelBuffer::getStride(). - virtual int getStride() const { return m_stride; } - // Override PixelBuffer::grabRegion(). virtual void grabRegion(const rfb::Region& region); @@ -61,9 +57,6 @@ protected: int m_offsetLeft; int m_offsetTop; - // The number of pixels in a row, with padding included. - int m_stride; - // Copy pixels from the screen to the pixel buffer, // for the specified rectangular area of the buffer. inline void grabRect(const Rect &r) { 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 8f426cce..e5cc3dc1 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); @@ -168,24 +164,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(); @@ -196,7 +174,7 @@ void XserverDesktop::unblockUpdates() server->unblockUpdates(); } -void XserverDesktop::setFramebuffer(int w, int h, void* fbptr, int stride) +void XserverDesktop::setFramebuffer(int w, int h, void* fbptr, int stride_) { ScreenSet layout; @@ -210,12 +188,12 @@ void XserverDesktop::setFramebuffer(int w, int h, void* fbptr, int stride) if (!fbptr) { fbptr = new rdr::U8[w * h * (format.bpp/8)]; - stride = w; + stride_ = w; directFbptr = false; } data = (rdr::U8*)fbptr; - stride_ = stride; + stride = stride_; layout = computeScreenLayout(); @@ -376,44 +354,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(); @@ -466,7 +406,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); @@ -477,42 +417,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; } } @@ -1105,33 +1045,6 @@ void XserverDesktop::grabRegion(const rfb::Region& region) grabbing = false; } -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 20c89dc5..5b4c2300 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); @@ -112,10 +109,6 @@ public: // rfb::PixelBuffer callbacks 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 +119,6 @@ public: char** reason); private: - void setColourMapEntries(int firstColour, int nColours); rfb::ScreenSet computeScreenLayout(); #ifdef RANDR RRModePtr findRandRMode(RROutputPtr output, int width, int height); @@ -137,8 +129,6 @@ private: rfb::HTTPServer* httpServer; network::TcpListener* listener; network::TcpListener* httpListener; - ColormapPtr cmap; - int stride_; bool deferredUpdateTimerSet; bool grabbing; bool ignoreHooks_; 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( |