2004-10-25 22:09:16 +01:00
|
|
|
/*
|
Update to SGI FreeB 2.0.
Under the terms of version 1.1, "once Covered Code has been published
under a particular version of the License, Recipient may, for the
duration of the License, continue to use it under the terms of that
version, or choose to use such Covered Code under the terms of any
subsequent version published by SGI."
FreeB 2.0 license refers to "dates of first publication". They are here
taken to be 1991-2000, as noted in the original license text:
** Original Code. The Original Code is: OpenGL Sample Implementation,
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
** Copyright in any portions created by third parties is as indicated
** elsewhere herein. All Rights Reserved.
Official FreeB 2.0 text:
http://oss.sgi.com/projects/FreeB/SGIFreeSWLicB.2.0.pdf
As always, this code has not been tested for conformance with the OpenGL
specification. OpenGL conformance testing is available from
http://khronos.org/ and is required for use of the OpenGL logo in
product advertising and promotion.
2008-09-19 22:16:53 +01:00
|
|
|
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
|
|
|
|
* Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
|
|
|
|
*
|
2022-12-14 18:27:16 +00:00
|
|
|
* SPDX-License-Identifier: SGI-B-2.0
|
Update to SGI FreeB 2.0.
Under the terms of version 1.1, "once Covered Code has been published
under a particular version of the License, Recipient may, for the
duration of the License, continue to use it under the terms of that
version, or choose to use such Covered Code under the terms of any
subsequent version published by SGI."
FreeB 2.0 license refers to "dates of first publication". They are here
taken to be 1991-2000, as noted in the original license text:
** Original Code. The Original Code is: OpenGL Sample Implementation,
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
** Copyright in any portions created by third parties is as indicated
** elsewhere herein. All Rights Reserved.
Official FreeB 2.0 text:
http://oss.sgi.com/projects/FreeB/SGIFreeSWLicB.2.0.pdf
As always, this code has not been tested for conformance with the OpenGL
specification. OpenGL conformance testing is available from
http://khronos.org/ and is required for use of the OpenGL logo in
product advertising and promotion.
2008-09-19 22:16:53 +01:00
|
|
|
*/
|
2004-10-25 22:09:16 +01:00
|
|
|
|
|
|
|
/*
|
2005-01-07 02:39:09 +00:00
|
|
|
* (C) Copyright IBM Corporation 2005
|
|
|
|
* All Rights Reserved.
|
|
|
|
*
|
|
|
|
* 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, sub license,
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
* 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 NON-INFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* IBM,
|
|
|
|
* AND/OR THEIR SUPPLIERS 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.
|
|
|
|
*/
|
2004-10-25 22:09:16 +01:00
|
|
|
|
2005-01-07 02:39:09 +00:00
|
|
|
#include "packrender.h"
|
2005-04-14 21:35:33 +01:00
|
|
|
#include "indirect.h"
|
2005-01-07 02:39:09 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Send a large image to the server. If necessary, a buffer is allocated
|
|
|
|
* to hold the unpacked data that is copied from the clients memory.
|
|
|
|
*
|
|
|
|
* \param gc Current GLX context
|
|
|
|
* \param compsize Size, in bytes, of the image portion
|
|
|
|
* \param dim Number of dimensions of the image
|
|
|
|
* \param width Width of the image
|
|
|
|
* \param height Height of the image, must be 1 for 1D images
|
|
|
|
* \param depth Depth of the image, must be 1 for 1D or 2D images
|
|
|
|
* \param format Format of the image
|
|
|
|
* \param type Data type of the image
|
|
|
|
* \param src Pointer to the image data
|
|
|
|
* \param pc Pointer to end of the command header
|
|
|
|
* \param modes Pointer to the pixel unpack data
|
|
|
|
*
|
|
|
|
* \todo
|
|
|
|
* Modify this function so that \c NULL images are sent using
|
|
|
|
* \c __glXSendLargeChunk instead of __glXSendLargeCommand. Doing this
|
|
|
|
* will eliminate the need to allocate a buffer for that case.
|
|
|
|
*/
|
|
|
|
void
|
2010-07-28 16:16:00 +01:00
|
|
|
__glXSendLargeImage(struct glx_context * gc, GLint compsize, GLint dim,
|
2008-10-13 13:34:43 +01:00
|
|
|
GLint width, GLint height, GLint depth,
|
|
|
|
GLenum format, GLenum type, const GLvoid * src,
|
|
|
|
GLubyte * pc, GLubyte * modes)
|
2005-01-07 02:39:09 +00:00
|
|
|
{
|
2011-06-01 18:00:57 +01:00
|
|
|
/* Allocate a temporary holding buffer */
|
2012-09-04 03:44:00 +01:00
|
|
|
GLubyte *buf = malloc(compsize);
|
2011-06-01 18:00:57 +01:00
|
|
|
if (!buf) {
|
|
|
|
__glXSetError(gc, GL_OUT_OF_MEMORY);
|
|
|
|
return;
|
|
|
|
}
|
2004-10-25 22:09:16 +01:00
|
|
|
|
2011-06-01 18:00:57 +01:00
|
|
|
/* Apply pixel store unpack modes to copy data into buf */
|
|
|
|
if (src != NULL) {
|
2019-08-23 17:51:08 +01:00
|
|
|
__glFillImage(gc, dim, width, height, depth, format, type,
|
|
|
|
src, buf, modes);
|
2011-06-01 18:00:57 +01:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (dim < 3) {
|
|
|
|
(void) memcpy(modes, __glXDefaultPixelStore + 4, 20);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
(void) memcpy(modes, __glXDefaultPixelStore + 0, 36);
|
|
|
|
}
|
|
|
|
}
|
2004-10-25 22:09:16 +01:00
|
|
|
|
2011-06-01 18:00:57 +01:00
|
|
|
/* Send large command */
|
|
|
|
__glXSendLargeCommand(gc, gc->pc, pc - gc->pc, buf, compsize);
|
2004-10-25 22:09:16 +01:00
|
|
|
|
2011-06-01 18:00:57 +01:00
|
|
|
/* Free buffer */
|
2012-09-05 06:52:36 +01:00
|
|
|
free((char *) buf);
|
2004-10-25 22:09:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************/
|
|
|
|
|
2005-01-07 02:39:09 +00:00
|
|
|
/**
|
|
|
|
* Implement GLX protocol for \c glSeparableFilter2D.
|
|
|
|
*/
|
2008-10-13 13:34:43 +01:00
|
|
|
void
|
|
|
|
__indirect_glSeparableFilter2D(GLenum target, GLenum internalformat,
|
|
|
|
GLsizei width, GLsizei height, GLenum format,
|
|
|
|
GLenum type, const GLvoid * row,
|
|
|
|
const GLvoid * column)
|
2004-10-25 22:09:16 +01:00
|
|
|
{
|
2008-10-13 13:34:43 +01:00
|
|
|
__GLX_DECLARE_VARIABLES();
|
|
|
|
GLuint compsize2, hdrlen, totalhdrlen, image1len, image2len;
|
2004-10-25 22:09:16 +01:00
|
|
|
|
2008-10-13 13:34:43 +01:00
|
|
|
__GLX_LOAD_VARIABLES();
|
|
|
|
compsize = __glImageSize(width, 1, 1, format, type, 0);
|
|
|
|
compsize2 = __glImageSize(height, 1, 1, format, type, 0);
|
|
|
|
totalhdrlen = __GLX_PAD(__GLX_CONV_FILT_CMD_HDR_SIZE);
|
|
|
|
hdrlen = __GLX_PAD(__GLX_CONV_FILT_HDR_SIZE);
|
|
|
|
image1len = __GLX_PAD(compsize);
|
|
|
|
image2len = __GLX_PAD(compsize2);
|
|
|
|
cmdlen = totalhdrlen + image1len + image2len;
|
|
|
|
if (!gc->currentDpy)
|
|
|
|
return;
|
2004-10-25 22:09:16 +01:00
|
|
|
|
2008-10-13 13:34:43 +01:00
|
|
|
if (cmdlen <= gc->maxSmallRenderCommandSize) {
|
|
|
|
/* Use GLXRender protocol to send small command */
|
|
|
|
__GLX_BEGIN_VARIABLE_WITH_PIXEL(X_GLrop_SeparableFilter2D, cmdlen);
|
|
|
|
__GLX_PUT_LONG(0, target);
|
|
|
|
__GLX_PUT_LONG(4, internalformat);
|
|
|
|
__GLX_PUT_LONG(8, width);
|
|
|
|
__GLX_PUT_LONG(12, height);
|
|
|
|
__GLX_PUT_LONG(16, format);
|
|
|
|
__GLX_PUT_LONG(20, type);
|
|
|
|
pc += hdrlen;
|
|
|
|
if (compsize > 0) {
|
2019-08-23 17:51:08 +01:00
|
|
|
__glFillImage(gc, 1, width, 1, 1, format, type, row, pc,
|
|
|
|
pixelHeaderPC);
|
2008-10-13 13:34:43 +01:00
|
|
|
pc += image1len;
|
|
|
|
}
|
|
|
|
if (compsize2 > 0) {
|
2019-08-23 17:51:08 +01:00
|
|
|
__glFillImage(gc, 1, height, 1, 1, format, type, column, pc, NULL);
|
2008-10-13 13:34:43 +01:00
|
|
|
pc += image2len;
|
|
|
|
}
|
|
|
|
if ((compsize == 0) && (compsize2 == 0)) {
|
|
|
|
/* Setup default store modes */
|
|
|
|
(void) memcpy(pixelHeaderPC, __glXDefaultPixelStore + 4, 20);
|
|
|
|
}
|
|
|
|
__GLX_END(0);
|
|
|
|
}
|
|
|
|
else {
|
2011-06-01 18:00:57 +01:00
|
|
|
GLubyte *buf;
|
2008-10-13 13:34:43 +01:00
|
|
|
const GLint bufsize = image1len + image2len;
|
2004-10-25 22:09:16 +01:00
|
|
|
|
2008-10-13 13:34:43 +01:00
|
|
|
/* Use GLXRenderLarge protocol to send command */
|
|
|
|
__GLX_BEGIN_VARIABLE_LARGE_WITH_PIXEL(X_GLrop_SeparableFilter2D,
|
|
|
|
cmdlen + 4);
|
|
|
|
__GLX_PUT_LONG(0, target);
|
|
|
|
__GLX_PUT_LONG(4, internalformat);
|
|
|
|
__GLX_PUT_LONG(8, width);
|
|
|
|
__GLX_PUT_LONG(12, height);
|
|
|
|
__GLX_PUT_LONG(16, format);
|
|
|
|
__GLX_PUT_LONG(20, type);
|
|
|
|
pc += hdrlen;
|
2004-10-25 22:09:16 +01:00
|
|
|
|
2011-06-01 18:00:57 +01:00
|
|
|
/* Allocate a temporary holding buffer */
|
2012-09-04 03:44:00 +01:00
|
|
|
buf = malloc(bufsize);
|
2011-06-01 18:00:57 +01:00
|
|
|
if (!buf) {
|
|
|
|
__glXSetError(gc, GL_OUT_OF_MEMORY);
|
|
|
|
return;
|
|
|
|
}
|
2019-08-23 17:51:08 +01:00
|
|
|
__glFillImage(gc, 1, width, 1, 1, format, type, row, buf,
|
|
|
|
pixelHeaderPC);
|
2004-10-25 22:09:16 +01:00
|
|
|
|
2019-08-23 17:51:08 +01:00
|
|
|
__glFillImage(gc, 1, height, 1, 1, format, type, column,
|
|
|
|
buf + image1len, pixelHeaderPC);
|
2004-10-25 22:09:16 +01:00
|
|
|
|
2011-06-01 18:00:57 +01:00
|
|
|
/* Send large command */
|
|
|
|
__glXSendLargeCommand(gc, gc->pc, (GLint) (pc - gc->pc), buf,
|
|
|
|
bufsize);
|
|
|
|
/* Free buffer */
|
2012-09-05 06:52:36 +01:00
|
|
|
free((char *) buf);
|
2008-10-13 13:34:43 +01:00
|
|
|
}
|
2004-10-25 22:09:16 +01:00
|
|
|
}
|