Exemple #1
0
void PACK_APIENTRY crPackTexSubImage1DSWAP (GLenum target, GLint level, 
		GLint xoffset, GLsizei width, GLenum format, GLenum type,
		const GLvoid *pixels, const CRPixelPackState *unpackstate )
{
	unsigned char *data_ptr;
	int packet_length;
    CRPixelPackState tmpUnpackState = *unpackstate;

	packet_length = 
		sizeof( target ) +
		sizeof( level ) +
		sizeof( xoffset ) +
		sizeof( width ) +
		sizeof( format ) +
		sizeof( type ) +
		crImageSize( format, type, width, 1 );

	data_ptr = (unsigned char *) crPackAlloc( packet_length );
	WRITE_DATA( 0, GLenum, SWAP32(target) );
	WRITE_DATA( 4, GLint, SWAP32(level) );
	WRITE_DATA( 8, GLint, SWAP32(xoffset) );
	WRITE_DATA( 12, GLsizei, SWAP32(width) );
	WRITE_DATA( 16, GLenum, SWAP32(format) );
	WRITE_DATA( 20, GLenum, SWAP32(type) );

	/* flip application-requested swapBytes state */
	tmpUnpackState.swapBytes = unpackstate->swapBytes ? GL_FALSE : GL_TRUE;

	crPixelCopy1D((GLvoid *) (data_ptr + 24), format, type,
								pixels, format, type, width, &tmpUnpackState );

	crHugePacket( CR_TEXSUBIMAGE1D_OPCODE, data_ptr );
	crPackFree( data_ptr );
}
Exemple #2
0
int crdlm_pointers_TexSubImage1D( struct instanceTexSubImage1D *instance, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels, CRClientState *c )
{
    unsigned int size = crImageSize(format, type, width, 1);

    if (instance && size > 0) {
	crPixelCopy1D(instance->pixels, format, type,
		pixels, format, type, width, &c->unpack);
    }

    return size;
}
Exemple #3
0
int crdlm_pointers_DrawPixels( struct instanceDrawPixels *instance, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels, CRClientState *c )
{
    unsigned int size = crImageSize(format, type, width, height);

    if (instance && size > 0) {
	crPixelCopy2D(width, height, 
		instance->pixels, format, type, NULL,
		pixels, format, type, &c->unpack);
    }

    return size;
}
Exemple #4
0
int crdlm_pointers_TexImage2D( struct instanceTexImage2D *instance, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels, CRClientState *c )
{
    unsigned int size = crImageSize(format, type, width, height);

    if (instance && size > 0) {
	crPixelCopy2D(width, height, 
		instance->pixels, format, type, NULL,
		pixels, format, type, &c->unpack);
    }

    return size;
}
Exemple #5
0
void PACK_APIENTRY crPackTexImage2DSWAP(GLenum target, GLint level, 
		GLint internalformat, GLsizei width, GLsizei height, GLint border, 
		GLenum format, GLenum type, const GLvoid *pixels,
		const CRPixelPackState *unpackstate )
{
	unsigned char *data_ptr;
	int packet_length;
	int isnull = (pixels == NULL);

	packet_length = 
		sizeof( target ) +
		sizeof( level ) +
		sizeof( internalformat ) +
		sizeof( width ) +
		sizeof( height ) + 
		sizeof( border ) +
		sizeof( format ) +
		sizeof( type ) +
		sizeof( int );

	if (pixels)
	{
		packet_length += crImageSize( format, type, width, height );
	}

	data_ptr = (unsigned char *) crPackAlloc( packet_length );
	WRITE_DATA( 0, GLenum, SWAP32(target) );
	WRITE_DATA( 4, GLint, SWAP32(level) );
	WRITE_DATA( 8, GLint, SWAP32(internalformat) );
	WRITE_DATA( 12, GLsizei, SWAP32(width) );
	WRITE_DATA( 16, GLsizei, SWAP32(height) );
	WRITE_DATA( 20, GLint, SWAP32(border) );
	WRITE_DATA( 24, GLenum, SWAP32(format) );
	WRITE_DATA( 28, GLenum, SWAP32(type) );
	WRITE_DATA( 32, int, SWAP32(isnull) );

	if (pixels)
	{
		CRPixelPackState tmpUnpackState = *unpackstate;
		/* flip application-requested swapBytes state */
		tmpUnpackState.swapBytes = unpackstate->swapBytes ? GL_FALSE : GL_TRUE;

		crPixelCopy2D( width, height,
									 (void *)(data_ptr + 36), format, type, NULL,  /* dst */
									 pixels, format, type, &tmpUnpackState );  /* src */
	}

	crHugePacket( CR_TEXIMAGE2D_OPCODE, data_ptr );
	crPackFree( data_ptr );
}
void PACK_APIENTRY crPackDrawPixels(GLsizei width, GLsizei height, 
                                    GLenum format, GLenum type,
                                    const GLvoid *pixels,
                                    const CRPixelPackState *unpackstate )
{
    unsigned char *data_ptr;
    int packet_length, imagesize;
    int noimagedata = (pixels == NULL) || crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB);

    packet_length = 
        sizeof( width ) +
        sizeof( height ) +
        sizeof( format ) +
        sizeof( type ) + sizeof(int) + sizeof(GLint);

    if (!noimagedata)
    {
        imagesize = crImageSize( format, type, width, height );

        if (imagesize<=0)
        {
            crDebug("crPackDrawPixels: 0 image size, ignoring");
            return;
        }
        packet_length += imagesize;
    }

    data_ptr = (unsigned char *) crPackAlloc( packet_length );
    WRITE_DATA( 0, GLsizei, width );
    WRITE_DATA( 4, GLsizei, height );
    WRITE_DATA( 8, GLenum, format );
    WRITE_DATA( 12, GLenum, type );
    WRITE_DATA( 16, GLint, noimagedata );
    WRITE_DATA( 20, GLint, (GLint) (uintptr_t) pixels );

    if (!noimagedata)
    {
        crPixelCopy2D(width, height,
                      (void *) (data_ptr + 24), format, type, NULL, /* dst */
                      pixels, format, type, unpackstate);  /* src */
    }

    crHugePacket( CR_DRAWPIXELS_OPCODE, data_ptr );
    crPackFree( data_ptr );
}
void crUnpackBitmap(PCrUnpackerState pState)
{
    CHECK_BUFFER_SIZE_STATIC_LAST(pState, sizeof(int) + 28, GLint);

    GLsizei width   = READ_DATA(pState, sizeof( int ) + 0, GLsizei );
    GLsizei height  = READ_DATA(pState,sizeof( int ) + 4, GLsizei );
    GLfloat xorig   = READ_DATA(pState, sizeof( int ) + 8, GLfloat );
    GLfloat yorig   = READ_DATA(pState, sizeof( int ) + 12, GLfloat );
    GLfloat xmove   = READ_DATA(pState, sizeof( int ) + 16, GLfloat );
    GLfloat ymove   = READ_DATA(pState, sizeof( int ) + 20, GLfloat );
    GLuint noimagedata = READ_DATA(pState, sizeof( int ) + 24, GLuint );
    GLubyte *bitmap;

    if (noimagedata && !crStateIsBufferBound(pState->pStateTracker, GL_PIXEL_UNPACK_BUFFER_ARB))
        return;

    if (noimagedata)
        bitmap = (GLubyte *) (uintptr_t) READ_DATA(pState,sizeof(int) + 28, GLint);
    else
    {
        /* Each pixel is one bit => 8 pixels per byte. */
        size_t cbImg = crImageSize(GL_COLOR_INDEX, GL_BITMAP, width, height);
        if (RT_UNLIKELY(cbImg == 0))
        {
            pState->rcUnpack = VERR_INVALID_PARAMETER;
            return;
        }

        bitmap = DATA_POINTER(pState, sizeof(int) + 32, GLubyte );
        CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, bitmap, cbImg, GLubyte);
    }

    pState->pDispatchTbl->PixelStorei( GL_UNPACK_ROW_LENGTH, 0 );
    pState->pDispatchTbl->PixelStorei( GL_UNPACK_SKIP_PIXELS, 0 );
    pState->pDispatchTbl->PixelStorei( GL_UNPACK_SKIP_ROWS, 0 );
    pState->pDispatchTbl->PixelStorei( GL_UNPACK_ALIGNMENT, 1 );

    pState->pDispatchTbl->Bitmap( width, height, xorig, yorig, xmove, ymove, bitmap );

    INCR_VAR_PTR(pState);
}
void crUnpackDrawPixels(PCrUnpackerState pState)
{
    CHECK_BUFFER_SIZE_STATIC_LAST(pState, sizeof(int) + 20, GLint);

    GLsizei width  = READ_DATA(pState, sizeof( int ) + 0, GLsizei );
    GLsizei height = READ_DATA(pState, sizeof( int ) + 4, GLsizei );
    GLenum format  = READ_DATA(pState, sizeof( int ) + 8, GLenum );
    GLenum type    = READ_DATA(pState, sizeof( int ) + 12, GLenum );
    GLint noimagedata = READ_DATA(pState, sizeof( int ) + 16, GLint );
    GLvoid *pixels;

    if (noimagedata && !crStateIsBufferBound(pState->pStateTracker, GL_PIXEL_UNPACK_BUFFER_ARB))
        return;

    if (noimagedata)
        pixels = (void*) (uintptr_t) READ_DATA(pState, sizeof( int ) + 20, GLint);
    else
    {
        size_t cbImg = crImageSize( format, type, width, height );
        if (RT_UNLIKELY(cbImg == 0))
        {
            pState->rcUnpack = VERR_INVALID_PARAMETER;
            return;
        }

        pixels = DATA_POINTER(pState, sizeof( int ) + 24, GLvoid );
        CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, pixels, cbImg, GLubyte);
    }

    pState->pDispatchTbl->PixelStorei( GL_UNPACK_ROW_LENGTH, 0 );
    pState->pDispatchTbl->PixelStorei( GL_UNPACK_SKIP_PIXELS, 0 );
    pState->pDispatchTbl->PixelStorei( GL_UNPACK_SKIP_ROWS, 0 );
    pState->pDispatchTbl->PixelStorei( GL_UNPACK_ALIGNMENT, 1 );

    pState->pDispatchTbl->DrawPixels( width, height, format, type, pixels );

    INCR_VAR_PTR(pState);
}