From 40dc5902d39c875d014520a244d842189021d11a Mon Sep 17 00:00:00 2001 From: Claudio Ciccani Date: Fri, 1 Dec 2006 11:42:58 +0000 Subject: Fixed compilation errors/warnings. Duplicate destination surface to avoid saving/restoring the rendering state during each Clear. --- src/mesa/drivers/directfb/idirectfbgl_mesa.c | 65 ++++++++++++++-------------- 1 file changed, 32 insertions(+), 33 deletions(-) (limited to 'src/mesa/drivers/directfb') diff --git a/src/mesa/drivers/directfb/idirectfbgl_mesa.c b/src/mesa/drivers/directfb/idirectfbgl_mesa.c index 323cdd6791..eefc964889 100644 --- a/src/mesa/drivers/directfb/idirectfbgl_mesa.c +++ b/src/mesa/drivers/directfb/idirectfbgl_mesa.c @@ -185,7 +185,7 @@ IDirectFBGL_Mesa_Lock( IDirectFBGL *thiz ) IDirectFBSurface *surface; int width = 0; int height = 0; - DFBResult err; + DFBResult ret; DIRECT_INTERFACE_GET_DATA( IDirectFBGL ); @@ -198,11 +198,11 @@ IDirectFBGL_Mesa_Lock( IDirectFBGL *thiz ) surface = data->surface; surface->GetSize( surface, &width, &height ); - err = surface->Lock( surface, DSLF_READ | DSLF_WRITE, + ret = surface->Lock( surface, DSLF_READ | DSLF_WRITE, (void*)&data->video.start, &data->video.pitch ); - if (err != DFB_OK) { + if (ret) { D_ERROR( "DirectFBGL/Mesa: couldn't lock surface.\n" ); - return err; + return ret; } data->video.end = data->video.start + (height-1) * data->video.pitch; @@ -270,7 +270,7 @@ IDirectFBGL_Mesa_GetAttributes( IDirectFBGL *thiz, attributes->accum_green_size = visual->accumGreenBits; attributes->accum_blue_size = visual->accumBlueBits; attributes->accum_alpha_size = visual->accumAlphaBits; - attributes->double_buffer = (caps & DSCAPS_FLIPPING) ? 1 : 0; + attributes->double_buffer = ((caps & DSCAPS_FLIPPING) != 0); attributes->stereo = (visual->stereoMode != 0); return DFB_OK; @@ -288,6 +288,8 @@ Probe( void *data ) static DFBResult Construct( IDirectFBGL *thiz, IDirectFBSurface *surface ) { + DFBResult ret; + /* Initialize global resources. */ if (directfbgl_init()) return DFB_INIT; @@ -296,12 +298,17 @@ Construct( IDirectFBGL *thiz, IDirectFBSurface *surface ) DIRECT_ALLOCATE_INTERFACE_DATA( thiz, IDirectFBGL ); /* Initialize interface data. */ - data->ref = 1; - data->surface = surface; + data->ref = 1; + + /* Duplicate destination surface. */ + ret = surface->GetSubSurface( surface, NULL, &data->surface ); + if (ret) { + IDirectFBGL_Mesa_Destruct( thiz ); + return ret; + } - surface->AddRef( surface ); - surface->GetPixelFormat( surface, &data->format ); - surface->GetSize( surface, &data->width, &data->height ); + data->surface->GetPixelFormat( data->surface, &data->format ); + data->surface->GetSize( data->surface, &data->width, &data->height ); /* Configure visual. */ if (!directfbgl_init_visual( &data->visual, data->format )) { @@ -375,11 +382,6 @@ static void dfbClear( GLcontext *ctx, GLbitfield mask ) { IDirectFBGL_data *data = (IDirectFBGL_data*) ctx->DriverCtx; - int x = ctx->DrawBuffer->_Xmin; - int y = ctx->DrawBuffer->_Ymin; - int width = ctx->DrawBuffer->_Xmax - x; - int height = ctx->DrawBuffer->_Ymax - y; - GLboolean all = (width == ctx->DrawBuffer->Width && height == ctx->DrawBuffer->height) if (mask & BUFFER_BIT_FRONT_LEFT && ctx->Color.ColorMask[0] && @@ -388,7 +390,7 @@ dfbClear( GLcontext *ctx, GLbitfield mask ) ctx->Color.ColorMask[3]) { DFBRegion clip; - __u8 a, r, g, b; + GLubyte a, r, g, b; UNCLAMPED_FLOAT_TO_UBYTE( a, ctx->Color.ClearColor[ACOMP] ); UNCLAMPED_FLOAT_TO_UBYTE( r, ctx->Color.ClearColor[RCOMP] ); @@ -397,25 +399,13 @@ dfbClear( GLcontext *ctx, GLbitfield mask ) data->surface->Unlock( data->surface ); -#if DIRECTFB_VERSION_CODE >= VERSION_CODE(0,9,25) - data->surface->GetClip( data->surface, &clip ); -#else - (void)clip; -#endif - - if (all) { - data->surface->SetClip( data->surface, NULL ); - } - else { - DFBRegion reg = { x1:x, y1:y, x2:x+width-1, y2:y+height-1 }; - data->surface->SetClip( data->surface, ® ); - } + clip.x1 = ctx->DrawBuffer->_Xmin; + clip.y1 = ctx->DrawBuffer->_Ymin; + clip.x2 = ctx->DrawBuffer->_Xmax - 1; + clip.y2 = ctx->DrawBuffer->_Ymax - 1; + data->surface->SetClip( data->surface, &clip ); data->surface->Clear( data->surface, r, g, b, a ); - -#if DIRECTFB_VERSION_CODE >= VERSION_CODE(0,9,25) - data->surface->SetClip( data->surface, &clip ); -#endif data->surface->Lock( data->surface, DSLF_READ | DSLF_WRITE, (void*)&data->video.start, &data->video.pitch ); @@ -790,6 +780,7 @@ directfbgl_create_context( GLcontext *context, data->render.GetRow = get_row_RGB332; data->render.GetValues = get_values_RGB332; data->render.PutRow = put_row_RGB332; + data->render.PutRowRGB = put_row_rgb_RGB332; data->render.PutMonoRow = put_mono_row_RGB332; data->render.PutValues = put_values_RGB332; data->render.PutMonoValues = put_mono_values_RGB332; @@ -798,6 +789,7 @@ directfbgl_create_context( GLcontext *context, data->render.GetRow = get_row_ARGB4444; data->render.GetValues = get_values_ARGB4444; data->render.PutRow = put_row_ARGB4444; + data->render.PutRowRGB = put_row_rgb_ARGB4444; data->render.PutMonoRow = put_mono_row_ARGB4444; data->render.PutValues = put_values_ARGB4444; data->render.PutMonoValues = put_mono_values_ARGB4444; @@ -806,6 +798,7 @@ directfbgl_create_context( GLcontext *context, data->render.GetRow = get_row_ARGB2554; data->render.GetValues = get_values_ARGB2554; data->render.PutRow = put_row_ARGB2554; + data->render.PutRowRGB = put_row_rgb_ARGB2554; data->render.PutMonoRow = put_mono_row_ARGB2554; data->render.PutValues = put_values_ARGB2554; data->render.PutMonoValues = put_mono_values_ARGB2554; @@ -814,6 +807,7 @@ directfbgl_create_context( GLcontext *context, data->render.GetRow = get_row_ARGB1555; data->render.GetValues = get_values_ARGB1555; data->render.PutRow = put_row_ARGB1555; + data->render.PutRowRGB = put_row_rgb_ARGB1555; data->render.PutMonoRow = put_mono_row_ARGB1555; data->render.PutValues = put_values_ARGB1555; data->render.PutMonoValues = put_mono_values_ARGB1555; @@ -822,6 +816,7 @@ directfbgl_create_context( GLcontext *context, data->render.GetRow = get_row_RGB16; data->render.GetValues = get_values_RGB16; data->render.PutRow = put_row_RGB16; + data->render.PutRowRGB = put_row_rgb_RGB16; data->render.PutMonoRow = put_mono_row_RGB16; data->render.PutValues = put_values_RGB16; data->render.PutMonoValues = put_mono_values_RGB16; @@ -830,6 +825,7 @@ directfbgl_create_context( GLcontext *context, data->render.GetRow = get_row_RGB24; data->render.GetValues = get_values_RGB24; data->render.PutRow = put_row_RGB24; + data->render.PutRowRGB = put_row_rgb_RGB24; data->render.PutMonoRow = put_mono_row_RGB24; data->render.PutValues = put_values_RGB24; data->render.PutMonoValues = put_mono_values_RGB24; @@ -838,6 +834,7 @@ directfbgl_create_context( GLcontext *context, data->render.GetRow = get_row_RGB32; data->render.GetValues = get_values_RGB32; data->render.PutRow = put_row_RGB32; + data->render.PutRowRGB = put_row_rgb_RGB32; data->render.PutMonoRow = put_mono_row_RGB32; data->render.PutValues = put_values_RGB32; data->render.PutMonoValues = put_mono_values_RGB32; @@ -846,6 +843,7 @@ directfbgl_create_context( GLcontext *context, data->render.GetRow = get_row_ARGB; data->render.GetValues = get_values_ARGB; data->render.PutRow = put_row_ARGB; + data->render.PutRowRGB = put_row_rgb_ARGB; data->render.PutMonoRow = put_mono_row_ARGB; data->render.PutValues = put_values_ARGB; data->render.PutMonoValues = put_mono_values_ARGB; @@ -854,6 +852,7 @@ directfbgl_create_context( GLcontext *context, data->render.GetRow = get_row_AiRGB; data->render.GetValues = get_values_AiRGB; data->render.PutRow = put_row_AiRGB; + data->render.PutRowRGB = put_row_rgb_AiRGB; data->render.PutMonoRow = put_mono_row_AiRGB; data->render.PutValues = put_values_AiRGB; data->render.PutMonoValues = put_mono_values_AiRGB; -- cgit v1.2.3 From 73fdecca9fdd9e63aa5e57bcd67911fbb761d318 Mon Sep 17 00:00:00 2001 From: Claudio Ciccani Date: Fri, 1 Dec 2006 14:12:05 +0000 Subject: Remove DirectFBGL header from Mesa bacause since 1.0.0 DirectFB installs its own header. Updated to the current DirectFBGL interface (i.e. added GetProcAddress()). --- src/mesa/drivers/directfb/idirectfbgl_mesa.c | 80 ++++++++++++++++++---------- 1 file changed, 52 insertions(+), 28 deletions(-) (limited to 'src/mesa/drivers/directfb') diff --git a/src/mesa/drivers/directfb/idirectfbgl_mesa.c b/src/mesa/drivers/directfb/idirectfbgl_mesa.c index eefc964889..f5bbd127c2 100644 --- a/src/mesa/drivers/directfb/idirectfbgl_mesa.c +++ b/src/mesa/drivers/directfb/idirectfbgl_mesa.c @@ -25,24 +25,16 @@ #include -#include -#include -#include - #include #include -#define VERSION_CODE( M, m, r ) (((M) * 1000) + ((m) * 100) + ((r))) -#define DIRECTFB_VERSION_CODE VERSION_CODE( DIRECTFB_MAJOR_VERSION, \ - DIRECTFB_MINOR_VERSION, \ - DIRECTFB_MICRO_VERSION ) - +#include -#ifdef CLAMP -# undef CLAMP -#endif +#include +#include +#include -#include "GL/directfbgl.h" +#undef CLAMP #include "glheader.h" #include "buffers.h" #include "context.h" @@ -62,6 +54,12 @@ #include "drivers/common/driverfuncs.h" +#define VERSION_CODE( M, m, r ) (((M) * 1000) + ((m) * 100) + ((r))) +#define DIRECTFB_VERSION_CODE VERSION_CODE( DIRECTFB_MAJOR_VERSION, \ + DIRECTFB_MINOR_VERSION, \ + DIRECTFB_MICRO_VERSION ) + + static DFBResult Probe( void *data ); @@ -79,7 +77,7 @@ DIRECT_INTERFACE_IMPLEMENTATION( IDirectFBGL, Mesa ) typedef struct { int ref; /* reference counter */ - DFBBoolean locked; + int locked; IDirectFBSurface *surface; DFBSurfacePixelFormat format; @@ -189,8 +187,10 @@ IDirectFBGL_Mesa_Lock( IDirectFBGL *thiz ) DIRECT_INTERFACE_GET_DATA( IDirectFBGL ); - if (data->locked) - return DFB_LOCKED; + if (data->locked) { + data->locked++; + return DFB_OK; + } if (directfbgl_lock()) return DFB_LOCKED; @@ -202,6 +202,7 @@ IDirectFBGL_Mesa_Lock( IDirectFBGL *thiz ) (void*)&data->video.start, &data->video.pitch ); if (ret) { D_ERROR( "DirectFBGL/Mesa: couldn't lock surface.\n" ); + directfbgl_unlock(); return ret; } data->video.end = data->video.start + (height-1) * data->video.pitch; @@ -218,7 +219,7 @@ IDirectFBGL_Mesa_Lock( IDirectFBGL *thiz ) &data->framebuffer, width, height); } - data->locked = DFB_TRUE; + data->locked++; return DFB_OK; } @@ -230,14 +231,14 @@ IDirectFBGL_Mesa_Unlock( IDirectFBGL *thiz ) if (!data->locked) return DFB_OK; - - _mesa_make_current( NULL, NULL, NULL ); + + if (--data->locked == 0) { + _mesa_make_current( NULL, NULL, NULL ); - data->surface->Unlock( data->surface ); - - directfbgl_unlock(); + data->surface->Unlock( data->surface ); - data->locked = DFB_FALSE; + directfbgl_unlock(); + } return DFB_OK; } @@ -276,6 +277,26 @@ IDirectFBGL_Mesa_GetAttributes( IDirectFBGL *thiz, return DFB_OK; } +#if DIRECTFBGL_INTERFACE_VERSION >= 1 +static DFBResult +IDirectFBGL_Mesa_GetProcAddress( IDirectFBGL *thiz, + const char *name, + void **ret_address ) +{ + DIRECT_INTERFACE_GET_DATA( IDirectFBGL ); + + if (!name) + return DFB_INVARG; + + if (!ret_address) + return DFB_INVARG; + + *ret_address = _glapi_get_proc_address( name ); + + return (*ret_address) ? DFB_OK : DFB_UNSUPPORTED; +} +#endif + /* exported symbols */ @@ -326,11 +347,14 @@ Construct( IDirectFBGL *thiz, IDirectFBSurface *surface ) } /* Assign interface pointers. */ - thiz->AddRef = IDirectFBGL_Mesa_AddRef; - thiz->Release = IDirectFBGL_Mesa_Release; - thiz->Lock = IDirectFBGL_Mesa_Lock; - thiz->Unlock = IDirectFBGL_Mesa_Unlock; - thiz->GetAttributes = IDirectFBGL_Mesa_GetAttributes; + thiz->AddRef = IDirectFBGL_Mesa_AddRef; + thiz->Release = IDirectFBGL_Mesa_Release; + thiz->Lock = IDirectFBGL_Mesa_Lock; + thiz->Unlock = IDirectFBGL_Mesa_Unlock; + thiz->GetAttributes = IDirectFBGL_Mesa_GetAttributes; +#if DIRECTFBGL_INTERFACE_VERSION >= 1 + thiz->GetProcAddress = IDirectFBGL_Mesa_GetProcAddress; +#endif return DFB_OK; } -- cgit v1.2.3 From e99d6746edeb80d73e356230dfe0d8ae8c643b65 Mon Sep 17 00:00:00 2001 From: Claudio Ciccani Date: Fri, 1 Dec 2006 20:58:26 +0000 Subject: Be aware that the surface storage can change between locks. --- src/mesa/drivers/directfb/idirectfbgl_mesa.c | 44 ++++++++++++++-------------- 1 file changed, 22 insertions(+), 22 deletions(-) (limited to 'src/mesa/drivers/directfb') diff --git a/src/mesa/drivers/directfb/idirectfbgl_mesa.c b/src/mesa/drivers/directfb/idirectfbgl_mesa.c index f5bbd127c2..3c8c6c256e 100644 --- a/src/mesa/drivers/directfb/idirectfbgl_mesa.c +++ b/src/mesa/drivers/directfb/idirectfbgl_mesa.c @@ -85,8 +85,8 @@ typedef struct { int height; struct { - __u8 *start; - __u8 *end; + GLubyte *start; + GLubyte *end; int pitch; } video; @@ -213,10 +213,10 @@ IDirectFBGL_Mesa_Lock( IDirectFBGL *thiz ) &data->framebuffer, &data->framebuffer ); if (data->width != width || data->height != height) { + _mesa_resize_framebuffer( &data->context, + &data->framebuffer, width, height ); data->width = width; - data->height = height; - _mesa_resize_framebuffer(&data->context, - &data->framebuffer, width, height); + data->height = height; } data->locked++; @@ -394,23 +394,21 @@ dfbGetBufferSize( GLframebuffer *buffer, GLuint *width, GLuint *height ) static void dfbSetViewport( GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h ) { - GLuint newWidth, newHeight; - GLframebuffer *buffer = ctx->WinSysDrawBuffer; - dfbGetBufferSize( buffer, &newWidth, &newHeight ); - if (buffer->Width != newWidth || buffer->Height != newHeight) { - _mesa_resize_framebuffer(ctx, buffer, newWidth, newHeight ); - } + /* Nothing to do (the surface can't be resized while it's locked). */ + return; } static void dfbClear( GLcontext *ctx, GLbitfield mask ) { IDirectFBGL_data *data = (IDirectFBGL_data*) ctx->DriverCtx; - - if (mask & BUFFER_BIT_FRONT_LEFT && - ctx->Color.ColorMask[0] && - ctx->Color.ColorMask[1] && - ctx->Color.ColorMask[2] && + +#define BUFFER_BIT_MASK (BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_FRONT_RIGHT | \ + BUFFER_BIT_BACK_LEFT | BUFFER_BIT_BACK_RIGHT ) + if (mask & BUFFER_BIT_MASK && + ctx->Color.ColorMask[0] && + ctx->Color.ColorMask[1] && + ctx->Color.ColorMask[2] && ctx->Color.ColorMask[3]) { DFBRegion clip; @@ -421,27 +419,29 @@ dfbClear( GLcontext *ctx, GLbitfield mask ) UNCLAMPED_FLOAT_TO_UBYTE( g, ctx->Color.ClearColor[GCOMP] ); UNCLAMPED_FLOAT_TO_UBYTE( b, ctx->Color.ClearColor[BCOMP] ); - data->surface->Unlock( data->surface ); - clip.x1 = ctx->DrawBuffer->_Xmin; clip.y1 = ctx->DrawBuffer->_Ymin; clip.x2 = ctx->DrawBuffer->_Xmax - 1; clip.y2 = ctx->DrawBuffer->_Ymax - 1; data->surface->SetClip( data->surface, &clip ); + data->surface->Unlock( data->surface ); + data->surface->Clear( data->surface, r, g, b, a ); data->surface->Lock( data->surface, DSLF_READ | DSLF_WRITE, (void*)&data->video.start, &data->video.pitch ); + data->video.end = data->video.start + (data->height-1) * data->video.pitch; + data->render.Data = data->video.start; - mask &= ~BUFFER_BIT_FRONT_LEFT; + mask &= ~BUFFER_BIT_MASK; } +#undef BUFFER_BIT_MASK if (mask) _swrast_Clear( ctx, mask ); -} - - +} + /************************ RenderBuffer functions *****************************/ -- cgit v1.2.3