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