dga_ab.c revision 830
98N/A/* Copyright 1999 Sun Microsystems, Inc. All rights reserved. 98N/A * Use is subject to license terms. 98N/A * Permission is hereby granted, free of charge, to any person obtaining a 1097N/A * copy of this software and associated documentation files (the 98N/A * "Software"), to deal in the Software without restriction, including 98N/A * without limitation the rights to use, copy, modify, merge, publish, 919N/A * distribute, and/or sell copies of the Software, and to permit persons 919N/A * to whom the Software is furnished to do so, provided that the above 919N/A * copyright notice(s) and this permission notice appear in all copies of 919N/A * the Software and that both the above copyright notice(s) and this 919N/A * permission notice appear in supporting documentation. 919N/A * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 919N/A * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 919N/A * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT 919N/A * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 919N/A * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL 919N/A * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING 919N/A * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 919N/A * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION 919N/A * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 919N/A * Except as contained in this notice, the name of a copyright holder 98N/A * shall not be used in advertising or otherwise to promote the sale, use 98N/A * or other dealings in this Software without prior written authorization 98N/A * of the copyright holder. 98N/A * dga_ab.c - the client side code for Ancillary Buffers (ABMG ) /* Set the data filed properly */ * Name : dga_draw_grab_buffer * Synopsis: This function requests the window system to provide * ancillary buffer service for the grabbed drawable name in the * dgadraw argument. The call requests the type of the buffer * specified to be grabbed to the client. If buffer_site is * DGA_SITE_SYSTEM, server allocates the buffer in the shared * memory. If it is DGA_SITE_DEVICE, the server tries to grab * hardware buffers. If the device does not support the given * buffer type in hardware, the request fails. * The drawable must have been grabbed previously via XDgaGrabDrawable. * Implementation: If buffer_stie is DGA_SITE_SYSTEM, this function * increments the grab_cnt if the buffer is already grabbed by other clients. * If this client has grabbed the specified buffer already, this function * returns the grabbed buffer pointer. * Otherwise, it sends a request to the server to grab a buffer. * If the request is successful, this function returns the buffer * A special case where if the grab_cnt is "0", this function still sends * a request to the server to grab the buffer because there is a chance * that the visual capabilities of the window might have been changed. /* Ancillary Buffers are not supported for drawable_type (
void)
fprintf(
stderr,
"dga_draw_grab_buffer: passed null pointer\n");
* Find out if this is an X window. If so get the Display and window (
void)
fprintf(
stderr,
"dga_draw_grab_buffer: Unsupported window type\n");
/* If grab_cnt is "0", then the reinitialization should go thru' * server. We can not just increment the grab_cnt. * There is a chance that the buffers capabilities might have * been changed in which case the server gets the bitsPerPixel * from SunExtVis info struct and reallocates the buffer. * If buffer_site is not DGA_SITE_SYSTEM, then it might be * Request the server to allow DGA to the buffers associated (
void)
fprintf(
stderr,
"dga_draw_grab_buffer: XDgaGrabABuffers failed\n");
/* infop will contain the proper pointer to the selected buffer since * it is in the dga shared page. /* get_specified_buffer: This function checks on the filenames * where if it is software buffer this member should have a * If it is NULL, then it may be a hardware buffer and just * return from this point where the hardware buffer would have * been allocated already. * Name : dga_draw_ungrab_buffer * Synopsis: This function ungrabs the buffer for the specified drawable * which has been grabbed previously. Note that ungrabbing a buffer does * not necessarily cause it to be freed. If any of these steps fail, * zero is returned. True is returned upon success. * Implementation: If the buffer is grabbed already, this function * decrements the grab_cnt. If grab_cnt is negative, it will be * If this client hasn't grabbed the buffer already, this function returns 0. * This function will send a request to the server to ungrab the * buffer only if buffer grabbed is in DGA_SITE_DEVICE ( Hardware ). /* Ancillary Buffers are not supported for drawable_type (
void)
fprintf(
stderr,
"dga_draw_ungrab_buffer: passed null pointer\n");
* Find out if this is an X window. If so get the Display and window (
void)
fprintf(
stderr,
"dga_draw_ungrab_buffer: Unsupported window type\n");
}
/* end of switch ( type ).. *//* Currently Just decrement the grab_cnt and if there is no grab * don't free it. Next time when it is getting grabbed, we will * If the when the grab_cnt is "0" and the dga_drawable is getting * resized then the buffers are thrown away. /* Buffer site is DGA_SITE_DEVICE */ (
void)
fprintf(
stderr,
"dga_draw_ungrab_buffer: XDgaUnGrabABuffers failed\n");
}
/* end of ( ret_buf->buffer_site == DGA_SITE_SYSTEM ).. */ * Name : dga_draw_get_buffers * Synopsis: This function returns the number of ancillary buffers * associated with the specified dgadraw and an arry of buffer * pointers. Note that only buffers which have been grabbed by * the client are returned. Buffers which might exist (because of * grabs by other clients or the server) are not returned. * Synopsis: This function returns the type of the buffer specified. /* We had this function for completeness. */ * Name : dga_buffer_get_drawable * Synopsis: This function returns the Dga_drawable associated with the * Name : dga_buffer_site (Lock Only) * Synopsis: This function returns the site of the buffer specified. * The values are the same as those returned by dga_draw_site(). * DGA_SITE_SYSTEM, DGA_SITE_DEVICE and DGA_SITE_NULL. * Name : dga_draw_bufferchg * Synopsis: This function returns True if any of the buffers * associated with the dgadraw have undergone a state change * since the last lock. When dga_draw_bufferchg returns True, * the client should call dga_buffer_sitechg for each of the * Name : dga_buffer_sitechg * Synopsis: This function returns True if the buffer has sitechg * flag set. Note that this function always returns False for * device buffers. Only memory buffers ever have a site chagne. * dga_buffer_sitechg() also returns the reason for site change. * Currenly the only possible values for reason are DGA_SITECHG_INITIAL, * which is reported the first time a Drawable is locaked after a buffer * has been created and DGA_SITECHG_CACHE which indicates that the * buffer has been resized since the time that the Dga_drawable was last return False;
/* Returning False may mislead the developer */ * Name : dga_buffer_address (Lock Only) * Synopsis: This function returns the data pointer from the shared * buffer page of the buffer specified. An address will be returned * only for buffers which are located in system memory. * If dga_buffer_address is called on a buffer located with * DGA_SITE_DEVICE, NULL will be returned. The value returned * remains valid across locks until a sitechg is reported as * Name : dga_buffer_linebytes * Synopsis: This function returns the number of bytes per scanline * of the buffer specified. Only buffers which are located in * system memory are addressable. If dga_buffer_linebytes is called * for a buffer located on the device, "0" is returned. * Name : dga_buffer_bitsperpixel * Synopsis: This function returns bitsperpixel of the buffer * specified if the buffer is located in system memory. If the * buffer is located on the device, zero is returned. Note that * the value might be different than the number of significant bits. * For example, an unpacked 4 bit stencil buffer would return * 8 bits per pixel, and a 24 bit Z buffer would return