2003-11-25 20:29:01 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 1998-2001 by The XFree86 Project, Inc.
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
|
|
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
|
|
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
|
|
* OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
*
|
|
|
|
* Except as contained in this notice, the name of the copyright holder(s)
|
|
|
|
* and author(s) shall not be used in advertising or otherwise to promote
|
|
|
|
* the sale, use or other dealings in this Software without prior written
|
|
|
|
* authorization from the copyright holder(s) and author(s).
|
|
|
|
*/
|
2003-11-14 17:48:57 +01:00
|
|
|
|
2005-07-03 09:02:09 +02:00
|
|
|
#ifdef HAVE_XORG_CONFIG_H
|
|
|
|
#include <xorg-config.h>
|
|
|
|
#endif
|
|
|
|
|
2005-07-03 10:53:54 +02:00
|
|
|
#include "misc.h"
|
2003-11-14 17:48:57 +01:00
|
|
|
#include "xf86.h"
|
|
|
|
|
2005-04-20 14:25:48 +02:00
|
|
|
#include <X11/X.h>
|
2003-11-14 17:48:57 +01:00
|
|
|
#include "scrnintstr.h"
|
|
|
|
#include "regionstr.h"
|
|
|
|
#include "xf86fbman.h"
|
|
|
|
|
2003-11-25 20:29:01 +01:00
|
|
|
/*
|
|
|
|
#define DEBUG
|
|
|
|
*/
|
|
|
|
|
2010-04-27 02:22:21 +02:00
|
|
|
static DevPrivateKeyRec xf86FBManagerKeyRec;
|
2008-08-29 00:05:40 +02:00
|
|
|
static DevPrivateKey xf86FBManagerKey;
|
2003-11-14 17:48:57 +01:00
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
Bool xf86RegisterOffscreenManager(
|
2003-11-14 17:48:57 +01:00
|
|
|
ScreenPtr pScreen,
|
|
|
|
FBManagerFuncsPtr funcs
|
|
|
|
){
|
|
|
|
|
2010-04-27 02:22:21 +02:00
|
|
|
xf86FBManagerKey = &xf86FBManagerKeyRec;
|
|
|
|
|
|
|
|
if (!dixRegisterPrivateKey(&xf86FBManagerKeyRec, PRIVATE_SCREEN, 0))
|
|
|
|
return FALSE;
|
|
|
|
|
2007-08-28 15:28:25 +02:00
|
|
|
dixSetPrivate(&pScreen->devPrivates, xf86FBManagerKey, funcs);
|
2003-11-14 17:48:57 +01:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
Bool
|
2003-11-14 17:48:57 +01:00
|
|
|
xf86FBManagerRunning(ScreenPtr pScreen)
|
|
|
|
{
|
2010-04-27 02:22:21 +02:00
|
|
|
if (xf86FBManagerKey == NULL)
|
2003-11-14 17:48:57 +01:00
|
|
|
return FALSE;
|
2010-04-27 02:22:21 +02:00
|
|
|
|
2007-08-28 15:28:25 +02:00
|
|
|
if(!dixLookupPrivate(&pScreen->devPrivates, xf86FBManagerKey))
|
2003-11-14 17:48:57 +01:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
Bool
|
2003-11-14 17:48:57 +01:00
|
|
|
xf86RegisterFreeBoxCallback(
|
|
|
|
ScreenPtr pScreen,
|
|
|
|
FreeBoxCallbackProcPtr FreeBoxCallback,
|
|
|
|
pointer devPriv
|
|
|
|
){
|
|
|
|
FBManagerFuncsPtr funcs;
|
|
|
|
|
2007-08-28 15:28:25 +02:00
|
|
|
if(xf86FBManagerKey == NULL)
|
2003-11-14 17:48:57 +01:00
|
|
|
return FALSE;
|
2007-08-28 15:28:25 +02:00
|
|
|
if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate(&pScreen->devPrivates,
|
|
|
|
xf86FBManagerKey)))
|
2003-11-14 17:48:57 +01:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return (*funcs->RegisterFreeBoxCallback)(pScreen, FreeBoxCallback, devPriv);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
FBAreaPtr
|
2003-11-14 17:48:57 +01:00
|
|
|
xf86AllocateOffscreenArea(
|
|
|
|
ScreenPtr pScreen,
|
|
|
|
int w, int h,
|
|
|
|
int gran,
|
|
|
|
MoveAreaCallbackProcPtr moveCB,
|
|
|
|
RemoveAreaCallbackProcPtr removeCB,
|
|
|
|
pointer privData
|
|
|
|
){
|
|
|
|
FBManagerFuncsPtr funcs;
|
|
|
|
|
2007-08-28 15:28:25 +02:00
|
|
|
if(xf86FBManagerKey == NULL)
|
2003-11-14 17:48:57 +01:00
|
|
|
return NULL;
|
2007-08-28 15:28:25 +02:00
|
|
|
if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate(&pScreen->devPrivates,
|
|
|
|
xf86FBManagerKey)))
|
2003-11-14 17:48:57 +01:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return (*funcs->AllocateOffscreenArea)(
|
|
|
|
pScreen, w, h, gran, moveCB, removeCB, privData);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
FBLinearPtr
|
2003-11-14 17:48:57 +01:00
|
|
|
xf86AllocateOffscreenLinear(
|
|
|
|
ScreenPtr pScreen,
|
|
|
|
int length,
|
|
|
|
int gran,
|
|
|
|
MoveLinearCallbackProcPtr moveCB,
|
|
|
|
RemoveLinearCallbackProcPtr removeCB,
|
|
|
|
pointer privData
|
|
|
|
){
|
|
|
|
FBManagerFuncsPtr funcs;
|
|
|
|
|
2007-08-28 15:28:25 +02:00
|
|
|
if(xf86FBManagerKey == NULL)
|
2003-11-14 17:48:57 +01:00
|
|
|
return NULL;
|
2007-08-28 15:28:25 +02:00
|
|
|
if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate(&pScreen->devPrivates,
|
|
|
|
xf86FBManagerKey)))
|
2003-11-14 17:48:57 +01:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return (*funcs->AllocateOffscreenLinear)(
|
|
|
|
pScreen, length, gran, moveCB, removeCB, privData);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
void
|
2003-11-14 17:48:57 +01:00
|
|
|
xf86FreeOffscreenArea(FBAreaPtr area)
|
|
|
|
{
|
|
|
|
FBManagerFuncsPtr funcs;
|
|
|
|
|
|
|
|
if(!area) return;
|
|
|
|
|
2007-08-28 15:28:25 +02:00
|
|
|
if(xf86FBManagerKey == NULL)
|
2003-11-14 17:48:57 +01:00
|
|
|
return;
|
2007-08-28 15:28:25 +02:00
|
|
|
if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate(
|
|
|
|
&area->pScreen->devPrivates, xf86FBManagerKey)))
|
2003-11-14 17:48:57 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
(*funcs->FreeOffscreenArea)(area);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
void
|
2003-11-25 20:29:01 +01:00
|
|
|
xf86FreeOffscreenLinear(FBLinearPtr linear)
|
2003-11-14 17:48:57 +01:00
|
|
|
{
|
|
|
|
FBManagerFuncsPtr funcs;
|
|
|
|
|
2003-11-25 20:29:01 +01:00
|
|
|
if(!linear) return;
|
2003-11-14 17:48:57 +01:00
|
|
|
|
2007-08-28 15:28:25 +02:00
|
|
|
if(xf86FBManagerKey == NULL)
|
2003-11-14 17:48:57 +01:00
|
|
|
return;
|
2007-08-28 15:28:25 +02:00
|
|
|
if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate(
|
|
|
|
&linear->pScreen->devPrivates, xf86FBManagerKey)))
|
2003-11-14 17:48:57 +01:00
|
|
|
return;
|
|
|
|
|
2003-11-25 20:29:01 +01:00
|
|
|
(*funcs->FreeOffscreenLinear)(linear);
|
2003-11-14 17:48:57 +01:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
Bool
|
2003-11-14 17:48:57 +01:00
|
|
|
xf86ResizeOffscreenArea(
|
|
|
|
FBAreaPtr resize,
|
|
|
|
int w, int h
|
|
|
|
){
|
|
|
|
FBManagerFuncsPtr funcs;
|
|
|
|
|
|
|
|
if(!resize) return FALSE;
|
|
|
|
|
2007-08-28 15:28:25 +02:00
|
|
|
if(xf86FBManagerKey == NULL)
|
2003-11-14 17:48:57 +01:00
|
|
|
return FALSE;
|
2007-08-28 15:28:25 +02:00
|
|
|
if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate(
|
|
|
|
&resize->pScreen->devPrivates, xf86FBManagerKey)))
|
2003-11-14 17:48:57 +01:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return (*funcs->ResizeOffscreenArea)(resize, w, h);
|
|
|
|
}
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
Bool
|
2003-11-14 17:48:57 +01:00
|
|
|
xf86ResizeOffscreenLinear(
|
|
|
|
FBLinearPtr resize,
|
|
|
|
int size
|
|
|
|
){
|
|
|
|
FBManagerFuncsPtr funcs;
|
|
|
|
|
|
|
|
if(!resize) return FALSE;
|
|
|
|
|
2007-08-28 15:28:25 +02:00
|
|
|
if(xf86FBManagerKey == NULL)
|
2003-11-14 17:48:57 +01:00
|
|
|
return FALSE;
|
2007-08-28 15:28:25 +02:00
|
|
|
if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate(
|
|
|
|
&resize->pScreen->devPrivates, xf86FBManagerKey)))
|
2003-11-14 17:48:57 +01:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return (*funcs->ResizeOffscreenLinear)(resize, size);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
Bool
|
2003-11-14 17:48:57 +01:00
|
|
|
xf86QueryLargestOffscreenArea(
|
|
|
|
ScreenPtr pScreen,
|
|
|
|
int *w, int *h,
|
|
|
|
int gran,
|
|
|
|
int preferences,
|
|
|
|
int severity
|
|
|
|
){
|
|
|
|
FBManagerFuncsPtr funcs;
|
|
|
|
|
|
|
|
*w = 0;
|
|
|
|
*h = 0;
|
|
|
|
|
2007-08-28 15:28:25 +02:00
|
|
|
if(xf86FBManagerKey == NULL)
|
2003-11-14 17:48:57 +01:00
|
|
|
return FALSE;
|
2007-08-28 15:28:25 +02:00
|
|
|
if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate(&pScreen->devPrivates,
|
|
|
|
xf86FBManagerKey)))
|
2003-11-14 17:48:57 +01:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return (*funcs->QueryLargestOffscreenArea)(
|
|
|
|
pScreen, w, h, gran, preferences, severity);
|
|
|
|
}
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
Bool
|
2003-11-14 17:48:57 +01:00
|
|
|
xf86QueryLargestOffscreenLinear(
|
|
|
|
ScreenPtr pScreen,
|
|
|
|
int *size,
|
|
|
|
int gran,
|
|
|
|
int severity
|
|
|
|
){
|
|
|
|
FBManagerFuncsPtr funcs;
|
|
|
|
|
|
|
|
*size = 0;
|
|
|
|
|
2007-08-28 15:28:25 +02:00
|
|
|
if(xf86FBManagerKey == NULL)
|
2003-11-14 17:48:57 +01:00
|
|
|
return FALSE;
|
2007-08-28 15:28:25 +02:00
|
|
|
if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate(&pScreen->devPrivates,
|
|
|
|
xf86FBManagerKey)))
|
2003-11-14 17:48:57 +01:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return (*funcs->QueryLargestOffscreenLinear)(
|
|
|
|
pScreen, size, gran, severity);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
Bool
|
2003-11-14 17:48:57 +01:00
|
|
|
xf86PurgeUnlockedOffscreenAreas(ScreenPtr pScreen)
|
|
|
|
{
|
|
|
|
FBManagerFuncsPtr funcs;
|
|
|
|
|
2007-08-28 15:28:25 +02:00
|
|
|
if(xf86FBManagerKey == NULL)
|
2003-11-14 17:48:57 +01:00
|
|
|
return FALSE;
|
2007-08-28 15:28:25 +02:00
|
|
|
if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate(&pScreen->devPrivates,
|
|
|
|
xf86FBManagerKey)))
|
2003-11-14 17:48:57 +01:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return (*funcs->PurgeOffscreenAreas)(pScreen);
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************\
|
|
|
|
|
|
|
|
Below is a specific implementation of an offscreen manager.
|
|
|
|
|
|
|
|
\************************************************************/
|
|
|
|
|
2010-04-27 02:22:21 +02:00
|
|
|
static DevPrivateKeyRec xf86FBScreenKeyRec;
|
|
|
|
#define xf86FBScreenKey (&xf86FBScreenKeyRec)
|
2003-11-14 17:48:57 +01:00
|
|
|
|
|
|
|
typedef struct _FBLink {
|
|
|
|
FBArea area;
|
|
|
|
struct _FBLink *next;
|
|
|
|
} FBLink, *FBLinkPtr;
|
|
|
|
|
|
|
|
typedef struct _FBLinearLink {
|
2003-11-25 20:29:01 +01:00
|
|
|
FBLinear linear;
|
|
|
|
int free; /* need to add free here as FBLinear is publicly accessible */
|
|
|
|
FBAreaPtr area; /* only used if allocation came from XY area */
|
2003-11-14 17:48:57 +01:00
|
|
|
struct _FBLinearLink *next;
|
|
|
|
} FBLinearLink, *FBLinearLinkPtr;
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
2003-11-25 20:29:01 +01:00
|
|
|
ScreenPtr pScreen;
|
|
|
|
RegionPtr InitialBoxes;
|
|
|
|
RegionPtr FreeBoxes;
|
|
|
|
FBLinkPtr UsedAreas;
|
|
|
|
int NumUsedAreas;
|
2003-11-14 17:48:57 +01:00
|
|
|
FBLinearLinkPtr LinearAreas;
|
|
|
|
CloseScreenProcPtr CloseScreen;
|
|
|
|
int NumCallbacks;
|
|
|
|
FreeBoxCallbackProcPtr *FreeBoxesUpdateCallback;
|
|
|
|
DevUnion *devPrivates;
|
|
|
|
} FBManager, *FBManagerPtr;
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
SendCallFreeBoxCallbacks(FBManagerPtr offman)
|
|
|
|
{
|
|
|
|
int i = offman->NumCallbacks;
|
|
|
|
|
|
|
|
while(i--) {
|
|
|
|
(*offman->FreeBoxesUpdateCallback[i])(
|
|
|
|
offman->pScreen, offman->FreeBoxes, offman->devPrivates[i].ptr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static Bool
|
|
|
|
localRegisterFreeBoxCallback(
|
|
|
|
ScreenPtr pScreen,
|
|
|
|
FreeBoxCallbackProcPtr FreeBoxCallback,
|
|
|
|
pointer devPriv
|
|
|
|
){
|
|
|
|
FBManagerPtr offman;
|
|
|
|
FreeBoxCallbackProcPtr *newCallbacks;
|
|
|
|
DevUnion *newPrivates;
|
|
|
|
|
2007-08-28 15:28:25 +02:00
|
|
|
offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates,
|
|
|
|
xf86FBScreenKey);
|
2010-05-05 20:44:06 +02:00
|
|
|
newCallbacks = realloc( offman->FreeBoxesUpdateCallback,
|
2003-11-14 17:48:57 +01:00
|
|
|
sizeof(FreeBoxCallbackProcPtr) * (offman->NumCallbacks + 1));
|
|
|
|
|
2010-05-05 20:44:06 +02:00
|
|
|
newPrivates = realloc(offman->devPrivates,
|
2003-11-14 17:48:57 +01:00
|
|
|
sizeof(DevUnion) * (offman->NumCallbacks + 1));
|
|
|
|
|
|
|
|
if(!newCallbacks || !newPrivates)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
offman->FreeBoxesUpdateCallback = newCallbacks;
|
|
|
|
offman->devPrivates = newPrivates;
|
|
|
|
|
|
|
|
offman->FreeBoxesUpdateCallback[offman->NumCallbacks] = FreeBoxCallback;
|
|
|
|
offman->devPrivates[offman->NumCallbacks].ptr = devPriv;
|
|
|
|
offman->NumCallbacks++;
|
|
|
|
|
|
|
|
SendCallFreeBoxCallbacks(offman);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static FBAreaPtr
|
|
|
|
AllocateArea(
|
|
|
|
FBManagerPtr offman,
|
|
|
|
int w, int h,
|
|
|
|
int granularity,
|
|
|
|
MoveAreaCallbackProcPtr moveCB,
|
|
|
|
RemoveAreaCallbackProcPtr removeCB,
|
|
|
|
pointer privData
|
|
|
|
){
|
|
|
|
ScreenPtr pScreen = offman->pScreen;
|
|
|
|
FBLinkPtr link = NULL;
|
|
|
|
FBAreaPtr area = NULL;
|
|
|
|
RegionRec NewReg;
|
|
|
|
int i, x = 0, num;
|
|
|
|
BoxPtr boxp;
|
|
|
|
|
|
|
|
if(granularity <= 1) granularity = 0;
|
|
|
|
|
2010-05-22 00:05:48 +02:00
|
|
|
boxp = RegionRects(offman->FreeBoxes);
|
|
|
|
num = RegionNumRects(offman->FreeBoxes);
|
2003-11-14 17:48:57 +01:00
|
|
|
|
|
|
|
/* look through the free boxes */
|
|
|
|
for(i = 0; i < num; i++, boxp++) {
|
|
|
|
x = boxp->x1;
|
2006-12-24 05:28:21 +01:00
|
|
|
if (granularity > 1)
|
|
|
|
x = ((x + granularity - 1) / granularity) * granularity;
|
2003-11-14 17:48:57 +01:00
|
|
|
|
|
|
|
if(((boxp->y2 - boxp->y1) < h) || ((boxp->x2 - x) < w))
|
|
|
|
continue;
|
|
|
|
|
2010-05-05 20:44:06 +02:00
|
|
|
link = malloc(sizeof(FBLink));
|
2003-11-14 17:48:57 +01:00
|
|
|
if(!link) return NULL;
|
|
|
|
|
|
|
|
area = &(link->area);
|
|
|
|
link->next = offman->UsedAreas;
|
|
|
|
offman->UsedAreas = link;
|
|
|
|
offman->NumUsedAreas++;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* try to boot a removeable one out if we are not expendable ourselves */
|
|
|
|
if(!area && !removeCB) {
|
|
|
|
link = offman->UsedAreas;
|
|
|
|
|
|
|
|
while(link) {
|
|
|
|
if(!link->area.RemoveAreaCallback) {
|
|
|
|
link = link->next;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
boxp = &(link->area.box);
|
|
|
|
x = boxp->x1;
|
2006-12-24 05:28:21 +01:00
|
|
|
if (granularity > 1)
|
|
|
|
x = ((x + granularity - 1) / granularity) * granularity;
|
2003-11-14 17:48:57 +01:00
|
|
|
|
|
|
|
if(((boxp->y2 - boxp->y1) < h) || ((boxp->x2 - x) < w)) {
|
|
|
|
link = link->next;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* bye, bye */
|
|
|
|
(*link->area.RemoveAreaCallback)(&link->area);
|
2010-05-22 00:05:48 +02:00
|
|
|
RegionInit(&NewReg, &(link->area.box), 1);
|
|
|
|
RegionUnion(offman->FreeBoxes, offman->FreeBoxes, &NewReg);
|
|
|
|
RegionUninit(&NewReg);
|
2003-11-14 17:48:57 +01:00
|
|
|
|
|
|
|
area = &(link->area);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(area) {
|
|
|
|
area->pScreen = pScreen;
|
|
|
|
area->granularity = granularity;
|
|
|
|
area->box.x1 = x;
|
|
|
|
area->box.x2 = x + w;
|
|
|
|
area->box.y1 = boxp->y1;
|
|
|
|
area->box.y2 = boxp->y1 + h;
|
|
|
|
area->MoveAreaCallback = moveCB;
|
|
|
|
area->RemoveAreaCallback = removeCB;
|
|
|
|
area->devPrivate.ptr = privData;
|
|
|
|
|
2010-05-22 00:05:48 +02:00
|
|
|
RegionInit(&NewReg, &(area->box), 1);
|
|
|
|
RegionSubtract(offman->FreeBoxes, offman->FreeBoxes, &NewReg);
|
|
|
|
RegionUninit(&NewReg);
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return area;
|
|
|
|
}
|
|
|
|
|
|
|
|
static FBAreaPtr
|
|
|
|
localAllocateOffscreenArea(
|
|
|
|
ScreenPtr pScreen,
|
|
|
|
int w, int h,
|
|
|
|
int gran,
|
|
|
|
MoveAreaCallbackProcPtr moveCB,
|
|
|
|
RemoveAreaCallbackProcPtr removeCB,
|
|
|
|
pointer privData
|
|
|
|
){
|
|
|
|
FBManagerPtr offman;
|
|
|
|
FBAreaPtr area = NULL;
|
|
|
|
|
2007-08-28 15:28:25 +02:00
|
|
|
offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates,
|
|
|
|
xf86FBScreenKey);
|
2003-11-14 17:48:57 +01:00
|
|
|
if((area = AllocateArea(offman, w, h, gran, moveCB, removeCB, privData)))
|
|
|
|
SendCallFreeBoxCallbacks(offman);
|
|
|
|
|
|
|
|
return area;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
localFreeOffscreenArea(FBAreaPtr area)
|
|
|
|
{
|
|
|
|
FBManagerPtr offman;
|
|
|
|
FBLinkPtr pLink, pLinkPrev = NULL;
|
|
|
|
RegionRec FreedRegion;
|
|
|
|
ScreenPtr pScreen;
|
|
|
|
|
|
|
|
pScreen = area->pScreen;
|
2007-08-28 15:28:25 +02:00
|
|
|
offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates,
|
|
|
|
xf86FBScreenKey);
|
2003-11-14 17:48:57 +01:00
|
|
|
pLink = offman->UsedAreas;
|
|
|
|
if(!pLink) return;
|
|
|
|
|
|
|
|
while(&(pLink->area) != area) {
|
|
|
|
pLinkPrev = pLink;
|
|
|
|
pLink = pLink->next;
|
|
|
|
if(!pLink) return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* put the area back into the pool */
|
2010-05-22 00:05:48 +02:00
|
|
|
RegionInit(&FreedRegion, &(pLink->area.box), 1);
|
|
|
|
RegionUnion(offman->FreeBoxes, offman->FreeBoxes, &FreedRegion);
|
|
|
|
RegionUninit(&FreedRegion);
|
2003-11-14 17:48:57 +01:00
|
|
|
|
|
|
|
if(pLinkPrev)
|
|
|
|
pLinkPrev->next = pLink->next;
|
|
|
|
else offman->UsedAreas = pLink->next;
|
|
|
|
|
2010-05-05 20:44:06 +02:00
|
|
|
free(pLink);
|
2003-11-14 17:48:57 +01:00
|
|
|
offman->NumUsedAreas--;
|
|
|
|
|
|
|
|
SendCallFreeBoxCallbacks(offman);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static Bool
|
|
|
|
localResizeOffscreenArea(
|
|
|
|
FBAreaPtr resize,
|
|
|
|
int w, int h
|
|
|
|
){
|
|
|
|
FBManagerPtr offman;
|
|
|
|
ScreenPtr pScreen;
|
|
|
|
BoxRec OrigArea;
|
|
|
|
RegionRec FreedReg;
|
|
|
|
FBAreaPtr area = NULL;
|
|
|
|
FBLinkPtr pLink, newLink, pLinkPrev = NULL;
|
|
|
|
|
|
|
|
pScreen = resize->pScreen;
|
2007-08-28 15:28:25 +02:00
|
|
|
offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates,
|
|
|
|
xf86FBScreenKey);
|
2003-11-14 17:48:57 +01:00
|
|
|
/* find this link */
|
|
|
|
if(!(pLink = offman->UsedAreas))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
while(&(pLink->area) != resize) {
|
|
|
|
pLinkPrev = pLink;
|
|
|
|
pLink = pLink->next;
|
|
|
|
if(!pLink) return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
OrigArea.x1 = resize->box.x1;
|
|
|
|
OrigArea.x2 = resize->box.x2;
|
|
|
|
OrigArea.y1 = resize->box.y1;
|
|
|
|
OrigArea.y2 = resize->box.y2;
|
|
|
|
|
|
|
|
/* if it's smaller, this is easy */
|
|
|
|
|
|
|
|
if((w <= (resize->box.x2 - resize->box.x1)) &&
|
|
|
|
(h <= (resize->box.y2 - resize->box.y1))) {
|
|
|
|
RegionRec NewReg;
|
|
|
|
|
|
|
|
resize->box.x2 = resize->box.x1 + w;
|
|
|
|
resize->box.y2 = resize->box.y1 + h;
|
|
|
|
|
|
|
|
if((resize->box.y2 == OrigArea.y2) &&
|
|
|
|
(resize->box.x2 == OrigArea.x2))
|
|
|
|
return TRUE;
|
|
|
|
|
2010-05-22 00:05:48 +02:00
|
|
|
RegionInit(&FreedReg, &OrigArea, 1);
|
|
|
|
RegionInit(&NewReg, &(resize->box), 1);
|
|
|
|
RegionSubtract(&FreedReg, &FreedReg, &NewReg);
|
|
|
|
RegionUnion(offman->FreeBoxes, offman->FreeBoxes, &FreedReg);
|
|
|
|
RegionUninit(&FreedReg);
|
|
|
|
RegionUninit(&NewReg);
|
2003-11-14 17:48:57 +01:00
|
|
|
|
|
|
|
SendCallFreeBoxCallbacks(offman);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* otherwise we remove the old region */
|
|
|
|
|
2010-05-22 00:05:48 +02:00
|
|
|
RegionInit(&FreedReg, &OrigArea, 1);
|
|
|
|
RegionUnion(offman->FreeBoxes, offman->FreeBoxes, &FreedReg);
|
2003-11-14 17:48:57 +01:00
|
|
|
|
|
|
|
/* remove the old link */
|
|
|
|
if(pLinkPrev)
|
|
|
|
pLinkPrev->next = pLink->next;
|
|
|
|
else offman->UsedAreas = pLink->next;
|
|
|
|
|
|
|
|
/* and try to add a new one */
|
|
|
|
|
|
|
|
if((area = AllocateArea(offman, w, h, resize->granularity,
|
|
|
|
resize->MoveAreaCallback, resize->RemoveAreaCallback,
|
|
|
|
resize->devPrivate.ptr))) {
|
|
|
|
|
|
|
|
/* copy data over to our link and replace the new with old */
|
|
|
|
memcpy(resize, area, sizeof(FBArea));
|
|
|
|
|
|
|
|
pLinkPrev = NULL;
|
|
|
|
newLink = offman->UsedAreas;
|
|
|
|
|
|
|
|
while(&(newLink->area) != area) {
|
|
|
|
pLinkPrev = newLink;
|
|
|
|
newLink = newLink->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(pLinkPrev)
|
|
|
|
pLinkPrev->next = newLink->next;
|
|
|
|
else offman->UsedAreas = newLink->next;
|
|
|
|
|
|
|
|
pLink->next = offman->UsedAreas;
|
|
|
|
offman->UsedAreas = pLink;
|
|
|
|
|
2010-05-05 20:44:06 +02:00
|
|
|
free(newLink);
|
2003-11-14 17:48:57 +01:00
|
|
|
|
|
|
|
/* AllocateArea added one but we really only exchanged one */
|
|
|
|
offman->NumUsedAreas--;
|
|
|
|
} else {
|
|
|
|
/* reinstate the old region */
|
2010-05-22 00:05:48 +02:00
|
|
|
RegionSubtract(offman->FreeBoxes, offman->FreeBoxes, &FreedReg);
|
|
|
|
RegionUninit(&FreedReg);
|
2003-11-14 17:48:57 +01:00
|
|
|
|
|
|
|
pLink->next = offman->UsedAreas;
|
|
|
|
offman->UsedAreas = pLink;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-05-22 00:05:48 +02:00
|
|
|
RegionUninit(&FreedReg);
|
2003-11-14 17:48:57 +01:00
|
|
|
|
|
|
|
SendCallFreeBoxCallbacks(offman);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Bool
|
|
|
|
localQueryLargestOffscreenArea(
|
|
|
|
ScreenPtr pScreen,
|
|
|
|
int *width, int *height,
|
|
|
|
int granularity,
|
|
|
|
int preferences,
|
|
|
|
int severity
|
|
|
|
){
|
|
|
|
FBManagerPtr offman;
|
|
|
|
RegionPtr newRegion = NULL;
|
|
|
|
BoxPtr pbox;
|
|
|
|
int nbox;
|
|
|
|
int x, w, h, area, oldArea;
|
|
|
|
|
|
|
|
*width = *height = oldArea = 0;
|
|
|
|
|
|
|
|
if(granularity <= 1) granularity = 0;
|
|
|
|
|
|
|
|
if((preferences < 0) || (preferences > 3))
|
|
|
|
return FALSE;
|
|
|
|
|
2007-08-28 15:28:25 +02:00
|
|
|
offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates,
|
|
|
|
xf86FBScreenKey);
|
2003-11-14 17:48:57 +01:00
|
|
|
if(severity < 0) severity = 0;
|
|
|
|
if(severity > 2) severity = 2;
|
|
|
|
|
|
|
|
switch(severity) {
|
|
|
|
case 2:
|
|
|
|
if(offman->NumUsedAreas) {
|
|
|
|
FBLinkPtr pLink;
|
|
|
|
RegionRec tmpRegion;
|
2010-05-22 00:05:48 +02:00
|
|
|
newRegion = RegionCreate(NULL, 1);
|
|
|
|
RegionCopy(newRegion, offman->InitialBoxes);
|
2003-11-14 17:48:57 +01:00
|
|
|
pLink = offman->UsedAreas;
|
|
|
|
|
|
|
|
while(pLink) {
|
|
|
|
if(!pLink->area.RemoveAreaCallback) {
|
2010-05-22 00:05:48 +02:00
|
|
|
RegionInit(&tmpRegion, &(pLink->area.box), 1);
|
|
|
|
RegionSubtract(newRegion, newRegion, &tmpRegion);
|
|
|
|
RegionUninit(&tmpRegion);
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
|
|
|
pLink = pLink->next;
|
|
|
|
}
|
|
|
|
|
2010-05-22 00:05:48 +02:00
|
|
|
nbox = RegionNumRects(newRegion);
|
|
|
|
pbox = RegionRects(newRegion);
|
2003-11-14 17:48:57 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 1:
|
|
|
|
if(offman->NumUsedAreas) {
|
|
|
|
FBLinkPtr pLink;
|
|
|
|
RegionRec tmpRegion;
|
2010-05-22 00:05:48 +02:00
|
|
|
newRegion = RegionCreate(NULL, 1);
|
|
|
|
RegionCopy(newRegion, offman->FreeBoxes);
|
2003-11-14 17:48:57 +01:00
|
|
|
pLink = offman->UsedAreas;
|
|
|
|
|
|
|
|
while(pLink) {
|
|
|
|
if(pLink->area.RemoveAreaCallback) {
|
2010-05-22 00:05:48 +02:00
|
|
|
RegionInit(&tmpRegion, &(pLink->area.box), 1);
|
|
|
|
RegionAppend(newRegion, &tmpRegion);
|
|
|
|
RegionUninit(&tmpRegion);
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
|
|
|
pLink = pLink->next;
|
|
|
|
}
|
|
|
|
|
2010-05-22 00:05:48 +02:00
|
|
|
nbox = RegionNumRects(newRegion);
|
|
|
|
pbox = RegionRects(newRegion);
|
2003-11-14 17:48:57 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
2010-05-22 00:05:48 +02:00
|
|
|
nbox = RegionNumRects(offman->FreeBoxes);
|
|
|
|
pbox = RegionRects(offman->FreeBoxes);
|
2003-11-14 17:48:57 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
while(nbox--) {
|
|
|
|
x = pbox->x1;
|
2006-12-24 05:28:21 +01:00
|
|
|
if (granularity > 1)
|
|
|
|
x = ((x + granularity - 1) / granularity) * granularity;
|
2003-11-14 17:48:57 +01:00
|
|
|
|
|
|
|
w = pbox->x2 - x;
|
|
|
|
h = pbox->y2 - pbox->y1;
|
|
|
|
area = w * h;
|
|
|
|
|
|
|
|
if(w > 0) {
|
|
|
|
Bool gotIt = FALSE;
|
|
|
|
switch(preferences) {
|
|
|
|
case FAVOR_AREA_THEN_WIDTH:
|
|
|
|
if((area > oldArea) || ((area == oldArea) && (w > *width)))
|
|
|
|
gotIt = TRUE;
|
|
|
|
break;
|
|
|
|
case FAVOR_AREA_THEN_HEIGHT:
|
|
|
|
if((area > oldArea) || ((area == oldArea) && (h > *height)))
|
|
|
|
gotIt = TRUE;
|
|
|
|
break;
|
|
|
|
case FAVOR_WIDTH_THEN_AREA:
|
|
|
|
if((w > *width) || ((w == *width) && (area > oldArea)))
|
|
|
|
gotIt = TRUE;
|
|
|
|
break;
|
|
|
|
case FAVOR_HEIGHT_THEN_AREA:
|
|
|
|
if((h > *height) || ((h == *height) && (area > oldArea)))
|
|
|
|
gotIt = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if(gotIt) {
|
|
|
|
*width = w;
|
|
|
|
*height = h;
|
|
|
|
oldArea = area;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pbox++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(newRegion)
|
2010-05-22 00:05:48 +02:00
|
|
|
RegionDestroy(newRegion);
|
2003-11-14 17:48:57 +01:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Bool
|
|
|
|
localPurgeUnlockedOffscreenAreas(ScreenPtr pScreen)
|
|
|
|
{
|
|
|
|
FBManagerPtr offman;
|
|
|
|
FBLinkPtr pLink, tmp, pPrev = NULL;
|
|
|
|
RegionRec FreedRegion;
|
|
|
|
Bool anyUsed = FALSE;
|
|
|
|
|
2007-08-28 15:28:25 +02:00
|
|
|
offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates,
|
|
|
|
xf86FBScreenKey);
|
2003-11-14 17:48:57 +01:00
|
|
|
pLink = offman->UsedAreas;
|
|
|
|
if(!pLink) return TRUE;
|
|
|
|
|
|
|
|
while(pLink) {
|
|
|
|
if(pLink->area.RemoveAreaCallback) {
|
|
|
|
(*pLink->area.RemoveAreaCallback)(&pLink->area);
|
|
|
|
|
2010-05-22 00:05:48 +02:00
|
|
|
RegionInit(&FreedRegion, &(pLink->area.box), 1);
|
|
|
|
RegionAppend(offman->FreeBoxes, &FreedRegion);
|
|
|
|
RegionUninit(&FreedRegion);
|
2003-11-14 17:48:57 +01:00
|
|
|
|
|
|
|
if(pPrev)
|
|
|
|
pPrev->next = pLink->next;
|
|
|
|
else offman->UsedAreas = pLink->next;
|
|
|
|
|
|
|
|
tmp = pLink;
|
|
|
|
pLink = pLink->next;
|
2010-05-05 20:44:06 +02:00
|
|
|
free(tmp);
|
2003-11-14 17:48:57 +01:00
|
|
|
offman->NumUsedAreas--;
|
|
|
|
anyUsed = TRUE;
|
|
|
|
} else {
|
|
|
|
pPrev = pLink;
|
|
|
|
pLink = pLink->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(anyUsed) {
|
2010-05-22 00:05:48 +02:00
|
|
|
RegionValidate(offman->FreeBoxes, &anyUsed);
|
2003-11-14 17:48:57 +01:00
|
|
|
SendCallFreeBoxCallbacks(offman);
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
LinearMoveCBWrapper(FBAreaPtr from, FBAreaPtr to)
|
|
|
|
{
|
|
|
|
/* this will never get called */
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
LinearRemoveCBWrapper(FBAreaPtr area)
|
|
|
|
{
|
|
|
|
FBManagerPtr offman;
|
|
|
|
FBLinearLinkPtr pLink, pLinkPrev = NULL;
|
|
|
|
ScreenPtr pScreen = area->pScreen;
|
|
|
|
|
2007-08-28 15:28:25 +02:00
|
|
|
offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates,
|
|
|
|
xf86FBScreenKey);
|
2003-11-14 17:48:57 +01:00
|
|
|
pLink = offman->LinearAreas;
|
|
|
|
if(!pLink) return;
|
|
|
|
|
|
|
|
while(pLink->area != area) {
|
|
|
|
pLinkPrev = pLink;
|
|
|
|
pLink = pLink->next;
|
|
|
|
if(!pLink) return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* give the user the callback it is expecting */
|
|
|
|
(*pLink->linear.RemoveLinearCallback)(&(pLink->linear));
|
|
|
|
|
|
|
|
if(pLinkPrev)
|
|
|
|
pLinkPrev->next = pLink->next;
|
|
|
|
else offman->LinearAreas = pLink->next;
|
|
|
|
|
2010-05-05 20:44:06 +02:00
|
|
|
free(pLink);
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
|
|
|
|
2003-11-25 20:29:01 +01:00
|
|
|
static void
|
2009-05-09 02:33:20 +02:00
|
|
|
DumpDebug(FBLinearLinkPtr pLink)
|
2003-11-25 20:29:01 +01:00
|
|
|
{
|
2009-05-09 02:33:20 +02:00
|
|
|
#ifdef DEBUG
|
2003-11-25 20:29:01 +01:00
|
|
|
if (!pLink) ErrorF("MMmm, PLINK IS NULL!\n");
|
|
|
|
|
|
|
|
while (pLink) {
|
|
|
|
ErrorF(" Offset:%08x, Size:%08x, %s,%s\n",
|
|
|
|
pLink->linear.offset,
|
|
|
|
pLink->linear.size,
|
|
|
|
pLink->free ? "Free" : "Used",
|
|
|
|
pLink->area ? "Area" : "Linear");
|
|
|
|
|
|
|
|
pLink = pLink->next;
|
|
|
|
}
|
|
|
|
#endif
|
2009-05-09 02:33:20 +02:00
|
|
|
}
|
2003-11-25 20:29:01 +01:00
|
|
|
|
|
|
|
static FBLinearPtr
|
|
|
|
AllocateLinear(
|
|
|
|
FBManagerPtr offman,
|
|
|
|
int size,
|
|
|
|
int granularity,
|
|
|
|
pointer privData
|
|
|
|
){
|
|
|
|
ScreenPtr pScreen = offman->pScreen;
|
|
|
|
FBLinearLinkPtr linear = NULL;
|
|
|
|
FBLinearLinkPtr newlink = NULL;
|
|
|
|
int offset, end;
|
|
|
|
|
|
|
|
if(size <= 0) return NULL;
|
|
|
|
|
|
|
|
if (!offman->LinearAreas) return NULL;
|
|
|
|
|
|
|
|
linear = offman->LinearAreas;
|
|
|
|
while (linear) {
|
|
|
|
/* Make sure we get a free area that's not an XY fallback case */
|
|
|
|
if (!linear->area && linear->free) {
|
2006-12-24 05:28:21 +01:00
|
|
|
offset = linear->linear.offset;
|
|
|
|
if (granularity > 1)
|
|
|
|
offset = ((offset + granularity - 1) / granularity) * granularity;
|
2003-11-25 20:29:01 +01:00
|
|
|
end = offset+size;
|
|
|
|
if (end <= (linear->linear.offset + linear->linear.size))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
linear = linear->next;
|
|
|
|
}
|
|
|
|
if (!linear)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
/* break left */
|
|
|
|
if (offset > linear->linear.offset) {
|
2010-05-05 20:44:06 +02:00
|
|
|
newlink = malloc(sizeof(FBLinearLink));
|
2003-11-25 20:29:01 +01:00
|
|
|
if (!newlink)
|
|
|
|
return NULL;
|
|
|
|
newlink->area = NULL;
|
|
|
|
newlink->linear.offset = offset;
|
|
|
|
newlink->linear.size = linear->linear.size - (offset - linear->linear.offset);
|
|
|
|
newlink->free = 1;
|
|
|
|
newlink->next = linear->next;
|
|
|
|
linear->linear.size -= newlink->linear.size;
|
|
|
|
linear->next = newlink;
|
|
|
|
linear = newlink;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* break right */
|
|
|
|
if (size < linear->linear.size) {
|
2010-05-05 20:44:06 +02:00
|
|
|
newlink = malloc(sizeof(FBLinearLink));
|
2003-11-25 20:29:01 +01:00
|
|
|
if (!newlink)
|
|
|
|
return NULL;
|
|
|
|
newlink->area = NULL;
|
|
|
|
newlink->linear.offset = offset + size;
|
|
|
|
newlink->linear.size = linear->linear.size - size;
|
|
|
|
newlink->free = 1;
|
|
|
|
newlink->next = linear->next;
|
|
|
|
linear->linear.size = size;
|
|
|
|
linear->next = newlink;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* p = middle block */
|
|
|
|
linear->linear.granularity = granularity;
|
|
|
|
linear->free = 0;
|
|
|
|
linear->linear.pScreen = pScreen;
|
|
|
|
linear->linear.MoveLinearCallback = NULL;
|
|
|
|
linear->linear.RemoveLinearCallback = NULL;
|
|
|
|
linear->linear.devPrivate.ptr = NULL;
|
|
|
|
|
2009-05-09 02:33:20 +02:00
|
|
|
DumpDebug(offman->LinearAreas);
|
2003-11-25 20:29:01 +01:00
|
|
|
|
|
|
|
return &(linear->linear);
|
|
|
|
}
|
2003-11-14 17:48:57 +01:00
|
|
|
|
|
|
|
static FBLinearPtr
|
|
|
|
localAllocateOffscreenLinear(
|
|
|
|
ScreenPtr pScreen,
|
|
|
|
int length,
|
|
|
|
int gran,
|
|
|
|
MoveLinearCallbackProcPtr moveCB,
|
|
|
|
RemoveLinearCallbackProcPtr removeCB,
|
|
|
|
pointer privData
|
|
|
|
){
|
|
|
|
FBManagerPtr offman;
|
|
|
|
FBLinearLinkPtr link;
|
|
|
|
FBAreaPtr area;
|
|
|
|
FBLinearPtr linear = NULL;
|
|
|
|
BoxPtr extents;
|
|
|
|
int w, h, pitch;
|
|
|
|
|
2007-08-28 15:28:25 +02:00
|
|
|
offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates,
|
|
|
|
xf86FBScreenKey);
|
2003-11-14 17:48:57 +01:00
|
|
|
|
2003-11-25 20:29:01 +01:00
|
|
|
/* Try to allocate from linear memory first...... */
|
2009-05-09 02:33:20 +02:00
|
|
|
DebugF("ALLOCATING LINEAR\n");
|
2003-11-25 20:29:01 +01:00
|
|
|
if ((linear = AllocateLinear(offman, length, gran, privData)))
|
2006-03-15 04:12:32 +01:00
|
|
|
return linear;
|
2003-11-14 17:48:57 +01:00
|
|
|
|
2009-05-09 02:33:20 +02:00
|
|
|
DebugF("NOPE, ALLOCATING AREA\n");
|
2003-11-14 17:48:57 +01:00
|
|
|
|
2010-05-05 20:44:06 +02:00
|
|
|
if(!(link = malloc(sizeof(FBLinearLink))))
|
2003-11-25 20:29:01 +01:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
/* No linear available, so try and pinch some from the XY areas */
|
2010-05-22 00:05:48 +02:00
|
|
|
extents = RegionExtents(offman->InitialBoxes);
|
2003-11-14 17:48:57 +01:00
|
|
|
pitch = extents->x2 - extents->x1;
|
|
|
|
|
2006-12-24 05:28:21 +01:00
|
|
|
if (gran > 1) {
|
|
|
|
if (gran > pitch) {
|
|
|
|
/* we can't match the specified alignment with XY allocations */
|
2010-05-05 20:44:06 +02:00
|
|
|
free(link);
|
2006-12-24 05:28:21 +01:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pitch % gran) {
|
|
|
|
/* pitch and granularity aren't a perfect match, let's allocate
|
|
|
|
* a bit more so we can align later on
|
|
|
|
*/
|
|
|
|
length += gran - 1;
|
|
|
|
}
|
|
|
|
}
|
2003-11-14 17:48:57 +01:00
|
|
|
|
|
|
|
if(length < pitch) { /* special case */
|
|
|
|
w = length;
|
|
|
|
h = 1;
|
|
|
|
} else {
|
|
|
|
w = pitch;
|
|
|
|
h = (length + pitch - 1) / pitch;
|
|
|
|
}
|
|
|
|
|
|
|
|
if((area = localAllocateOffscreenArea(pScreen, w, h, gran,
|
|
|
|
moveCB ? LinearMoveCBWrapper : NULL,
|
|
|
|
removeCB ? LinearRemoveCBWrapper : NULL,
|
|
|
|
privData)))
|
|
|
|
{
|
|
|
|
link->area = area;
|
2003-11-25 20:29:01 +01:00
|
|
|
link->free = 0;
|
2003-11-14 17:48:57 +01:00
|
|
|
link->next = offman->LinearAreas;
|
|
|
|
offman->LinearAreas = link;
|
|
|
|
linear = &(link->linear);
|
|
|
|
linear->pScreen = pScreen;
|
|
|
|
linear->size = h * w;
|
|
|
|
linear->offset = (pitch * area->box.y1) + area->box.x1;
|
2006-12-24 05:28:21 +01:00
|
|
|
if (gran > 1)
|
2007-03-07 01:18:59 +01:00
|
|
|
linear->offset = ((linear->offset + gran - 1) / gran) * gran;
|
2003-11-14 17:48:57 +01:00
|
|
|
linear->granularity = gran;
|
|
|
|
linear->MoveLinearCallback = moveCB;
|
|
|
|
linear->RemoveLinearCallback = removeCB;
|
|
|
|
linear->devPrivate.ptr = privData;
|
|
|
|
} else
|
2010-05-05 20:44:06 +02:00
|
|
|
free(link);
|
2003-11-14 17:48:57 +01:00
|
|
|
|
2009-05-09 02:33:20 +02:00
|
|
|
DumpDebug(offman->LinearAreas);
|
2003-11-25 20:29:01 +01:00
|
|
|
|
2003-11-14 17:48:57 +01:00
|
|
|
return linear;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
localFreeOffscreenLinear(FBLinearPtr linear)
|
|
|
|
{
|
|
|
|
FBManagerPtr offman;
|
|
|
|
FBLinearLinkPtr pLink, pLinkPrev = NULL;
|
|
|
|
ScreenPtr pScreen = linear->pScreen;
|
|
|
|
|
2007-08-28 15:28:25 +02:00
|
|
|
offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates,
|
|
|
|
xf86FBScreenKey);
|
2003-11-14 17:48:57 +01:00
|
|
|
pLink = offman->LinearAreas;
|
|
|
|
if(!pLink) return;
|
|
|
|
|
|
|
|
while(&(pLink->linear) != linear) {
|
|
|
|
pLinkPrev = pLink;
|
|
|
|
pLink = pLink->next;
|
|
|
|
if(!pLink) return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(pLink->area) { /* really an XY area */
|
2009-05-09 02:33:20 +02:00
|
|
|
DebugF("FREEING AREA\n");
|
2003-11-25 20:29:01 +01:00
|
|
|
localFreeOffscreenArea(pLink->area);
|
|
|
|
if(pLinkPrev)
|
|
|
|
pLinkPrev->next = pLink->next;
|
|
|
|
else offman->LinearAreas = pLink->next;
|
2010-05-05 20:44:06 +02:00
|
|
|
free(pLink);
|
2009-05-09 02:33:20 +02:00
|
|
|
DumpDebug(offman->LinearAreas);
|
2003-11-25 20:29:01 +01:00
|
|
|
return;
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
|
|
|
|
2003-11-25 20:29:01 +01:00
|
|
|
pLink->free = 1;
|
2003-11-14 17:48:57 +01:00
|
|
|
|
2003-11-25 20:29:01 +01:00
|
|
|
if (pLink->next && pLink->next->free) {
|
|
|
|
FBLinearLinkPtr p = pLink->next;
|
|
|
|
pLink->linear.size += p->linear.size;
|
|
|
|
pLink->next = p->next;
|
|
|
|
free(p);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(pLinkPrev) {
|
|
|
|
if (pLinkPrev->next && pLinkPrev->next->free && !pLinkPrev->area) {
|
|
|
|
FBLinearLinkPtr p = pLinkPrev->next;
|
|
|
|
pLinkPrev->linear.size += p->linear.size;
|
|
|
|
pLinkPrev->next = p->next;
|
|
|
|
free(p);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-09 02:33:20 +02:00
|
|
|
DebugF("FREEING LINEAR\n");
|
|
|
|
DumpDebug(offman->LinearAreas);
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static Bool
|
|
|
|
localResizeOffscreenLinear(FBLinearPtr resize, int length)
|
|
|
|
{
|
|
|
|
FBManagerPtr offman;
|
2003-11-25 20:29:01 +01:00
|
|
|
FBLinearLinkPtr pLink;
|
2003-11-14 17:48:57 +01:00
|
|
|
ScreenPtr pScreen = resize->pScreen;
|
|
|
|
|
2007-08-28 15:28:25 +02:00
|
|
|
offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates,
|
|
|
|
xf86FBScreenKey);
|
2003-11-14 17:48:57 +01:00
|
|
|
pLink = offman->LinearAreas;
|
|
|
|
if(!pLink) return FALSE;
|
|
|
|
|
|
|
|
while(&(pLink->linear) != resize) {
|
|
|
|
pLink = pLink->next;
|
|
|
|
if(!pLink) return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* This could actually be alot smarter and try to move allocations
|
|
|
|
from XY to linear when available. For now if it was XY, we keep
|
|
|
|
it XY */
|
|
|
|
|
|
|
|
if(pLink->area) { /* really an XY area */
|
|
|
|
BoxPtr extents;
|
|
|
|
int pitch, w, h;
|
|
|
|
|
2010-05-22 00:05:48 +02:00
|
|
|
extents = RegionExtents(offman->InitialBoxes);
|
2003-11-14 17:48:57 +01:00
|
|
|
pitch = extents->x2 - extents->x1;
|
|
|
|
|
|
|
|
if(length < pitch) { /* special case */
|
|
|
|
w = length;
|
|
|
|
h = 1;
|
|
|
|
} else {
|
|
|
|
w = pitch;
|
|
|
|
h = (length + pitch - 1) / pitch;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(localResizeOffscreenArea(pLink->area, w, h)) {
|
|
|
|
resize->size = h * w;
|
|
|
|
resize->offset = (pitch * pLink->area->box.y1) + pLink->area->box.x1;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
} else {
|
2003-11-25 20:29:01 +01:00
|
|
|
/* TODO!!!! resize the linear area */
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static Bool
|
|
|
|
localQueryLargestOffscreenLinear(
|
|
|
|
ScreenPtr pScreen,
|
|
|
|
int *size,
|
|
|
|
int gran,
|
|
|
|
int priority
|
|
|
|
)
|
|
|
|
{
|
2007-08-28 15:28:25 +02:00
|
|
|
FBManagerPtr offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates,
|
|
|
|
xf86FBScreenKey);
|
2003-11-25 20:29:01 +01:00
|
|
|
FBLinearLinkPtr pLink;
|
|
|
|
FBLinearLinkPtr pLinkRet;
|
2003-11-14 17:48:57 +01:00
|
|
|
|
|
|
|
*size = 0;
|
2003-11-25 20:29:01 +01:00
|
|
|
|
|
|
|
pLink = offman->LinearAreas;
|
2003-11-14 17:48:57 +01:00
|
|
|
|
2004-08-27 23:44:54 +02:00
|
|
|
if (pLink && !pLink->area) {
|
|
|
|
pLinkRet = pLink;
|
2003-11-25 20:29:01 +01:00
|
|
|
while (pLink) {
|
|
|
|
if (pLink->free) {
|
|
|
|
if (pLink->linear.size > pLinkRet->linear.size)
|
|
|
|
pLinkRet = pLink;
|
|
|
|
}
|
|
|
|
pLink = pLink->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pLinkRet->free) {
|
|
|
|
*size = pLinkRet->linear.size;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
int w, h;
|
|
|
|
|
|
|
|
if(localQueryLargestOffscreenArea(pScreen, &w, &h, gran,
|
|
|
|
FAVOR_WIDTH_THEN_AREA, priority))
|
|
|
|
{
|
|
|
|
FBManagerPtr offman;
|
|
|
|
BoxPtr extents;
|
|
|
|
|
2007-08-28 15:28:25 +02:00
|
|
|
offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates,
|
|
|
|
xf86FBScreenKey);
|
2010-05-22 00:05:48 +02:00
|
|
|
extents = RegionExtents(offman->InitialBoxes);
|
2003-11-25 20:29:01 +01:00
|
|
|
if((extents->x2 - extents->x1) == w)
|
|
|
|
*size = w * h;
|
|
|
|
return TRUE;
|
|
|
|
}
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static FBManagerFuncs xf86FBManFuncs = {
|
|
|
|
localAllocateOffscreenArea,
|
|
|
|
localFreeOffscreenArea,
|
|
|
|
localResizeOffscreenArea,
|
|
|
|
localQueryLargestOffscreenArea,
|
|
|
|
localRegisterFreeBoxCallback,
|
|
|
|
localAllocateOffscreenLinear,
|
|
|
|
localFreeOffscreenLinear,
|
|
|
|
localResizeOffscreenLinear,
|
|
|
|
localQueryLargestOffscreenLinear,
|
|
|
|
localPurgeUnlockedOffscreenAreas
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static Bool
|
|
|
|
xf86FBCloseScreen (int i, ScreenPtr pScreen)
|
|
|
|
{
|
|
|
|
FBLinkPtr pLink, tmp;
|
|
|
|
FBLinearLinkPtr pLinearLink, tmp2;
|
2007-08-28 15:28:25 +02:00
|
|
|
FBManagerPtr offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates,
|
|
|
|
xf86FBScreenKey);
|
2003-11-14 17:48:57 +01:00
|
|
|
|
|
|
|
pScreen->CloseScreen = offman->CloseScreen;
|
|
|
|
|
|
|
|
pLink = offman->UsedAreas;
|
|
|
|
while(pLink) {
|
|
|
|
tmp = pLink;
|
|
|
|
pLink = pLink->next;
|
2010-05-05 20:44:06 +02:00
|
|
|
free(tmp);
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
pLinearLink = offman->LinearAreas;
|
|
|
|
while(pLinearLink) {
|
|
|
|
tmp2 = pLinearLink;
|
|
|
|
pLinearLink = pLinearLink->next;
|
2010-05-05 20:44:06 +02:00
|
|
|
free(tmp2);
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
|
|
|
|
2010-05-22 00:05:48 +02:00
|
|
|
RegionDestroy(offman->InitialBoxes);
|
|
|
|
RegionDestroy(offman->FreeBoxes);
|
2003-11-14 17:48:57 +01:00
|
|
|
|
2010-05-05 20:44:06 +02:00
|
|
|
free(offman->FreeBoxesUpdateCallback);
|
|
|
|
free(offman->devPrivates);
|
|
|
|
free(offman);
|
2007-08-28 15:28:25 +02:00
|
|
|
dixSetPrivate(&pScreen->devPrivates, xf86FBScreenKey, NULL);
|
2003-11-14 17:48:57 +01:00
|
|
|
|
|
|
|
return (*pScreen->CloseScreen) (i, pScreen);
|
|
|
|
}
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
Bool
|
2003-11-14 17:48:57 +01:00
|
|
|
xf86InitFBManager(
|
|
|
|
ScreenPtr pScreen,
|
|
|
|
BoxPtr FullBox
|
|
|
|
){
|
|
|
|
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
|
|
|
|
RegionRec ScreenRegion;
|
|
|
|
RegionRec FullRegion;
|
|
|
|
BoxRec ScreenBox;
|
|
|
|
Bool ret;
|
|
|
|
|
|
|
|
ScreenBox.x1 = 0;
|
|
|
|
ScreenBox.y1 = 0;
|
|
|
|
ScreenBox.x2 = pScrn->virtualX;
|
|
|
|
ScreenBox.y2 = pScrn->virtualY;
|
|
|
|
|
|
|
|
if((FullBox->x1 > ScreenBox.x1) || (FullBox->y1 > ScreenBox.y1) ||
|
|
|
|
(FullBox->x2 < ScreenBox.x2) || (FullBox->y2 < ScreenBox.y2)) {
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (FullBox->y2 < FullBox->y1) return FALSE;
|
2006-03-08 04:32:07 +01:00
|
|
|
if (FullBox->x2 < FullBox->x1) return FALSE;
|
2003-11-14 17:48:57 +01:00
|
|
|
|
2010-05-22 00:05:48 +02:00
|
|
|
RegionInit(&ScreenRegion, &ScreenBox, 1);
|
|
|
|
RegionInit(&FullRegion, FullBox, 1);
|
2003-11-14 17:48:57 +01:00
|
|
|
|
2010-05-22 00:05:48 +02:00
|
|
|
RegionSubtract(&FullRegion, &FullRegion, &ScreenRegion);
|
2003-11-14 17:48:57 +01:00
|
|
|
|
|
|
|
ret = xf86InitFBManagerRegion(pScreen, &FullRegion);
|
|
|
|
|
2010-05-22 00:05:48 +02:00
|
|
|
RegionUninit(&ScreenRegion);
|
|
|
|
RegionUninit(&FullRegion);
|
2003-11-14 17:48:57 +01:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
Bool
|
2003-11-14 17:48:57 +01:00
|
|
|
xf86InitFBManagerArea(
|
|
|
|
ScreenPtr pScreen,
|
|
|
|
int PixelArea,
|
|
|
|
int Verbosity
|
|
|
|
)
|
|
|
|
{
|
|
|
|
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
|
|
|
|
xRectangle Rect[3];
|
|
|
|
RegionPtr pRegion, pScreenRegion;
|
|
|
|
int nRect;
|
|
|
|
Bool ret = FALSE;
|
|
|
|
|
|
|
|
if (PixelArea < (pScrn->displayWidth * pScrn->virtualY))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
Rect[0].x = Rect[0].y = 0;
|
|
|
|
Rect[0].width = pScrn->displayWidth;
|
|
|
|
Rect[0].height = PixelArea / pScrn->displayWidth;
|
|
|
|
nRect = 1;
|
|
|
|
|
|
|
|
/* Add a possible partial scanline */
|
|
|
|
if ((Rect[1].height = Rect[1].width = PixelArea % pScrn->displayWidth)) {
|
|
|
|
Rect[1].x = 0;
|
|
|
|
Rect[1].y = Rect[0].height;
|
|
|
|
Rect[1].height = 1;
|
|
|
|
nRect++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Factor out virtual resolution */
|
2010-05-22 00:05:48 +02:00
|
|
|
pRegion = RegionFromRects(nRect, Rect, 0);
|
2003-11-14 17:48:57 +01:00
|
|
|
if (pRegion) {
|
2010-05-22 00:05:48 +02:00
|
|
|
if (!RegionNar(pRegion)) {
|
2003-11-14 17:48:57 +01:00
|
|
|
Rect[2].x = Rect[2].y = 0;
|
|
|
|
Rect[2].width = pScrn->virtualX;
|
|
|
|
Rect[2].height = pScrn->virtualY;
|
|
|
|
|
2010-05-22 00:05:48 +02:00
|
|
|
pScreenRegion = RegionFromRects(1, &Rect[2], 0);
|
2003-11-14 17:48:57 +01:00
|
|
|
if (pScreenRegion) {
|
2010-05-22 00:05:48 +02:00
|
|
|
if (!RegionNar(pScreenRegion)) {
|
|
|
|
RegionSubtract(pRegion, pRegion, pScreenRegion);
|
2003-11-14 17:48:57 +01:00
|
|
|
|
|
|
|
ret = xf86InitFBManagerRegion(pScreen, pRegion);
|
|
|
|
|
|
|
|
if (ret && xf86GetVerbosity() >= Verbosity) {
|
|
|
|
int scrnIndex = pScrn->scrnIndex;
|
|
|
|
|
|
|
|
xf86DrvMsgVerb(scrnIndex, X_INFO, Verbosity,
|
|
|
|
"Largest offscreen areas (with overlaps):\n");
|
|
|
|
|
|
|
|
if (Rect[2].width < Rect[0].width) {
|
|
|
|
xf86DrvMsgVerb(scrnIndex, X_INFO, Verbosity,
|
|
|
|
"\t%d x %d rectangle at %d,0\n",
|
|
|
|
Rect[0].width - Rect[2].width,
|
|
|
|
Rect[0].height,
|
|
|
|
Rect[2].width);
|
|
|
|
}
|
|
|
|
if (Rect[2].width < Rect[1].width) {
|
|
|
|
xf86DrvMsgVerb(scrnIndex, X_INFO, Verbosity,
|
|
|
|
"\t%d x %d rectangle at %d,0\n",
|
|
|
|
Rect[1].width - Rect[2].width,
|
|
|
|
Rect[0].height + Rect[1].height,
|
|
|
|
Rect[2].width);
|
|
|
|
}
|
|
|
|
if (Rect[2].height < Rect[0].height) {
|
|
|
|
xf86DrvMsgVerb(scrnIndex, X_INFO, Verbosity,
|
|
|
|
"\t%d x %d rectangle at 0,%d\n",
|
|
|
|
Rect[0].width,
|
|
|
|
Rect[0].height - Rect[2].height,
|
|
|
|
Rect[2].height);
|
|
|
|
}
|
|
|
|
if (Rect[1].height) {
|
|
|
|
xf86DrvMsgVerb(scrnIndex, X_INFO, Verbosity,
|
|
|
|
"\t%d x %d rectangle at 0,%d\n",
|
|
|
|
Rect[1].width,
|
|
|
|
Rect[0].height - Rect[2].height +
|
|
|
|
Rect[1].height,
|
|
|
|
Rect[2].height);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-05-22 00:05:48 +02:00
|
|
|
RegionDestroy(pScreenRegion);
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-05-22 00:05:48 +02:00
|
|
|
RegionDestroy(pRegion);
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
Bool
|
2003-11-14 17:48:57 +01:00
|
|
|
xf86InitFBManagerRegion(
|
|
|
|
ScreenPtr pScreen,
|
|
|
|
RegionPtr FullRegion
|
|
|
|
){
|
|
|
|
FBManagerPtr offman;
|
|
|
|
|
2010-05-22 00:05:48 +02:00
|
|
|
if(RegionNil(FullRegion))
|
2003-11-14 17:48:57 +01:00
|
|
|
return FALSE;
|
|
|
|
|
2010-04-27 02:22:21 +02:00
|
|
|
if (!dixRegisterPrivateKey(&xf86FBScreenKeyRec, PRIVATE_SCREEN, 0))
|
|
|
|
return FALSE;
|
|
|
|
|
2003-11-14 17:48:57 +01:00
|
|
|
if(!xf86RegisterOffscreenManager(pScreen, &xf86FBManFuncs))
|
|
|
|
return FALSE;
|
|
|
|
|
2010-05-05 20:44:06 +02:00
|
|
|
offman = malloc(sizeof(FBManager));
|
2003-11-14 17:48:57 +01:00
|
|
|
if(!offman) return FALSE;
|
|
|
|
|
2007-08-28 15:28:25 +02:00
|
|
|
dixSetPrivate(&pScreen->devPrivates, xf86FBScreenKey, offman);
|
2003-11-14 17:48:57 +01:00
|
|
|
|
|
|
|
offman->CloseScreen = pScreen->CloseScreen;
|
|
|
|
pScreen->CloseScreen = xf86FBCloseScreen;
|
|
|
|
|
2010-05-22 00:05:48 +02:00
|
|
|
offman->InitialBoxes = RegionCreate(NULL, 1);
|
|
|
|
offman->FreeBoxes = RegionCreate(NULL, 1);
|
2003-11-14 17:48:57 +01:00
|
|
|
|
2010-05-22 00:05:48 +02:00
|
|
|
RegionCopy(offman->InitialBoxes, FullRegion);
|
|
|
|
RegionCopy(offman->FreeBoxes, FullRegion);
|
2003-11-14 17:48:57 +01:00
|
|
|
|
|
|
|
offman->pScreen = pScreen;
|
|
|
|
offman->UsedAreas = NULL;
|
|
|
|
offman->LinearAreas = NULL;
|
|
|
|
offman->NumUsedAreas = 0;
|
|
|
|
offman->NumCallbacks = 0;
|
|
|
|
offman->FreeBoxesUpdateCallback = NULL;
|
|
|
|
offman->devPrivates = NULL;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
Bool
|
2003-11-25 20:29:01 +01:00
|
|
|
xf86InitFBManagerLinear(
|
|
|
|
ScreenPtr pScreen,
|
|
|
|
int offset,
|
|
|
|
int size
|
|
|
|
){
|
|
|
|
FBManagerPtr offman;
|
|
|
|
FBLinearLinkPtr link;
|
|
|
|
FBLinearPtr linear;
|
|
|
|
|
|
|
|
if (size <= 0)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
/* we expect people to have called the Area setup first for pixmap cache */
|
2007-08-28 15:28:25 +02:00
|
|
|
if (!dixLookupPrivate(&pScreen->devPrivates, xf86FBScreenKey))
|
2003-11-25 20:29:01 +01:00
|
|
|
return FALSE;
|
|
|
|
|
2007-08-28 15:28:25 +02:00
|
|
|
offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates,
|
|
|
|
xf86FBScreenKey);
|
2010-05-05 20:44:06 +02:00
|
|
|
offman->LinearAreas = malloc(sizeof(FBLinearLink));
|
2003-11-25 20:29:01 +01:00
|
|
|
if (!offman->LinearAreas)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
link = offman->LinearAreas;
|
|
|
|
link->area = NULL;
|
|
|
|
link->next = NULL;
|
|
|
|
link->free = 1;
|
|
|
|
linear = &(link->linear);
|
|
|
|
linear->pScreen = pScreen;
|
|
|
|
linear->size = size;
|
|
|
|
linear->offset = offset;
|
|
|
|
linear->granularity = 0;
|
|
|
|
linear->MoveLinearCallback = NULL;
|
|
|
|
linear->RemoveLinearCallback = NULL;
|
|
|
|
linear->devPrivate.ptr = NULL;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
2003-11-14 17:48:57 +01:00
|
|
|
|
|
|
|
|
|
|
|
/* This is an implementation specific function and should
|
|
|
|
disappear after the next release. People should use the
|
|
|
|
real linear functions instead */
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
FBAreaPtr
|
2003-11-14 17:48:57 +01:00
|
|
|
xf86AllocateLinearOffscreenArea (
|
|
|
|
ScreenPtr pScreen,
|
|
|
|
int length,
|
|
|
|
int gran,
|
|
|
|
MoveAreaCallbackProcPtr moveCB,
|
|
|
|
RemoveAreaCallbackProcPtr removeCB,
|
|
|
|
pointer privData
|
|
|
|
){
|
|
|
|
FBManagerFuncsPtr funcs;
|
|
|
|
FBManagerPtr offman;
|
|
|
|
BoxPtr extents;
|
|
|
|
int w, h;
|
|
|
|
|
2007-08-28 15:28:25 +02:00
|
|
|
if(xf86FBManagerKey == NULL)
|
2003-11-14 17:48:57 +01:00
|
|
|
return NULL;
|
2007-08-28 15:28:25 +02:00
|
|
|
if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate(&pScreen->devPrivates,
|
|
|
|
xf86FBManagerKey)))
|
2003-11-14 17:48:57 +01:00
|
|
|
return NULL;
|
|
|
|
|
2007-08-28 15:28:25 +02:00
|
|
|
offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates,
|
|
|
|
xf86FBScreenKey);
|
2010-05-22 00:05:48 +02:00
|
|
|
extents = RegionExtents(offman->InitialBoxes);
|
2003-11-14 17:48:57 +01:00
|
|
|
w = extents->x2 - extents->x1;
|
|
|
|
|
2006-12-24 05:28:21 +01:00
|
|
|
if (gran > 1) {
|
|
|
|
if (gran > w)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if (w % gran)
|
|
|
|
length += gran - 1;
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if(length <= w) { /* special case */
|
|
|
|
h = 1;
|
|
|
|
w = length;
|
|
|
|
} else {
|
|
|
|
h = (length + w - 1) / w;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (*funcs->AllocateOffscreenArea)(
|
|
|
|
pScreen, w, h, gran, moveCB, removeCB, privData);
|
|
|
|
}
|