Hi, I'd like to push the following patch, what do you think?
Alternatively, this could be done by statically defining the size of *data as gfx driver property and allocating / freeing it transparently, without the need for two extra callbacks. This would then be more similar to other subsystems, like extra system data, etc. Cheers, Andre'
>From 31f0933e1580233c2732da7faf9d80b1befd00d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Draszik?= <andre.dras...@st.com> Date: Thu, 29 Sep 2011 12:02:26 +0100 Subject: [PATCH] gfxcard / state: allow a graphics driver to hold extra state information Two new callbacks are added to GraphicsDeviceFuncs, that if set, will be called whenever a state is created or destroyed. This allows a graphics driver to store custom state specific data in CardState, which is useful if e.g. extra data needs to be preserved between calls to CheckState() and SetState(). --- src/core/gfxcard.c | 22 ++++++++++++++++++++++ src/core/gfxcard.h | 10 ++++++++++ src/core/state.c | 4 ++++ src/core/state.h | 2 ++ 4 files changed, 38 insertions(+), 0 deletions(-) diff --git a/src/core/gfxcard.c b/src/core/gfxcard.c index 5ace8e6..fd25eb3 100644 --- a/src/core/gfxcard.c +++ b/src/core/gfxcard.c @@ -910,6 +910,28 @@ dfb_gfxcard_state_release( CardState *state ) } } +void +dfb_gfxcard_state_init ( CardState *state ) +{ + D_ASSERT( card != NULL ); + D_ASSERT( card->shared != NULL ); + D_MAGIC_ASSERT( state, CardState ); + + if (!dfb_config->software_only && card->funcs.StateInit) + card->funcs.StateInit( card->driver_data, card->device_data, state ); +} + +void +dfb_gfxcard_state_destroy ( CardState *state ) +{ + D_ASSERT( card != NULL ); + D_ASSERT( card->shared != NULL ); + D_MAGIC_ASSERT( state, CardState ); + + if (!dfb_config->software_only && card->funcs.StateDestroy) + card->funcs.StateDestroy( card->driver_data, card->device_data, state ); +} + /** DRAWING FUNCTIONS **/ #define DFB_TRANSFORM(x, y, m, affine) \ diff --git a/src/core/gfxcard.h b/src/core/gfxcard.h index af782c3..68f304c 100644 --- a/src/core/gfxcard.h +++ b/src/core/gfxcard.h @@ -304,6 +304,13 @@ typedef struct _GraphicsDeviceFuncs { bool (*BatchFill)( void *driver_data, void *device_data, const DFBRectangle *rects, unsigned int num, unsigned int *ret_num ); + + /* + * callbacks when a state is created or destroyed. This allows a graphics + * driver to hold additional state. + */ + void (*StateInit) ( void *driver_data, void *device_data, CardState *state ); + void (*StateDestroy)( void *driver_data, void *device_data, CardState *state ); } GraphicsDeviceFuncs; typedef struct { @@ -344,6 +351,9 @@ void dfb_gfxcard_holdup( void ); bool dfb_gfxcard_state_check( CardState *state, DFBAccelerationMask accel ); +void dfb_gfxcard_state_init( CardState *state ); +void dfb_gfxcard_state_destroy( CardState *state ); + /* * Signal beginning of a sequence of operations using this state. * Any number of states can be 'drawing'. diff --git a/src/core/state.c b/src/core/state.c index 8853160..c10de4d 100644 --- a/src/core/state.c +++ b/src/core/state.c @@ -145,6 +145,8 @@ dfb_state_init( CardState *state, CoreDFB *core ) D_MAGIC_SET( state, CardState ); + dfb_gfxcard_state_init( state ); + return 0; } @@ -162,6 +164,8 @@ dfb_state_destroy( CardState *state ) D_MAGIC_CLEAR( state ); + dfb_gfxcard_state_destroy( state ); + direct_serial_deinit( &state->dst_serial ); direct_serial_deinit( &state->src_serial ); direct_serial_deinit( &state->src_mask_serial ); diff --git a/src/core/state.h b/src/core/state.h index e705a70..38d7686 100644 --- a/src/core/state.h +++ b/src/core/state.h @@ -204,6 +204,8 @@ struct _CardState { s32 src_colormatrix[12]; /* transformation matrix for DSBLIT_SRC_COLORMATRIX (fixed 16.16) */ DFBConvolutionFilter src_convolution; + + void *data; /* gfx driver specific state data */ }; int dfb_state_init( CardState *state, CoreDFB *core ); -- 1.7.1
_______________________________________________ directfb-dev mailing list directfb-dev@directfb.org http://mail.directfb.org/cgi-bin/mailman/listinfo/directfb-dev