*
* 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, sublicense,
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* 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. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
/*
* dga_ab.c - the client side code for Ancillary Buffers (ABMG )
*/
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include "dga_incls.h"
#ifdef DEBUG
if(!(expr)) \
abort();}
#else
#endif /* DEBUG */
if ( addr ) { \
}
if ( bufferp) { \
if (resize_flag) \
if ( bufferp ) { \
} \
else {\
if (bufferp) { \
} \
else { \
} \
}\
}\
}
static dga_buffer
{
/* Set the data filed properly */
}
}
return return_buf;
}
static void
{
char *filename;
int count = 0;
return;
STORE_BUFFERS((dga_internal_buffer)dgawin->back, infop->wx_abuf.back_fn, infop->wx_abuf.back_fn[0], infop->wx_abuf.back_size);
STORE_BUFFERS((dga_internal_buffer)dgawin->depth, infop->wx_abuf.depth_fn, infop->wx_abuf.depth_fn[0], infop->wx_abuf.depth_size);
STORE_BUFFERS((dga_internal_buffer)dgawin->stencil, infop->wx_abuf.stencil_fn, infop->wx_abuf.stencil_fn[0], infop->wx_abuf.stencil_size);
STORE_BUFFERS((dga_internal_buffer)dgawin->accum, infop->wx_abuf.accum_fn, infop->wx_abuf.accum_fn[0], infop->wx_abuf.accum_size);
STORE_BUFFERS((dga_internal_buffer)dgawin->alpha, infop->wx_abuf.alpha_fn, infop->wx_abuf.alpha_fn[0], infop->wx_abuf.alpha_size);
return;
}
/*
* 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
* address.
* 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.
*/
{
int depth = 0;
/* Ancillary Buffers are not supported for drawable_type
* DGA_DRAW_PIXMAP
*/
return (0);
return (0);
#ifdef DEBUG
#endif
return (0);
}
/*
* Find out if this is an X window. If so get the Display and window
* id.
*/
#ifdef DEBUG
#endif
return (0);
}
switch ( type ) {
case DGA_BACK_BUFFER:
break;
case DGA_DEPTH_BUFFER:
break;
case DGA_STENCIL_BUFFER:
break;
case DGA_ACCUM_BUFFER:
break;
case DGA_ALPHA_BUFFER:
break;
default:
return (0);
}
/* 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
* a Hardware Buffers.
*/
return (Dga_buffer ) ret_buf;
}
/*
* Request the server to allow DGA to the buffers associated
* with this Dga_window.
*/
#ifdef DEBUG
#endif
return (0);
}
/* 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
* valid file name.
* 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.
*/
switch ( type ) {
case DGA_BACK_BUFFER:
break;
case DGA_DEPTH_BUFFER:
break;
case DGA_STENCIL_BUFFER:
break;
case DGA_ACCUM_BUFFER:
break;
case DGA_ALPHA_BUFFER:
break;
}
if ( bufferp ) {
return (Dga_buffer) ret_buf;
} else {
if (buffer_site == DGA_SITE_DEVICE)
return (Dga_buffer) c_bufferp;
}
return NULL;
}
/*
* 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
* reset to "0".
* 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 ).
*/
int
{
/* Ancillary Buffers are not supported for drawable_type
* DGA_DRAW_PIXMAP
*/
return (0);
return (0);
#ifdef DEBUG
#endif
return (0);
}
/*
* Find out if this is an X window. If so get the Display and window
* id.
*/
#ifdef DEBUG
#endif
return (0);
}
switch ( type ) {
case DGA_BACK_BUFFER:
return 0;
break;
case DGA_DEPTH_BUFFER:
return 0;
break;
case DGA_STENCIL_BUFFER:
return 0;
break;
case DGA_ACCUM_BUFFER:
return 0;
break;
case DGA_ALPHA_BUFFER:
return 0;
break;
default:
return (0);
} /* 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
* increment the count
* If the when the grab_cnt is "0" and the dga_drawable is getting
* resized then the buffers are thrown away.
*/
if ( !bufferp )
return (0);
switch ( type ) {
case DGA_BACK_BUFFER:
break;
case DGA_DEPTH_BUFFER:
break;
case DGA_STENCIL_BUFFER:
break;
case DGA_ACCUM_BUFFER:
break;
case DGA_ALPHA_BUFFER:
break;
default:
return (0);
} /* end of switch */
}
else {
/* Buffer site is DGA_SITE_DEVICE */
#ifdef DEBUG
#endif
return (0);
}
} /* end of ( ret_buf->buffer_site == DGA_SITE_SYSTEM ).. */
return 1;
}
/*
* 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.
*/
int
{
char *filename;
int count = 0;
resize_flag = True;
STORE_BUFFERS((dga_internal_buffer)dgawin->back, infop->wx_abuf.back_fn, infop->wx_abuf.back_fn[0], infop->wx_abuf.back_size);
STORE_BUFFERS((dga_internal_buffer)dgawin->depth, infop->wx_abuf.depth_fn, infop->wx_abuf.depth_fn[0], infop->wx_abuf.depth_size);
STORE_BUFFERS((dga_internal_buffer)dgawin->stencil, infop->wx_abuf.stencil_fn, infop->wx_abuf.stencil_fn[0], infop->wx_abuf.stencil_size);
STORE_BUFFERS((dga_internal_buffer)dgawin->accum, infop->wx_abuf.accum_fn, infop->wx_abuf.accum_fn[0], infop->wx_abuf.accum_size);
STORE_BUFFERS((dga_internal_buffer)dgawin->alpha, infop->wx_abuf.alpha_fn, infop->wx_abuf.alpha_fn[0], infop->wx_abuf.alpha_size);
if ( resize_flag )
return count;
}
/*
* Name : dga_buffer_type
* Synopsis: This function returns the type of the buffer specified.
*/
{
return -1;
}
return local_buf->buffer_type;
}
#if 0
/* We had this function for completeness. */
/*
* Name : dga_buffer_get_drawable
* Synopsis: This function returns the Dga_drawable associated with the
* buffer specified.
*/
{
if ( !bufferp )
return NULL;
}
#endif
/*
* 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.
*/
int
{
return DGA_SITE_NULL;
}
return local_buf->buffer_site;
}
/*
* 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
* Drawable's buffers.
*/
int
{
return True;
return False;
}
/*
* 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
* locked.
*/
int
{
return False; /* Returning False may mislead the developer */
}
return False;
return True;
} else
return False;
}
/*
* 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
* described above.
*/
void *
{
return NULL;
}
}
else
return NULL;
}
/*
* 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.
*/
int
{
return 0;
}
else
return 0;
}
/*
* 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
* 32 bits per pixel.
*/
int
{
return 0;
}
return local_buf->bitsPerPixel;
else
return 0;
}
void
{
if (visfunc)
}
return;
}
int
{
return 1;
}
return 0;
}