multivis.c revision 1233
/*-
* multivis.c - Mechanism for GetImage across Multiple Visuals
*
* Original author:
* Milind M. Pansare
* Window Systems Group
* Sun Microsystems, Inc.
*
* Revision History:
* 11-15-90 Written
*/
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
#include <stdlib.h>
#ifdef SHAPE
#endif /* SHAPE */
#include "multivis.h"
static int mvScreen; /* Screen */
static int mvNumVis; /* Number of visuals in list */
#ifdef SHAPE
#endif /* SHAPE */
Sorted back to front */
into */
static int request_width,
request_height; /* size of requested rectangle */
rectangle in Root Space */
#ifdef UPDATE_HACK
static void *mvCallbackData;
static mvCallbackFunc mvCallbackFunction;
#endif /* UPDATE_HACK */
/*
* Initialise the mvLib routines ...
*/
void
#ifdef UPDATE_HACK
int screen,
int num_vis,
void *callbackData,
#else
int screen,
int num_vis)
#endif /* UPDATE_HACK */
{
#ifdef SHAPE
int tmp;
#endif /* SHAPE */
/* Initialise screen info */
#ifdef SHAPE
#endif /* SHAPE */
#ifdef UPDATE_HACK
#endif /* UPDATE_HACK */
}
/*
* Create an Img.. Cleared to zeros.
* returns 0 if failure, non-zero for success.
* Note that it is the reponsibility of the caller
* to verify that any resulting XGetImage will
* be within the bounds of the screen.
* i.e, x, y, wd, ht must be such that the rectangle
* is fully within the bounds of the screen.
*/
int
{
/* Create mvImg */
request_width = wd;
request_height = ht;
request_x = x;
request_y = y;
!= NULL) {
return 1;
}
return 0;
}
/*
* Reset the mvLib routines
*/
void
mvReset(void)
{
#ifdef SHAPE
int i;
#endif /* SHAPE */
/* Free mvImg */
if (mvImg)
/* Clean winList */
#ifdef SHAPE
while (i--) {
}
#endif /* SHAPE */
}
/* Clean colmap list */
while (colMaps) {
}
}
/*
* Recursively walk the window tree.
* Find windows that intersect the requested region.
* Create a list of such windows in global winList.
* Assumes winList was cleared beforehand.
*/
void
int x, int y, /* Top left of requested rectangle in root space */
#ifdef SHAPE
#endif /* SHAPE */
)
{
int n;
unsigned int nchild;
#ifdef SHAPE
#endif /* SHAPE */
return;
}
/* compute top-left of image in root space */
return;
}
/* We're interested ... */
}
#ifdef SHAPE
/* Is it a Shaped Window ? Help ! */
/* Empty shape, ignore it */
return;
}
while (count--) {
}
}
tmpreg = XCreateRegion();
}
if (ancestorShaped) {
/* make a local copy */
/* Translate from relative parent's origin to this window's origin */
if (isShaped) { /* Compute effective bdg shape */
}
else {
tmpreg = XCreateRegion();
}
}
#endif /* SHAPE */
/* Find children, back to front */
#ifdef SHAPE
#endif /* SHAPE */
for (n=0; n<nchild; n++) {
#ifdef SHAPE
tmpreg);
#else /* !SHAPE */
#endif /* SHAPE */
}
/* free children */
if (nchild > 0)
}
return;
}
/*
* CHANGE
* Returns 0 if no problems,
* Returns 1 if depths differ
* returns 2 if colormap or visinfo differ
* NOTE that this chenge & the previous change are reprehensible hacks,
* to let xmag work with pageview, and xcolor respectively.
* USED TO BE...
* CHANGE
* Returns 0 if no problems,
* Returns 1 if visinfo or depth differ
* returns 2 if colormap only differ
* USED TO BE...
* Returns non-zero if the winList created by mvWalkTree
* might potentially have windows of different Visuals
* else returns 0
*/
int
mvIsMultiVis(void)
{
int retcode = 0;
while (i--) {
return 1;
retcode = 2;
retcode = 2;
}
return retcode;
}
/*
* Traverse the window list front to back. Get the entire Image
* from each window, but only Label a pixel in the Img once.
* That is, once a pixel has been Labeled, any more fetches
* from the same pixel position are discarded. Once all pixels
* positions have been fetched, we're done. This will eliminate
* windows that have nothing to contibute to the requested region,
* but will nevertheless have the problem of the painters
* algorithm, where more pixels were fetched from a
* window than were essential.
* Assumes that winList has been filled beforehand, and Img was cleared.
*/
void
mvDoWindowsFrontToBack(void)
{
int i;
return;
}
/* For each pixel in the returned Image */
#ifdef UPDATE_HACK
if ((yi % 128) == 0) {
}
#endif /* UPDATE_HACK */
/* If the pixel hasn't been labelled before */
/* label the pixel in the map with this window's cmap */
/*
* If Pixel value can be discarded, this is where
* you get the RGB value instead.
* Call a routine like mvFindColorInColormap() with the pixel
* value, and Colormap as parameters.
* The 'Label', instead of pPel->colmap could be a scratch bit ?
* But if its a full 32 bit pixel, and there are no
* free bits, you need to hang in extra bits somewhere.
* Maybe a bitmask associated with Img ?
*/
#ifdef SHAPE
#ifdef XNEWS
#endif /* XNEWS */
)
) {
#endif /* SHAPE */
/* and pixel value */
#ifdef SHAPE
}
#endif /* SHAPE */
}
}
}
/* free image */
}
}
/*
* Get all the colors from this window's colormap.
* That's slightly complicated when we hit
* a true color or direct color visual.
* Assumes that a global list of colmaps is present, and
* that the Colors field was NULLed beforehand.
*/
static void
{
/* Allocate enough memory */
unsigned long i;
/* We have to create a composite pixel value */
}
}
else {
unsigned long i;
/* Fill in the pixel values by hand */
for (i = 0; i < (unsigned long)(size);) {
}
}
}
}
/*
* Given a VisualID, return a pointer to the VisualInfo structure.
* Assumes that a global mvVlist for this screen has already
* been created. Uses globals mvNumVis, and mvVlist.
* Returns NULL if the vid is not matched.
*/
static XVisualInfo *
{
return pVis;
}
pVis++;
}
return NULL;
}
/*
* Calculate a composite pixel value that indexes into all
* three primaries . Assumes Composite Calcs have been performed
* already on the colmap.
*/
static unsigned long
{
unsigned long val = 0;
return val;
}
/*
* Calculate the offsets used to composite a pixel value for
* the TrueColor & DirectColor cases
* Assumes its called only on a True or DirectColor visual.
*/
static void
{
/* Check if this has been done before */
if (!pCmp->doComposite) {
/* These are the sizes of each primary map ... */
}
}
/*
* Calculate number of 1 bits in mask
* Classic hack not written by this author.
*/
int
{
unsigned long y;
return (((y + (y >> 3)) & 030707070707) % 077);
}
/*
* Calculate the number of shifts till we hit the mask
*/
int
{
int y = 0;
if (mask) {
while(!(mask&0x1)) {
y++;
}
}
return y;
}
/*
* find & creat a colmap struct for this cmap
* Assumes that colMaps was cleared before the first time
* it is called.
*/
static MVColmap *
{
/* if we've seen this cmap before, return its struct colmap */
return pCmap;
}
/* First time for this cmap, creat & link */
return pCmap;
}
/*
* Use pixel value at x, y as an index into
* the colmap's list of Colors.
* If the pixel value were not important, this would be called
* in mvDoWindowsFrontToBack(), with the pixel value
* and colmap as parameters, to get RGB values directly.
*/
XColor *
mvFindColorInColormap(int x, int y)
{
/* Treat the pixel value as 3 separate indices, composite
the color into scratch, return a pointer to scratch */
return(&scratch);
}
else { /* This is simple */
}
}