rtn_grab.c revision 830
/* Copyright 1998 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. * 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, and/or sell copies of the Software, and to permit persons * to whom the Software is furnished to do so, provided that the above * copyright notice(s) and this permission notice appear in all copies of * the Software and that both the above copyright notice(s) and this * permission notice appear in supporting documentation. * 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 * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * Except as contained in this notice, the name of a copyright holder * shall not be used in advertising or otherwise to promote the sale, use * or other dealings in this Software without prior written authorization * of the copyright holder. * @@@@ @@@@@ @ @ @@@@ @@@@ @@@ @@@@ * @ @ @ @@ @ @ @ @ @ @ @ @ * @@@@ @ @ @ @ @ @@@ @@@@ @@@@@ @@@@ * @ @ @ @ @@ @ @ @ @ @ @ @ @ * @ @ @ @ @ @@@@@ @@@@ @ @ @ @ @@@@ * DGA shared retained window access routines * dga_rtn_active(clientp) * dga_rtn_cached(clientp) * dga_rtn_devinfo(clientp) * dga_rtn_devtype(clientp, type, name) * dga_rtn_dimensions(clientp, width, height, linebytes) * dga_rtn_pixels(clientp) * dga_rtn_ungrab(clientp) * _dga_rtn_unmap(clientp) * DGA Retained Windows Active. This function is called to determine * if DGA to the retained portion of the specified dga_window is currently * active. Since the server can drop support for this functionality at * any time, the client should always call this function when a change has * been has been recorded in the retained window information. This function * should be called prior to accessing any other retained window information. * The function returns a non-zero result if DGA to the retained portion * of the window is active. A zero result is returned if support has * Inputs: Dga_window - Pointer to the client structure. * Outputs: 0 - DGA Retained window support has been dropped. * -1 - DGA Retained window support continues. * DGA Retained HW Cache status. This function returns a non-zero * value if the retained raster is cached in hardware. If set to * DGA_RTN_NEW_DEV then the server has re-cached the retained * raster from one device to another. If set to DGA_RTN_SAME_DEV * the raster remains cached in the same device as previously * recorded. If the retained raster is not cached in hw then the * function returns DGA_RTN_NOT_CACHED (0). * Inputs: Dga_window - Pointer to the client structure. * Outputs: DGA_RTN_NOT_CACHED - not cached in hw * DGA_RTN_SAME_DEV - cached in the same hw device * DGA_RTN_NEW_DEV - cached in the new hw device * Externals: RTN_INFOP() Internal MACRO * dga_rtn_devinfop() <---external interface just to be consistent * DGA Retained Device Info. This function returns a pointer to * the shared device specific retained raster information when * the retained raster is cached in hw. The pointer is invalid * if the retained raster isn't cached in hw. * Inputs: Dga_window - Pointer to the client structure. * Outputs: void * - Pointer to the device specific information * Externals: RTN_INFOP() Internal MACRO /* This is the internal interface */ * DGA Retained Device Type. This function is used to obtain * the retained raster hardware cache device type and name. * Inputs: Dga_window - Pointer to the client structure. * Unsign8 * - Pointer to location to store device type. * char ** - Pointer to location to store name string pointer. * Externals: RTN_INFOP() Internal MACRO * DGA Retained Raster Dimensions. This function is used to obtain * the retained raster's dimensions. * Inputs: Dga_window - Pointer to the client structure. * short * - Pointer to location to store the width. * short * - Pointer to location to store the height. * u_int * - Pointer to the location to store the linebytes. * Externals: RTN_INFOP() Internal MACRO * DGA Retained Window Grab. This function creates the shared memory * interface to allow the calling process Direct Graphics Access (DGA) * to the retained raster associated with the specified DGA window. * A request to allow DGA access to the retained raster is sent to the * X/NeWS server. Should the server honor this request, shared memory * mappings within the calling process's address space are then created. * Should any of these steps fail, 0 is returned and the calling process * is not allowed DGA to the retained raster. A non-zero result is * Inputs: Dga_window - Pointer to the Dga_window for which DGA * to the retained raster is desired. * Externals: XDgaGrabRetainedWindow() * XDgaUnGrabRetainedWindow() * Check for an invalid Dga_window /* Determine the window associated with this clientp */ /* Check to see if backing store has been turned on for thw window */ /* Map the shared memory into the calling process's address space.*/ /* Ungrab the retained raster */ * If the retained raster has already been grabbed. Don't * Find out if this is an X window. If so get the Display and window * id. These are used to determine the name of the shared retained * info file. NOTE: DGA to retained rasters are currently supported (
void)
fprintf(
stderr,
"dga_rtn_grab: Unsupported window type\n");
/* Check to see if backing store is turned on for this window; if not (
void)
fprintf(
stderr,
"dga_rtn_grab: Window has no backing store\n");
* Request the server to allow DGA to the retained raster associated (
void)
fprintf(
stderr,
"dga_rtn_grab: XDgaGrabRetainedWindow failed\n");
* Now map the shared memory into the calling process's address (
void)
fprintf(
stderr,
"dga_rtn_grab: unable to map shared info\n");
* Ungrab the retained raster * DGA Retained Pixel Memory . This function returns a pointer * to the shared retained pixel memory. * Inputs: Dga_window - Pointer to the client structure. * Outputs: u_char * - Pointer to retained pixel memory. * DGA Retained Window Ungrab. This function frees the resources * associated with a DGA retained retained raster. The shared * memory mappings in the calling process's address space are * unmapped, the shared info file is closed, and the server is * notified through a protocol extension to free all its resources * associated with the DGA retained raster. Should any of these * steps fail, 0 is returned. A non-zero result is returned upon * Inputs: Dga_window - Pointer to the Dga_window for which DGA * to the retained raster is desired. * Externals: DisplayString() X11 MACRO * XDgaUnGrabRetainedWindow() * Check for an invalid Dga_window * If the retained window has not been grabbed then don't * Unmap the calling process's resources if present. * Set the dga_window retained window server sequence counter pointer * to reflect that the retained raster has NOT been grabbed. /* Determine the window associated with this clientp */ * Find out if this is an X window. If so get the Display and window * id. These are used to determine the name of the shared retained * info file. NOTE: DGA to retained rasters is currently supported (
void)
fprintf(
stderr,
"dga_rtn_grab: Unsupported window type\n");
* Tell the server to deallocate its retained window * resources.if there are no other clients grabbing this window * DGA Retained Window Map. This function maps the retained window * shared memory into the clients address space after determining * the path to the retained window information file. The shared * retained info structure is mapped followed by the actual pixel * array used when the pixels are not cached in hardware. The * address of the shared retained info structure is then place in * the dga_window structure along with the client dependent information. * Should any operation fail, a NULL pointer is placed in the dga_window * structure and 0 is returned. * Inputs: Dga_window - Pointer to the dga_window structure * Externals: DisplayString() X11 MACRO * getpagesize() SUNOS ONLY * Check for a non-zero pointer. (
void)
fprintf(
stderr,
"_dga_rtn_map: dga_window pointer (NULL)\n");
* If the shared retained information has already been mapped don't /* Determine the window associated with this clientp */ /* Initialise clientp's retained info structure - refer dga.h */ clientp->
rtn_fd = 0;
/* I don't think that it is needed any more */ * Find out if this is an X window. If so get the Display and window * id. These are used to determine the name of the shared retained * info file. NOTE: DGA to retained rasters are currently supported (
void)
fprintf(
stderr,
"_dga_rtn_map: Unsupported window type\n");
* Now locate the shared retained info file within the file system. * This file is located in /tmp by default, but through a server * command line option, can be located anywhere on the system in * question. Get the path from the server using the protocol * extension. Then create the filename using the display string (
void)
fprintf(
stderr,
"_dga_rtn_map: XDgaGetRetainedPath failed\n");
* If the path is equal to "", then use the default directory (
void)
fprintf(
stderr,
"_dga_rtn_map: path longer than supported\n");
* Now get the port number for this display * Combine the port number and the window id with the path * Now unlink the file to guarantee that it will disappear * should the client or server crash. * Check the state of the file. If the size of the file * is insufficient to contain the first page of the shared * retained info structure (ie < pagesize) report a failure. (
void)
fprintf(
stderr,
"_dga_rtn_map: unable get file status\n");
(
void)
fprintf(
stderr,
"_dga_rtn_map: file not correct size, %ld\n",
* Map the SHARED_RETAINED_INFO structure * If the file is not actually a shared retained information file * or its the wrong version, unmap the shared memory, close the * file and return the error status. (
void)
fprintf(
stderr,
"_dga_rtn_map: contents of file %s incorrect\n",
(
void)
fprintf(
stderr,
"_dga_rtn_map: unable to mmap pixel area\n");
* Set the fields of the client information. * DGA Retained Window Unmap. This function unmaps the retained window * shared memory from the clients address space given the pointer to the * dga_window structure. The pixel array associated with the retained info * structure is unmapped first followed by the shared retained info * structure. The pointer to the shared memory info structure within the * dga_window structure is set to NULL and the shared memory file is then * closed. Should any operation fail zero is returned. * Inputs: Dga_window - Pointer to the dga_window structure for which * the the shared retained info structure is to * getpagesize() SUNOS ONLY (
void)
fprintf(
stderr,
"_dga_rtn_unmap: info page unmap failed\n");
* DGA Retained Info Structure Dump. This function prints out the contents * of the shared retained info structure found at the specified address. * Inputs: SHARED_RETAINED_INFO * - Pointer to the structure to dump. (
void)
printf(
"NULL info pointer passed to _dga_rtn_dump\n");
(
void)
printf(
"Retained window info page is %p\n",
infop);