Example #1
0
void glGetSeparableFilter(GLenum target, GLenum format, GLenum type,
			  GLvoid *row, GLvoid *column, GLvoid *span)
{
    __GLX_SINGLE_DECLARE_VARIABLES();
    xGLXGetSeparableFilterReply reply;
    GLubyte *rowBuf, *colBuf;

    if (!dpy) return;
    __GLX_SINGLE_LOAD_VARIABLES();

    /* Send request */
    __GLX_SINGLE_BEGIN(X_GLsop_GetSeparableFilter, __GLX_PAD(13));
    __GLX_SINGLE_PUT_LONG(0,target);
    __GLX_SINGLE_PUT_LONG(4,format);
    __GLX_SINGLE_PUT_LONG(8,type);
    __GLX_SINGLE_PUT_CHAR(12,gc->state.storePack.swapEndian);
    __GLX_SINGLE_READ_XREPLY();
    compsize = reply.length << 2;

    if (compsize != 0) {
	GLint width, height;
	GLint widthsize, heightsize;

	width = reply.width;
	height = reply.height;

	widthsize = __glImageSize(width,1,1,format, type);
	heightsize = __glImageSize(height,1,1,format, type);

	/* Allocate a holding buffer to transform the data from */
	rowBuf = (GLubyte*) Xmalloc(widthsize);
	if (!rowBuf) {
	    /* Throw data away */
	    _XEatData(dpy, compsize);
	    __glXSetError(gc, GL_OUT_OF_MEMORY);
	    UnlockDisplay(dpy);
	    SyncHandle();
	    return;
	} else {
	    __GLX_SINGLE_GET_CHAR_ARRAY(((char*)rowBuf),widthsize);
	    __glEmptyImage(gc, 1, width, 1, 1, format, type, rowBuf, row);
	    Xfree((char*) rowBuf);
	}
	colBuf = (GLubyte*) Xmalloc(heightsize);
	if (!colBuf) {
	    /* Throw data away */
	    _XEatData(dpy, compsize - __GLX_PAD(widthsize));
	    __glXSetError(gc, GL_OUT_OF_MEMORY);
	    UnlockDisplay(dpy);
	    SyncHandle();
	    return;
	} else {
	    __GLX_SINGLE_GET_CHAR_ARRAY(((char*)colBuf),heightsize);
	    __glEmptyImage(gc, 1, height, 1, 1, format, type, colBuf, column);
	    Xfree((char*) colBuf);
	}
    } else {
	/*
	** don't modify user's buffer.
	*/
    }
    __GLX_SINGLE_END();
    
}
Example #2
0
/**
 * Implement GLX protocol for \c glSeparableFilter2D.
 */
void
__indirect_glSeparableFilter2D(GLenum target, GLenum internalformat,
                               GLsizei width, GLsizei height, GLenum format,
                               GLenum type, const GLvoid * row,
                               const GLvoid * column)
{
   __GLX_DECLARE_VARIABLES();
   GLuint compsize2, hdrlen, totalhdrlen, image1len, image2len;

   __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;

   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) {
         (*gc->fillImage) (gc, 1, width, 1, 1, format, type,
                           row, pc, pixelHeaderPC);
         pc += image1len;
      }
      if (compsize2 > 0) {
         (*gc->fillImage) (gc, 1, height, 1, 1, format, type,
                           column, pc, NULL);
         pc += image2len;
      }
      if ((compsize == 0) && (compsize2 == 0)) {
         /* Setup default store modes */
         (void) memcpy(pixelHeaderPC, __glXDefaultPixelStore + 4, 20);
      }
      __GLX_END(0);
   }
   else {
      GLubyte *buf;
      const GLint bufsize = image1len + image2len;

      /* 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;

      /* Allocate a temporary holding buffer */
      buf = malloc(bufsize);
      if (!buf) {
         __glXSetError(gc, GL_OUT_OF_MEMORY);
         return;
      }
      (*gc->fillImage) (gc, 1, width, 1, 1, format, type, row, buf,
                        pixelHeaderPC);

      (*gc->fillImage) (gc, 1, height, 1, 1, format, type, column,
                        buf + image1len, pixelHeaderPC);

      /* Send large command */
      __glXSendLargeCommand(gc, gc->pc, (GLint) (pc - gc->pc), buf,
                            bufsize);
      /* Free buffer */
      free((char *) buf);
   }
}
Example #3
0
/* it is defined to gl_dispatch_stub_NNN in indirect.h */
void gl_dispatch_stub_GetSeparableFilterEXT (GLenum target, GLenum format,
                                             GLenum type, GLvoid * row,
                                             GLvoid * column, GLvoid * span)
{
   struct glx_context *const gc = __glXGetCurrentContext();

#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
   if (gc->isDirect) {
      const _glapi_proc *const table = (_glapi_proc *) GET_DISPATCH();
      PFNGLGETSEPARABLEFILTEREXTPROC p =
         (PFNGLGETSEPARABLEFILTEREXTPROC) table[359];

      p(target, format, type, row, column, span);
      return;
   }
   else
#endif
   {
      Display *const dpy = gc->currentDpy;
      const GLuint cmdlen = __GLX_PAD(13);

      if (dpy != NULL) {
         const __GLXattribute *const state = gc->client_state_private;
         xGLXGetSeparableFilterReply reply;
         GLubyte const *pc =
            __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply,
                                    X_GLvop_GetSeparableFilterEXT, cmdlen);
         unsigned compsize;


         (void) memcpy((void *) (pc + 0), (void *) (&target), 4);
         (void) memcpy((void *) (pc + 4), (void *) (&format), 4);
         (void) memcpy((void *) (pc + 8), (void *) (&type), 4);
         *(int8_t *) (pc + 12) = state->storePack.swapEndian;

         (void) _XReply(dpy, (xReply *) & reply, 0, False);

         compsize = reply.length << 2;

         if (compsize != 0) {
            const GLint width = reply.width;
            const GLint height = reply.height;
            const GLint widthsize =
               __glImageSize(width, 1, 1, format, type, 0);
            const GLint heightsize =
               __glImageSize(height, 1, 1, format, type, 0);
            GLubyte *const buf =
               malloc((widthsize > heightsize) ? widthsize : heightsize);

            if (buf == NULL) {
               /* Throw data away */
               _XEatData(dpy, compsize);
               __glXSetError(gc, GL_OUT_OF_MEMORY);

               UnlockDisplay(dpy);
               SyncHandle();
               return;
            }
            else {
               int extra;

               extra = 4 - (widthsize & 3);
               _XRead(dpy, (char *) buf, widthsize);
               if (extra < 4) {
                  _XEatData(dpy, extra);
               }

               __glEmptyImage(gc, 1, width, 1, 1, format, type, buf, row);

               extra = 4 - (heightsize & 3);
               _XRead(dpy, (char *) buf, heightsize);
               if (extra < 4) {
                  _XEatData(dpy, extra);
               }

               __glEmptyImage(gc, 1, height, 1, 1, format, type, buf, column);

               free((char *) buf);
            }
         }
      }
   }
}
Example #4
0
void NAME(_gloffset_GetSeparableFilter)(GLenum target, GLenum format, GLenum type,
					GLvoid *row, GLvoid *column, GLvoid *span)
{
    __GLXcontext * const gc = __glXGetCurrentContext();

    if (gc->isDirect) {
	CALL_GetSeparableFilter(GET_DISPATCH(),
				(target, format, type, row, column, span));
	return;
    }
    else {
        Display *const dpy = gc->currentDpy;
	const GLuint cmdlen = __GLX_PAD(13);

	if (dpy != NULL) {
	    const __GLXattribute * const state = gc->client_state_private;
	    xGLXGetSeparableFilterReply reply;
	    GLubyte const *pc =
	      __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply,
				      X_GLvop_GetSeparableFilterEXT, cmdlen);
	    unsigned compsize;


	    (void) memcpy((void *) (pc + 0), (void *) (&target), 4);
	    (void) memcpy((void *) (pc + 4), (void *) (&format), 4);
	    (void) memcpy((void *) (pc + 8), (void *) (&type), 4);
	    *(int8_t *) (pc + 12) = state->storePack.swapEndian;

	    (void) _XReply(dpy, (xReply *) & reply, 0, False);

	    compsize = reply.length << 2;

	    if (compsize != 0) {
		const GLint width = reply.width;
		const GLint height = reply.height;
		const GLint widthsize =
		  __glImageSize(width, 1, 1, format, type, 0);
		const GLint heightsize =
		  __glImageSize(height, 1, 1, format, type, 0);
		GLubyte * const buf =
		  (GLubyte*) Xmalloc((widthsize > heightsize) ? widthsize : heightsize);

		if (buf == NULL) {
		    /* Throw data away */
		    _XEatData(dpy, compsize);
		    __glXSetError(gc, GL_OUT_OF_MEMORY);

		    UnlockDisplay(dpy);
		    SyncHandle();
		    return;
		} else {
		    int extra;
		    
		    extra = 4 - (widthsize & 3);
		    _XRead(dpy, (char *)buf, widthsize);
		    if (extra < 4) {
			_XEatData(dpy, extra);
		    }

		    __glEmptyImage(gc, 1, width, 1, 1, format, type, buf,
				   row);

		    extra = 4 - (heightsize & 3);
		    _XRead(dpy, (char *)buf, heightsize);
		    if (extra < 4) {
			_XEatData(dpy, extra);
		    }

		    __glEmptyImage(gc, 1, height, 1, 1, format, type, buf,
				   column);

		    Xfree((char*) buf);
		}
	    }
	}
    }
}