943N/A/* Copyright (c) 1996, 1999, Oracle and/or its affiliates. All rights reserved. 830N/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. 830N/A * dga_ab.c - the client side code for Ancillary Buffers (ABMG ) 830N/A /* Set the data filed properly */ 830N/A * Name : dga_draw_grab_buffer 830N/A * Synopsis: This function requests the window system to provide 830N/A * ancillary buffer service for the grabbed drawable name in the 830N/A * dgadraw argument. The call requests the type of the buffer 830N/A * specified to be grabbed to the client. If buffer_site is 830N/A * DGA_SITE_SYSTEM, server allocates the buffer in the shared 830N/A * memory. If it is DGA_SITE_DEVICE, the server tries to grab 830N/A * hardware buffers. If the device does not support the given 830N/A * buffer type in hardware, the request fails. 830N/A * The drawable must have been grabbed previously via XDgaGrabDrawable. 830N/A * Implementation: If buffer_stie is DGA_SITE_SYSTEM, this function 830N/A * increments the grab_cnt if the buffer is already grabbed by other clients. 830N/A * If this client has grabbed the specified buffer already, this function 830N/A * returns the grabbed buffer pointer. 830N/A * Otherwise, it sends a request to the server to grab a buffer. 830N/A * If the request is successful, this function returns the buffer 830N/A * A special case where if the grab_cnt is "0", this function still sends 830N/A * a request to the server to grab the buffer because there is a chance 830N/A * that the visual capabilities of the window might have been changed. 830N/A /* Ancillary Buffers are not supported for drawable_type 830N/A * Find out if this is an X window. If so get the Display and window 830N/A /* If grab_cnt is "0", then the reinitialization should go thru' 830N/A * server. We can not just increment the grab_cnt. 830N/A * There is a chance that the buffers capabilities might have 830N/A * been changed in which case the server gets the bitsPerPixel 830N/A * from SunExtVis info struct and reallocates the buffer. 830N/A * If buffer_site is not DGA_SITE_SYSTEM, then it might be 830N/A * Request the server to allow DGA to the buffers associated 830N/A * with this Dga_window. 830N/A /* infop will contain the proper pointer to the selected buffer since 830N/A * it is in the dga shared page. 830N/A /* get_specified_buffer: This function checks on the filenames 830N/A * where if it is software buffer this member should have a 830N/A * If it is NULL, then it may be a hardware buffer and just 830N/A * return from this point where the hardware buffer would have 830N/A * been allocated already. 830N/A * Name : dga_draw_ungrab_buffer 830N/A * Synopsis: This function ungrabs the buffer for the specified drawable 830N/A * which has been grabbed previously. Note that ungrabbing a buffer does 830N/A * not necessarily cause it to be freed. If any of these steps fail, 830N/A * zero is returned. True is returned upon success. 830N/A * Implementation: If the buffer is grabbed already, this function 830N/A * decrements the grab_cnt. If grab_cnt is negative, it will be 830N/A * If this client hasn't grabbed the buffer already, this function returns 0. 830N/A * This function will send a request to the server to ungrab the 830N/A * buffer only if buffer grabbed is in DGA_SITE_DEVICE ( Hardware ). 830N/A /* Ancillary Buffers are not supported for drawable_type 830N/A * Find out if this is an X window. If so get the Display and window 830N/A }
/* end of switch ( type ).. */ 830N/A/* Currently Just decrement the grab_cnt and if there is no grab 830N/A * don't free it. Next time when it is getting grabbed, we will 830N/A * If the when the grab_cnt is "0" and the dga_drawable is getting 830N/A * resized then the buffers are thrown away. 830N/A /* Buffer site is DGA_SITE_DEVICE */ 830N/A }
/* end of ( ret_buf->buffer_site == DGA_SITE_SYSTEM ).. */ 830N/A * Name : dga_draw_get_buffers 830N/A * Synopsis: This function returns the number of ancillary buffers 830N/A * associated with the specified dgadraw and an arry of buffer 830N/A * pointers. Note that only buffers which have been grabbed by 830N/A * the client are returned. Buffers which might exist (because of 830N/A * grabs by other clients or the server) are not returned. 830N/A * Name : dga_buffer_type 830N/A * Synopsis: This function returns the type of the buffer specified. 830N/A/* We had this function for completeness. */ 830N/A * Name : dga_buffer_get_drawable 830N/A * Synopsis: This function returns the Dga_drawable associated with the 830N/A * Name : dga_buffer_site (Lock Only) 830N/A * Synopsis: This function returns the site of the buffer specified. 830N/A * The values are the same as those returned by dga_draw_site(). 830N/A * DGA_SITE_SYSTEM, DGA_SITE_DEVICE and DGA_SITE_NULL. 830N/A * Name : dga_draw_bufferchg 830N/A * Synopsis: This function returns True if any of the buffers 830N/A * associated with the dgadraw have undergone a state change 830N/A * since the last lock. When dga_draw_bufferchg returns True, 830N/A * the client should call dga_buffer_sitechg for each of the 830N/A * Name : dga_buffer_sitechg 830N/A * Synopsis: This function returns True if the buffer has sitechg 830N/A * flag set. Note that this function always returns False for 830N/A * device buffers. Only memory buffers ever have a site chagne. 830N/A * dga_buffer_sitechg() also returns the reason for site change. 830N/A * Currenly the only possible values for reason are DGA_SITECHG_INITIAL, 830N/A * which is reported the first time a Drawable is locaked after a buffer 830N/A * has been created and DGA_SITECHG_CACHE which indicates that the 830N/A * buffer has been resized since the time that the Dga_drawable was last 830N/A return False;
/* Returning False may mislead the developer */ 830N/A * Name : dga_buffer_address (Lock Only) 830N/A * Synopsis: This function returns the data pointer from the shared 830N/A * buffer page of the buffer specified. An address will be returned 830N/A * only for buffers which are located in system memory. 830N/A * If dga_buffer_address is called on a buffer located with 830N/A * DGA_SITE_DEVICE, NULL will be returned. The value returned 830N/A * remains valid across locks until a sitechg is reported as 830N/A * Name : dga_buffer_linebytes 830N/A * Synopsis: This function returns the number of bytes per scanline 830N/A * of the buffer specified. Only buffers which are located in 830N/A * system memory are addressable. If dga_buffer_linebytes is called 830N/A * for a buffer located on the device, "0" is returned. 830N/A * Name : dga_buffer_bitsperpixel 830N/A * Synopsis: This function returns bitsperpixel of the buffer 830N/A * specified if the buffer is located in system memory. If the 830N/A * buffer is located on the device, zero is returned. Note that 830N/A * the value might be different than the number of significant bits. 830N/A * For example, an unpacked 4 bit stencil buffer would return 830N/A * 8 bits per pixel, and a 24 bit Z buffer would return