Compare commits

...

51 Commits

Author SHA1 Message Date
Keith Packard b84acf6410 fix stale dri2 build 2008-09-11 17:06:07 -07:00
Keith Packard 40b3d2972d Replace dixLookupResource by dixLookupResourceBy{Type,Class}
dixLookupResource attempted to automatically detect whether the caller
wanted a lookup by-type or by-class, unfortunately, it guessed wrong for
RT_NONE. Instead of trying to make the guess better, this patch just reverts
the unification and creates separate functions for each operation.
2008-08-06 15:26:24 -07:00
Keith Packard bda289b0ae Reset lastSlave when disabling devices 2008-07-29 11:58:16 -07:00
Keith Packard 2386c9a465 Implement RandR output property events 2008-07-29 11:57:52 -07:00
Keith Packard f209924c36 Merge commit 'origin/master' into transform-proposal
Conflicts:

	Xi/exevents.c
	configure.ac
	hw/xfree86/modes/xf86Rotate.c

All of these merges were of differently formated but equivalent code.
2008-07-21 11:08:04 -07:00
Keith Packard dfb622f991 Make button down state a bitmask. Master buttons track union of slave buttons
Mixing usage where some parts of the code treated this field as a bitmask
and other parts as an array of card8 was wrong, and as the wire protocol
wanted bitmasks, it was less invasive to switch the newer counting code use
booleans.

Master devices track slave buttons by waiting for all slave buttons to be
released before delivering the release event to the client.

This also removes the state merging code in DeepCopyDeviceClasses -- that
code was changing master device state without delivering any events,
violating protocol invariants. The result will be that existing slave
button state which does not match the master will not be visible through the
master device. Fixing this would require that we synthesize events in this
function, which seems like a bad idea. Note that keyboards have the same
issue.
2008-06-18 11:33:20 -07:00
Keith Packard 62a02e88f2 Leave unmapped button number in event until delivery.
Button numbers were getting double-mapped when updating state, and DGA state
update conflicted with X state update. Leave button numbers untranslated in
the event structure until the event is delivered to fix both of these
problems.
2008-06-14 13:28:27 -07:00
Keith Packard 222c7d67c6 Merge commit 'origin/master' into transform-proposal 2008-06-13 23:21:25 -07:00
Keith Packard 93b9a6d067 Merge commit 'origin/master' into transform-proposal 2008-06-13 10:13:53 -07:00
Keith Packard e2da91cc15 Randr before Render for Xnest 2008-06-03 23:12:13 -07:00
Keith Packard 04a1da3771 Merge commit 'origin/master' into transform-proposal
Conflicts:

	configure.ac
	xkb/ddxLoad.c
2008-06-03 21:55:15 -07:00
Keith Packard 33e5a176e6 Merge commit 'origin/master' into transform-proposal-old
Conflicts:

	configure.ac
	exa/exa.c
2008-05-04 22:24:56 -07:00
Keith Packard e48f6bcd94 Debug XKB bits 2008-04-29 08:30:51 -07:00
Keith Packard 4c7ca04362 kludge around glx crashes during server exit 2008-04-29 08:30:17 -07:00
Keith Packard 15cd904558 Handle transform failure when computing shadow damage area.
PictureTransformBounds can fail, when this happens, damage the entire screen
so that the shadow gets repainted correctly.
2008-04-29 08:29:42 -07:00
Keith Packard b93c9a1553 Fix up kdrive build (again) 2008-04-29 08:27:57 -07:00
Keith Packard 862558c708 Merge commit 'origin/master' into transform-proposal 2008-04-11 20:07:39 -07:00
Keith Packard 06e7e1d048 Wrap AddTraps in exa and damage.
This fine (and unused) function wasn't ever wrapped which made it not work
under exa.
2008-04-04 12:11:14 -07:00
Keith Packard 436a549e73 [randr] don't try to compute crtc transform when no mode is set.
Dereferencing the NULL mode pointer would cause a crash. As these transform
matrices won't be used while the CRTC is disabled, just leave their values
alone.
2008-03-30 19:05:07 -07:00
Keith Packard e6f10f62f7 Update RandR global transform when driver notifies of transform change.
Need to compute and save the global transform when the driver changes it.
2008-03-27 11:46:39 -07:00
Keith Packard 127068ac7b Export rrtransform.h as needed by randrstr.h
When the transform management was moved from randrstr.h, the associated
header file became necessary to build drivers. Include it as a part of the
sdk headers.
2008-03-27 11:45:53 -07:00
Keith Packard 5ab0acfc51 Write a framework to decode edid data in an external program.
This isn't complete, but demonstrates how one would write an external EDID
parser that can work from binary data as dumped by the X server.
2008-03-27 11:44:37 -07:00
Keith Packard 501bdedc11 Merge commit 'origin/master' into transform-proposal 2008-03-27 11:43:29 -07:00
Keith Packard 16ff2196e2 Be careful about copying transforms around; they have allocated memory. 2008-03-21 03:16:09 -07:00
Keith Packard 6acc7e9f65 Fix rotated/reflected cursor positions.
Doing projective transforms required repositioning the cursor using the
hotspot, but that requires relocating the upper left corner in terms of said
hotspot.
2008-03-21 03:15:00 -07:00
Keith Packard ea5aeee7b9 rrtransform needs randrstr to get RANDR_INTERFACE defines 2008-03-21 03:14:47 -07:00
Keith Packard f4d9775253 Create rrtransform.[ch]. Add RRTransform argument to RRCrtcNotify.
Instead of using a separate function to notify DIX about transform changes,
add the transform to RRCrtcNotify so that the whole Crtc state changes
atomically.
2008-03-21 02:39:49 -07:00
Keith Packard adae567297 Avoid overflow in PictureTransformPoint. Fix PictureTransformIsIdentity.
PictureTransformPoint computes homogeneous coordinates internally, but fails
to handle intermediate values larger than 16.16. Use 64 bit intermediate
values while computing the final result at 16.16 and only complain if that
result is too large.

PictureTransformIsIdentity was completely wrong -- it was not checking for
identity transforms at all.
2008-03-21 02:35:28 -07:00
Keith Packard 6b59159fdf Allow drivers to set crtc transforms.
Track curent transform down in the mode setting code so that it may be set
separately from RandR.
2008-03-19 12:15:39 -07:00
Keith Packard 5360d47549 Handle RandR transform matrices in floating point.
RandR matrix computations lose too much precision in fixed point;
computations using the inverted matrix can be as much as 10 pixels off.
Convert them to double precision values and pass those around. These API
changes are fairly heavyweight; the official Render interface remains fixed
point, so the fixed point matrix comes along for the ride everywhere.
2008-03-19 00:46:35 -07:00
Keith Packard 71267eb380 Eliminate inverse matrix from randr transform protocol
It is easier, and potentially more precise, to compute the inverse in the
server where everything can eventually be kept in floating point form.
2008-03-18 16:06:06 -07:00
Keith Packard fd7b5e2c28 Report whether transforms are support from driver through extension to client
Add APIs to xf86RandR12 support and randr extension to record whether the
driver supports transforms, report that value in the RRGetCrtcTransform
reply.
2008-03-18 16:05:34 -07:00
Keith Packard 85ff452bfc Clear shadow pixmaps before using them.
This eliminates some ugly flashing, as well as clearing the borders when the
shadow will not be completely painted.
2008-03-18 15:35:12 -07:00
Keith Packard 02b8d204e1 When converting from double to fixed, round carefully.
This reduces the matrix representation error after inverting a
transformation matrix (although it doesn't eliminate it entirely).

Perhaps we should extend Render to include 64-bit floating point transforms...
2008-03-18 15:15:40 -07:00
Keith Packard 4184a2db90 Compute matrix inversion instead of using wire version in RRCrtcTransformSet
It doesn't make sense to have the client invert this matrix when the server
can do so reasonably efficiently. This avoids weird fixed point rounding
errors when testing the transform against its inverse. Now to fix the
protocol.
2008-03-17 23:04:49 -07:00
Keith Packard 47dcd54077 Add matrix inversion function (uses doubles)
The obvious matrix inversion function, coded using doubles to avoid fiddling
with fixed point precision adventures.
2008-03-17 23:03:56 -07:00
Keith Packard 5ec18f40e7 Adjust transformed cursor position to account for hotspot 2008-03-17 16:14:43 -07:00
Keith Packard c9204c8fcf Actually use filter kernel size to expand transform redisplay box 2008-03-17 16:14:15 -07:00
Keith Packard 21457a5a6b Correct bilinear filter kernel size (should be 2x2) 2008-03-17 16:13:25 -07:00
Keith Packard 18d6f5b801 Handle filter widths in xf86Rotate 2008-03-17 15:22:06 -07:00
Keith Packard 3b0552541f Initialize and cleanup new filter fields in xf86Crtc. 2008-03-17 15:21:26 -07:00
Keith Packard 1970640dc6 Pass filter kernel size through transforms 2008-03-17 15:20:52 -07:00
Keith Packard 698047944f Add kernel size to Render filters.
This width/height value lets filter users know how far the filter spreads
into the source image.
2008-03-17 15:19:17 -07:00
Keith Packard 2193d49ff1 Use transform when computing scanout size of modes
Report transformed crtc sizes through RandR and Xinerama. Test screen size
against transformed mode sizes when configuring the Crtc.
2008-03-17 13:57:47 -07:00
Keith Packard 715b158e15 [RANDR] Support filters in CRTC transforms.
Create new RRTransform datatype to hold all of the transform related
information, use that in lots of places to pass filters around.
2008-03-15 00:36:45 -07:00
Keith Packard 207869447a [render] Split out filter finding from filter setting.
To prepare for RandR using filters in transforms, split out
code paths so that the RandR code can validate the filter name and
parameters during the transform set operation so that use of the filter
later will not have unreportable errors.
2008-03-14 13:46:30 -07:00
Keith Packard 90b55ca9a5 Wire up RandR CRTC transform protocol, bump server to RandR 1.3
This involved removing a pile of matrix code from the DDX,
as well as moving a bit of transform logic from DDX to DIX.
2008-03-13 21:31:12 -07:00
Keith Packard 404de98155 Add funcs to convert between protocol and pixman matrices 2008-03-13 21:30:18 -07:00
Keith Packard 3bf59c2fac Randr now depends on Render for matrices 2008-03-13 21:29:19 -07:00
Keith Packard e65e9b4b12 Export a bunch of matrix operations from render.
The render extension uses many matrix operations internally, this change
exposes those functions to other parts of the server, drivers and
extensions. The change is motivated by the 'transform' additions to the
RandR extension but will likely be useful elsewhere.
2008-03-13 14:50:13 -07:00
Keith Packard 3c01bd180d Add projective transforms to RandR DIX/DDX API.
New RRCrtcGetTransform function in DIX that DDX can use to get the pending
transform. The DDX code should be complete; the DIX code is just a stub at
this point.
2008-03-13 14:26:01 -07:00
59 changed files with 2296 additions and 625 deletions

View File

@ -1064,7 +1064,7 @@ ScreenSaverSetAttributes (ClientPtr client)
}
else
{
ret = dixLookupResource((pointer *)&pPixmap, pixID, RT_PIXMAP,
ret = dixLookupResourceByType((pointer *)&pPixmap, pixID, RT_PIXMAP,
client, DixReadAccess);
if (ret == Success)
{
@ -1102,7 +1102,7 @@ ScreenSaverSetAttributes (ClientPtr client)
}
else
{
ret = dixLookupResource((pointer *)&pPixmap, pixID, RT_PIXMAP,
ret = dixLookupResourceByType((pointer *)&pPixmap, pixID, RT_PIXMAP,
client, DixReadAccess);
if (ret == Success)
{
@ -1196,7 +1196,7 @@ ScreenSaverSetAttributes (ClientPtr client)
break;
case CWColormap:
cmap = (Colormap) *pVlist;
ret = dixLookupResource((pointer *)&pCmap, cmap, RT_COLORMAP,
ret = dixLookupResourceByType((pointer *)&pCmap, cmap, RT_COLORMAP,
client, DixUseAccess);
if (ret != Success)
{
@ -1220,7 +1220,7 @@ ScreenSaverSetAttributes (ClientPtr client)
}
else
{
ret = dixLookupResource((pointer *)&pCursor, cursorID,
ret = dixLookupResourceByType((pointer *)&pCursor, cursorID,
RT_CURSOR, client, DixUseAccess);
if (ret != Success)
{

View File

@ -1014,7 +1014,7 @@ SecurityClientState(CallbackListPtr *pcbl, pointer unused, pointer calldata)
case ClientStateRunning:
state->authId = AuthorizationIDOfClient(pci->client);
rc = dixLookupResource((pointer *)&pAuth, state->authId,
rc = dixLookupResourceByType((pointer *)&pAuth, state->authId,
SecurityAuthorizationResType, serverClient,
DixGetAttrAccess);
if (rc == Success) {
@ -1029,7 +1029,7 @@ SecurityClientState(CallbackListPtr *pcbl, pointer unused, pointer calldata)
case ClientStateGone:
case ClientStateRetained:
rc = dixLookupResource((pointer *)&pAuth, state->authId,
rc = dixLookupResourceByType((pointer *)&pAuth, state->authId,
SecurityAuthorizationResType, serverClient,
DixGetAttrAccess);
if (rc == Success) {

View File

@ -438,7 +438,7 @@ ProcShapeMask (client)
if (stuff->src == None)
srcRgn = 0;
else {
rc = dixLookupResource((pointer *)&pPixmap, stuff->src, RT_PIXMAP,
rc = dixLookupResourceByType((pointer *)&pPixmap, stuff->src, RT_PIXMAP,
client, DixReadAccess);
if (rc != Success)
return (rc == BadValue) ? BadPixmap : rc;

View File

@ -440,7 +440,7 @@ SyncInitTrigger(client, pTrigger, counter, changes)
{
if (counter == None)
pCounter = NULL;
else if (Success != (rc = dixLookupResource((pointer *)&pCounter,
else if (Success != (rc = dixLookupResourceByType ((pointer *)&pCounter,
counter, RTCounter, client, DixReadAccess)))
{
client->errorValue = counter;

View File

@ -555,7 +555,7 @@ SELinuxLabelInitial(void)
SELinuxScreen(NULL, NULL, &srec);
/* Do the default colormap */
dixLookupResource(&unused, screenInfo.screens[i]->defColormap,
dixLookupResourceByType(&unused, screenInfo.screens[i]->defColormap,
RT_COLORMAP, serverClient, DixCreateAccess);
}
}

View File

@ -135,8 +135,8 @@ ProcXTestCompareCursor(client)
else if (stuff->cursor == XTestCurrentCursor)
pCursor = GetSpriteCursor(ptr);
else {
rc = dixLookupResource((pointer *)&pCursor, stuff->cursor, RT_CURSOR,
client, DixReadAccess);
rc = dixLookupResourceByType((pointer *)&pCursor, stuff->cursor, RT_CURSOR,
client, DixReadAccess);
if (rc != Success)
{
client->errorValue = stuff->cursor;
@ -169,7 +169,7 @@ ProcXTestFakeInput(client)
int numValuators = 0;
int firstValuator = 0;
EventListPtr events;
int nevents;
int nevents = 0;
int i;
int base = 0;

View File

@ -907,10 +907,10 @@ UpdateDeviceState(DeviceIntPtr device, xEvent* xE, int count)
if (!b)
return DONT_PROCESS;
kptr = &b->down[key >> 3];
kptr = &b->down[key >> 3];
if ((*kptr & bit) != 0)
return DONT_PROCESS;
*kptr |= bit;
*kptr |= bit;
if (device->valuator)
device->valuator->motionHintWindow = NullWindow;
b->buttonsDown++;
@ -924,25 +924,25 @@ UpdateDeviceState(DeviceIntPtr device, xEvent* xE, int count)
if (!b)
return DONT_PROCESS;
kptr = &b->down[key>>3];
kptr = &b->down[key>>3];
if (!(*kptr & bit))
return DONT_PROCESS;
if (device->isMaster) {
DeviceIntPtr sd;
if (device->isMaster) {
DeviceIntPtr sd;
/*
* Leave the button down if any slave has the
* button still down. Note that this depends on the
* event being delivered through the slave first
*/
for (sd = inputInfo.devices; sd; sd = sd->next) {
if (sd->isMaster || sd->u.master != device)
continue;
if ((sd->button->down[key>>3] & bit) != 0)
return DONT_PROCESS;
}
}
*kptr &= ~bit;
/*
* Leave the button down if any slave has the
* button still down. Note that this depends on the
* event being delivered through the slave first
*/
for (sd = inputInfo.devices; sd; sd = sd->next) {
if (sd->isMaster || sd->u.master != device)
continue;
if ((sd->button->down[key>>3] & bit) != 0)
return DONT_PROCESS;
}
}
*kptr &= ~bit;
if (device->valuator)
device->valuator->motionHintWindow = NullWindow;
if (b->buttonsDown >= 1 && !--b->buttonsDown)
@ -1010,6 +1010,7 @@ ProcessOtherEvent(xEventPtr xE, DeviceIntPtr device, int count)
if (device->isMaster)
CheckMotion(xE, device);
key = xE->u.u.detail;
if (xE->u.u.type != DeviceValuator && xE->u.u.type != GenericEvent) {
GetSpritePosition(device, &rootX, &rootY);
xE->u.keyButtonPointer.rootX = rootX;
@ -1018,7 +1019,6 @@ ProcessOtherEvent(xEventPtr xE, DeviceIntPtr device, int count)
xE->u.keyButtonPointer.state = state;
key = xE->u.u.detail;
}
if (DeviceEventCallback) {
DeviceEventInfoRec eventinfo;
@ -1369,7 +1369,7 @@ GrabButton(ClientPtr client, DeviceIntPtr dev, BYTE this_device_mode,
if (rcursor == None)
cursor = NullCursor;
else {
rc = dixLookupResource((pointer *)&cursor, rcursor, RT_CURSOR,
rc = dixLookupResourceByType((pointer *)&cursor, rcursor, RT_CURSOR,
client, DixUseAccess);
if (rc != Success)
{

View File

@ -148,7 +148,7 @@ ProcCompositeRedirectWindow (ClientPtr client)
REQUEST(xCompositeRedirectWindowReq);
REQUEST_SIZE_MATCH(xCompositeRedirectWindowReq);
rc = dixLookupResource((pointer *)&pWin, stuff->window, RT_WINDOW, client,
rc = dixLookupResourceByType((pointer *)&pWin, stuff->window, RT_WINDOW, client,
DixSetAttrAccess|DixManageAccess|DixBlendAccess);
if (rc != Success)
{
@ -166,7 +166,7 @@ ProcCompositeRedirectSubwindows (ClientPtr client)
REQUEST(xCompositeRedirectSubwindowsReq);
REQUEST_SIZE_MATCH(xCompositeRedirectSubwindowsReq);
rc = dixLookupResource((pointer *)&pWin, stuff->window, RT_WINDOW, client,
rc = dixLookupResourceByType((pointer *)&pWin, stuff->window, RT_WINDOW, client,
DixSetAttrAccess|DixManageAccess|DixBlendAccess);
if (rc != Success)
{
@ -218,7 +218,7 @@ ProcCompositeCreateRegionFromBorderClip (ClientPtr client)
REQUEST(xCompositeCreateRegionFromBorderClipReq);
REQUEST_SIZE_MATCH(xCompositeCreateRegionFromBorderClipReq);
rc = dixLookupResource((pointer *)&pWin, stuff->window, RT_WINDOW, client,
rc = dixLookupResourceByType((pointer *)&pWin, stuff->window, RT_WINDOW, client,
DixGetAttrAccess);
if (rc != Success)
{
@ -254,7 +254,7 @@ ProcCompositeNameWindowPixmap (ClientPtr client)
REQUEST(xCompositeNameWindowPixmapReq);
REQUEST_SIZE_MATCH(xCompositeNameWindowPixmapReq);
rc = dixLookupResource((pointer *)&pWin, stuff->window, RT_WINDOW, client,
rc = dixLookupResourceByType((pointer *)&pWin, stuff->window, RT_WINDOW, client,
DixGetAttrAccess);
if (rc != Success)
{
@ -302,7 +302,7 @@ ProcCompositeGetOverlayWindow (ClientPtr client)
int rc;
REQUEST_SIZE_MATCH(xCompositeGetOverlayWindowReq);
rc = dixLookupResource((pointer *)&pWin, stuff->window, RT_WINDOW, client,
rc = dixLookupResourceByType((pointer *)&pWin, stuff->window, RT_WINDOW, client,
DixGetAttrAccess);
if (rc != Success)
{

View File

@ -1219,7 +1219,7 @@ AC_MSG_RESULT([$XNEST])
AM_CONDITIONAL(XNEST, [test "x$XNEST" = xyes])
if test "x$XNEST" = xyes; then
XNEST_LIBS="$FB_LIB $FIXES_LIB $MI_LIB $XEXT_LIB $DBE_LIB $RECORD_LIB $GLX_LIBS $RENDER_LIB $RANDR_LIB $DAMAGE_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $COMPOSITE_LIB $DIX_LIB $OS_LIB $CONFIG_LIB"
XNEST_LIBS="$FB_LIB $FIXES_LIB $MI_LIB $XEXT_LIB $DBE_LIB $RECORD_LIB $GLX_LIBS $RANDR_LIB $RENDER_LIB $DAMAGE_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $COMPOSITE_LIB $DIX_LIB $OS_LIB $CONFIG_LIB"
XNEST_SYS_LIBS="$XNESTMODULES_LIBS"
AC_SUBST([XNEST_LIBS])
AC_SUBST([XNEST_SYS_LIBS])
@ -1762,7 +1762,7 @@ if test "$KDRIVE" = yes; then
KDRIVE_STUB_LIB='$(top_builddir)/hw/kdrive/src/libkdrivestubs.a'
KDRIVE_LOCAL_LIBS="$DIX_LIB $KDRIVE_LIB $KDRIVE_STUB_LIB $CONFIG_LIB"
KDRIVE_LOCAL_LIBS="$KDRIVE_LOCAL_LIBS $FB_LIB $MI_LIB $KDRIVE_PURE_LIBS"
KDRIVE_LOCAL_LIBS="$KDRIVE_LOCAL_LIBS $KDRIVE_OS_LIB $OS_LIB"
KDRIVE_LOCAL_LIBS="$KDRIVE_LOCAL_LIBS $KDRIVE_OS_LIB $OS_LIB $XEXT_LIB"
KDRIVE_LIBS="$TSLIB_LIBS $KDRIVE_LOCAL_LIBS $XSERVER_SYS_LIBS $GLX_SYS_LIBS"
AC_SUBST([XEPHYR_LIBS])

View File

@ -298,15 +298,15 @@ AllocGlyphCursor(Font source, unsigned sourceChar, Font mask, unsigned maskChar,
GlyphSharePtr pShare;
DeviceIntPtr pDev;
rc = dixLookupResource((pointer *)&sourcefont, source, RT_FONT, client,
DixUseAccess);
rc = dixLookupResourceByType((pointer *)&sourcefont, source, RT_FONT, client,
DixUseAccess);
if (rc != Success)
{
client->errorValue = source;
return (rc == BadValue) ? BadFont : rc;
}
rc = dixLookupResource((pointer *)&maskfont, mask, RT_FONT, client,
DixUseAccess);
rc = dixLookupResourceByType((pointer *)&maskfont, mask, RT_FONT, client,
DixUseAccess);
if (rc != Success && mask != None)
{
client->errorValue = mask;

View File

@ -115,48 +115,66 @@ LookupClient(XID id, ClientPtr client)
return (i == Success) ? pClient : NULL;
}
/* replaced by dixLookupResource */
/* replaced by dixLookupResourceByType */
_X_EXPORT pointer
SecurityLookupIDByType(ClientPtr client, XID id, RESTYPE rtype,
Mask access_mode)
{
pointer retval;
int i = dixLookupResource(&retval, id, rtype, client, access_mode);
int i = dixLookupResourceByType(&retval, id, rtype, client, access_mode);
static int warn = 1;
if (warn > 0 && --warn)
ErrorF("Warning: LookupIDByType()/SecurityLookupIDByType() "
"are deprecated. Please convert your driver/module "
"to use dixLookupResource().\n");
"to use dixLookupResourceByType().\n");
return (i == Success) ? retval : NULL;
}
/* replaced by dixLookupResource */
/* replaced by dixLookupResourceByClass */
_X_EXPORT pointer
SecurityLookupIDByClass(ClientPtr client, XID id, RESTYPE classes,
Mask access_mode)
{
pointer retval;
int i = dixLookupResource(&retval, id, classes, client, access_mode);
int i = dixLookupResourceByClass(&retval, id, classes, client, access_mode);
static int warn = 1;
if (warn > 0 && --warn)
ErrorF("Warning: LookupIDByClass()/SecurityLookupIDByClass() "
"are deprecated. Please convert your driver/module "
"to use dixLookupResource().\n");
"to use dixLookupResourceByClass().\n");
return (i == Success) ? retval : NULL;
}
/* replaced by dixLookupResource */
/* replaced by dixLookupResourceByType */
_X_EXPORT pointer
LookupIDByType(XID id, RESTYPE rtype)
{
return SecurityLookupIDByType(NullClient, id, rtype, DixUnknownAccess);
}
/* replaced by dixLookupResource */
/* replaced by dixLookupResourceByClass */
_X_EXPORT pointer
LookupIDByClass(XID id, RESTYPE classes)
{
return SecurityLookupIDByClass(NullClient, id, classes, DixUnknownAccess);
}
/* replaced by dixLookupResourceBy{Type,Class} */
_X_EXPORT int
dixLookupResource (pointer *result, XID id, RESTYPE rtype,
ClientPtr client, Mask mode)
{
Bool istype = ((rtype & TypeMask) && (rtype != RC_ANY)) || (rtype == RT_NONE);
static int warn = 1;
if (warn > 0 && --warn)
ErrorF("Warning: dixLookupResource() "
"is deprecated. Please convert your driver/module "
"to use dixLookupResourceByType/dixLookupResourceByClass().\n");
if (istype)
return dixLookupResourceByType (result, id, rtype, client, mode);
else
return dixLookupResourceByClass (result, id, rtype, client, mode);
}
/* end deprecated functions */

View File

@ -315,6 +315,14 @@ DisableDevice(DeviceIntPtr dev)
AttachDevice(NULL, other, NULL);
}
}
else
{
for (other = inputInfo.devices; other; other = other->next)
{
if (other->isMaster && other->u.lastSlave == dev)
other->u.lastSlave = NULL;
}
}
if (dev->isMaster && dev->spriteInfo->sprite)
{

View File

@ -1136,11 +1136,11 @@ ProcQueryFont(ClientPtr client)
REQUEST_SIZE_MATCH(xResourceReq);
client->errorValue = stuff->id; /* EITHER font or gc */
rc = dixLookupResource((pointer *)&pFont, stuff->id, RT_FONT, client,
DixGetAttrAccess);
rc = dixLookupResourceByType((pointer *)&pFont, stuff->id, RT_FONT, client,
DixGetAttrAccess);
if (rc == BadValue) {
rc = dixLookupResource((pointer *)&pGC, stuff->id, RT_GC, client,
DixGetAttrAccess);
rc = dixLookupResourceByType((pointer *)&pGC, stuff->id, RT_GC, client,
DixGetAttrAccess);
if (rc == Success)
pFont = pGC->font;
}
@ -1194,10 +1194,10 @@ ProcQueryTextExtents(ClientPtr client)
REQUEST_AT_LEAST_SIZE(xQueryTextExtentsReq);
client->errorValue = stuff->fid; /* EITHER font or gc */
rc = dixLookupResource((pointer *)&pFont, stuff->fid, RT_FONT, client,
DixGetAttrAccess);
rc = dixLookupResourceByType((pointer *)&pFont, stuff->fid, RT_FONT, client,
DixGetAttrAccess);
if (rc == BadValue) {
rc = dixLookupResource((pointer *)&pGC, stuff->fid, RT_GC, client,
rc = dixLookupResourceByType((pointer *)&pGC, stuff->fid, RT_GC, client,
DixGetAttrAccess);
if (rc == Success)
pFont = pGC->font;
@ -1342,7 +1342,7 @@ ProcFreePixmap(ClientPtr client)
REQUEST(xResourceReq);
REQUEST_SIZE_MATCH(xResourceReq);
rc = dixLookupResource((pointer *)&pMap, stuff->id, RT_PIXMAP, client,
rc = dixLookupResourceByType((pointer *)&pMap, stuff->id, RT_PIXMAP, client,
DixDestroyAccess);
if (rc == Success)
{
@ -2288,7 +2288,7 @@ ProcFreeColormap(ClientPtr client)
REQUEST(xResourceReq);
REQUEST_SIZE_MATCH(xResourceReq);
rc = dixLookupResource((pointer *)&pmap, stuff->id, RT_COLORMAP, client,
rc = dixLookupResourceByType((pointer *)&pmap, stuff->id, RT_COLORMAP, client,
DixDestroyAccess);
if (rc == Success)
{
@ -2316,7 +2316,7 @@ ProcCopyColormapAndFree(ClientPtr client)
REQUEST_SIZE_MATCH(xCopyColormapAndFreeReq);
mid = stuff->mid;
LEGAL_NEW_RESOURCE(mid, client);
rc = dixLookupResource((pointer *)&pSrcMap, stuff->srcCmap, RT_COLORMAP,
rc = dixLookupResourceByType((pointer *)&pSrcMap, stuff->srcCmap, RT_COLORMAP,
client, DixReadAccess|DixRemoveAccess);
if (rc == Success)
{
@ -2341,7 +2341,7 @@ ProcInstallColormap(ClientPtr client)
REQUEST(xResourceReq);
REQUEST_SIZE_MATCH(xResourceReq);
rc = dixLookupResource((pointer *)&pcmp, stuff->id, RT_COLORMAP, client,
rc = dixLookupResourceByType((pointer *)&pcmp, stuff->id, RT_COLORMAP, client,
DixInstallAccess);
if (rc != Success)
goto out;
@ -2366,7 +2366,7 @@ ProcUninstallColormap(ClientPtr client)
REQUEST(xResourceReq);
REQUEST_SIZE_MATCH(xResourceReq);
rc = dixLookupResource((pointer *)&pcmp, stuff->id, RT_COLORMAP, client,
rc = dixLookupResourceByType((pointer *)&pcmp, stuff->id, RT_COLORMAP, client,
DixUninstallAccess);
if (rc != Success)
goto out;
@ -2433,7 +2433,7 @@ ProcAllocColor (ClientPtr client)
REQUEST(xAllocColorReq);
REQUEST_SIZE_MATCH(xAllocColorReq);
rc = dixLookupResource((pointer *)&pmap, stuff->cmap, RT_COLORMAP, client,
rc = dixLookupResourceByType((pointer *)&pmap, stuff->cmap, RT_COLORMAP, client,
DixAddAccess);
if (rc == Success)
{
@ -2474,7 +2474,7 @@ ProcAllocNamedColor (ClientPtr client)
REQUEST(xAllocNamedColorReq);
REQUEST_FIXED_SIZE(xAllocNamedColorReq, stuff->nbytes);
rc = dixLookupResource((pointer *)&pcmp, stuff->cmap, RT_COLORMAP, client,
rc = dixLookupResourceByType((pointer *)&pcmp, stuff->cmap, RT_COLORMAP, client,
DixAddAccess);
if (rc == Success)
{
@ -2525,7 +2525,7 @@ ProcAllocColorCells (ClientPtr client)
REQUEST(xAllocColorCellsReq);
REQUEST_SIZE_MATCH(xAllocColorCellsReq);
rc = dixLookupResource((pointer *)&pcmp, stuff->cmap, RT_COLORMAP, client,
rc = dixLookupResourceByType((pointer *)&pcmp, stuff->cmap, RT_COLORMAP, client,
DixAddAccess);
if (rc == Success)
{
@ -2592,7 +2592,7 @@ ProcAllocColorPlanes(ClientPtr client)
REQUEST(xAllocColorPlanesReq);
REQUEST_SIZE_MATCH(xAllocColorPlanesReq);
rc = dixLookupResource((pointer *)&pcmp, stuff->cmap, RT_COLORMAP, client,
rc = dixLookupResourceByType((pointer *)&pcmp, stuff->cmap, RT_COLORMAP, client,
DixAddAccess);
if (rc == Success)
{
@ -2657,7 +2657,7 @@ ProcFreeColors(ClientPtr client)
REQUEST(xFreeColorsReq);
REQUEST_AT_LEAST_SIZE(xFreeColorsReq);
rc = dixLookupResource((pointer *)&pcmp, stuff->cmap, RT_COLORMAP, client,
rc = dixLookupResourceByType((pointer *)&pcmp, stuff->cmap, RT_COLORMAP, client,
DixRemoveAccess);
if (rc == Success)
{
@ -2692,7 +2692,7 @@ ProcStoreColors (ClientPtr client)
REQUEST(xStoreColorsReq);
REQUEST_AT_LEAST_SIZE(xStoreColorsReq);
rc = dixLookupResource((pointer *)&pcmp, stuff->cmap, RT_COLORMAP, client,
rc = dixLookupResourceByType((pointer *)&pcmp, stuff->cmap, RT_COLORMAP, client,
DixWriteAccess);
if (rc == Success)
{
@ -2726,7 +2726,7 @@ ProcStoreNamedColor (ClientPtr client)
REQUEST(xStoreNamedColorReq);
REQUEST_FIXED_SIZE(xStoreNamedColorReq, stuff->nbytes);
rc = dixLookupResource((pointer *)&pcmp, stuff->cmap, RT_COLORMAP, client,
rc = dixLookupResourceByType((pointer *)&pcmp, stuff->cmap, RT_COLORMAP, client,
DixWriteAccess);
if (rc == Success)
{
@ -2760,7 +2760,7 @@ ProcQueryColors(ClientPtr client)
REQUEST(xQueryColorsReq);
REQUEST_AT_LEAST_SIZE(xQueryColorsReq);
rc = dixLookupResource((pointer *)&pcmp, stuff->cmap, RT_COLORMAP, client,
rc = dixLookupResourceByType((pointer *)&pcmp, stuff->cmap, RT_COLORMAP, client,
DixReadAccess);
if (rc == Success)
{
@ -2812,7 +2812,7 @@ ProcLookupColor(ClientPtr client)
REQUEST(xLookupColorReq);
REQUEST_FIXED_SIZE(xLookupColorReq, stuff->nbytes);
rc = dixLookupResource((pointer *)&pcmp, stuff->cmap, RT_COLORMAP, client,
rc = dixLookupResourceByType((pointer *)&pcmp, stuff->cmap, RT_COLORMAP, client,
DixReadAccess);
if (rc == Success)
{
@ -2861,14 +2861,14 @@ ProcCreateCursor (ClientPtr client)
REQUEST_SIZE_MATCH(xCreateCursorReq);
LEGAL_NEW_RESOURCE(stuff->cid, client);
rc = dixLookupResource((pointer *)&src, stuff->source, RT_PIXMAP, client,
rc = dixLookupResourceByType((pointer *)&src, stuff->source, RT_PIXMAP, client,
DixReadAccess);
if (rc != Success) {
client->errorValue = stuff->source;
return (rc == BadValue) ? BadPixmap : rc;
}
rc = dixLookupResource((pointer *)&msk, stuff->mask, RT_PIXMAP, client,
rc = dixLookupResourceByType((pointer *)&msk, stuff->mask, RT_PIXMAP, client,
DixReadAccess);
if (rc != Success)
{
@ -2968,7 +2968,7 @@ ProcFreeCursor (ClientPtr client)
REQUEST(xResourceReq);
REQUEST_SIZE_MATCH(xResourceReq);
rc = dixLookupResource((pointer *)&pCursor, stuff->id, RT_CURSOR, client,
rc = dixLookupResourceByType((pointer *)&pCursor, stuff->id, RT_CURSOR, client,
DixDestroyAccess);
if (rc == Success)
{

View File

@ -216,7 +216,7 @@ dixLookupDrawable(DrawablePtr *pDraw, XID id, ClientPtr client,
if (id == INVALID)
return BadDrawable;
rc = dixLookupResource((pointer *)&pTmp, id, RC_DRAWABLE, client, access);
rc = dixLookupResourceByClass((pointer *)&pTmp, id, RC_DRAWABLE, client, access);
if (rc == BadValue)
return BadDrawable;
@ -259,7 +259,7 @@ dixLookupClient(ClientPtr *pClient, XID rid, ClientPtr client, Mask access)
if (!clientIndex || !clients[clientIndex] || (rid & SERVER_BIT))
goto bad;
rc = dixLookupResource(&pRes, rid, RC_ANY, client, DixGetAttrAccess);
rc = dixLookupResourceByClass(&pRes, rid, RC_ANY, client, DixGetAttrAccess);
if (rc != Success)
goto bad;

View File

@ -5091,7 +5091,7 @@ ProcGrabPointer(ClientPtr client)
cursor = NullCursor;
else
{
rc = dixLookupResource((pointer *)&cursor, stuff->cursor, RT_CURSOR,
rc = dixLookupResourceByType((pointer *)&cursor, stuff->cursor, RT_CURSOR,
client, DixUseAccess);
if (rc != Success)
{
@ -5191,8 +5191,8 @@ ProcChangeActivePointerGrab(ClientPtr client)
newCursor = NullCursor;
else
{
int rc = dixLookupResource((pointer *)&newCursor, stuff->cursor,
RT_CURSOR, client, DixUseAccess);
int rc = dixLookupResourceByType((pointer *)&newCursor, stuff->cursor,
RT_CURSOR, client, DixUseAccess);
if (rc != Success)
{
client->errorValue = stuff->cursor;
@ -5798,7 +5798,7 @@ ProcGrabButton(ClientPtr client)
cursor = NullCursor;
else
{
rc = dixLookupResource((pointer *)&cursor, stuff->cursor, RT_CURSOR,
rc = dixLookupResourceByType((pointer *)&cursor, stuff->cursor, RT_CURSOR,
client, DixUseAccess);
if (rc != Success)
if (!cursor)
@ -6048,7 +6048,7 @@ ProcRecolorCursor(ClientPtr client)
REQUEST(xRecolorCursorReq);
REQUEST_SIZE_MATCH(xRecolorCursorReq);
rc = dixLookupResource((pointer *)&pCursor, stuff->cursor, RT_CURSOR,
rc = dixLookupResourceByType((pointer *)&pCursor, stuff->cursor, RT_CURSOR,
client, DixWriteAccess);
if (rc != Success)
{

View File

@ -273,7 +273,7 @@ dixChangeGC(ClientPtr client, GC *pGC, BITS32 mask, CARD32 *pC32, ChangeGCValPtr
else
{
NEXTVAL(XID, newpix);
rc = dixLookupResource((pointer *)&pPixmap, newpix,
rc = dixLookupResourceByType((pointer *)&pPixmap, newpix,
RT_PIXMAP, client, DixReadAccess);
}
if (rc == Success)
@ -310,7 +310,7 @@ dixChangeGC(ClientPtr client, GC *pGC, BITS32 mask, CARD32 *pC32, ChangeGCValPtr
else
{
NEXTVAL(XID, newstipple)
rc = dixLookupResource((pointer *)&pPixmap, newstipple,
rc = dixLookupResourceByType((pointer *)&pPixmap, newstipple,
RT_PIXMAP, client, DixReadAccess);
}
if (rc == Success)
@ -353,7 +353,7 @@ dixChangeGC(ClientPtr client, GC *pGC, BITS32 mask, CARD32 *pC32, ChangeGCValPtr
else
{
NEXTVAL(XID, newfont)
rc = dixLookupResource((pointer *)&pFont, newfont,
rc = dixLookupResourceByType((pointer *)&pFont, newfont,
RT_FONT, client, DixUseAccess);
}
if (rc == Success)
@ -420,7 +420,7 @@ dixChangeGC(ClientPtr client, GC *pGC, BITS32 mask, CARD32 *pC32, ChangeGCValPtr
pPixmap = NullPixmap;
}
else {
rc = dixLookupResource((pointer *)&pPixmap, pid,
rc = dixLookupResourceByType((pointer *)&pPixmap, pid,
RT_PIXMAP, client,
DixReadAccess);
if (rc != Success) {

View File

@ -846,11 +846,10 @@ LegalNewID(XID id, ClientPtr client)
}
_X_EXPORT int
dixLookupResource(pointer *result, XID id, RESTYPE rtype,
ClientPtr client, Mask mode)
dixLookupResourceByType(pointer *result, XID id, RESTYPE rtype,
ClientPtr client, Mask mode)
{
int cid = CLIENT_ID(id);
int istype = (rtype & TypeMask) && (rtype != RC_ANY);
ResourcePtr res = NULL;
*result = NULL;
@ -859,8 +858,38 @@ dixLookupResource(pointer *result, XID id, RESTYPE rtype,
res = clientTable[cid].resources[Hash(cid, id)];
for (; res; res = res->next)
if ((res->id == id) && ((istype && res->type == rtype) ||
(!istype && res->type & rtype)))
if (res->id == id && res->type == rtype)
break;
}
if (!res)
return BadValue;
if (client) {
client->errorValue = id;
cid = XaceHook(XACE_RESOURCE_ACCESS, client, id, res->type,
res->value, RT_NONE, NULL, mode);
if (cid != Success)
return cid;
}
*result = res->value;
return Success;
}
_X_EXPORT int
dixLookupResourceByClass(pointer *result, XID id, RESTYPE rclass,
ClientPtr client, Mask mode)
{
int cid = CLIENT_ID(id);
ResourcePtr res = NULL;
*result = NULL;
if ((cid < MAXCLIENTS) && clientTable[cid].buckets) {
res = clientTable[cid].resources[Hash(cid, id)];
for (; res; res = res->next)
if (res->id == id && (res->type & rclass))
break;
}
if (!res)

View File

@ -1086,7 +1086,7 @@ ChangeWindowAttributes(WindowPtr pWin, Mask vmask, XID *vlist, ClientPtr client)
}
else
{
rc = dixLookupResource((pointer *)&pPixmap, pixID, RT_PIXMAP,
rc = dixLookupResourceByType((pointer *)&pPixmap, pixID, RT_PIXMAP,
client, DixReadAccess);
if (rc == Success)
{
@ -1146,7 +1146,7 @@ ChangeWindowAttributes(WindowPtr pWin, Mask vmask, XID *vlist, ClientPtr client)
pixID = pWin->parent->border.pixmap->drawable.id;
}
}
rc = dixLookupResource((pointer *)&pPixmap, pixID, RT_PIXMAP,
rc = dixLookupResourceByType((pointer *)&pPixmap, pixID, RT_PIXMAP,
client, DixReadAccess);
if (rc == Success)
{
@ -1348,7 +1348,7 @@ ChangeWindowAttributes(WindowPtr pWin, Mask vmask, XID *vlist, ClientPtr client)
error = BadMatch;
goto PatchUp;
}
rc = dixLookupResource((pointer *)&pCmap, cmap, RT_COLORMAP,
rc = dixLookupResourceByType((pointer *)&pCmap, cmap, RT_COLORMAP,
client, DixUseAccess);
if (rc != Success)
{
@ -1424,7 +1424,7 @@ ChangeWindowAttributes(WindowPtr pWin, Mask vmask, XID *vlist, ClientPtr client)
}
else
{
rc = dixLookupResource((pointer *)&pCursor, cursorID,
rc = dixLookupResourceByType((pointer *)&pCursor, cursorID,
RT_CURSOR, client, DixUseAccess);
if (rc != Success)
{

View File

@ -769,6 +769,7 @@ exaCloseScreen(int i, ScreenPtr pScreen)
ps->Composite = pExaScr->SavedComposite;
ps->Glyphs = pExaScr->SavedGlyphs;
ps->Trapezoids = pExaScr->SavedTrapezoids;
ps->AddTraps = pExaScr->SavedAddTraps;
ps->Triangles = pExaScr->SavedTriangles;
}
#endif
@ -939,6 +940,9 @@ exaDriverInit (ScreenPtr pScreen,
pExaScr->SavedTrapezoids = ps->Trapezoids;
ps->Trapezoids = exaTrapezoids;
pExaScr->SavedAddTraps = ps->AddTraps;
ps->AddTraps = ExaCheckAddTraps;
}
#endif

View File

@ -147,6 +147,7 @@ typedef struct {
TrianglesProcPtr SavedTriangles;
GlyphsProcPtr SavedGlyphs;
TrapezoidsProcPtr SavedTrapezoids;
AddTrapsProcPtr SavedAddTraps;
#endif
Bool swappedOut;
@ -338,6 +339,13 @@ ExaCheckGetSpans (DrawablePtr pDrawable,
int nspans,
char *pdstStart);
void
ExaCheckAddTraps (PicturePtr pPicture,
INT16 x_off,
INT16 y_off,
int ntrap,
xTrap *traps);
/* exa_accel.c */
static _X_INLINE Bool

View File

@ -353,6 +353,20 @@ ExaCheckComposite (CARD8 op,
REGION_UNINIT(pScreen, &region);
}
void
ExaCheckAddTraps (PicturePtr pPicture,
INT16 x_off,
INT16 y_off,
int ntrap,
xTrap *traps)
{
EXA_FALLBACK(("to pict %p (%c)\n",
exaDrawableLocation(pPicture->pDrawable)));
exaPrepareAccess(pPicture->pDrawable, EXA_PREPARE_DEST);
fbAddTraps (pPicture, x_off, y_off, ntrap, traps);
exaFinishAccess(pPicture->pDrawable, EXA_PREPARE_DEST);
}
/**
* Gets the 0,0 pixel of a pixmap. Used for doing solid fills of tiled pixmaps
* that happen to be 1x1. Pixmap must be at least 8bpp.

View File

@ -471,7 +471,8 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
char filename[128];
size_t buffer_size;
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
unsigned int sareaHandle;
drm_handle_t sareaHandle;
unsigned int sareaSize;
const __DRIextension **extensions;
const __DRIconfig **driConfigs;
int i;
@ -482,7 +483,7 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
memset(screen, 0, sizeof *screen);
if (!xf86LoaderCheckSymbol("DRI2Connect") ||
!DRI2Connect(pScreen, &screen->fd, &driverName, &sareaHandle)) {
!DRI2Connect(pScreen, &screen->fd, &driverName, &sareaHandle, &sareaSize)) {
LogMessage(X_INFO,
"AIGLX: Screen %d is not DRI2 capable\n", pScreen->myNum);
return NULL;
@ -530,6 +531,7 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
(*screen->core->createNewScreen)(pScreen->myNum,
screen->fd,
sareaHandle,
sareaSize,
loader_extensions,
&driConfigs,
screen);

View File

@ -378,7 +378,7 @@ void glxSuspendClients(void)
int i;
for (i = 1; i < currentMaxClients; i++) {
if (clients[i] && glxGetClient(clients[i])->inUse)
if (clients[i] && clients[i]->osPrivate && glxGetClient(clients[i])->inUse)
IgnoreClient(clients[i]);
}

View File

@ -10,3 +10,7 @@ INCLUDES = $(XORG_INCS) -I$(srcdir)/../i2c
AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS)
EXTRA_DIST = ddcPriv.h DDC.HOWTO
bin_PROGRAMS = decode_edid
decode_edid_SOURCES = decode_edid.c interpret_edid.c print_edid.c

View File

@ -0,0 +1,80 @@
#ifdef HAVE_XORG_CONFIG_H
#include <xorg-config.h>
#endif
#include "misc.h"
#include "xf86.h"
#include "xf86_OSproc.h"
#define _PARSE_EDID_
#include "xf86DDC.h"
#include <string.h>
Uchar edid[] = {
0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
0x52, 0x62, 0x05, 0x01, 0x00, 0x00, 0x00, 0x00,
0x00, 0x11, 0x01, 0x03, 0x80, 0x69, 0x3b, 0x78,
0x0a, 0x0d, 0xc9, 0xa0, 0x57, 0x47, 0x98, 0x27,
0x12, 0x48, 0x4c, 0x20, 0x00, 0x00, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x3a,
0x80, 0xd0, 0x72, 0x38, 0x2d, 0x40, 0x10, 0x2c,
0x45, 0x80, 0xc4, 0x8e, 0x21, 0x00, 0x00, 0x1e,
0x8c, 0x0a, 0xd0, 0x90, 0x20, 0x40, 0x31, 0x20,
0x0c, 0x40, 0x55, 0x00, 0xc4, 0x8e, 0x21, 0x00,
0x00, 0x18, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x54,
0x4f, 0x53, 0x48, 0x49, 0x42, 0x41, 0x2d, 0x54,
0x56, 0x0a, 0x20, 0x20, 0x00, 0x00, 0x00, 0xfd,
0x00, 0x17, 0x3d, 0x0f, 0x44, 0x0f, 0x00, 0x0a,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x01, 0x3b,
};
int
main (int argc, char **argv)
{
xf86MonPtr m;
m = xf86InterpretEDID (0, edid);
(void) xf86PrintEDID (m);
return 0;
}
pointer
XNFcalloc (unsigned long amount)
{
return calloc (amount, 1);
}
#include <stdarg.h>
void
xf86DrvMsg (int srcn, MessageType type, const char *fmt, ...)
{
va_list args;
va_start (args, fmt);
vprintf (fmt, args);
}
void
xf86Msg (MessageType type, const char *fmt, ...)
{
va_list args;
va_start (args, fmt);
vprintf (fmt, args);
}
void
xf86ErrorF (const char *fmt, ...)
{
va_list args;
va_start (args, fmt);
vprintf (fmt, args);
}
void
Xfree (pointer x)
{
free (x);
}

View File

@ -57,8 +57,8 @@ typedef struct _DRI2DrawablePriv {
typedef struct _DRI2Screen {
int fd;
drmBO sareaBO;
void *sarea;
drm_handle_t sareaHandle;
unsigned int sareaSize;
const char *driverName;
unsigned int nextHandle;
@ -257,8 +257,7 @@ DRI2CloseScreen(ScreenPtr pScreen)
pScreen->ClipNotify = ds->ClipNotify;
pScreen->HandleExposures = ds->HandleExposures;
drmBOUnmap(ds->fd, &ds->sareaBO);
drmBOUnreference(ds->fd, &ds->sareaBO);
drmRmMap(ds->fd, ds->sareaHandle);
xfree(ds);
dixSetPrivate(&pScreen->devPrivates, dri2ScreenPrivateKey, NULL);
@ -350,7 +349,8 @@ DRI2ReemitDrawableInfo(DrawablePtr pDraw, unsigned int *head)
Bool
DRI2Connect(ScreenPtr pScreen, int *fd, const char **driverName,
unsigned int *sareaHandle)
drm_handle_t *sareaHandle,
drmSize *sareaSize)
{
DRI2ScreenPtr ds = DRI2GetScreen(pScreen);
@ -359,7 +359,8 @@ DRI2Connect(ScreenPtr pScreen, int *fd, const char **driverName,
*fd = ds->fd;
*driverName = ds->driverName;
*sareaHandle = ds->sareaBO.handle;
*sareaHandle = ds->sareaHandle;
*sareaSize = ds->sareaSize;
return TRUE;
}
@ -387,7 +388,7 @@ static void *
DRI2SetupSAREA(ScreenPtr pScreen, size_t driverSareaSize)
{
DRI2ScreenPtr ds = DRI2GetScreen(pScreen);
unsigned long mask;
const size_t event_buffer_size = 32 * 1024;
ds->sareaSize =
@ -395,21 +396,18 @@ DRI2SetupSAREA(ScreenPtr pScreen, size_t driverSareaSize)
driverSareaSize +
sizeof (unsigned int);
mask = DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE | DRM_BO_FLAG_MAPPABLE |
DRM_BO_FLAG_MEM_LOCAL | DRM_BO_FLAG_SHAREABLE;
if (drmBOCreate(ds->fd, ds->sareaSize, 1, NULL, mask, 0, &ds->sareaBO))
if (drmAddMap(ds->fd, 1, ds->sareaSize, DRM_SHM,
DRM_CONTAINS_LOCK, &ds->sareaHandle) != 0)
return NULL;
if (drmBOMap(ds->fd, &ds->sareaBO,
DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE, 0, &ds->sarea)) {
drmBOUnreference(ds->fd, &ds->sareaBO);
if (drmMap(ds->fd, ds->sareaHandle, ds->sareaSize, &ds->sarea)) {
drmRmMap (ds->fd, ds->sareaHandle);
return NULL;
}
xf86DrvMsg(pScreen->myNum, X_INFO,
"[DRI2] Allocated %d byte SAREA, BO handle 0x%08x\n",
ds->sareaSize, ds->sareaBO.handle);
"[DRI2] Allocated %d byte SAREA, handle 0x%08x\n",
ds->sareaSize, ds->sareaHandle);
memset(ds->sarea, 0, ds->sareaSize);
ds->buffer = ds->sarea;

View File

@ -56,7 +56,8 @@ void DRI2CloseScreen(ScreenPtr pScreen);
Bool DRI2Connect(ScreenPtr pScreen,
int *fd,
const char **driverName,
unsigned int *sareaHandle);
drm_handle_t *sareaHandle,
drmSize *sareaSize);
Bool DRI2AuthConnection(ScreenPtr pScreen, drm_magic_t magic);

View File

@ -115,7 +115,8 @@ ProcDRI2Connect(ClientPtr client)
int fd;
const char *driverName;
char *busId = NULL;
unsigned int sareaHandle;
drm_handle_t sareaHandle;
unsigned int sareaSize;
REQUEST_SIZE_MATCH(xDRI2ConnectReq);
if (!validScreen(client, stuff->screen, &pScreen))
@ -127,8 +128,9 @@ ProcDRI2Connect(ClientPtr client)
rep.driverNameLength = 0;
rep.busIdLength = 0;
rep.sareaHandle = 0;
rep.sareaSize = 0;
if (!DRI2Connect(pScreen, &fd, &driverName, &sareaHandle))
if (!DRI2Connect(pScreen, &fd, &driverName, &sareaHandle, &sareaSize))
goto fail;
busId = drmGetBusid(fd);
@ -137,7 +139,8 @@ ProcDRI2Connect(ClientPtr client)
rep.driverNameLength = strlen(driverName);
rep.busIdLength = strlen(busId);
rep.sareaHandle = sareaHandle;
rep.sareaHandle = (CARD32) sareaHandle;
rep.sareaSize = (CARD32) sareaSize;
rep.length = (rep.driverNameLength + 3) / 4 + (rep.busIdLength + 3) / 4;
fail:

View File

@ -276,6 +276,8 @@ _X_HIDDEN void *dixLookupTab[] = {
SYMFUNC(ChangeResourceValue)
SYMFUNC(CreateNewResourceClass)
SYMFUNC(CreateNewResourceType)
SYMFUNC(dixLookupResourceByType)
SYMFUNC(dixLookupResourceByClass)
SYMFUNC(dixLookupResource)
SYMFUNC(FakeClientID)
SYMFUNC(FreeResource)

View File

@ -103,6 +103,17 @@ xf86CrtcCreate (ScrnInfoPtr scrn,
#endif
crtc->rotation = RR_Rotate_0;
crtc->desiredRotation = RR_Rotate_0;
PictureTransformInitIdentity (&crtc->crtc_to_framebuffer);
pict_f_transform_init_identity (&crtc->f_crtc_to_framebuffer);
pict_f_transform_init_identity (&crtc->f_framebuffer_to_crtc);
crtc->filter = NULL;
crtc->params = NULL;
crtc->nparams = 0;
crtc->filter_width = 0;
crtc->filter_height = 0;
crtc->transform_in_use = FALSE;
memset (&crtc->bounds, '\0', sizeof (crtc->bounds));
if (xf86_config->crtc)
crtcs = xrealloc (xf86_config->crtc,
(xf86_config->num_crtc + 1) * sizeof (xf86CrtcPtr));
@ -134,6 +145,8 @@ xf86CrtcDestroy (xf86CrtcPtr crtc)
xf86_config->num_crtc--;
break;
}
if (crtc->params)
xfree (crtc->params);
xfree (crtc);
}
@ -224,8 +237,8 @@ xf86CrtcSetScreenSubpixelOrder (ScreenPtr pScreen)
* Sets the given video mode on the given crtc
*/
_X_EXPORT Bool
xf86CrtcSetMode (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation,
int x, int y)
xf86CrtcSetModeTransform (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation,
RRTransformPtr transform, int x, int y)
{
ScrnInfoPtr scrn = crtc->scrn;
xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
@ -236,6 +249,8 @@ xf86CrtcSetMode (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation,
DisplayModeRec saved_mode;
int saved_x, saved_y;
Rotation saved_rotation;
RRTransformRec saved_transform;
Bool saved_transform_present;
if (crtc->funcs->set_mode_major)
return crtc->funcs->set_mode_major(crtc, mode, rotation, x, y);
@ -256,6 +271,12 @@ xf86CrtcSetMode (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation,
saved_x = crtc->x;
saved_y = crtc->y;
saved_rotation = crtc->rotation;
if (crtc->transformPresent) {
RRTransformInit (&saved_transform);
RRTransformCopy (&saved_transform, &crtc->transform);
}
saved_transform_present = crtc->transformPresent;
/* Update crtc values up front so the driver can rely on them for mode
* setting.
*/
@ -263,6 +284,11 @@ xf86CrtcSetMode (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation,
crtc->x = x;
crtc->y = y;
crtc->rotation = rotation;
if (transform) {
RRTransformCopy (&crtc->transform, transform);
crtc->transformPresent = TRUE;
} else
crtc->transformPresent = FALSE;
/* Shift offsets that move us out of virtual size */
if (x + mode->HDisplay > xf86_config->maxWidth ||
@ -309,9 +335,8 @@ xf86CrtcSetMode (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation,
goto done;
}
if (!xf86CrtcRotate (crtc, mode, rotation)) {
if (!xf86CrtcRotate (crtc))
goto done;
}
/* Prepare the outputs and CRTCs before setting the mode. */
for (i = 0; i < xf86_config->num_output; i++) {
@ -343,13 +368,7 @@ xf86CrtcSetMode (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation,
{
xf86OutputPtr output = xf86_config->output[i];
if (output->crtc == crtc)
{
output->funcs->commit(output);
#ifdef RANDR_12_INTERFACE
if (output->randr_output)
RRPostPendingProperties (output->randr_output);
#endif
}
}
/* XXX free adjustedmode */
@ -363,6 +382,9 @@ done:
crtc->y = saved_y;
crtc->rotation = saved_rotation;
crtc->mode = saved_mode;
if (saved_transform_present)
RRTransformCopy (&crtc->transform, &saved_transform);
crtc->transformPresent = saved_transform_present;
}
if (didLock)
@ -371,6 +393,17 @@ done:
return ret;
}
/**
* Sets the given video mode on the given crtc, but without providing
* a transform
*/
_X_EXPORT Bool
xf86CrtcSetMode (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation,
int x, int y)
{
return xf86CrtcSetModeTransform (crtc, mode, rotation, NULL, x, y);
}
/*
* Output functions
*/
@ -719,11 +752,17 @@ xf86CrtcScreenInit (ScreenPtr screen)
break;
}
if (c == config->num_crtc)
{
xf86RandR12SetRotations (screen, RR_Rotate_0 | RR_Rotate_90 |
RR_Rotate_180 | RR_Rotate_270 |
RR_Reflect_X | RR_Reflect_Y);
xf86RandR12SetTransformSupport (screen, TRUE);
}
else
{
xf86RandR12SetRotations (screen, RR_Rotate_0);
xf86RandR12SetTransformSupport (screen, FALSE);
}
/* Wrap CreateScreenResources so we can initialize the RandR code */
config->CreateScreenResources = screen->CreateScreenResources;
@ -2174,6 +2213,7 @@ xf86InitialConfiguration (ScrnInfoPtr scrn, Bool canGrow)
crtc->desiredRotation = output->initial_rotation;
crtc->desiredX = output->initial_x;
crtc->desiredY = output->initial_y;
crtc->desiredTransformPresent = FALSE;
crtc->enabled = TRUE;
crtc->x = output->initial_x;
crtc->y = output->initial_y;
@ -2305,6 +2345,7 @@ xf86SetDesiredModes (ScrnInfoPtr scrn)
xf86CrtcPtr crtc = config->crtc[c];
xf86OutputPtr output = NULL;
int o;
RRTransformPtr transform;
/* Skip disabled CRTCs */
if (!crtc->enabled)
@ -2335,12 +2376,17 @@ xf86SetDesiredModes (ScrnInfoPtr scrn)
return FALSE;
crtc->desiredMode = *mode;
crtc->desiredRotation = RR_Rotate_0;
crtc->desiredTransformPresent = FALSE;
crtc->desiredX = 0;
crtc->desiredY = 0;
}
if (!xf86CrtcSetMode (crtc, &crtc->desiredMode, crtc->desiredRotation,
crtc->desiredX, crtc->desiredY))
if (crtc->desiredTransformPresent)
transform = &crtc->desiredTransform;
else
transform = NULL;
if (!xf86CrtcSetModeTransform (crtc, &crtc->desiredMode, crtc->desiredRotation,
transform, crtc->desiredX, crtc->desiredY))
return FALSE;
}
@ -2469,12 +2515,13 @@ xf86SetSingleMode (ScrnInfoPtr pScrn, DisplayModePtr desired, Rotation rotation)
crtc->enabled = FALSE;
continue;
}
if (!xf86CrtcSetMode (crtc, crtc_mode, rotation, 0, 0))
if (!xf86CrtcSetModeTransform (crtc, crtc_mode, rotation, NULL, 0, 0))
ok = FALSE;
else
{
crtc->desiredMode = *crtc_mode;
crtc->desiredRotation = rotation;
crtc->desiredTransformPresent = FALSE;
crtc->desiredX = 0;
crtc->desiredY = 0;
}

View File

@ -305,8 +305,18 @@ struct _xf86Crtc {
* Current transformation matrix
*/
PictTransform crtc_to_framebuffer;
PictTransform framebuffer_to_crtc;
struct pict_f_transform f_crtc_to_framebuffer;
struct pict_f_transform f_framebuffer_to_crtc;
PictFilterPtr filter;
xFixed *params;
int nparams;
int filter_width;
int filter_height;
Bool transform_in_use;
RRTransformRec transform;
Bool transformPresent;
RRTransformRec desiredTransform;
Bool desiredTransformPresent;
/**
* Bounding box in screen space
*/
@ -654,6 +664,11 @@ xf86CrtcDestroy (xf86CrtcPtr crtc);
/**
* Sets the given video mode on the given crtc
*/
Bool
xf86CrtcSetModeTransform (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation,
RRTransformPtr transform, int x, int y);
Bool
xf86CrtcSetMode (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation,
int x, int y);
@ -662,7 +677,7 @@ xf86CrtcSetMode (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation,
* Assign crtc rotation during mode set
*/
Bool
xf86CrtcRotate (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation);
xf86CrtcRotate (xf86CrtcPtr crtc);
/*
* free shadow memory allocated for all crtcs

View File

@ -37,6 +37,7 @@
#include "xf86Crtc.h"
#include "xf86Modes.h"
#include "xf86RandR12.h"
#include "xf86CursorPriv.h"
#include "X11/extensions/render.h"
#define DPMS_SERVER
#include "X11/extensions/dpms.h"
@ -321,25 +322,31 @@ xf86_crtc_set_cursor_position (xf86CrtcPtr crtc, int x, int y)
*/
if (crtc->transform_in_use)
{
PictVector v;
v.vector[0] = IntToxFixed (x); v.vector[1] = IntToxFixed (y); v.vector[2] = IntToxFixed(1);
PictureTransformPoint (&crtc->framebuffer_to_crtc, &v);
x = xFixedToInt (v.vector[0]); y = xFixedToInt (v.vector[1]);
}
ScreenPtr screen = scrn->pScreen;
xf86CursorScreenPtr ScreenPriv =
(xf86CursorScreenPtr)dixLookupPrivate(&screen->devPrivates,
xf86CursorScreenKey);
struct pict_f_vector v;
v.v[0] = x + ScreenPriv->HotX; v.v[1] = y + ScreenPriv->HotY; v.v[2] = 1;
pict_f_transform_point (&crtc->f_framebuffer_to_crtc, &v);
x = floor (v.v[0] + 0.5);
y = floor (v.v[1] + 0.5);
/*
* Transform position of cursor upper left corner
*/
xf86_crtc_rotate_coord_back (crtc->rotation,
cursor_info->MaxWidth,
cursor_info->MaxHeight,
ScreenPriv->HotX, ScreenPriv->HotY, &dx, &dy);
x -= dx;
y -= dy;
}
else
{
x -= crtc->x;
y -= crtc->y;
}
/*
* Transform position of cursor upper left corner
*/
xf86_crtc_rotate_coord_back (crtc->rotation,
cursor_info->MaxWidth,
cursor_info->MaxHeight,
0, 0, &dx, &dy);
x -= dx;
y -= dy;
/*
* Disable the cursor when it is outside the viewport

View File

@ -567,6 +567,31 @@ xf86RandR12SetRotations (ScreenPtr pScreen, Rotation rotations)
randrp->supported_rotations = rotations;
}
_X_EXPORT void
xf86RandR12SetTransformSupport (ScreenPtr pScreen, Bool transforms)
{
XF86RandRInfoPtr randrp;
#if RANDR_13_INTERFACE
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
int c;
xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
#endif
#if XORG_VERSION_CURRENT < XORG_VERSION_NUMERIC(7,0,0,0,0)
if (xf86RandR12Key == NULL)
return;
#endif
randrp = XF86RANDRINFO(pScreen);
#if RANDR_13_INTERFACE
for (c = 0; c < config->num_crtc; c++) {
xf86CrtcPtr crtc = config->crtc[c];
RRCrtcSetTransformSupport (crtc->randr_crtc, transforms);
}
#endif
}
_X_EXPORT void
xf86RandR12GetOriginalVirtualSize(ScrnInfoPtr pScrn, int *x, int *y)
{
@ -689,7 +714,9 @@ xf86RandR12CrtcNotify (RRCrtcPtr randr_crtc)
}
}
ret = RRCrtcNotify (randr_crtc, randr_mode, x, y,
rotation, numOutputs, randr_outputs);
rotation,
crtc->transformPresent ? &crtc->transform : NULL,
numOutputs, randr_outputs);
xfree(randr_outputs);
return ret;
}
@ -725,18 +752,19 @@ xf86RandRModeConvert (ScrnInfoPtr scrn,
}
static Bool
xf86RandR12CrtcSet (ScreenPtr pScreen,
RRCrtcPtr randr_crtc,
RRModePtr randr_mode,
int x,
int y,
Rotation rotation,
int num_randr_outputs,
RROutputPtr *randr_outputs)
xf86RandR12CrtcSet (ScreenPtr pScreen,
RRCrtcPtr randr_crtc,
RRModePtr randr_mode,
int x,
int y,
Rotation rotation,
int num_randr_outputs,
RROutputPtr *randr_outputs)
{
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
xf86CrtcPtr crtc = randr_crtc->devPrivate;
RRTransformPtr transform;
Bool changed = FALSE;
int o, ro;
xf86CrtcPtr *save_crtcs;
@ -754,6 +782,13 @@ xf86RandR12CrtcSet (ScreenPtr pScreen,
if (rotation != crtc->rotation)
changed = TRUE;
transform = RRCrtcGetTransform (randr_crtc);
if ((transform != NULL) != crtc->transformPresent)
changed = TRUE;
else if (transform && memcmp (&transform->transform, &crtc->transform.transform,
sizeof (transform->transform)) != 0)
changed = TRUE;
if (x != crtc->x || y != crtc->y)
changed = TRUE;
for (o = 0; o < config->num_output; o++)
@ -791,9 +826,10 @@ xf86RandR12CrtcSet (ScreenPtr pScreen,
if (randr_mode)
{
DisplayModeRec mode;
RRTransformPtr transform = RRCrtcGetTransform (randr_crtc);
xf86RandRModeConvert (pScrn, randr_mode, &mode);
if (!xf86CrtcSetMode (crtc, &mode, rotation, x, y))
if (!xf86CrtcSetModeTransform (crtc, &mode, rotation, transform, x, y))
{
crtc->enabled = save_enabled;
for (o = 0; o < config->num_output; o++)
@ -809,6 +845,12 @@ xf86RandR12CrtcSet (ScreenPtr pScreen,
*/
crtc->desiredMode = mode;
crtc->desiredRotation = rotation;
if (transform) {
crtc->desiredTransform = *transform;
crtc->desiredTransformPresent = TRUE;
} else
crtc->desiredTransformPresent = FALSE;
crtc->desiredX = x;
crtc->desiredY = y;
}

View File

@ -31,6 +31,7 @@
Bool xf86RandR12CreateScreenResources (ScreenPtr pScreen);
Bool xf86RandR12Init(ScreenPtr pScreen);
void xf86RandR12SetRotations (ScreenPtr pScreen, Rotation rotation);
void xf86RandR12SetTransformSupport (ScreenPtr pScreen, Bool transforms);
Bool xf86RandR12SetConfig(ScreenPtr pScreen, Rotation rotation, int rate,
RRScreenSizePtr pSize);
Rotation xf86RandR12GetRotation(ScreenPtr pScreen);

View File

@ -38,6 +38,7 @@
#define xf86CrtcInUse XF86NAME(xf86CrtcInUse)
#define xf86CrtcRotate XF86NAME(xf86CrtcRotate)
#define xf86CrtcScreenInit XF86NAME(xf86CrtcScreenInit)
#define xf86CrtcSetModeTransform XF86NAME(xf86CrtcSetModeTransform)
#define xf86CrtcSetMode XF86NAME(xf86CrtcSetMode)
#define xf86CrtcSetSizeRange XF86NAME(xf86CrtcSetSizeRange)
#define xf86CVTMode XF86NAME(xf86CVTMode)

View File

@ -70,204 +70,8 @@ compWindowFormat (WindowPtr pWin)
#define F(x) IntToxFixed(x)
static void
PictureTransformIdentity (PictTransformPtr matrix)
{
int i;
memset (matrix, '\0', sizeof (PictTransform));
for (i = 0; i < 3; i++)
matrix->matrix[i][i] = F(1);
}
static Bool
PictureTransformMultiply (PictTransformPtr dst, PictTransformPtr l, PictTransformPtr r)
{
PictTransform d;
int dx, dy;
int o;
for (dy = 0; dy < 3; dy++)
for (dx = 0; dx < 3; dx++)
{
xFixed_48_16 v;
xFixed_32_32 partial;
v = 0;
for (o = 0; o < 3; o++)
{
partial = (xFixed_32_32) l->matrix[dy][o] * (xFixed_32_32) r->matrix[o][dx];
v += partial >> 16;
}
if (v > MAX_FIXED_48_16 || v < MIN_FIXED_48_16)
return FALSE;
d.matrix[dy][dx] = (xFixed) v;
}
*dst = d;
return TRUE;
}
static void
PictureTransformInitScale (PictTransformPtr t, xFixed sx, xFixed sy)
{
memset (t, '\0', sizeof (PictTransform));
t->matrix[0][0] = sx;
t->matrix[1][1] = sy;
t->matrix[2][2] = F (1);
}
static xFixed
fixed_inverse (xFixed x)
{
return (xFixed) ((((xFixed_48_16) F(1)) * F(1)) / x);
}
static Bool
PictureTransformScale (PictTransformPtr forward,
PictTransformPtr reverse,
xFixed sx, xFixed sy)
{
PictTransform t;
PictureTransformInitScale (&t, sx, sy);
if (!PictureTransformMultiply (forward, &t, forward))
return FALSE;
PictureTransformInitScale (&t, fixed_inverse (sx), fixed_inverse (sy));
if (!PictureTransformMultiply (reverse, reverse, &t))
return FALSE;
return TRUE;
}
static void
PictureTransformInitRotate (PictTransformPtr t, xFixed c, xFixed s)
{
memset (t, '\0', sizeof (PictTransform));
t->matrix[0][0] = c;
t->matrix[0][1] = -s;
t->matrix[1][0] = s;
t->matrix[1][1] = c;
t->matrix[2][2] = F (1);
}
static Bool
PictureTransformRotate (PictTransformPtr forward,
PictTransformPtr reverse,
xFixed c, xFixed s)
{
PictTransform t;
PictureTransformInitRotate (&t, c, s);
if (!PictureTransformMultiply (forward, &t, forward))
return FALSE;
PictureTransformInitRotate (&t, c, -s);
if (!PictureTransformMultiply (reverse, reverse, &t))
return FALSE;
return TRUE;
}
static void
PictureTransformInitTranslate (PictTransformPtr t, xFixed tx, xFixed ty)
{
memset (t, '\0', sizeof (PictTransform));
t->matrix[0][0] = F (1);
t->matrix[0][2] = tx;
t->matrix[1][1] = F (1);
t->matrix[1][2] = ty;
t->matrix[2][2] = F (1);
}
static Bool
PictureTransformTranslate (PictTransformPtr forward,
PictTransformPtr reverse,
xFixed tx, xFixed ty)
{
PictTransform t;
PictureTransformInitTranslate (&t, tx, ty);
if (!PictureTransformMultiply (forward, &t, forward))
return FALSE;
PictureTransformInitTranslate (&t, -tx, -ty);
if (!PictureTransformMultiply (reverse, reverse, &t))
return FALSE;
return TRUE;
}
static void
PictureTransformBounds (BoxPtr b, PictTransformPtr matrix)
{
PictVector v[4];
int i;
int x1, y1, x2, y2;
v[0].vector[0] = F (b->x1); v[0].vector[1] = F (b->y1); v[0].vector[2] = F(1);
v[1].vector[0] = F (b->x2); v[1].vector[1] = F (b->y1); v[1].vector[2] = F(1);
v[2].vector[0] = F (b->x2); v[2].vector[1] = F (b->y2); v[2].vector[2] = F(1);
v[3].vector[0] = F (b->x1); v[3].vector[1] = F (b->y2); v[3].vector[2] = F(1);
for (i = 0; i < 4; i++)
{
PictureTransformPoint (matrix, &v[i]);
x1 = xFixedToInt (v[i].vector[0]);
y1 = xFixedToInt (v[i].vector[1]);
x2 = xFixedToInt (xFixedCeil (v[i].vector[0]));
y2 = xFixedToInt (xFixedCeil (v[i].vector[1]));
if (i == 0)
{
b->x1 = x1; b->y1 = y1;
b->x2 = x2; b->y2 = y2;
}
else
{
if (x1 < b->x1) b->x1 = x1;
if (y1 < b->y1) b->y1 = y1;
if (x2 > b->x2) b->x2 = x2;
if (y2 > b->y2) b->y2 = y2;
}
}
}
static Bool
PictureTransformIsIdentity(PictTransform *t)
{
return ((t->matrix[0][0] == t->matrix[1][1]) &&
(t->matrix[0][0] == t->matrix[2][2]) &&
(t->matrix[0][0] != 0) &&
(t->matrix[0][1] == 0) &&
(t->matrix[0][2] == 0) &&
(t->matrix[1][0] == 0) &&
(t->matrix[1][2] == 0) &&
(t->matrix[2][0] == 0) &&
(t->matrix[2][1] == 0));
}
#define toF(x) ((float) (x) / 65536.0f)
static void
PictureTransformErrorF (PictTransform *t)
{
ErrorF ("{ { %f %f %f } { %f %f %f } { %f %f %f } }",
toF(t->matrix[0][0]), toF(t->matrix[0][1]), toF(t->matrix[0][2]),
toF(t->matrix[1][0]), toF(t->matrix[1][1]), toF(t->matrix[1][2]),
toF(t->matrix[2][0]), toF(t->matrix[2][1]), toF(t->matrix[2][2]));
}
static Bool
PictureTransformIsInverse (char *where, PictTransform *a, PictTransform *b)
{
PictTransform t;
PictureTransformMultiply (&t, a, b);
if (!PictureTransformIsIdentity (&t))
{
ErrorF ("%s: ", where);
PictureTransformErrorF (a);
ErrorF (" * ");
PictureTransformErrorF (b);
ErrorF (" = ");
PictureTransformErrorF (a);
ErrorF ("\n");
return FALSE;
}
return TRUE;
}
static void
xf86RotateCrtcRedisplay (xf86CrtcPtr crtc, RegionPtr region)
{
@ -305,13 +109,20 @@ xf86RotateCrtcRedisplay (xf86CrtcPtr crtc, RegionPtr region)
error = SetPictureTransform (src, &crtc->crtc_to_framebuffer);
if (error)
return;
if (crtc->transform_in_use && crtc->filter)
SetPicturePictFilter (src, crtc->filter,
crtc->params, crtc->nparams);
while (n--)
{
BoxRec dst_box;
dst_box = *b;
PictureTransformBounds (&dst_box, &crtc->framebuffer_to_crtc);
dst_box.x1 -= crtc->filter_width >> 1;
dst_box.x2 += crtc->filter_width >> 1;
dst_box.y1 -= crtc->filter_height >> 1;
dst_box.y2 += crtc->filter_height >> 1;
pict_f_transform_bounds (&crtc->f_framebuffer_to_crtc, &dst_box);
CompositePicture (PictOpSrc,
src, NULL, dst,
dst_box.x1, dst_box.y1, 0, 0, dst_box.x1, dst_box.y1,
@ -323,6 +134,37 @@ xf86RotateCrtcRedisplay (xf86CrtcPtr crtc, RegionPtr region)
FreePicture (dst, None);
}
static void
xf86CrtcShadowClear (xf86CrtcPtr crtc)
{
PixmapPtr dst_pixmap = crtc->rotatedPixmap;
ScrnInfoPtr scrn = crtc->scrn;
ScreenPtr screen = scrn->pScreen;
PicturePtr dst;
PictFormatPtr format = compWindowFormat (WindowTable[screen->myNum]);
static xRenderColor black = { 0, 0, 0, 0 };
xRectangle rect;
int error;
if (!dst_pixmap)
return;
dst = CreatePicture (None,
&dst_pixmap->drawable,
format,
0L,
NULL,
serverClient,
&error);
if (!dst)
return;
rect.x = 0;
rect.y = 0;
rect.width = dst_pixmap->drawable.width;
rect.height = dst_pixmap->drawable.height;
CompositeRects (PictOpSrc, dst, &black, 1, &rect);
FreePicture (dst, None);
}
static void
xf86CrtcDamageShadow (xf86CrtcPtr crtc)
{
@ -331,14 +173,26 @@ xf86CrtcDamageShadow (xf86CrtcPtr crtc)
RegionRec damage_region;
ScreenPtr pScreen = pScrn->pScreen;
damage_box.x1 = crtc->x;
damage_box.x2 = crtc->x + xf86ModeWidth (&crtc->mode, crtc->rotation);
damage_box.y1 = crtc->y;
damage_box.y2 = crtc->y + xf86ModeHeight (&crtc->mode, crtc->rotation);
damage_box.x1 = 0;
damage_box.x2 = crtc->mode.HDisplay;
damage_box.y1 = 0;
damage_box.y2 = crtc->mode.VDisplay;
if (1 || !PictureTransformBounds (&damage_box, &crtc->crtc_to_framebuffer))
{
damage_box.x1 = 0;
damage_box.y1 = 0;
damage_box.x2 = pScreen->width;
damage_box.y2 = pScreen->height;
}
if (damage_box.x1 < 0) damage_box.x1 = 0;
if (damage_box.y1 < 0) damage_box.y1 = 0;
if (damage_box.x2 > pScreen->width) damage_box.x2 = pScreen->width;
if (damage_box.y2 > pScreen->height) damage_box.y2 = pScreen->height;
REGION_INIT (pScreen, &damage_region, &damage_box, 1);
DamageDamageRegion (&(*pScreen->GetScreenPixmap)(pScreen)->drawable,
&damage_region);
REGION_UNINIT (pScreen, &damage_region);
xf86CrtcShadowClear (crtc);
}
static void
@ -401,7 +255,7 @@ xf86RotateRedisplay(ScreenPtr pScreen)
{
xf86CrtcPtr crtc = xf86_config->crtc[c];
if (crtc->rotation != RR_Rotate_0 && crtc->enabled)
if (crtc->transform_in_use && crtc->enabled)
{
RegionRec crtc_damage;
@ -506,116 +360,90 @@ xf86RotateCloseScreen (ScreenPtr screen)
xf86RotateDestroy (xf86_config->crtc[c]);
}
static Bool
xf86CrtcFitsScreen (xf86CrtcPtr crtc, struct pict_f_transform *crtc_to_fb)
{
ScrnInfoPtr pScrn = crtc->scrn;
/* if this is called during ScreenInit() we don't have pScrn->pScreen yet */
ScreenPtr pScreen = screenInfo.screens[pScrn->scrnIndex];
BoxRec b;
if (!pScreen)
return TRUE;
b.x1 = 0;
b.y1 = 0;
b.x2 = crtc->mode.HDisplay;
b.y2 = crtc->mode.VDisplay;
if (crtc_to_fb)
pict_f_transform_bounds (crtc_to_fb, &b);
else {
b.x1 += crtc->x;
b.y1 += crtc->y;
b.x2 += crtc->x;
b.y2 += crtc->y;
}
return (0 <= b.x1 && b.x2 <= pScreen->width &&
0 <= b.y1 && b.y2 <= pScreen->height);
}
_X_EXPORT Bool
xf86CrtcRotate (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation)
xf86CrtcRotate (xf86CrtcPtr crtc)
{
ScrnInfoPtr pScrn = crtc->scrn;
xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
/* if this is called during ScreenInit() we don't have pScrn->pScreen yet */
ScreenPtr pScreen = screenInfo.screens[pScrn->scrnIndex];
PictTransform crtc_to_fb, fb_to_crtc;
PictureTransformIdentity (&crtc_to_fb);
PictureTransformIdentity (&fb_to_crtc);
PictureTransformIsInverse ("identity", &crtc_to_fb, &fb_to_crtc);
if (rotation != RR_Rotate_0)
PictTransform crtc_to_fb;
struct pict_f_transform f_crtc_to_fb, f_fb_to_crtc;
xFixed *new_params = NULL;
int new_nparams = 0;
PictFilterPtr new_filter = NULL;
int new_width = 0;
int new_height = 0;
RRTransformPtr transform = NULL;
if (crtc->transformPresent)
transform = &crtc->transform;
if (!RRTransformCompute (crtc->x, crtc->y,
crtc->mode.HDisplay, crtc->mode.VDisplay,
crtc->rotation,
transform,
&crtc_to_fb,
&f_crtc_to_fb,
&f_fb_to_crtc) &&
xf86CrtcFitsScreen (crtc, &f_crtc_to_fb))
{
xFixed rot_cos, rot_sin, rot_dx, rot_dy;
xFixed scale_x, scale_y, scale_dx, scale_dy;
int mode_w = crtc->mode.HDisplay;
int mode_h = crtc->mode.VDisplay;
/* rotation */
switch (rotation & 0xf) {
default:
case RR_Rotate_0:
rot_cos = F ( 1); rot_sin = F ( 0);
rot_dx = F ( 0); rot_dy = F ( 0);
break;
case RR_Rotate_90:
rot_cos = F ( 0); rot_sin = F ( 1);
rot_dx = F ( mode_h); rot_dy = F (0);
break;
case RR_Rotate_180:
rot_cos = F (-1); rot_sin = F ( 0);
rot_dx = F (mode_w); rot_dy = F ( mode_h);
break;
case RR_Rotate_270:
rot_cos = F ( 0); rot_sin = F (-1);
rot_dx = F ( 0); rot_dy = F ( mode_w);
break;
}
PictureTransformRotate (&crtc_to_fb, &fb_to_crtc, rot_cos, rot_sin);
PictureTransformIsInverse ("rotate", &crtc_to_fb, &fb_to_crtc);
PictureTransformTranslate (&crtc_to_fb, &fb_to_crtc, rot_dx, rot_dy);
PictureTransformIsInverse ("rotate translate", &crtc_to_fb, &fb_to_crtc);
/* reflection */
scale_x = F (1);
scale_dx = 0;
scale_y = F (1);
scale_dy = 0;
if (rotation & RR_Reflect_X)
{
scale_x = F(-1);
if (rotation & (RR_Rotate_0|RR_Rotate_180))
scale_dx = F(mode_w);
else
scale_dx = F(mode_h);
}
if (rotation & RR_Reflect_Y)
{
scale_y = F(-1);
if (rotation & (RR_Rotate_0|RR_Rotate_180))
scale_dy = F(mode_h);
else
scale_dy = F(mode_w);
}
PictureTransformScale (&crtc_to_fb, &fb_to_crtc, scale_x, scale_y);
PictureTransformIsInverse ("scale", &crtc_to_fb, &fb_to_crtc);
PictureTransformTranslate (&crtc_to_fb, &fb_to_crtc, scale_dx, scale_dy);
PictureTransformIsInverse ("scale translate", &crtc_to_fb, &fb_to_crtc);
}
/*
* If the untranslated transformation is the identity,
* disable the shadow buffer
*/
if (PictureTransformIsIdentity (&crtc_to_fb))
{
crtc->transform_in_use = FALSE;
PictureTransformInitTranslate (&crtc->crtc_to_framebuffer,
F (-crtc->x), F (-crtc->y));
PictureTransformInitTranslate (&crtc->framebuffer_to_crtc,
F ( crtc->x), F ( crtc->y));
/*
* If the untranslated transformation is the identity,
* disable the shadow buffer
*/
xf86RotateDestroy (crtc);
crtc->transform_in_use = FALSE;
if (new_params)
xfree (new_params);
new_params = NULL;
new_nparams = 0;
new_filter = NULL;
new_width = 0;
new_height = 0;
}
else
{
int width, height, old_width, old_height;
void *shadowData;
PixmapPtr shadow;
PictureTransformTranslate (&crtc_to_fb, &fb_to_crtc, F(crtc->x), F(crtc->y));
PictureTransformIsInverse ("offset", &crtc_to_fb, &fb_to_crtc);
/*
/*
* these are the size of the shadow pixmap, which
* matches the mode, not the pre-rotated copy in the
* frame buffer
*/
width = mode->HDisplay;
height = mode->VDisplay;
shadowData = crtc->rotatedData;
shadow = crtc->rotatedPixmap;
old_width = shadow ? shadow->drawable.width : 0;
old_height = shadow ? shadow->drawable.height : 0;
int width = crtc->mode.HDisplay;
int height = crtc->mode.VDisplay;
void *shadowData = crtc->rotatedData;
PixmapPtr shadow = crtc->rotatedPixmap;
int old_width = shadow ? shadow->drawable.width : 0;
int old_height = shadow ? shadow->drawable.height : 0;
/* Allocate memory for rotation */
if (old_width != width || old_height != height)
{
@ -650,6 +478,27 @@ xf86CrtcRotate (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation)
xf86_config->BlockHandler = pScreen->BlockHandler;
pScreen->BlockHandler = xf86RotateBlockHandler;
}
#ifdef RANDR_12_INTERFACE
if (transform)
{
if (transform->nparams) {
new_params = xalloc (transform->nparams * sizeof (xFixed));
if (new_params) {
memcpy (new_params, transform->params,
transform->nparams * sizeof (xFixed));
new_nparams = transform->nparams;
new_filter = transform->filter;
}
} else
new_filter = transform->filter;
if (new_filter)
{
new_width = new_filter->width;
new_height = new_filter->height;
}
}
#endif
if (0)
{
bail2:
@ -668,15 +517,23 @@ xf86CrtcRotate (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation)
return FALSE;
}
crtc->transform_in_use = TRUE;
crtc->crtc_to_framebuffer = crtc_to_fb;
crtc->framebuffer_to_crtc = fb_to_crtc;
crtc->bounds.x1 = 0;
crtc->bounds.x2 = crtc->mode.HDisplay;
crtc->bounds.y1 = 0;
crtc->bounds.y2 = crtc->mode.VDisplay;
PictureTransformBounds (&crtc->bounds, &crtc_to_fb);
}
crtc->crtc_to_framebuffer = crtc_to_fb;
crtc->f_crtc_to_framebuffer = f_crtc_to_fb;
crtc->f_framebuffer_to_crtc = f_fb_to_crtc;
if (crtc->params)
xfree (crtc->params);
crtc->params = new_params;
crtc->nparams = new_nparams;
crtc->filter = new_filter;
crtc->filter_width = new_width;
crtc->filter_height = new_height;
crtc->bounds.x1 = 0;
crtc->bounds.x2 = crtc->mode.HDisplay;
crtc->bounds.y1 = 0;
crtc->bounds.y2 = crtc->mode.VDisplay;
pict_f_transform_bounds (&f_crtc_to_fb, &crtc->bounds);
/* All done */
return TRUE;
}

View File

@ -218,13 +218,20 @@ extern pointer LookupClientResourceComplex(
FindComplexResType func,
pointer cdata);
extern int dixLookupResource(
extern int dixLookupResourceByType(
pointer *result,
XID id,
RESTYPE rtype,
ClientPtr client,
Mask access_mode);
extern int dixLookupResourceByClass(
pointer *result,
XID id,
RESTYPE rclass,
ClientPtr client,
Mask access_mode);
extern void GetXIDRange(
int /*client*/,
Bool /*server*/,
@ -244,29 +251,43 @@ extern RESTYPE TypeMask;
* Please use the noted replacements instead.
*/
/* replaced by dixLookupResource */
#ifdef __GNUC__
#define X_DEPRECATED __attribute__((deprecated))
#else
#define X_DEPRECATED
#endif
/* replaced by dixLookupResourceByType or dixLookupResourceByClass */
extern int dixLookupResource(
pointer *result,
XID id,
RESTYPE rtype,
ClientPtr client,
Mask access_mode) X_DEPRECATED;
/* replaced by dixLookupResourceByType */
extern pointer SecurityLookupIDByType(
ClientPtr client,
XID id,
RESTYPE rtype,
Mask access_mode);
Mask access_mode) X_DEPRECATED;
/* replaced by dixLookupResource */
/* replaced by dixLookupResourceByClass */
extern pointer SecurityLookupIDByClass(
ClientPtr client,
XID id,
RESTYPE classes,
Mask access_mode);
Mask access_mode) X_DEPRECATED;
/* replaced by dixLookupResource */
/* replaced by dixLookupResourceByType */
extern pointer LookupIDByType(
XID id,
RESTYPE rtype);
RESTYPE rtype) X_DEPRECATED;
/* replaced by dixLookupResource */
/* replaced by dixLookupResourceByClass */
extern pointer LookupIDByClass(
XID id,
RESTYPE classes);
RESTYPE classes) X_DEPRECATED;
#endif /* RESOURCE_H */

View File

@ -655,6 +655,58 @@ damageGlyphs (CARD8 op,
damageReportPostOp (pDst->pDrawable);
wrap (pScrPriv, ps, Glyphs, damageGlyphs);
}
static void
damageAddTraps (PicturePtr pPicture,
INT16 x_off,
INT16 y_off,
int ntrap,
xTrap *traps)
{
ScreenPtr pScreen = pPicture->pDrawable->pScreen;
PictureScreenPtr ps = GetPictureScreen(pScreen);
damageScrPriv(pScreen);
if (checkPictureDamage (pPicture))
{
BoxRec box;
int i;
int x, y;
xTrap *t = traps;
box.x1 = 32767;
box.y1 = 32767;
box.x2 = -32767;
box.y2 = -32767;
x = pPicture->pDrawable->x + x_off;
y = pPicture->pDrawable->y + y_off;
for (i = 0; i < ntrap; i++)
{
pixman_fixed_t l = min (t->top.l, t->bot.l);
pixman_fixed_t r = max (t->top.r, t->bot.r);
int x1 = x + pixman_fixed_to_int (l);
int x2 = x + pixman_fixed_to_int (pixman_fixed_ceil (r));
int y1 = y + pixman_fixed_to_int (t->top.y);
int y2 = y + pixman_fixed_to_int (pixman_fixed_ceil (t->bot.y));
if (x1 < box.x1)
box.x1 = x1;
if (x2 > box.x2)
box.x2 = x2;
if (y1 < box.y1)
box.y1 = y1;
if (y2 > box.y2)
box.y2 = y2;
}
TRIM_PICTURE_BOX (box, pPicture);
if (BOX_NOT_EMPTY(box))
damageDamageBox (pPicture->pDrawable, &box, pPicture->subWindowMode);
}
unwrap (pScrPriv, ps, AddTraps);
(*ps->AddTraps) (pPicture, x_off, y_off, ntrap, traps);
damageReportPostOp (pPicture->pDrawable);
wrap (pScrPriv, ps, AddTraps, damageAddTraps);
}
#endif
/**********************************************************/
@ -1767,6 +1819,7 @@ DamageSetup (ScreenPtr pScreen)
if (ps) {
wrap (pScrPriv, ps, Glyphs, damageGlyphs);
wrap (pScrPriv, ps, Composite, damageComposite);
wrap (pScrPriv, ps, AddTraps, damageAddTraps);
}
#endif

View File

@ -70,6 +70,7 @@ typedef struct _damageScrPriv {
#ifdef RENDER
CompositeProcPtr Composite;
GlyphsProcPtr Glyphs;
AddTrapsProcPtr AddTraps;
#endif
} DamageScrPrivRec, *DamageScrPrivPtr;

View File

@ -5,7 +5,7 @@ AM_CFLAGS = $(DIX_CFLAGS)
XINERAMA_SRCS = rrxinerama.c
if XORG
sdk_HEADERS = randrstr.h
sdk_HEADERS = randrstr.h rrtransform.h
endif
librandr_la_SOURCES = \
@ -20,7 +20,9 @@ librandr_la_SOURCES = \
rrpointer.c \
rrproperty.c \
rrscreen.c \
rrsdispatch.c
rrsdispatch.c \
rrtransform.h \
rrtransform.c
if XINERAMA
librandr_la_SOURCES += ${XINERAMA_SRCS}

View File

@ -159,7 +159,7 @@ miRandRInit (ScreenPtr pScreen)
return FALSE;
if (!RROutputSetConnection (output, RR_Connected))
return FALSE;
RRCrtcNotify (crtc, mode, 0, 0, RR_Rotate_0, 1, &output);
RRCrtcNotify (crtc, mode, 0, 0, RR_Rotate_0, NULL, 1, &output);
#endif
return TRUE;
}

View File

@ -43,6 +43,7 @@
#include "pixmapstr.h"
#include "extnsionst.h"
#include "servermd.h"
#include "rrtransform.h"
#include <X11/extensions/randr.h>
#include <X11/extensions/randrproto.h>
#ifdef RENDER
@ -119,6 +120,12 @@ struct _rrCrtc {
CARD16 *gammaBlue;
CARD16 *gammaGreen;
void *devPrivate;
Bool transforms;
RRTransformRec client_pending_transform;
RRTransformRec client_current_transform;
PictTransform transform;
struct pict_f_transform f_transform;
struct pict_f_transform f_inverse;
};
struct _rrOutput {
@ -523,6 +530,12 @@ RRCrtcCreate (ScreenPtr pScreen, void *devPrivate);
void
RRCrtcSetRotations (RRCrtcPtr crtc, Rotation rotations);
/*
* Set whether transforms are allowed on a CRTC
*/
void
RRCrtcSetTransformSupport (RRCrtcPtr crtc, Bool transforms);
/*
* Notify the extension that the Crtc has been reconfigured,
* the driver calls this whenever it has updated the mode
@ -533,6 +546,7 @@ RRCrtcNotify (RRCrtcPtr crtc,
int x,
int y,
Rotation rotation,
RRTransformPtr transform,
int numOutputs,
RROutputPtr *outputs);
@ -586,12 +600,58 @@ RRCrtcGammaSetSize (RRCrtcPtr crtc,
void
RRCrtcGetScanoutSize(RRCrtcPtr crtc, int *width, int *height);
/*
* Compute the complete transformation matrix including
* client-specified transform, rotation/reflection values and the crtc
* offset.
*
* Return TRUE if the resulting transform is not a simple translation.
*/
Bool
RRTransformCompute (int x,
int y,
int width,
int height,
Rotation rotation,
RRTransformPtr rr_transform,
PictTransformPtr transform,
struct pict_f_transform *f_transform,
struct pict_f_transform *f_inverse);
/*
* Return crtc transform
*/
RRTransformPtr
RRCrtcGetTransform (RRCrtcPtr crtc);
/*
* Check whether the pending and current transforms are the same
*/
Bool
RRCrtcPendingTransform (RRCrtcPtr crtc);
/*
* Destroy a Crtc at shutdown
*/
void
RRCrtcDestroy (RRCrtcPtr crtc);
/*
* Set the pending CRTC transformation
*/
int
RRCrtcTransformSet (RRCrtcPtr crtc,
PictTransformPtr transform,
struct pict_f_transform *f_transform,
struct pict_f_transform *f_inverse,
char *filter,
int filter_len,
xFixed *params,
int nparams);
/*
* Initialize crtc type
*/
@ -617,6 +677,12 @@ ProcRRGetCrtcGamma (ClientPtr client);
int
ProcRRSetCrtcGamma (ClientPtr client);
int
ProcRRSetCrtcTransform (ClientPtr client);
int
ProcRRGetCrtcTransform (ClientPtr client);
/* rrdispatch.c */
Bool
RRClientKnowsRates (ClientPtr pClient);

View File

@ -89,6 +89,11 @@ RRCrtcCreate (ScreenPtr pScreen, void *devPrivate)
crtc->gammaRed = crtc->gammaBlue = crtc->gammaGreen = NULL;
crtc->changed = FALSE;
crtc->devPrivate = devPrivate;
RRTransformInit (&crtc->client_pending_transform);
RRTransformInit (&crtc->client_current_transform);
PictureTransformInitIdentity (&crtc->transform);
pict_f_transform_init_identity (&crtc->f_transform);
pict_f_transform_init_identity (&crtc->f_inverse);
if (!AddResource (crtc->id, RRCrtcType, (pointer) crtc))
return NULL;
@ -109,6 +114,15 @@ RRCrtcSetRotations (RRCrtcPtr crtc, Rotation rotations)
crtc->rotations = rotations;
}
/*
* Set whether transforms are allowed on a CRTC
*/
void
RRCrtcSetTransformSupport (RRCrtcPtr crtc, Bool transforms)
{
crtc->transforms = transforms;
}
/*
* Notify the extension that the Crtc has been reconfigured,
* the driver calls this whenever it has updated the mode
@ -119,6 +133,7 @@ RRCrtcNotify (RRCrtcPtr crtc,
int x,
int y,
Rotation rotation,
RRTransformPtr transform,
int numOutputs,
RROutputPtr *outputs)
{
@ -214,6 +229,19 @@ RRCrtcNotify (RRCrtcPtr crtc,
crtc->rotation = rotation;
RRCrtcChanged (crtc, TRUE);
}
if (!RRTransformEqual (transform, &crtc->client_current_transform)) {
RRTransformCopy (&crtc->client_current_transform, transform);
RRCrtcChanged (crtc, TRUE);
}
if (crtc->changed && mode)
{
RRTransformCompute (x, y,
mode->mode.width, mode->mode.height,
rotation,
&crtc->client_current_transform,
&crtc->transform, &crtc->f_transform,
&crtc->f_inverse);
}
return TRUE;
}
@ -290,7 +318,8 @@ RRCrtcSet (RRCrtcPtr crtc,
crtc->rotation == rotation &&
crtc->numOutputs == numOutputs &&
!memcmp (crtc->outputs, outputs, numOutputs * sizeof (RROutputPtr)) &&
!RRCrtcPendingProperties (crtc))
!RRCrtcPendingProperties (crtc) &&
!RRCrtcPendingTransform (crtc))
{
ret = TRUE;
}
@ -313,7 +342,7 @@ RRCrtcSet (RRCrtcPtr crtc,
if (!mode)
{
RRCrtcNotify (crtc, NULL, x, y, rotation, 0, NULL);
RRCrtcNotify (crtc, NULL, x, y, rotation, NULL, 0, NULL);
ret = TRUE;
}
else
@ -339,7 +368,7 @@ RRCrtcSet (RRCrtcPtr crtc,
*/
if (ret)
{
RRCrtcNotify (crtc, mode, x, y, rotation, 1, outputs);
RRCrtcNotify (crtc, mode, x, y, rotation, NULL, 1, outputs);
RRScreenSizeNotify (pScreen);
}
}
@ -358,6 +387,30 @@ RRCrtcSet (RRCrtcPtr crtc,
return ret;
}
/*
* Return crtc transform
*/
RRTransformPtr
RRCrtcGetTransform (RRCrtcPtr crtc)
{
RRTransformPtr transform = &crtc->client_pending_transform;
if (PictureTransformIsIdentity (&transform->transform))
return NULL;
return transform;
}
/*
* Check whether the pending and current transforms are the same
*/
Bool
RRCrtcPendingTransform (RRCrtcPtr crtc)
{
return memcmp (&crtc->client_current_transform.transform,
&crtc->client_pending_transform.transform,
sizeof (PictTransform)) != 0;
}
/*
* Destroy a Crtc at shutdown
*/
@ -438,30 +491,35 @@ RRCrtcGammaNotify (RRCrtcPtr crtc)
return TRUE; /* not much going on here */
}
static void
RRModeGetScanoutSize (RRModePtr mode, PictTransformPtr transform,
int *width, int *height)
{
BoxRec box;
if (mode == NULL) {
*width = 0;
*height = 0;
return;
}
box.x1 = 0;
box.y1 = 0;
box.x2 = mode->mode.width;
box.y2 = mode->mode.height;
PictureTransformBounds (&box, transform);
*width = box.x2 - box.x1;
*height = box.y2 - box.y1;
}
/**
* Returns the width/height that the crtc scans out from the framebuffer
*/
void
RRCrtcGetScanoutSize(RRCrtcPtr crtc, int *width, int *height)
{
if (crtc->mode == NULL) {
*width = 0;
*height = 0;
return;
}
switch (crtc->rotation & 0xf) {
case RR_Rotate_0:
case RR_Rotate_180:
*width = crtc->mode->mode.width;
*height = crtc->mode->mode.height;
break;
case RR_Rotate_90:
case RR_Rotate_270:
*width = crtc->mode->mode.height;
*height = crtc->mode->mode.width;
break;
}
return RRModeGetScanoutSize (crtc->mode, &crtc->transform, width, height);
}
/*
@ -493,6 +551,59 @@ RRCrtcGammaSetSize (RRCrtcPtr crtc,
return TRUE;
}
/*
* Set the pending CRTC transformation
*/
int
RRCrtcTransformSet (RRCrtcPtr crtc,
PictTransformPtr transform,
struct pict_f_transform *f_transform,
struct pict_f_transform *f_inverse,
char *filter_name,
int filter_len,
xFixed *params,
int nparams)
{
PictFilterPtr filter = NULL;
int width = 0, height = 0;
if (!crtc->transforms)
return BadValue;
if (filter_len)
{
filter = PictureFindFilter (crtc->pScreen,
filter_name,
filter_len);
if (!filter)
return BadName;
if (filter->ValidateParams)
{
if (!filter->ValidateParams (crtc->pScreen, filter->id,
params, nparams, &width, &height))
return BadMatch;
}
else {
width = filter->width;
height = filter->height;
}
}
else
{
if (nparams)
return BadMatch;
}
if (!RRTransformSetFilter (&crtc->client_pending_transform,
filter, params, nparams, width, height))
return BadAlloc;
crtc->client_pending_transform.transform = *transform;
crtc->client_pending_transform.f_transform = *f_transform;
crtc->client_pending_transform.f_inverse = *f_inverse;
return Success;
}
/*
* Initialize crtc type
*/
@ -789,18 +900,24 @@ ProcRRSetCrtcConfig (ClientPtr client)
/*
* Check screen size bounds if the DDX provides a 1.2 interface
* for setting screen size. Else, assume the CrtcSet sets
* the size along with the mode
* the size along with the mode. If the driver supports transforms,
* then it must allow crtcs to display a subset of the screen, so
* only do this check for drivers without transform support.
*/
if (pScrPriv->rrScreenSetSize)
if (pScrPriv->rrScreenSetSize && !crtc->transforms)
{
int source_width = mode->mode.width;
int source_height = mode->mode.height;
int source_width;
int source_height;
PictTransform transform;
struct pict_f_transform f_transform, f_inverse;
if ((rotation & 0xf) == RR_Rotate_90 || (rotation & 0xf) == RR_Rotate_270)
{
source_width = mode->mode.height;
source_height = mode->mode.width;
}
RRTransformCompute (stuff->x, stuff->y,
mode->mode.width, mode->mode.height,
rotation,
&crtc->client_pending_transform,
&transform, &f_transform, &f_inverse);
RRModeGetScanoutSize (mode, &transform, &source_width, &source_height);
if (stuff->x + source_width > pScreen->width)
{
client->errorValue = stuff->x;
@ -949,3 +1066,144 @@ ProcRRSetCrtcGamma (ClientPtr client)
return Success;
}
/* Version 1.3 additions */
int
ProcRRSetCrtcTransform (ClientPtr client)
{
REQUEST(xRRSetCrtcTransformReq);
RRCrtcPtr crtc;
PictTransform transform;
struct pict_f_transform f_transform, f_inverse;
char *filter;
int nbytes;
xFixed *params;
int nparams;
REQUEST_AT_LEAST_SIZE(xRRSetCrtcTransformReq);
crtc = LookupCrtc (client, stuff->crtc, DixWriteAccess);
if (!crtc)
return RRErrorBase + BadRRCrtc;
PictTransform_from_xRenderTransform (&transform, &stuff->transform);
pict_f_transform_from_pixman_transform (&f_transform, &transform);
if (!pict_f_transform_invert (&f_inverse, &f_transform))
return BadMatch;
filter = (char *) (stuff + 1);
nbytes = stuff->nbytesFilter;
params = (xFixed *) (filter + ((nbytes + 3) & ~3));
nparams = ((xFixed *) stuff + client->req_len) - params;
if (nparams < 0)
return BadLength;
return RRCrtcTransformSet (crtc, &transform, &f_transform, &f_inverse,
filter, nbytes, params, nparams);
}
#define CrtcTransformExtra (SIZEOF(xRRGetCrtcTransformReply) - 32)
static int
transform_filter_length (RRTransformPtr transform)
{
int nbytes, nparams;
if (transform->filter == NULL)
return 0;
nbytes = strlen (transform->filter->name);
nparams = transform->nparams;
return ((nbytes + 3) & ~3) + (nparams * sizeof (xFixed));
}
static int
transform_filter_encode (ClientPtr client, char *output,
CARD16 *nbytesFilter,
CARD16 *nparamsFilter,
RRTransformPtr transform)
{
int nbytes, nparams;
int n;
if (transform->filter == NULL) {
*nbytesFilter = 0;
*nparamsFilter = 0;
return 0;
}
nbytes = strlen (transform->filter->name);
nparams = transform->nparams;
*nbytesFilter = nbytes;
*nparamsFilter = nparams;
memcpy (output, transform->filter->name, nbytes);
while ((nbytes & 3) != 0)
output[nbytes++] = 0;
memcpy (output + nbytes, transform->params, nparams * sizeof (xFixed));
if (client->swapped) {
swaps (nbytesFilter, n);
swaps (nparamsFilter, n);
SwapLongs ((CARD32 *) (output + nbytes),
nparams * sizeof (xFixed));
}
nbytes += nparams * sizeof (xFixed);
return nbytes;
}
static void
transform_encode (ClientPtr client, xRenderTransform *wire, PictTransform *pict)
{
xRenderTransform_from_PictTransform (wire, pict);
if (client->swapped)
SwapLongs ((CARD32 *) wire, sizeof (xRenderTransform));
}
int
ProcRRGetCrtcTransform (ClientPtr client)
{
REQUEST(xRRGetCrtcTransformReq);
xRRGetCrtcTransformReply *reply;
RRCrtcPtr crtc;
int n, nextra;
RRTransformPtr current, pending;
char *extra;
REQUEST_SIZE_MATCH (xRRGetCrtcTransformReq);
crtc = LookupCrtc (client, stuff->crtc, DixWriteAccess);
if (!crtc)
return RRErrorBase + BadRRCrtc;
pending = &crtc->client_pending_transform;
current = &crtc->client_current_transform;
nextra = (transform_filter_length (pending) +
transform_filter_length (current));
reply = xalloc (sizeof (xRRGetCrtcTransformReply) + nextra);
if (!reply)
return BadAlloc;
extra = (char *) (reply + 1);
reply->type = X_Reply;
reply->sequenceNumber = client->sequence;
reply->length = (CrtcTransformExtra + nextra) >> 2;
reply->hasTransforms = crtc->transforms;
transform_encode (client, &reply->pendingTransform, &pending->transform);
extra += transform_filter_encode (client, extra,
&reply->pendingNbytesFilter,
&reply->pendingNparamsFilter,
pending);
transform_encode (client, &reply->currentTransform, &current->transform);
extra += transform_filter_encode (client, extra,
&reply->currentNbytesFilter,
&reply->currentNparamsFilter,
current);
if (client->swapped) {
swaps (&reply->sequenceNumber, n);
swapl (&reply->length, n);
}
WriteToClient (client, sizeof (xRRGetCrtcTransformReply) + nextra, (char *) reply);
return client->noClientException;
}

View File

@ -23,7 +23,7 @@
#include "randrstr.h"
#define SERVER_RANDR_MAJOR 1
#define SERVER_RANDR_MINOR 2
#define SERVER_RANDR_MINOR 3
Bool
RRClientKnowsRates (ClientPtr pClient)
@ -210,5 +210,8 @@ int (*ProcRandrVector[RRNumberRequests])(ClientPtr) = {
ProcRRGetCrtcGammaSize, /* 22 */
ProcRRGetCrtcGamma, /* 23 */
ProcRRSetCrtcGamma, /* 24 */
/* V1.3 additions */
ProcRRSetCrtcTransform, /* 25 */
ProcRRGetCrtcTransform, /* 26 */
};

View File

@ -170,7 +170,7 @@ RRScanOldConfig (ScreenPtr pScreen, Rotation rotations)
/* notice current mode */
if (newMode)
RRCrtcNotify (crtc, newMode, 0, 0, pScrPriv->rotation,
1, &output);
NULL, 1, &output);
}
#endif

View File

@ -320,6 +320,9 @@ ProcRRCreateMode (ClientPtr client)
swapl(&rep.mode, n);
}
WriteToClient(client, sizeof(xRRCreateModeReply), (char *)&rep);
/* Drop our reference to this mode */
RRModeDestroy (mode);
return client->noClientException;
}

View File

@ -24,10 +24,36 @@
#include "propertyst.h"
#include "swaprep.h"
static void
RRDeliverEvent (ScreenPtr pScreen, xEvent *event, CARD32 mask)
static int
DeliverPropertyEvent (WindowPtr pWin, pointer value)
{
xRROutputPropertyNotifyEvent *event = value;
RREventPtr *pHead, pRREvent;
ClientPtr client;
pHead = (RREventPtr *) LookupIDByType (pWin->drawable.id, RREventType);
if (!pHead)
return WT_WALKCHILDREN;
for (pRREvent = *pHead; pRREvent; pRREvent = pRREvent->next)
{
client = pRREvent->client;
if (client == serverClient || client->clientGone)
continue;
if (!(pRREvent->mask & RROutputPropertyNotifyMask))
continue;
event->window = pRREvent->window->drawable.id;
WriteEventsToClient(pRREvent->client, 1, (xEvent *) event);
}
return WT_WALKCHILDREN;
}
static void
RRDeliverPropertyEvent (ScreenPtr pScreen, xEvent *event)
{
WalkTree (pScreen, DeliverPropertyEvent, (pointer) event);
}
void
@ -45,7 +71,7 @@ RRDeleteAllOutputProperties (RROutputPtr output)
event.state = PropertyDelete;
event.atom = prop->propertyName;
event.timestamp = currentTime.milliseconds;
RRDeliverEvent (output->pScreen, (xEvent *) &event, RROutputPropertyNotifyMask);
RRDeliverPropertyEvent (output->pScreen, (xEvent *) &event);
if (prop->current.data)
xfree(prop->current.data);
if (prop->pending.data)
@ -113,7 +139,7 @@ RRDeleteOutputProperty (RROutputPtr output, Atom property)
event.state = PropertyDelete;
event.atom = prop->propertyName;
event.timestamp = currentTime.milliseconds;
RRDeliverEvent (output->pScreen, (xEvent *) &event, RROutputPropertyNotifyMask);
RRDeliverPropertyEvent (output->pScreen, (xEvent *) &event);
RRDestroyOutputProperty (prop);
}
}
@ -238,7 +264,7 @@ RRChangeOutputProperty (RROutputPtr output, Atom property, Atom type,
event.state = PropertyNewValue;
event.atom = prop->propertyName;
event.timestamp = currentTime.milliseconds;
RRDeliverEvent (output->pScreen, (xEvent *) &event, RROutputPropertyNotifyMask);
RRDeliverPropertyEvent (output->pScreen, (xEvent *) &event);
}
return(Success);
}
@ -674,7 +700,7 @@ ProcRRGetOutputProperty (ClientPtr client)
event.state = PropertyDelete;
event.atom = prop->propertyName;
event.timestamp = currentTime.milliseconds;
RRDeliverEvent (output->pScreen, (xEvent *) &event, RROutputPropertyNotifyMask);
RRDeliverPropertyEvent (output->pScreen, (xEvent *) &event);
}
WriteReplyToClient(client, sizeof(xGenericReply), &reply);

View File

@ -271,6 +271,26 @@ SProcRRSetCrtcGamma (ClientPtr client)
return BadImplementation;
}
static int
SProcRRSetCrtcTransform (ClientPtr client)
{
REQUEST(xRRSetCrtcTransformReq);
REQUEST_SIZE_MATCH(xRRSetCrtcTransformReq);
(void) stuff;
return BadImplementation;
}
static int
SProcRRGetCrtcTransform (ClientPtr client)
{
REQUEST(xRRGetCrtcTransformReq);
REQUEST_SIZE_MATCH(xRRGetCrtcTransformReq);
(void) stuff;
return BadImplementation;
}
int (*SProcRandrVector[RRNumberRequests])(ClientPtr) = {
SProcRRQueryVersion, /* 0 */
/* we skip 1 to make old clients fail pretty immediately */
@ -301,5 +321,8 @@ int (*SProcRandrVector[RRNumberRequests])(ClientPtr) = {
SProcRRGetCrtcGammaSize, /* 22 */
SProcRRGetCrtcGamma, /* 23 */
SProcRRSetCrtcGamma, /* 24 */
/* V1.3 additions */
SProcRRSetCrtcTransform, /* 25 */
SProcRRGetCrtcTransform, /* 26 */
};

260
randr/rrtransform.c Normal file
View File

@ -0,0 +1,260 @@
/*
* Copyright © 2007 Keith Packard
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that copyright
* notice and this permission notice appear in supporting documentation, and
* that the name of the copyright holders not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. The copyright holders make no representations
* about the suitability of this software for any purpose. It is provided "as
* is" without express or implied warranty.
*
* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
* OF THIS SOFTWARE.
*/
#include "randrstr.h"
#include "rrtransform.h"
void
RRTransformInit (RRTransformPtr transform)
{
PictureTransformInitIdentity (&transform->transform);
pict_f_transform_init_identity (&transform->f_transform);
pict_f_transform_init_identity (&transform->f_inverse);
transform->filter = NULL;
transform->params = NULL;
transform->nparams = 0;
}
void
RRTransformFini (RRTransformPtr transform)
{
if (transform->params)
xfree (transform->params);
}
Bool
RRTransformEqual (RRTransformPtr a, RRTransformPtr b)
{
if (a && PictureTransformIsIdentity (&a->transform))
a = NULL;
if (b && PictureTransformIsIdentity (&b->transform))
b = NULL;
if (a == NULL && b == NULL)
return TRUE;
if (a == NULL || b == NULL)
return FALSE;
if (memcmp (&a->transform, &b->transform, sizeof (a->transform)) != 0)
return FALSE;
if (a->filter != b->filter)
return FALSE;
if (a->nparams != b->nparams)
return FALSE;
if (memcmp (a->params, b->params, a->nparams * sizeof (xFixed)) != 0)
return FALSE;
return TRUE;
}
Bool
RRTransformSetFilter (RRTransformPtr dst,
PictFilterPtr filter,
xFixed *params,
int nparams,
int width,
int height)
{
xFixed *new_params;
if (nparams)
{
new_params = xalloc (nparams * sizeof (xFixed));
if (!new_params)
return FALSE;
memcpy (new_params, params, nparams * sizeof (xFixed));
}
else
new_params = NULL;
if (dst->params)
xfree (dst->params);
dst->filter = filter;
dst->params = new_params;
dst->nparams = nparams;
dst->width = width;
dst->height = height;
return TRUE;
}
Bool
RRTransformCopy (RRTransformPtr dst, RRTransformPtr src)
{
if (src && PictureTransformIsIdentity (&src->transform))
src = NULL;
if (src)
{
if (!RRTransformSetFilter (dst, src->filter,
src->params, src->nparams, src->width, src->height))
return FALSE;
dst->transform = src->transform;
dst->f_transform = src->f_transform;
dst->f_inverse = src->f_inverse;
}
else
{
if (!RRTransformSetFilter (dst, NULL, NULL, 0, 0, 0))
return FALSE;
PictureTransformInitIdentity (&dst->transform);
pict_f_transform_init_identity (&dst->f_transform);
pict_f_transform_init_identity (&dst->f_inverse);
}
return TRUE;
}
#define F(x) IntToxFixed(x)
/*
* Compute the complete transformation matrix including
* client-specified transform, rotation/reflection values and the crtc
* offset.
*
* Return TRUE if the resulting transform is not a simple translation.
*/
Bool
RRTransformCompute (int x,
int y,
int width,
int height,
Rotation rotation,
RRTransformPtr rr_transform,
PictTransformPtr transform,
struct pict_f_transform *f_transform,
struct pict_f_transform *f_inverse)
{
PictTransform t_transform, inverse;
struct pict_f_transform tf_transform, tf_inverse;
if (!transform) transform = &t_transform;
if (!f_transform) f_transform = &tf_transform;
if (!f_inverse) f_inverse = &tf_inverse;
PictureTransformInitIdentity (transform);
PictureTransformInitIdentity (&inverse);
pict_f_transform_init_identity (f_transform);
pict_f_transform_init_identity (f_inverse);
if (rotation != RR_Rotate_0)
{
double f_rot_cos, f_rot_sin, f_rot_dx, f_rot_dy;
double f_scale_x, f_scale_y, f_scale_dx, f_scale_dy;
xFixed rot_cos, rot_sin, rot_dx, rot_dy;
xFixed scale_x, scale_y, scale_dx, scale_dy;
/* rotation */
switch (rotation & 0xf) {
default:
case RR_Rotate_0:
f_rot_cos = 1; f_rot_sin = 0;
f_rot_dx = 0; f_rot_dy = 0;
rot_cos = F ( 1); rot_sin = F ( 0);
rot_dx = F ( 0); rot_dy = F ( 0);
break;
case RR_Rotate_90:
f_rot_cos = 0; f_rot_sin = 1;
f_rot_dx = height; f_rot_dy = 0;
rot_cos = F ( 0); rot_sin = F ( 1);
rot_dx = F ( height); rot_dy = F (0);
break;
case RR_Rotate_180:
f_rot_cos = -1; f_rot_sin = 0;
f_rot_dx = width; f_rot_dy = height;
rot_cos = F (-1); rot_sin = F ( 0);
rot_dx = F (width); rot_dy = F ( height);
break;
case RR_Rotate_270:
f_rot_cos = 0; f_rot_sin = -1;
f_rot_dx = 0; f_rot_dy = width;
rot_cos = F ( 0); rot_sin = F (-1);
rot_dx = F ( 0); rot_dy = F ( width);
break;
}
PictureTransformRotate (transform, &inverse, rot_cos, rot_sin);
PictureTransformTranslate (transform, &inverse, rot_dx, rot_dy);
pict_f_transform_rotate (f_transform, f_inverse, f_rot_cos, f_rot_sin);
pict_f_transform_translate (f_transform, f_inverse, f_rot_dx, f_rot_dy);
/* reflection */
f_scale_x = 1;
f_scale_dx = 0;
f_scale_y = 1;
f_scale_dy = 0;
scale_x = F (1);
scale_dx = 0;
scale_y = F (1);
scale_dy = 0;
if (rotation & RR_Reflect_X)
{
f_scale_x = -1;
scale_x = F(-1);
if (rotation & (RR_Rotate_0|RR_Rotate_180)) {
f_scale_dx = width;
scale_dx = F(width);
} else {
f_scale_dx = height;
scale_dx = F(height);
}
}
if (rotation & RR_Reflect_Y)
{
f_scale_y = -1;
scale_y = F(-1);
if (rotation & (RR_Rotate_0|RR_Rotate_180)) {
f_scale_dy = height;
scale_dy = F(height);
} else {
f_scale_dy = width;
scale_dy = F(width);
}
}
PictureTransformScale (transform, &inverse, scale_x, scale_y);
pict_f_transform_scale (f_transform, f_inverse, f_scale_x, f_scale_y);
PictureTransformTranslate (transform, &inverse, scale_dx, scale_dy);
pict_f_transform_translate (f_transform, f_inverse, f_scale_dx, f_scale_dy);
}
#ifdef RANDR_12_INTERFACE
if (rr_transform)
{
PictureTransformMultiply (transform, transform, &rr_transform->transform);
pict_f_transform_multiply (f_transform, f_transform, &rr_transform->f_transform);
pict_f_transform_multiply (f_inverse, &rr_transform->f_inverse, f_inverse);
}
#endif
/*
* Compute the class of the resulting transform
*/
if (PictureTransformIsIdentity (transform))
{
PictureTransformInitTranslate (transform, F ( x), F ( y));
pict_f_transform_init_translate (f_transform, F( x), F( y));
pict_f_transform_init_translate (f_inverse, F(-x), F(-y));
return FALSE;
}
else
{
PictureTransformTranslate (&inverse, transform, x, y);
pict_f_transform_translate (f_inverse, f_transform, x, y);
return TRUE;
}
}

75
randr/rrtransform.h Normal file
View File

@ -0,0 +1,75 @@
/*
* Copyright © 2007 Keith Packard
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that copyright
* notice and this permission notice appear in supporting documentation, and
* that the name of the copyright holders not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. The copyright holders make no representations
* about the suitability of this software for any purpose. It is provided "as
* is" without express or implied warranty.
*
* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
* OF THIS SOFTWARE.
*/
#ifndef _RRTRANSFORM_H_
#define _RRTRANSFORM_H_
#include <X11/extensions/randr.h>
#include "picturestr.h"
typedef struct _rrTransform RRTransformRec, *RRTransformPtr;
struct _rrTransform {
PictTransform transform;
struct pict_f_transform f_transform;
struct pict_f_transform f_inverse;
PictFilterPtr filter;
xFixed *params;
int nparams;
int width;
int height;
};
void
RRTransformInit (RRTransformPtr transform);
void
RRTransformFini (RRTransformPtr transform);
Bool
RRTransformEqual (RRTransformPtr a, RRTransformPtr b);
Bool
RRTransformSetFilter (RRTransformPtr dst,
PictFilterPtr filter,
xFixed *params,
int nparams,
int width,
int height);
Bool
RRTransformCopy (RRTransformPtr dst, RRTransformPtr src);
Bool
RRTransformCompute (int x,
int y,
int width,
int height,
Rotation rotation,
RRTransformPtr rr_transform,
PictTransformPtr transform,
struct pict_f_transform *f_transform,
struct pict_f_transform *f_inverse);
#endif /* _RRTRANSFORM_H_ */

View File

@ -6,6 +6,7 @@ librender_la_SOURCES = \
animcur.c \
filter.c \
glyph.c \
matrix.c \
miindex.c \
mipict.c \
mirect.c \

View File

@ -126,7 +126,9 @@ PictureFreeFilterIds (void)
_X_EXPORT int
PictureAddFilter (ScreenPtr pScreen,
char *filter,
PictFilterValidateParamsProcPtr ValidateParams)
PictFilterValidateParamsProcPtr ValidateParams,
int width,
int height)
{
PictureScreenPtr ps = GetPictureScreen(pScreen);
int id = PictureGetFilterId (filter, -1, TRUE);
@ -152,6 +154,8 @@ PictureAddFilter (ScreenPtr pScreen,
ps->filters[i].name = PictureGetFilterName (id);
ps->filters[i].id = id;
ps->filters[i].ValidateParams = ValidateParams;
ps->filters[i].width = width;
ps->filters[i].height = height;
return id;
}
@ -213,21 +217,29 @@ PictureFindFilter (ScreenPtr pScreen, char *name, int len)
}
static Bool
convolutionFilterValidateParams (PicturePtr pPicture,
convolutionFilterValidateParams (ScreenPtr pScreen,
int filter,
xFixed *params,
int nparams)
int nparams,
int *width,
int *height)
{
int w, h;
if (nparams < 3)
return FALSE;
if (xFixedFrac (params[0]) || xFixedFrac (params[1]))
return FALSE;
w = xFixedToInt (params[0]);
h = xFixedToInt (params[1]);
nparams -= 2;
if ((xFixedToInt (params[0]) * xFixedToInt (params[1])) > nparams)
if (w * h > nparams)
return FALSE;
*width = w;
*height = h;
return TRUE;
}
@ -238,9 +250,9 @@ PictureSetDefaultFilters (ScreenPtr pScreen)
if (!filterNames)
if (!PictureSetDefaultIds ())
return FALSE;
if (PictureAddFilter (pScreen, FilterNearest, 0) < 0)
if (PictureAddFilter (pScreen, FilterNearest, 0, 1, 1) < 0)
return FALSE;
if (PictureAddFilter (pScreen, FilterBilinear, 0) < 0)
if (PictureAddFilter (pScreen, FilterBilinear, 0, 2, 2) < 0)
return FALSE;
if (!PictureSetFilterAlias (pScreen, FilterNearest, FilterFast))
@ -250,7 +262,7 @@ PictureSetDefaultFilters (ScreenPtr pScreen)
if (!PictureSetFilterAlias (pScreen, FilterBilinear, FilterBest))
return FALSE;
if (PictureAddFilter (pScreen, FilterConvolution, convolutionFilterValidateParams) < 0)
if (PictureAddFilter (pScreen, FilterConvolution, convolutionFilterValidateParams, 0, 0) < 0)
return FALSE;
return TRUE;
@ -270,29 +282,52 @@ int
SetPictureFilter (PicturePtr pPicture, char *name, int len, xFixed *params, int nparams)
{
PictFilterPtr pFilter;
xFixed *new_params;
int i, s, result;
ScreenPtr pScreen;
pFilter = PictureFindFilter (screenInfo.screens[0], name, len);
if (pPicture->pDrawable != NULL)
pScreen = pPicture->pDrawable->pScreen;
else
pScreen = screenInfo.screens[0];
if (pPicture->pDrawable == NULL) {
/* For source pictures, the picture isn't tied to a screen. So, ensure
* that all screens can handle a filter we set for the picture.
*/
for (s = 0; s < screenInfo.numScreens; s++) {
if (PictureFindFilter (screenInfo.screens[s], name, len)->id !=
pFilter->id)
{
return BadMatch;
}
}
}
pFilter = PictureFindFilter (pScreen, name, len);
if (!pFilter)
return BadName;
if (pPicture->pDrawable == NULL)
{
int s;
/* For source pictures, the picture isn't tied to a screen. So, ensure
* that all screens can handle a filter we set for the picture.
*/
for (s = 1; s < screenInfo.numScreens; s++)
{
PictFilterPtr pScreenFilter;
pScreenFilter = PictureFindFilter (screenInfo.screens[s],
name, len);
if (!pScreenFilter || pScreenFilter->id != pFilter->id)
return BadMatch;
}
}
return SetPicturePictFilter (pPicture, pFilter, params, nparams);
}
int
SetPicturePictFilter (PicturePtr pPicture, PictFilterPtr pFilter,
xFixed *params, int nparams)
{
ScreenPtr pScreen;
int i;
if (pPicture->pDrawable)
pScreen = pPicture->pDrawable->pScreen;
else
pScreen = screenInfo.screens[0];
if (pFilter->ValidateParams)
{
if (!(*pFilter->ValidateParams) (pPicture, pFilter->id, params, nparams))
int width, height;
if (!(*pFilter->ValidateParams) (pScreen, pFilter->id, params, nparams, &width, &height))
return BadMatch;
}
else if (nparams)
@ -300,7 +335,7 @@ SetPictureFilter (PicturePtr pPicture, char *name, int len, xFixed *params, int
if (nparams != pPicture->filter_nparams)
{
new_params = xalloc (nparams * sizeof (xFixed));
xFixed *new_params = xalloc (nparams * sizeof (xFixed));
if (!new_params)
return BadAlloc;
xfree (pPicture->filter_params);
@ -311,9 +346,10 @@ SetPictureFilter (PicturePtr pPicture, char *name, int len, xFixed *params, int
pPicture->filter_params[i] = params[i];
pPicture->filter = pFilter->id;
if (pPicture->pDrawable) {
ScreenPtr pScreen = pPicture->pDrawable->pScreen;
PictureScreenPtr ps = GetPictureScreen(pScreen);
if (pPicture->pDrawable)
{
PictureScreenPtr ps = GetPictureScreen(pScreen);
int result;
result = (*ps->ChangePictureFilter) (pPicture, pPicture->filter,
params, nparams);

631
render/matrix.c Normal file
View File

@ -0,0 +1,631 @@
/*
* Copyright © 2007 Keith Packard
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that copyright
* notice and this permission notice appear in supporting documentation, and
* that the name of the copyright holders not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. The copyright holders make no representations
* about the suitability of this software for any purpose. It is provided "as
* is" without express or implied warranty.
*
* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
* OF THIS SOFTWARE.
*/
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#include "misc.h"
#include "scrnintstr.h"
#include "os.h"
#include "regionstr.h"
#include "validate.h"
#include "windowstr.h"
#include "input.h"
#include "resource.h"
#include "colormapst.h"
#include "cursorstr.h"
#include "dixstruct.h"
#include "gcstruct.h"
#include "servermd.h"
#include "picturestr.h"
#define F(x) IntToxFixed(x)
_X_EXPORT void
PictureTransformInitIdentity (PictTransformPtr matrix)
{
int i;
memset (matrix, '\0', sizeof (PictTransform));
for (i = 0; i < 3; i++)
matrix->matrix[i][i] = F(1);
}
typedef xFixed_32_32 xFixed_34_30;
_X_EXPORT Bool
PictureTransformPoint3d (PictTransformPtr transform,
PictVectorPtr vector)
{
PictVector result;
int i, j;
xFixed_32_32 partial;
xFixed_48_16 v;
for (j = 0; j < 3; j++)
{
v = 0;
for (i = 0; i < 3; i++)
{
partial = ((xFixed_48_16) transform->matrix[j][i] *
(xFixed_48_16) vector->vector[i]);
v += partial >> 16;
}
if (v > MAX_FIXED_48_16 || v < MIN_FIXED_48_16)
return FALSE;
result.vector[j] = (xFixed) v;
}
*vector = result;
if (!result.vector[2])
return FALSE;
return TRUE;
}
_X_EXPORT Bool
PictureTransformPoint (PictTransformPtr transform,
PictVectorPtr vector)
{
int i, j;
xFixed_32_32 partial;
xFixed_34_30 v[3];
xFixed_48_16 quo;
for (j = 0; j < 3; j++)
{
v[j] = 0;
for (i = 0; i < 3; i++)
{
partial = ((xFixed_32_32) transform->matrix[j][i] *
(xFixed_32_32) vector->vector[i]);
v[j] += partial >> 2;
}
}
if (!v[2])
return FALSE;
for (j = 0; j < 2; j++)
{
quo = v[j] / (v[2] >> 16);
if (quo > MAX_FIXED_48_16 || quo < MIN_FIXED_48_16)
return FALSE;
vector->vector[j] = (xFixed) quo;
}
vector->vector[2] = xFixed1;
return TRUE;
}
_X_EXPORT Bool
PictureTransformMultiply (PictTransformPtr dst, PictTransformPtr l, PictTransformPtr r)
{
PictTransform d;
int dx, dy;
int o;
for (dy = 0; dy < 3; dy++)
for (dx = 0; dx < 3; dx++)
{
xFixed_48_16 v;
xFixed_32_32 partial;
v = 0;
for (o = 0; o < 3; o++)
{
partial = (xFixed_32_32) l->matrix[dy][o] * (xFixed_32_32) r->matrix[o][dx];
v += partial >> 16;
}
if (v > MAX_FIXED_48_16 || v < MIN_FIXED_48_16)
return FALSE;
d.matrix[dy][dx] = (xFixed) v;
}
*dst = d;
return TRUE;
}
_X_EXPORT void
PictureTransformInitScale (PictTransformPtr t, xFixed sx, xFixed sy)
{
memset (t, '\0', sizeof (PictTransform));
t->matrix[0][0] = sx;
t->matrix[1][1] = sy;
t->matrix[2][2] = F (1);
}
static xFixed
fixed_inverse (xFixed x)
{
return (xFixed) ((((xFixed_48_16) F(1)) * F(1)) / x);
}
_X_EXPORT Bool
PictureTransformScale (PictTransformPtr forward,
PictTransformPtr reverse,
xFixed sx, xFixed sy)
{
PictTransform t;
if (sx == 0 || sy == 0)
return FALSE;
PictureTransformInitScale (&t, sx, sy);
if (!PictureTransformMultiply (forward, &t, forward))
return FALSE;
PictureTransformInitScale (&t, fixed_inverse (sx), fixed_inverse (sy));
if (!PictureTransformMultiply (reverse, reverse, &t))
return FALSE;
return TRUE;
}
_X_EXPORT void
PictureTransformInitRotate (PictTransformPtr t, xFixed c, xFixed s)
{
memset (t, '\0', sizeof (PictTransform));
t->matrix[0][0] = c;
t->matrix[0][1] = -s;
t->matrix[1][0] = s;
t->matrix[1][1] = c;
t->matrix[2][2] = F (1);
}
_X_EXPORT Bool
PictureTransformRotate (PictTransformPtr forward,
PictTransformPtr reverse,
xFixed c, xFixed s)
{
PictTransform t;
PictureTransformInitRotate (&t, c, s);
if (!PictureTransformMultiply (forward, &t, forward))
return FALSE;
PictureTransformInitRotate (&t, c, -s);
if (!PictureTransformMultiply (reverse, reverse, &t))
return FALSE;
return TRUE;
}
_X_EXPORT void
PictureTransformInitTranslate (PictTransformPtr t, xFixed tx, xFixed ty)
{
memset (t, '\0', sizeof (PictTransform));
t->matrix[0][0] = F (1);
t->matrix[0][2] = tx;
t->matrix[1][1] = F (1);
t->matrix[1][2] = ty;
t->matrix[2][2] = F (1);
}
_X_EXPORT Bool
PictureTransformTranslate (PictTransformPtr forward,
PictTransformPtr reverse,
xFixed tx, xFixed ty)
{
PictTransform t;
PictureTransformInitTranslate (&t, tx, ty);
if (!PictureTransformMultiply (forward, &t, forward))
return FALSE;
PictureTransformInitTranslate (&t, -tx, -ty);
if (!PictureTransformMultiply (reverse, reverse, &t))
return FALSE;
return TRUE;
}
_X_EXPORT Bool
PictureTransformBounds (BoxPtr b, PictTransformPtr matrix)
{
PictVector v[4];
int i;
int x1, y1, x2, y2;
v[0].vector[0] = F (b->x1); v[0].vector[1] = F (b->y1); v[0].vector[2] = F(1);
v[1].vector[0] = F (b->x2); v[1].vector[1] = F (b->y1); v[1].vector[2] = F(1);
v[2].vector[0] = F (b->x2); v[2].vector[1] = F (b->y2); v[2].vector[2] = F(1);
v[3].vector[0] = F (b->x1); v[3].vector[1] = F (b->y2); v[3].vector[2] = F(1);
for (i = 0; i < 4; i++)
{
if (!PictureTransformPoint (matrix, &v[i]))
return FALSE;
x1 = xFixedToInt (v[i].vector[0]);
y1 = xFixedToInt (v[i].vector[1]);
x2 = xFixedToInt (xFixedCeil (v[i].vector[0]));
y2 = xFixedToInt (xFixedCeil (v[i].vector[1]));
if (i == 0)
{
b->x1 = x1; b->y1 = y1;
b->x2 = x2; b->y2 = y2;
}
else
{
if (x1 < b->x1) b->x1 = x1;
if (y1 < b->y1) b->y1 = y1;
if (x2 > b->x2) b->x2 = x2;
if (y2 > b->y2) b->y2 = y2;
}
}
return TRUE;
}
_X_EXPORT Bool
PictureTransformInvert (PictTransformPtr dst, const PictTransformPtr src)
{
struct pict_f_transform m, r;
pict_f_transform_from_pixman_transform (&m, src);
if (!pict_f_transform_invert (&r, &m))
return FALSE;
if (!pixman_transform_from_pict_f_transform (dst, &r))
return FALSE;
return TRUE;
}
static Bool
within_epsilon (xFixed a, xFixed b, xFixed epsilon)
{
xFixed t = a - b;
if (t < 0) t = -t;
return t <= epsilon;
}
#define epsilon (xFixed) (2)
#define IsSame(a,b) (within_epsilon (a, b, epsilon))
#define IsZero(a) (within_epsilon (a, 0, epsilon))
#define IsOne(a) (within_epsilon (a, F(1), epsilon))
#define IsUnit(a) (within_epsilon (a, F( 1), epsilon) || \
within_epsilon (a, F(-1), epsilon) || \
IsZero (a))
#define IsInt(a) (IsZero (xFixedFrac(a)))
_X_EXPORT Bool
PictureTransformIsIdentity(PictTransform *t)
{
return (IsSame (t->matrix[0][0], t->matrix[1][1]) &&
IsSame (t->matrix[0][0], t->matrix[2][2]) &&
!IsZero (t->matrix[0][0]) &&
IsZero (t->matrix[0][1]) &&
IsZero (t->matrix[0][2]) &&
IsZero (t->matrix[1][0]) &&
IsZero (t->matrix[1][2]) &&
IsZero (t->matrix[2][0]) &&
IsZero (t->matrix[2][1]));
}
_X_EXPORT Bool
PictureTransformIsScale(PictTransform *t)
{
return (!IsZero (t->matrix[0][0]) &&
IsZero (t->matrix[0][1]) &&
IsZero (t->matrix[0][2]) &&
IsZero (t->matrix[1][0]) &&
!IsZero (t->matrix[1][1]) &&
IsZero (t->matrix[1][2]) &&
IsZero (t->matrix[2][0]) &&
IsZero (t->matrix[2][1]) &&
!IsZero (t->matrix[2][2]));
}
_X_EXPORT Bool
PictureTransformIsIntTranslate(PictTransform *t)
{
return ( IsOne (t->matrix[0][0]) &&
IsZero (t->matrix[0][1]) &&
IsInt (t->matrix[0][2]) &&
IsZero (t->matrix[1][0]) &&
IsOne (t->matrix[1][1]) &&
IsInt (t->matrix[1][2]) &&
IsZero (t->matrix[2][0]) &&
IsZero (t->matrix[2][1]) &&
IsOne (t->matrix[2][2]));
}
_X_EXPORT Bool
PictureTransformIsInverse (PictTransform *a, PictTransform *b)
{
PictTransform t;
PictureTransformMultiply (&t, a, b);
return PictureTransformIsIdentity (&t);
}
_X_EXPORT void
PictTransform_from_xRenderTransform (PictTransformPtr pict,
xRenderTransform *render)
{
pict->matrix[0][0] = render->matrix11;
pict->matrix[0][1] = render->matrix12;
pict->matrix[0][2] = render->matrix13;
pict->matrix[1][0] = render->matrix21;
pict->matrix[1][1] = render->matrix22;
pict->matrix[1][2] = render->matrix23;
pict->matrix[2][0] = render->matrix31;
pict->matrix[2][1] = render->matrix32;
pict->matrix[2][2] = render->matrix33;
}
void
xRenderTransform_from_PictTransform (xRenderTransform *render,
PictTransformPtr pict)
{
render->matrix11 = pict->matrix[0][0];
render->matrix12 = pict->matrix[0][1];
render->matrix13 = pict->matrix[0][2];
render->matrix21 = pict->matrix[1][0];
render->matrix22 = pict->matrix[1][1];
render->matrix23 = pict->matrix[1][2];
render->matrix31 = pict->matrix[2][0];
render->matrix32 = pict->matrix[2][1];
render->matrix33 = pict->matrix[2][2];
}
/*
* Floating point matrix interfaces
*/
_X_EXPORT void
pict_f_transform_from_pixman_transform (struct pict_f_transform *ft,
struct pixman_transform *t)
{
int i, j;
for (j = 0; j < 3; j++)
for (i = 0; i < 3; i++)
ft->m[j][i] = pixman_fixed_to_double (t->matrix[j][i]);
}
_X_EXPORT Bool
pixman_transform_from_pict_f_transform (struct pixman_transform *t,
struct pict_f_transform *ft)
{
int i, j;
for (j = 0; j < 3; j++)
for (i = 0; i < 3; i++)
{
double d = ft->m[j][i];
if (d < -32767.0 || d > 32767.0)
return FALSE;
d = d * 65536.0 + 0.5;
t->matrix[j][i] = (xFixed) floor (d);
}
return TRUE;
}
static const int a[3] = { 3, 3, 2 };
static const int b[3] = { 2, 1, 1 };
_X_EXPORT Bool
pict_f_transform_invert (struct pict_f_transform *r,
struct pict_f_transform *m)
{
double det;
int i, j;
static int a[3] = { 2, 2, 1 };
static int b[3] = { 1, 0, 0 };
det = 0;
for (i = 0; i < 3; i++) {
double p;
int ai = a[i];
int bi = b[i];
p = m->m[i][0] * (m->m[ai][2] * m->m[bi][1] - m->m[ai][1] * m->m[bi][2]);
if (i == 1)
p = -p;
det += p;
}
if (det == 0)
return FALSE;
det = 1/det;
for (j = 0; j < 3; j++) {
for (i = 0; i < 3; i++) {
double p;
int ai = a[i];
int aj = a[j];
int bi = b[i];
int bj = b[j];
p = m->m[ai][aj] * m->m[bi][bj] - m->m[ai][bj] * m->m[bi][aj];
if (((i + j) & 1) != 0)
p = -p;
r->m[j][i] = det * p;
}
}
return TRUE;
}
_X_EXPORT Bool
pict_f_transform_point (struct pict_f_transform *t,
struct pict_f_vector *v)
{
struct pict_f_vector result;
int i, j;
double a;
for (j = 0; j < 3; j++)
{
a = 0;
for (i = 0; i < 3; i++)
a += t->m[j][i] * v->v[i];
result.v[j] = a;
}
if (!result.v[2])
return FALSE;
for (j = 0; j < 2; j++)
v->v[j] = result.v[j] / result.v[2];
v->v[2] = 1;
return TRUE;
}
_X_EXPORT void
pict_f_transform_point_3d (struct pict_f_transform *t,
struct pict_f_vector *v)
{
struct pict_f_vector result;
int i, j;
double a;
for (j = 0; j < 3; j++)
{
a = 0;
for (i = 0; i < 3; i++)
a += t->m[j][i] * v->v[i];
result.v[j] = a;
}
*v = result;
}
_X_EXPORT void
pict_f_transform_multiply (struct pict_f_transform *dst,
struct pict_f_transform *l, struct pict_f_transform *r)
{
struct pict_f_transform d;
int dx, dy;
int o;
for (dy = 0; dy < 3; dy++)
for (dx = 0; dx < 3; dx++)
{
double v = 0;
for (o = 0; o < 3; o++)
v += l->m[dy][o] * r->m[o][dx];
d.m[dy][dx] = v;
}
*dst = d;
}
_X_EXPORT void
pict_f_transform_init_scale (struct pict_f_transform *t, double sx, double sy)
{
t->m[0][0] = sx; t->m[0][1] = 0; t->m[0][2] = 0;
t->m[1][0] = 0; t->m[1][1] = sy; t->m[1][2] = 0;
t->m[2][0] = 0; t->m[2][1] = 0; t->m[2][2] = 1;
}
_X_EXPORT Bool
pict_f_transform_scale (struct pict_f_transform *forward,
struct pict_f_transform *reverse,
double sx, double sy)
{
struct pict_f_transform t;
if (sx == 0 || sy == 0)
return FALSE;
pict_f_transform_init_scale (&t, sx, sy);
pict_f_transform_multiply (forward, &t, forward);
pict_f_transform_init_scale (&t, 1/sx, 1/sy);
pict_f_transform_multiply (reverse, reverse, &t);
return TRUE;
}
_X_EXPORT void
pict_f_transform_init_rotate (struct pict_f_transform *t, double c, double s)
{
t->m[0][0] = c; t->m[0][1] = -s; t->m[0][2] = 0;
t->m[1][0] = s; t->m[1][1] = c; t->m[1][2] = 0;
t->m[2][0] = 0; t->m[2][1] = 0; t->m[2][2] = 1;
}
_X_EXPORT Bool
pict_f_transform_rotate (struct pict_f_transform *forward,
struct pict_f_transform *reverse,
double c, double s)
{
struct pict_f_transform t;
pict_f_transform_init_rotate (&t, c, s);
pict_f_transform_multiply (forward, &t, forward);
pict_f_transform_init_rotate (&t, c, -s);
pict_f_transform_multiply (reverse, reverse, &t);
return TRUE;
}
_X_EXPORT void
pict_f_transform_init_translate (struct pict_f_transform *t, double tx, double ty)
{
t->m[0][0] = 1; t->m[0][1] = 0; t->m[0][2] = tx;
t->m[1][0] = 0; t->m[1][1] = 1; t->m[1][2] = ty;
t->m[2][0] = 0; t->m[2][1] = 0; t->m[2][2] = 1;
}
_X_EXPORT Bool
pict_f_transform_translate (struct pict_f_transform *forward,
struct pict_f_transform *reverse,
double tx, double ty)
{
struct pict_f_transform t;
pict_f_transform_init_translate (&t, tx, ty);
pict_f_transform_multiply (forward, &t, forward);
pict_f_transform_init_translate (&t, -tx, -ty);
pict_f_transform_multiply (reverse, reverse, &t);
return TRUE;
}
_X_EXPORT Bool
pict_f_transform_bounds (struct pict_f_transform *t, BoxPtr b)
{
struct pict_f_vector v[4];
int i;
int x1, y1, x2, y2;
v[0].v[0] = b->x1; v[0].v[1] = b->y1; v[0].v[2] = 1;
v[1].v[0] = b->x2; v[1].v[1] = b->y1; v[1].v[2] = 1;
v[2].v[0] = b->x2; v[2].v[1] = b->y2; v[2].v[2] = 1;
v[3].v[0] = b->x1; v[3].v[1] = b->y2; v[3].v[2] = 1;
for (i = 0; i < 4; i++)
{
if (!pict_f_transform_point (t, &v[i]))
return FALSE;
x1 = floor (v[i].v[0]);
y1 = floor (v[i].v[1]);
x2 = ceil (v[i].v[0]);
y2 = ceil (v[i].v[1]);
if (i == 0)
{
b->x1 = x1; b->y1 = y1;
b->x2 = x2; b->y2 = y2;
}
else
{
if (x1 < b->x1) b->x1 = x1;
if (y1 < b->y1) b->y1 = y1;
if (x2 > b->x2) b->x2 = x2;
if (y2 > b->y2) b->y2 = y2;
}
}
return TRUE;
}
_X_EXPORT void
pict_f_transform_init_identity (struct pict_f_transform *t)
{
int i, j;
for (j = 0; j < 3; j++)
for (i = 0; i < 3; i++)
t->m[j][i] = i == j ? 1 : 0;
}

View File

@ -1069,7 +1069,7 @@ ChangePicture (PicturePtr pPicture,
pAlpha = 0;
else
{
error = dixLookupResource((pointer *)&pAlpha, pid,
error = dixLookupResourceByType((pointer *)&pAlpha, pid,
PictureType, client,
DixReadAccess);
if (error != Success)
@ -1130,7 +1130,7 @@ ChangePicture (PicturePtr pPicture,
else
{
clipType = CT_PIXMAP;
error = dixLookupResource((pointer *)&pPixmap, pid,
error = dixLookupResourceByType((pointer *)&pPixmap, pid,
RT_PIXMAP, client,
DixReadAccess);
if (error != Success)
@ -1779,67 +1779,3 @@ AddTraps (PicturePtr pPicture,
(*ps->AddTraps) (pPicture, xOff, yOff, ntrap, traps);
}
_X_EXPORT Bool
PictureTransformPoint3d (PictTransformPtr transform,
PictVectorPtr vector)
{
PictVector result;
int i, j;
xFixed_32_32 partial;
xFixed_48_16 v;
for (j = 0; j < 3; j++)
{
v = 0;
for (i = 0; i < 3; i++)
{
partial = ((xFixed_48_16) transform->matrix[j][i] *
(xFixed_48_16) vector->vector[i]);
v += partial >> 16;
}
if (v > MAX_FIXED_48_16 || v < MIN_FIXED_48_16)
return FALSE;
result.vector[j] = (xFixed) v;
}
if (!result.vector[2])
return FALSE;
*vector = result;
return TRUE;
}
_X_EXPORT Bool
PictureTransformPoint (PictTransformPtr transform,
PictVectorPtr vector)
{
PictVector result;
int i, j;
xFixed_32_32 partial;
xFixed_48_16 v;
for (j = 0; j < 3; j++)
{
v = 0;
for (i = 0; i < 3; i++)
{
partial = ((xFixed_48_16) transform->matrix[j][i] *
(xFixed_48_16) vector->vector[i]);
v += partial >> 16;
}
if (v > MAX_FIXED_48_16 || v < MIN_FIXED_48_16)
return FALSE;
result.vector[j] = (xFixed) v;
}
if (!result.vector[2])
return FALSE;
for (j = 0; j < 2; j++)
{
partial = (xFixed_48_16) result.vector[j] << 16;
v = partial / result.vector[2];
if (v > MAX_FIXED_48_16 || v < MIN_FIXED_48_16)
return FALSE;
vector->vector[j] = (xFixed) v;
}
vector->vector[2] = xFixed1;
return TRUE;
}

View File

@ -56,6 +56,14 @@ typedef struct _PictFormat {
typedef struct pixman_vector PictVector, *PictVectorPtr;
typedef struct pixman_transform PictTransform, *PictTransformPtr;
struct pict_f_vector {
double v[3];
};
struct pict_f_transform {
double m[3][3];
};
#define PICT_GRADIENT_STOPTABLE_SIZE 1024
#define SourcePictTypeSolidFill 0
#define SourcePictTypeLinear 1
@ -184,12 +192,14 @@ typedef struct _Picture {
SourcePictPtr pSourcePict;
} PictureRec;
typedef Bool (*PictFilterValidateParamsProcPtr) (PicturePtr pPicture, int id,
xFixed *params, int nparams);
typedef Bool (*PictFilterValidateParamsProcPtr) (ScreenPtr pScreen, int id,
xFixed *params, int nparams,
int *width, int *height);
typedef struct {
char *name;
int id;
PictFilterValidateParamsProcPtr ValidateParams;
int width, height;
} PictFilterRec, *PictFilterPtr;
#define PictFilterNearest 0
@ -461,7 +471,9 @@ PictureGetFilterName (int id);
int
PictureAddFilter (ScreenPtr pScreen,
char *filter,
PictFilterValidateParamsProcPtr ValidateParams);
PictFilterValidateParamsProcPtr ValidateParams,
int width,
int height);
Bool
PictureSetFilterAlias (ScreenPtr pScreen, char *filter, char *alias);
@ -476,7 +488,12 @@ PictFilterPtr
PictureFindFilter (ScreenPtr pScreen, char *name, int len);
int
SetPictureFilter (PicturePtr pPicture, char *name, int len, xFixed *params, int nparams);
SetPicturePictFilter (PicturePtr pPicture, PictFilterPtr pFilter,
xFixed *params, int nparams);
int
SetPictureFilter (PicturePtr pPicture, char *name, int len,
xFixed *params, int nparams);
Bool
PictureFinishInit (void);
@ -605,14 +622,6 @@ CompositeTriFan (CARD8 op,
int npoints,
xPointFixed *points);
Bool
PictureTransformPoint (PictTransformPtr transform,
PictVectorPtr vector);
Bool
PictureTransformPoint3d (PictTransformPtr transform,
PictVectorPtr vector);
CARD32
PictureGradientColor (PictGradientStopPtr stop1,
PictGradientStopPtr stop2,
@ -676,4 +685,127 @@ void PanoramiXRenderInit (void);
void PanoramiXRenderReset (void);
#endif
/*
* matrix.c
*/
void
PictureTransformInitIdentity (PictTransformPtr matrix);
Bool
PictureTransformPoint3d (PictTransformPtr transform,
PictVectorPtr vector);
Bool
PictureTransformPoint (PictTransformPtr transform,
PictVectorPtr vector);
Bool
PictureTransformMultiply (PictTransformPtr dst,
PictTransformPtr l, PictTransformPtr r);
void
PictureTransformInitScale (PictTransformPtr t, xFixed sx, xFixed sy);
Bool
PictureTransformScale (PictTransformPtr forward,
PictTransformPtr reverse,
xFixed sx, xFixed sy);
void
PictureTransformInitRotate (PictTransformPtr t, xFixed c, xFixed s);
Bool
PictureTransformRotate (PictTransformPtr forward,
PictTransformPtr reverse,
xFixed c, xFixed s);
void
PictureTransformInitTranslate (PictTransformPtr t, xFixed tx, xFixed ty);
Bool
PictureTransformTranslate (PictTransformPtr forward,
PictTransformPtr reverse,
xFixed tx, xFixed ty);
Bool
PictureTransformBounds (BoxPtr b, PictTransformPtr matrix);
Bool
PictureTransformInvert (PictTransformPtr dst, const PictTransformPtr src);
Bool
PictureTransformIsIdentity(PictTransform *t);
Bool
PictureTransformIsScale(PictTransform *t);
Bool
PictureTransformIsIntTranslate (PictTransform *t);
Bool
PictureTransformIsInverse(PictTransform *t, PictTransform *i);
void
PictTransform_from_xRenderTransform (PictTransformPtr pict,
xRenderTransform *render);
void
xRenderTransform_from_PictTransform (xRenderTransform *render,
PictTransformPtr pict);
void
pict_f_transform_from_pixman_transform (struct pict_f_transform *ft,
struct pixman_transform *t);
Bool
pixman_transform_from_pict_f_transform (struct pixman_transform *t,
struct pict_f_transform *ft);
Bool
pict_f_transform_invert (struct pict_f_transform *r,
struct pict_f_transform *m);
Bool
pict_f_transform_point (struct pict_f_transform *t,
struct pict_f_vector *v);
void
pict_f_transform_point_3d (struct pict_f_transform *t,
struct pict_f_vector *v);
void
pict_f_transform_multiply (struct pict_f_transform *dst,
struct pict_f_transform *l, struct pict_f_transform *r);
void
pict_f_transform_init_scale (struct pict_f_transform *t, double sx, double sy);
Bool
pict_f_transform_scale (struct pict_f_transform *forward,
struct pict_f_transform *reverse,
double sx, double sy);
void
pict_f_transform_init_rotate (struct pict_f_transform *t, double c, double s);
Bool
pict_f_transform_rotate (struct pict_f_transform *forward,
struct pict_f_transform *reverse,
double c, double s);
void
pict_f_transform_init_translate (struct pict_f_transform *t, double tx, double ty);
Bool
pict_f_transform_translate (struct pict_f_transform *forward,
struct pict_f_transform *reverse,
double tx, double ty);
Bool
pict_f_transform_bounds (struct pict_f_transform *t, BoxPtr b);
void
pict_f_transform_init_identity (struct pict_f_transform *t);
#endif /* _PICTURESTR_H_ */

View File

@ -1018,7 +1018,7 @@ ProcRenderReferenceGlyphSet (ClientPtr client)
LEGAL_NEW_RESOURCE(stuff->gsid, client);
rc = dixLookupResource((pointer *)&glyphSet, stuff->existing, GlyphSetType,
rc = dixLookupResourceByType((pointer *)&glyphSet, stuff->existing, GlyphSetType,
client, DixGetAttrAccess);
if (rc != Success)
{
@ -1042,7 +1042,7 @@ ProcRenderFreeGlyphSet (ClientPtr client)
REQUEST(xRenderFreeGlyphSetReq);
REQUEST_SIZE_MATCH(xRenderFreeGlyphSetReq);
rc = dixLookupResource((pointer *)&glyphSet, stuff->glyphset, GlyphSetType,
rc = dixLookupResourceByType((pointer *)&glyphSet, stuff->glyphset, GlyphSetType,
client, DixDestroyAccess);
if (rc != Success)
{
@ -1081,7 +1081,7 @@ ProcRenderAddGlyphs (ClientPtr client)
CARD32 component_alpha;
REQUEST_AT_LEAST_SIZE(xRenderAddGlyphsReq);
err = dixLookupResource((pointer *)&glyphSet, stuff->glyphset, GlyphSetType,
err = dixLookupResourceByType((pointer *)&glyphSet, stuff->glyphset, GlyphSetType,
client, DixAddAccess);
if (err != Success)
{
@ -1271,7 +1271,7 @@ ProcRenderFreeGlyphs (ClientPtr client)
CARD32 glyph;
REQUEST_AT_LEAST_SIZE(xRenderFreeGlyphsReq);
rc = dixLookupResource((pointer *)&glyphSet, stuff->glyphset, GlyphSetType,
rc = dixLookupResourceByType((pointer *)&glyphSet, stuff->glyphset, GlyphSetType,
client, DixRemoveAccess);
if (rc != Success)
{

View File

@ -850,7 +850,7 @@ ProcXFixesHideCursor (ClientPtr client)
REQUEST_SIZE_MATCH (xXFixesHideCursorReq);
ret = dixLookupResource((pointer *)&pWin, stuff->window, RT_WINDOW,
ret = dixLookupResourceByType((pointer *)&pWin, stuff->window, RT_WINDOW,
client, DixGetAttrAccess);
if (ret != Success) {
client->errorValue = stuff->window;
@ -908,7 +908,7 @@ ProcXFixesShowCursor (ClientPtr client)
REQUEST_SIZE_MATCH (xXFixesShowCursorReq);
rc = dixLookupResource((pointer *)&pWin, stuff->window, RT_WINDOW,
rc = dixLookupResourceByType((pointer *)&pWin, stuff->window, RT_WINDOW,
client, DixGetAttrAccess);
if (rc != Success) {
client->errorValue = stuff->window;

View File

@ -115,7 +115,7 @@ ProcXFixesCreateRegionFromBitmap (ClientPtr client)
REQUEST_SIZE_MATCH (xXFixesCreateRegionFromBitmapReq);
LEGAL_NEW_RESOURCE (stuff->region, client);
rc = dixLookupResource((pointer *)&pPixmap, stuff->bitmap, RT_PIXMAP,
rc = dixLookupResourceByType((pointer *)&pPixmap, stuff->bitmap, RT_PIXMAP,
client, DixReadAccess);
if (rc != Success)
{
@ -160,7 +160,7 @@ ProcXFixesCreateRegionFromWindow (ClientPtr client)
REQUEST_SIZE_MATCH (xXFixesCreateRegionFromWindowReq);
LEGAL_NEW_RESOURCE (stuff->region, client);
rc = dixLookupResource((pointer *)&pWin, stuff->window, RT_WINDOW,
rc = dixLookupResourceByType((pointer *)&pWin, stuff->window, RT_WINDOW,
client, DixGetAttrAccess);
if (rc != Success)
{
@ -687,7 +687,7 @@ ProcXFixesSetWindowShapeRegion (ClientPtr client)
REQUEST(xXFixesSetWindowShapeRegionReq);
REQUEST_SIZE_MATCH(xXFixesSetWindowShapeRegionReq);
rc = dixLookupResource((pointer *)&pWin, stuff->dest, RT_WINDOW,
rc = dixLookupResourceByType((pointer *)&pWin, stuff->dest, RT_WINDOW,
client, DixSetAttrAccess);
if (rc != Success)
{

View File

@ -75,6 +75,9 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
#define PATHSEPARATOR "/"
#endif
#define DEBUG
#define xkbDebugFlags 65535
#ifdef WIN32
#include <X11/Xwindows.h>