summaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorJamey Sharp <jamey@minilop.net>2010-04-26 18:09:23 -0700
committerJamey Sharp <jamey@minilop.net>2010-04-27 10:14:21 -0700
commit20e84b0b44e8b3b40a3ecab5b2e64a27de247b16 (patch)
treea0bee24ff74e8e3459fc737eee06efabf339e86c /hw
parenteeb84547556b943af2acff207e034823205c7dfe (diff)
Xvfb: Simplify screen option processing.
Inspired by Jon Turney's "Xwin: Simplify screen option processing" patch, which does something similar for the Xwin server. Besides making the code more readable, this eliminates most of Xvfb's references to MAXSCREENS. Signed-off-by: Jamey Sharp <jamey@minilop.net> Reviewed-by: Tiago Vignatti <tiago.vignatti@nokia.com>
Diffstat (limited to 'hw')
-rw-r--r--hw/vfb/InitOutput.c91
1 files changed, 27 insertions, 64 deletions
diff --git a/hw/vfb/InitOutput.c b/hw/vfb/InitOutput.c
index 6d827eb1a..f71082854 100644
--- a/hw/vfb/InitOutput.c
+++ b/hw/vfb/InitOutput.c
@@ -105,6 +105,14 @@ typedef struct
static int vfbNumScreens;
static vfbScreenInfo vfbScreens[MAXSCREENS];
+static vfbScreenInfo defaultScreenInfo = {
+ .width = VFB_DEFAULT_WIDTH,
+ .height = VFB_DEFAULT_HEIGHT,
+ .depth = VFB_DEFAULT_DEPTH,
+ .blackPixel = VFB_DEFAULT_BLACKPIXEL,
+ .whitePixel = VFB_DEFAULT_WHITEPIXEL,
+ .lineBias = VFB_DEFAULT_LINEBIAS,
+};
static Bool vfbPixmapDepths[33];
#ifdef HAS_MMAP
static char *pfbdir = NULL;
@@ -112,7 +120,6 @@ static char *pfbdir = NULL;
typedef enum { NORMAL_MEMORY_FB, SHARED_MEMORY_FB, MMAPPED_FILE_FB } fbMemType;
static fbMemType fbmemtype = NORMAL_MEMORY_FB;
static char needswap = 0;
-static int lastScreen = -1;
static Bool Render = TRUE;
#define swapcopy16(_dst, _src) \
@@ -133,24 +140,6 @@ vfbInitializePixmapDepths(void)
vfbPixmapDepths[i] = FALSE;
}
-static void
-vfbInitializeDefaultScreens(void)
-{
- int i;
-
- for (i = 0; i < MAXSCREENS; i++)
- {
- vfbScreens[i].width = VFB_DEFAULT_WIDTH;
- vfbScreens[i].height = VFB_DEFAULT_HEIGHT;
- vfbScreens[i].depth = VFB_DEFAULT_DEPTH;
- vfbScreens[i].blackPixel = VFB_DEFAULT_BLACKPIXEL;
- vfbScreens[i].whitePixel = VFB_DEFAULT_WHITEPIXEL;
- vfbScreens[i].lineBias = VFB_DEFAULT_LINEBIAS;
- vfbScreens[i].pfbMemory = NULL;
- }
- vfbNumScreens = 1;
-}
-
static int
vfbBitsPerPixel(int depth)
{
@@ -265,14 +254,20 @@ int
ddxProcessArgument(int argc, char *argv[], int i)
{
static Bool firstTime = TRUE;
+ static int lastScreen = -1;
+ vfbScreenInfo *currentScreen;
if (firstTime)
{
- vfbInitializeDefaultScreens();
vfbInitializePixmapDepths();
firstTime = FALSE;
}
+ if (lastScreen == -1)
+ currentScreen = &defaultScreenInfo;
+ else
+ currentScreen = &vfbScreens[lastScreen];
+
#define CHECK_FOR_REQUIRED_ARGUMENTS(num) \
if (((i + num) >= argc) || (!argv[i + num])) { \
ErrorF("Required argument to %s not specified\n", argv[i]); \
@@ -292,6 +287,10 @@ ddxProcessArgument(int argc, char *argv[], int i)
FatalError("Invalid screen number %d passed to -screen\n",
screenNum);
}
+
+ for (; vfbNumScreens <= screenNum; ++vfbNumScreens)
+ vfbScreens[vfbNumScreens] = defaultScreenInfo;
+
if (3 != sscanf(argv[i+2], "%dx%dx%d",
&vfbScreens[screenNum].width,
&vfbScreens[screenNum].height,
@@ -303,8 +302,6 @@ ddxProcessArgument(int argc, char *argv[], int i)
argv[i+2], screenNum);
}
- if (screenNum >= vfbNumScreens)
- vfbNumScreens = screenNum + 1;
lastScreen = screenNum;
return 3;
}
@@ -346,61 +343,22 @@ ddxProcessArgument(int argc, char *argv[], int i)
if (strcmp (argv[i], "-blackpixel") == 0) /* -blackpixel n */
{
- Pixel pix;
CHECK_FOR_REQUIRED_ARGUMENTS(1);
- pix = atoi(argv[++i]);
- if (-1 == lastScreen)
- {
- int i;
- for (i = 0; i < MAXSCREENS; i++)
- {
- vfbScreens[i].blackPixel = pix;
- }
- }
- else
- {
- vfbScreens[lastScreen].blackPixel = pix;
- }
+ currentScreen->blackPixel = atoi(argv[++i]);
return 2;
}
if (strcmp (argv[i], "-whitepixel") == 0) /* -whitepixel n */
{
- Pixel pix;
CHECK_FOR_REQUIRED_ARGUMENTS(1);
- pix = atoi(argv[++i]);
- if (-1 == lastScreen)
- {
- int i;
- for (i = 0; i < MAXSCREENS; i++)
- {
- vfbScreens[i].whitePixel = pix;
- }
- }
- else
- {
- vfbScreens[lastScreen].whitePixel = pix;
- }
+ currentScreen->whitePixel = atoi(argv[++i]);
return 2;
}
if (strcmp (argv[i], "-linebias") == 0) /* -linebias n */
{
- unsigned int linebias;
CHECK_FOR_REQUIRED_ARGUMENTS(1);
- linebias = atoi(argv[++i]);
- if (-1 == lastScreen)
- {
- int i;
- for (i = 0; i < MAXSCREENS; i++)
- {
- vfbScreens[i].lineBias = linebias;
- }
- }
- else
- {
- vfbScreens[lastScreen].lineBias = linebias;
- }
+ currentScreen->lineBias = atoi(argv[++i]);
return 2;
}
@@ -993,6 +951,11 @@ InitOutput(ScreenInfo *screenInfo, int argc, char **argv)
/* initialize screens */
+ if (vfbNumScreens < 1)
+ {
+ vfbScreens[0] = defaultScreenInfo;
+ vfbNumScreens = 1;
+ }
for (i = 0; i < vfbNumScreens; i++)
{
if (-1 == AddScreen(vfbScreenInit, argc, argv))