Compare commits

..

2 Commits

Author SHA1 Message Date
Enrico Weigelt, metux IT consult ce2bcc0a4f miext: damage: tolerate NULL pointers in DamageScreenFuncsRec
For now that case doensn't practically happen yet - all fields are at
least assigned to some default/dummy function. But in the future, we
might wanna get rid of dummies.

From now on, video drivers are allowed to assign them to NULL, if they
don't wanna have the default implementations and nothing happening
at all instead (no more need for having their own empty dummies)

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-07-04 18:40:29 +02:00
Enrico Weigelt, metux IT consult 83a28d5af2 miext: damage: document DamageScreenFuncsRec
This struct (and associated functions) needs to be part of public driver ABI,
so video drivers can get notifications on damage certain operations, but
there hasn't been any documentation on it.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-07-04 18:40:29 +02:00
5 changed files with 31 additions and 58 deletions

View File

@ -370,23 +370,6 @@ ddxProcessArgument(int argc, char **argv, int i)
return KdProcessArgument(argc, argv, i);
}
static int
EphyrInit(void)
{
/*
* make sure at least one screen
* has been added to the system.
*/
if (!KdCardInfoLast()) {
processScreenArg("640x480", NULL);
}
return hostx_init();
}
KdOsFuncs EphyrOsFuncs = {
.Init = EphyrInit,
};
void
OsVendorInit(void)
{
@ -398,7 +381,12 @@ OsVendorInit(void)
if (hostx_want_host_cursor())
ephyrFuncs.initCursor = &ephyrCursorInit;
KdOsInit(&EphyrOsFuncs);
if (serverGeneration == 1) {
if (!KdCardInfoLast()) {
processScreenArg("640x480", NULL);
}
hostx_init();
}
}
KdCardFuncs ephyrFuncs = {

View File

@ -91,14 +91,6 @@ const char *kdGlobalXkbLayout = NULL;
const char *kdGlobalXkbVariant = NULL;
const char *kdGlobalXkbOptions = NULL;
/*
* Carry arguments from InitOutput through driver initialization
* to KdScreenInit
*/
KdOsFuncs *kdOsFuncs = NULL;
void
KdDisableScreen(ScreenPtr pScreen)
{
@ -525,19 +517,6 @@ KdProcessArgument(int argc, char **argv, int i)
return 0;
}
void
KdOsInit(KdOsFuncs * pOsFuncs)
{
kdOsFuncs = pOsFuncs;
if (pOsFuncs) {
if (serverGeneration == 1) {
KdDoSwitchCmd("start");
if (pOsFuncs->Init)
(*pOsFuncs->Init) ();
}
}
}
static Bool
KdAllocatePrivates(ScreenPtr pScreen)
{

View File

@ -278,16 +278,6 @@ int KdAddConfigKeyboard(char *pointer);
int KdAddKeyboard(KdKeyboardInfo * ki);
void KdRemoveKeyboard(KdKeyboardInfo * ki);
typedef struct _KdOsFuncs {
int (*Init) (void); /* Only called when the X server is started, when serverGeneration == 1 */
void (*Enable) (void);
Bool (*SpecialKey) (KeySym);
void (*Disable) (void);
void (*Fini) (void);
void (*pollEvents) (void);
void (*Bell) (int, int, int);
} KdOsFuncs;
typedef struct _KdPointerMatrix {
int matrix[2][3];
} KdPointerMatrix;
@ -299,8 +289,6 @@ extern DevPrivateKeyRec kdScreenPrivateKeyRec;
extern Bool kdEmulateMiddleButton;
extern Bool kdDisableZaphod;
extern KdOsFuncs *kdOsFuncs;
#define KdGetScreenPriv(pScreen) ((KdPrivScreenPtr) \
dixLookupPrivate(&(pScreen)->devPrivates, kdScreenPrivateKey))
#define KdSetScreenPriv(pScreen,v) \
@ -357,9 +345,6 @@ void
int
KdProcessArgument(int argc, char **argv, int i);
void
KdOsInit(KdOsFuncs * pOsFuncs);
void
KdOsAddInputDrivers(void);

View File

@ -1714,7 +1714,8 @@ DamageCreate(DamageReportFunc damageReport,
pDamage->damageDestroy = damageDestroy;
pDamage->pScreen = pScreen;
(*pScrPriv->funcs.Create) (pDamage);
if (pScrPriv->funcs.Create)
pScrPriv->funcs.Create (pDamage);
return pDamage;
}
@ -1755,7 +1756,8 @@ DamageRegister(DrawablePtr pDrawable, DamagePtr pDamage)
pDamage->isWindow = FALSE;
pDamage->pDrawable = pDrawable;
damageInsertDamage(getDrawableDamageRef(pDrawable), pDamage);
(*pScrPriv->funcs.Register) (pDrawable, pDamage);
if (pScrPriv->funcs.Register)
pScrPriv->funcs.Register (pDrawable, pDamage);
}
void
@ -1774,7 +1776,8 @@ DamageUnregister(DamagePtr pDamage)
damageScrPriv(pScreen);
(*pScrPriv->funcs.Unregister) (pDrawable, pDamage);
if (pScrPriv->funcs.Unregister)
pScrPriv->funcs.Unregister (pDrawable, pDamage);
if (pDrawable->type == DRAWABLE_WINDOW) {
WindowPtr pWindow = (WindowPtr) pDrawable;
@ -1817,7 +1820,10 @@ DamageDestroy(DamagePtr pDamage)
if (pDamage->damageDestroy)
(*pDamage->damageDestroy) (pDamage, pDamage->closure);
(*pScrPriv->funcs.Destroy) (pDamage);
if (pScrPriv->funcs.Destroy)
pScrPriv->funcs.Destroy (pDamage);
RegionUninit(&pDamage->damage);
RegionUninit(&pDamage->pendingDamage);
free(pDamage);

View File

@ -46,6 +46,21 @@ typedef void (*DamageScreenRegisterFunc) (DrawablePtr, DamagePtr);
typedef void (*DamageScreenUnregisterFunc) (DrawablePtr, DamagePtr);
typedef void (*DamageScreenDestroyFunc) (DamagePtr);
/* @public
*
* @brief Driver callbacks for getting notified on several damage calls
*
* The pointer to this struct can be obtained via DamageGetScreenFuncs().
* Drivers can inject themselves here, in order to get notified on
* DamageCreate(), DamageRegister(), DamageUnregister(), DamageDestroy().
*
* The fields may be assigned to NULL, if no action at all is wanted.
* (by default assigned to default implementations)
*
* This should ONLY be touched by video drivers, nobody else.
*
* So far the only one using it is the proprietary NVidia driver.
*/
typedef struct _damageScreenFuncs {
DamageScreenCreateFunc Create;
DamageScreenRegisterFunc Register;