dga_ab.c revision 919
210N/A/* Copyright 1999 Sun Microsystems, Inc. All rights reserved. 210N/A * Use is subject to license terms. 210N/A * Permission is hereby granted, free of charge, to any person obtaining a 851N/A * copy of this software and associated documentation files (the "Software"), 851N/A * to deal in the Software without restriction, including without limitation 210N/A * the rights to use, copy, modify, merge, publish, distribute, sublicense, 210N/A * and/or sell copies of the Software, and to permit persons to whom the 210N/A * Software is furnished to do so, subject to the following conditions: 210N/A * The above copyright notice and this permission notice (including the next 210N/A * paragraph) shall be included in all copies or substantial portions of the 210N/A * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 210N/A * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 210N/A * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 210N/A * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 210N/A * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 210N/A * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 210N/A * DEALINGS IN THE SOFTWARE. 210N/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