xv: use embedded private instead of pointer
The private struct is pretty small and it needs to be allocated anyways, so save an extra allocation by directly embedding it. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
parent
2ad1d1d6cb
commit
7b00d306b3
|
@ -103,7 +103,7 @@ SOFTWARE.
|
||||||
#include "xvdisp.h"
|
#include "xvdisp.h"
|
||||||
|
|
||||||
#define SCREEN_PROLOGUE(pScreen, field) ((pScreen)->field = ((XvScreenPtr) \
|
#define SCREEN_PROLOGUE(pScreen, field) ((pScreen)->field = ((XvScreenPtr) \
|
||||||
dixLookupPrivate(&(pScreen)->devPrivates, XvScreenKey))->field)
|
dixLookupPrivate(&(pScreen)->devPrivates, &XvScreenKeyRec))->field)
|
||||||
|
|
||||||
#define SCREEN_EPILOGUE(pScreen, field, wrapper)\
|
#define SCREEN_EPILOGUE(pScreen, field, wrapper)\
|
||||||
((pScreen)->field = wrapper)
|
((pScreen)->field = wrapper)
|
||||||
|
@ -119,7 +119,6 @@ static DevPrivateKeyRec XvScreenKeyRec;
|
||||||
|
|
||||||
Bool noXvExtension = FALSE;
|
Bool noXvExtension = FALSE;
|
||||||
|
|
||||||
#define XvScreenKey (&XvScreenKeyRec)
|
|
||||||
static unsigned long XvExtensionGeneration = 0;
|
static unsigned long XvExtensionGeneration = 0;
|
||||||
static unsigned long XvScreenGeneration = 0;
|
static unsigned long XvScreenGeneration = 0;
|
||||||
static unsigned long XvResourceGeneration = 0;
|
static unsigned long XvResourceGeneration = 0;
|
||||||
|
@ -164,7 +163,7 @@ XvExtensionInit(void)
|
||||||
{
|
{
|
||||||
ExtensionEntry *extEntry;
|
ExtensionEntry *extEntry;
|
||||||
|
|
||||||
if (!dixRegisterPrivateKey(&XvScreenKeyRec, PRIVATE_SCREEN, 0))
|
if (!dixRegisterPrivateKey(&XvScreenKeyRec, PRIVATE_SCREEN, sizeof(XvScreenPtr)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Look to see if any screens were initialized; if not then
|
/* Look to see if any screens were initialized; if not then
|
||||||
|
@ -260,8 +259,6 @@ CreateResourceTypes(void)
|
||||||
int
|
int
|
||||||
XvScreenInit(ScreenPtr pScreen)
|
XvScreenInit(ScreenPtr pScreen)
|
||||||
{
|
{
|
||||||
XvScreenPtr pxvs;
|
|
||||||
|
|
||||||
if (XvScreenGeneration != serverGeneration) {
|
if (XvScreenGeneration != serverGeneration) {
|
||||||
if (!CreateResourceTypes()) {
|
if (!CreateResourceTypes()) {
|
||||||
ErrorF("XvScreenInit: Unable to allocate resource types\n");
|
ErrorF("XvScreenInit: Unable to allocate resource types\n");
|
||||||
|
@ -273,22 +270,14 @@ XvScreenInit(ScreenPtr pScreen)
|
||||||
XvScreenGeneration = serverGeneration;
|
XvScreenGeneration = serverGeneration;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!dixRegisterPrivateKey(&XvScreenKeyRec, PRIVATE_SCREEN, 0))
|
if (!dixRegisterPrivateKey(&XvScreenKeyRec, PRIVATE_SCREEN, sizeof(XvScreenPtr)))
|
||||||
return BadAlloc;
|
return BadAlloc;
|
||||||
|
|
||||||
if (dixLookupPrivate(&pScreen->devPrivates, XvScreenKey)) {
|
if (dixLookupPrivate(&pScreen->devPrivates, &XvScreenKeyRec)) {
|
||||||
ErrorF("XvScreenInit: screen devPrivates ptr non-NULL before init\n");
|
ErrorF("XvScreenInit: screen devPrivates ptr non-NULL before init\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ALLOCATE SCREEN PRIVATE RECORD */
|
XvScreenPtr pxvs = dixLookupPrivate(&pScreen->devPrivates, &XvScreenKeyRec);
|
||||||
|
|
||||||
pxvs = malloc(sizeof(XvScreenRec));
|
|
||||||
if (!pxvs) {
|
|
||||||
ErrorF("XvScreenInit: Unable to allocate screen private structure\n");
|
|
||||||
return BadAlloc;
|
|
||||||
}
|
|
||||||
|
|
||||||
dixSetPrivate(&pScreen->devPrivates, XvScreenKey, pxvs);
|
|
||||||
|
|
||||||
pxvs->DestroyPixmap = pScreen->DestroyPixmap;
|
pxvs->DestroyPixmap = pScreen->DestroyPixmap;
|
||||||
pxvs->DestroyWindow = pScreen->DestroyWindow;
|
pxvs->DestroyWindow = pScreen->DestroyWindow;
|
||||||
|
@ -304,19 +293,12 @@ XvScreenInit(ScreenPtr pScreen)
|
||||||
static Bool
|
static Bool
|
||||||
XvCloseScreen(ScreenPtr pScreen)
|
XvCloseScreen(ScreenPtr pScreen)
|
||||||
{
|
{
|
||||||
|
XvScreenPtr pxvs = dixLookupPrivate(&pScreen->devPrivates, &XvScreenKeyRec);
|
||||||
XvScreenPtr pxvs;
|
|
||||||
|
|
||||||
pxvs = (XvScreenPtr) dixLookupPrivate(&pScreen->devPrivates, XvScreenKey);
|
|
||||||
|
|
||||||
pScreen->DestroyPixmap = pxvs->DestroyPixmap;
|
pScreen->DestroyPixmap = pxvs->DestroyPixmap;
|
||||||
pScreen->DestroyWindow = pxvs->DestroyWindow;
|
pScreen->DestroyWindow = pxvs->DestroyWindow;
|
||||||
pScreen->CloseScreen = pxvs->CloseScreen;
|
pScreen->CloseScreen = pxvs->CloseScreen;
|
||||||
|
|
||||||
free(pxvs);
|
|
||||||
|
|
||||||
dixSetPrivate(&pScreen->devPrivates, XvScreenKey, NULL);
|
|
||||||
|
|
||||||
return (*pScreen->CloseScreen) (pScreen);
|
return (*pScreen->CloseScreen) (pScreen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -329,7 +311,7 @@ XvResetProc(ExtensionEntry * extEntry)
|
||||||
DevPrivateKey
|
DevPrivateKey
|
||||||
XvGetScreenKey(void)
|
XvGetScreenKey(void)
|
||||||
{
|
{
|
||||||
return XvScreenKey;
|
return &XvScreenKeyRec;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long
|
unsigned long
|
||||||
|
@ -342,7 +324,7 @@ static void
|
||||||
XvStopAdaptors(DrawablePtr pDrawable)
|
XvStopAdaptors(DrawablePtr pDrawable)
|
||||||
{
|
{
|
||||||
ScreenPtr pScreen = pDrawable->pScreen;
|
ScreenPtr pScreen = pDrawable->pScreen;
|
||||||
XvScreenPtr pxvs = dixLookupPrivate(&pScreen->devPrivates, XvScreenKey);
|
XvScreenPtr pxvs = dixLookupPrivate(&pScreen->devPrivates, &XvScreenKeyRec);
|
||||||
XvAdaptorPtr pa = pxvs->pAdaptors;
|
XvAdaptorPtr pa = pxvs->pAdaptors;
|
||||||
int na = pxvs->nAdaptors;
|
int na = pxvs->nAdaptors;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue