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.
diff --git a/common/rfb/PixelTransformer.cxx b/common/rfb/PixelTransformer.cxx
index cedf900..73ec349 100644
--- a/common/rfb/PixelTransformer.cxx
+++ b/common/rfb/PixelTransformer.cxx
@@ -22,10 +22,7 @@
#include <string.h>
#include <rfb/PixelFormat.h>
#include <rfb/Exception.h>
-#include <rfb/ColourMap.h>
-#include <rfb/TrueColourMap.h>
#include <rfb/PixelBuffer.h>
-#include <rfb/ColourCube.h>
#include <rfb/PixelTransformer.h>
using namespace rfb;
@@ -100,50 +97,23 @@
{ transRGB16to8, transRGB16to16, transRGB16to32 },
{ transRGB32to8, transRGB32to16, transRGB32to32 }
};
-static transFnType transRGBCubeFns[][3] = {
- { transRGBCube16to8, transRGBCube16to16, transRGBCube16to32 },
- { transRGBCube32to8, transRGBCube32to16, transRGBCube32to32 }
-};
// Table initialisation functions.
-typedef void (*initCMtoTCFnType)(rdr::U8** tablep, const PixelFormat& inPF,
- ColourMap* cm, const PixelFormat& outPF);
-typedef void (*initTCtoTCFnType)(rdr::U8** tablep, const PixelFormat& inPF,
- const PixelFormat& outPF);
-typedef void (*initCMtoCubeFnType)(rdr::U8** tablep, const PixelFormat& inPF,
- ColourMap* cm, ColourCube* cube);
-typedef void (*initTCtoCubeFnType)(rdr::U8** tablep, const PixelFormat& inPF,
- ColourCube* cube);
+typedef void (*initFnType)(rdr::U8** tablep, const PixelFormat& inPF,
+ const PixelFormat& outPF);
-
-static initCMtoTCFnType initSimpleCMtoTCFns[] = {
- initSimpleCMtoTC8, initSimpleCMtoTC16, initSimpleCMtoTC32
+static initFnType initSimpleFns[] = {
+ initSimple8, initSimple16, initSimple32
};
-static initTCtoTCFnType initSimpleTCtoTCFns[] = {
- initSimpleTCtoTC8, initSimpleTCtoTC16, initSimpleTCtoTC32
-};
-
-static initCMtoCubeFnType initSimpleCMtoCubeFns[] = {
- initSimpleCMtoCube8, initSimpleCMtoCube16, initSimpleCMtoCube32
-};
-
-static initTCtoCubeFnType initSimpleTCtoCubeFns[] = {
- initSimpleTCtoCube8, initSimpleTCtoCube16, initSimpleTCtoCube32
-};
-
-static initTCtoTCFnType initRGBTCtoTCFns[] = {
- initRGBTCtoTC8, initRGBTCtoTC16, initRGBTCtoTC32
-};
-
-static initTCtoCubeFnType initRGBTCtoCubeFns[] = {
- initRGBTCtoCube8, initRGBTCtoCube16, initRGBTCtoCube32
+static initFnType initRGBFns[] = {
+ initRGB8, initRGB16, initRGB32
};
PixelTransformer::PixelTransformer(bool econ)
- : economic(econ), cmCallback(0), cube(0), table(0), transFn(0)
+ : economic(econ), table(0), transFn(0)
{
}
@@ -152,17 +122,11 @@
delete [] table;
}
-void PixelTransformer::init(const PixelFormat& inPF_, ColourMap* inCM_,
- const PixelFormat& outPF_, ColourCube* cube_,
- setCMFnType cmCallback_, void *cbData_)
+void PixelTransformer::init(const PixelFormat& inPF_,
+ const PixelFormat& outPF_)
{
inPF = inPF_;
- inCM = inCM_;
-
outPF = outPF_;
- cube = cube_;
- cmCallback = cmCallback_;
- cbData = cbData_;
if (table)
delete [] table;
@@ -175,79 +139,17 @@
if ((outPF.bpp != 8) && (outPF.bpp != 16) && (outPF.bpp != 32))
throw Exception("PixelTransformer: bpp out not 8, 16 or 32");
- if (!outPF.trueColour) {
- if (outPF.bpp != 8)
- throw Exception("PixelTransformer: outPF has color map but not 8bpp");
-
- if (!inPF.trueColour) {
- if (inPF.bpp != 8)
- throw Exception("PixelTransformer: inPF has colorMap but not 8bpp");
- if (!inCM)
- throw Exception("PixelTransformer: inPF has colorMap but no colour map specified");
-
- // CM to CM/Cube
-
- if (cube) {
- transFn = transSimpleFns[0][0];
- (*initSimpleCMtoCubeFns[0]) (&table, inPF, inCM, cube);
- } else {
- transFn = noTransFn;
- setColourMapEntries(0, 256);
- }
- return;
- }
-
- // TC to CM/Cube
-
- ColourCube defaultCube(6,6,6);
- if (!cube) cube = &defaultCube;
-
- if ((inPF.bpp > 16) || (economic && (inPF.bpp == 16))) {
- transFn = transRGBCubeFns[inPF.bpp/32][0];
- (*initRGBTCtoCubeFns[0]) (&table, inPF, cube);
- } else {
- transFn = transSimpleFns[inPF.bpp/16][0];
- (*initSimpleTCtoCubeFns[0]) (&table, inPF, cube);
- }
-
- if (cube != &defaultCube)
- return;
-
- if (!cmCallback)
- throw Exception("PixelTransformer: Neither colour map callback nor colour cube provided");
-
- cmCallback(0, 216, cube, cbData);
- cube = 0;
- return;
- }
-
if (inPF.equal(outPF)) {
transFn = noTransFn;
return;
}
- if (!inPF.trueColour) {
-
- // CM to TC
-
- if (inPF.bpp != 8)
- throw Exception("PixelTransformer: inPF has colorMap but not 8bpp");
- if (!inCM)
- throw Exception("PixelTransformer: inPF has colorMap but no colour map specified");
-
- transFn = transSimpleFns[0][outPF.bpp/16];
- (*initSimpleCMtoTCFns[outPF.bpp/16]) (&table, inPF, inCM, outPF);
- return;
- }
-
- // TC to TC
-
if ((inPF.bpp > 16) || (economic && (inPF.bpp == 16))) {
transFn = transRGBFns[inPF.bpp/32][outPF.bpp/16];
- (*initRGBTCtoTCFns[outPF.bpp/16]) (&table, inPF, outPF);
+ (*initRGBFns[outPF.bpp/16]) (&table, inPF, outPF);
} else {
transFn = transSimpleFns[inPF.bpp/16][outPF.bpp/16];
- (*initSimpleTCtoTCFns[outPF.bpp/16]) (&table, inPF, outPF);
+ (*initSimpleFns[outPF.bpp/16]) (&table, inPF, outPF);
}
}
@@ -256,39 +158,11 @@
return inPF;
}
-const ColourMap *PixelTransformer::getInColourMap() const
-{
- return inCM;
-}
-
const PixelFormat &PixelTransformer::getOutPF() const
{
return outPF;
}
-const ColourCube *PixelTransformer::getOutColourCube() const
-{
- return cube;
-}
-
-void PixelTransformer::setColourMapEntries(int firstCol, int nCols)
-{
- if (nCols == 0)
- nCols = (1 << inPF.depth) - firstCol;
-
- if (inPF.trueColour) return; // shouldn't be called in this case
-
- if (outPF.trueColour) {
- (*initSimpleCMtoTCFns[outPF.bpp/16]) (&table, inPF, inCM, outPF);
- } else if (cube) {
- (*initSimpleCMtoCubeFns[outPF.bpp/16]) (&table, inPF, inCM, cube);
- } else {
- if (!cmCallback)
- throw Exception("PixelTransformer: Neither colour map callback nor colour cube provided");
- cmCallback(firstCol, nCols, inCM, cbData);
- }
-}
-
void PixelTransformer::translatePixels(const void* inPtr, void* outPtr,
int nPixels) const
{