rootless: Use screen_x and screen_y instead of pixmap pointer hacks
This updates rootless to treat pixmaps consistently with COMPOSITE, using the screen_x and screen_y values rather than doing hacky math. This will allow for proper bounds checking on a given PixmapRec. Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
This commit is contained in:
parent
820b1dc461
commit
16e7cdba48
|
@ -2182,7 +2182,7 @@ DoGetImage(ClientPtr client, int format, Drawable drawable,
|
||||||
PixmapPtr pPix = (*pDraw->pScreen->GetWindowPixmap) (pWin);
|
PixmapPtr pPix = (*pDraw->pScreen->GetWindowPixmap) (pWin);
|
||||||
|
|
||||||
pBoundingDraw = &pPix->drawable;
|
pBoundingDraw = &pPix->drawable;
|
||||||
#ifdef COMPOSITE
|
#if defined(COMPOSITE) || defined(ROOTLESS)
|
||||||
relx -= pPix->screen_x;
|
relx -= pPix->screen_x;
|
||||||
rely -= pPix->screen_y;
|
rely -= pPix->screen_y;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -125,7 +125,7 @@ exaGetDrawablePixmap(DrawablePtr pDrawable)
|
||||||
void
|
void
|
||||||
exaGetDrawableDeltas(DrawablePtr pDrawable, PixmapPtr pPixmap, int *xp, int *yp)
|
exaGetDrawableDeltas(DrawablePtr pDrawable, PixmapPtr pPixmap, int *xp, int *yp)
|
||||||
{
|
{
|
||||||
#ifdef COMPOSITE
|
#if defined(COMPOSITE) || defined(ROOTLESS)
|
||||||
if (pDrawable->type == DRAWABLE_WINDOW) {
|
if (pDrawable->type == DRAWABLE_WINDOW) {
|
||||||
*xp = -pPixmap->screen_x;
|
*xp = -pPixmap->screen_x;
|
||||||
*yp = -pPixmap->screen_y;
|
*yp = -pPixmap->screen_y;
|
||||||
|
|
|
@ -963,7 +963,7 @@ exaCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
|
||||||
RegionInit(&rgnDst, NullBox, 0);
|
RegionInit(&rgnDst, NullBox, 0);
|
||||||
|
|
||||||
RegionIntersect(&rgnDst, &pWin->borderClip, prgnSrc);
|
RegionIntersect(&rgnDst, &pWin->borderClip, prgnSrc);
|
||||||
#ifdef COMPOSITE
|
#if defined(COMPOSITE) || defined(ROOTLESS)
|
||||||
if (pPixmap->screen_x || pPixmap->screen_y)
|
if (pPixmap->screen_x || pPixmap->screen_y)
|
||||||
RegionTranslate(&rgnDst, -pPixmap->screen_x, -pPixmap->screen_y);
|
RegionTranslate(&rgnDst, -pPixmap->screen_x, -pPixmap->screen_y);
|
||||||
#endif
|
#endif
|
||||||
|
|
2
fb/fb.h
2
fb/fb.h
|
@ -441,7 +441,7 @@ typedef struct {
|
||||||
#define __fbPixDrawableX(pPix) ((pPix)->drawable.x)
|
#define __fbPixDrawableX(pPix) ((pPix)->drawable.x)
|
||||||
#define __fbPixDrawableY(pPix) ((pPix)->drawable.y)
|
#define __fbPixDrawableY(pPix) ((pPix)->drawable.y)
|
||||||
|
|
||||||
#ifdef COMPOSITE
|
#if defined(COMPOSITE) || defined(ROOTLESS)
|
||||||
#define __fbPixOffXWin(pPix) (__fbPixDrawableX(pPix) - (pPix)->screen_x)
|
#define __fbPixOffXWin(pPix) (__fbPixDrawableX(pPix) - (pPix)->screen_x)
|
||||||
#define __fbPixOffYWin(pPix) (__fbPixDrawableY(pPix) - (pPix)->screen_y)
|
#define __fbPixOffYWin(pPix) (__fbPixDrawableY(pPix) - (pPix)->screen_y)
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -76,7 +76,7 @@ fbCreatePixmap(ScreenPtr pScreen, int width, int height, int depth,
|
||||||
fbInitializeDrawable(&pPixmap->drawable);
|
fbInitializeDrawable(&pPixmap->drawable);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef COMPOSITE
|
#if defined(COMPOSITE) || defined(ROOTLESS)
|
||||||
pPixmap->screen_x = 0;
|
pPixmap->screen_x = 0;
|
||||||
pPixmap->screen_y = 0;
|
pPixmap->screen_y = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -116,7 +116,7 @@ fbCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
|
||||||
|
|
||||||
RegionIntersect(&rgnDst, &pWin->borderClip, prgnSrc);
|
RegionIntersect(&rgnDst, &pWin->borderClip, prgnSrc);
|
||||||
|
|
||||||
#ifdef COMPOSITE
|
#if defined(COMPOSITE) || defined(ROOTLESS)
|
||||||
if (pPixmap->screen_x || pPixmap->screen_y)
|
if (pPixmap->screen_x || pPixmap->screen_y)
|
||||||
RegionTranslate(&rgnDst, -pPixmap->screen_x, -pPixmap->screen_y);
|
RegionTranslate(&rgnDst, -pPixmap->screen_x, -pPixmap->screen_y);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -781,7 +781,7 @@ glamor_copy_window(WindowPtr window, DDXPointRec old_origin, RegionPtr src_regio
|
||||||
|
|
||||||
RegionIntersect(&dst_region, &window->borderClip, src_region);
|
RegionIntersect(&dst_region, &window->borderClip, src_region);
|
||||||
|
|
||||||
#ifdef COMPOSITE
|
#if defined(COMPOSITE) || defined(ROOTLESS)
|
||||||
if (pixmap->screen_x || pixmap->screen_y)
|
if (pixmap->screen_x || pixmap->screen_y)
|
||||||
RegionTranslate(&dst_region, -pixmap->screen_x, -pixmap->screen_y);
|
RegionTranslate(&dst_region, -pixmap->screen_x, -pixmap->screen_y);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -39,7 +39,7 @@ void
|
||||||
glamor_get_drawable_deltas(DrawablePtr drawable, PixmapPtr pixmap,
|
glamor_get_drawable_deltas(DrawablePtr drawable, PixmapPtr pixmap,
|
||||||
int *x, int *y)
|
int *x, int *y)
|
||||||
{
|
{
|
||||||
#ifdef COMPOSITE
|
#if defined(COMPOSITE) || defined(ROOTLESS)
|
||||||
if (drawable->type == DRAWABLE_WINDOW) {
|
if (drawable->type == DRAWABLE_WINDOW) {
|
||||||
*x = -pixmap->screen_x;
|
*x = -pixmap->screen_x;
|
||||||
*y = -pixmap->screen_y;
|
*y = -pixmap->screen_y;
|
||||||
|
|
|
@ -78,7 +78,7 @@ typedef struct _Pixmap {
|
||||||
int refcnt;
|
int refcnt;
|
||||||
int devKind; /* This is the pitch of the pixmap, typically width*bpp/8. */
|
int devKind; /* This is the pitch of the pixmap, typically width*bpp/8. */
|
||||||
DevUnion devPrivate; /* When !NULL, devPrivate.ptr points to the raw pixel data. */
|
DevUnion devPrivate; /* When !NULL, devPrivate.ptr points to the raw pixel data. */
|
||||||
#ifdef COMPOSITE
|
#if defined(COMPOSITE) || defined(ROOTLESS)
|
||||||
short screen_x;
|
short screen_x;
|
||||||
short screen_y;
|
short screen_y;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -461,7 +461,7 @@ miPaintWindow(WindowPtr pWin, RegionPtr prgn, int what)
|
||||||
tile_x_off = pWin->drawable.x;
|
tile_x_off = pWin->drawable.x;
|
||||||
tile_y_off = pWin->drawable.y;
|
tile_y_off = pWin->drawable.y;
|
||||||
|
|
||||||
#ifdef COMPOSITE
|
#if defined(COMPOSITE) || defined(ROOTLESS)
|
||||||
draw_x_off = pixmap->screen_x;
|
draw_x_off = pixmap->screen_x;
|
||||||
draw_y_off = pixmap->screen_y;
|
draw_y_off = pixmap->screen_y;
|
||||||
tile_x_off -= draw_x_off;
|
tile_x_off -= draw_x_off;
|
||||||
|
|
|
@ -142,7 +142,7 @@ damageRegionAppend(DrawablePtr pDrawable, RegionPtr pRegion, Bool clip,
|
||||||
RegionRec pixClip;
|
RegionRec pixClip;
|
||||||
int draw_x, draw_y;
|
int draw_x, draw_y;
|
||||||
|
|
||||||
#ifdef COMPOSITE
|
#if defined(COMPOSITE) || defined(ROOTLESS)
|
||||||
int screen_x = 0, screen_y = 0;
|
int screen_x = 0, screen_y = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -150,7 +150,7 @@ damageRegionAppend(DrawablePtr pDrawable, RegionPtr pRegion, Bool clip,
|
||||||
if (!RegionNotEmpty(pRegion))
|
if (!RegionNotEmpty(pRegion))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
#ifdef COMPOSITE
|
#if defined(COMPOSITE) || defined(ROOTLESS)
|
||||||
/*
|
/*
|
||||||
* When drawing to a pixmap which is storing window contents,
|
* When drawing to a pixmap which is storing window contents,
|
||||||
* the region presented is in pixmap relative coordinates which
|
* the region presented is in pixmap relative coordinates which
|
||||||
|
@ -201,7 +201,7 @@ damageRegionAppend(DrawablePtr pDrawable, RegionPtr pRegion, Bool clip,
|
||||||
|
|
||||||
draw_x = pDamage->pDrawable->x;
|
draw_x = pDamage->pDrawable->x;
|
||||||
draw_y = pDamage->pDrawable->y;
|
draw_y = pDamage->pDrawable->y;
|
||||||
#ifdef COMPOSITE
|
#if defined(COMPOSITE) || defined(ROOTLESS)
|
||||||
/*
|
/*
|
||||||
* Need to move everyone to screen coordinates
|
* Need to move everyone to screen coordinates
|
||||||
* XXX what about off-screen pixmaps with non-zero x/y?
|
* XXX what about off-screen pixmaps with non-zero x/y?
|
||||||
|
@ -274,7 +274,7 @@ damageRegionAppend(DrawablePtr pDrawable, RegionPtr pRegion, Bool clip,
|
||||||
if (pDamageRegion == pRegion && (draw_x || draw_y))
|
if (pDamageRegion == pRegion && (draw_x || draw_y))
|
||||||
RegionTranslate(pDamageRegion, draw_x, draw_y);
|
RegionTranslate(pDamageRegion, draw_x, draw_y);
|
||||||
}
|
}
|
||||||
#ifdef COMPOSITE
|
#if defined(COMPOSITE) || defined(ROOTLESS)
|
||||||
if (screen_x || screen_y)
|
if (screen_x || screen_y)
|
||||||
RegionTranslate(pRegion, -screen_x, -screen_y);
|
RegionTranslate(pRegion, -screen_x, -screen_y);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -226,20 +226,10 @@ extern RegionRec rootlessHugeRoot;
|
||||||
* Can't access the bits before the first word of the drawable's data in
|
* Can't access the bits before the first word of the drawable's data in
|
||||||
* rootless mode, so make sure our base address is always 32-bit aligned.
|
* rootless mode, so make sure our base address is always 32-bit aligned.
|
||||||
*/
|
*/
|
||||||
#define SetPixmapBaseToScreen(pix, _x, _y) { \
|
#define SetPixmapBaseToScreen(pix, _x, _y) do { \
|
||||||
PixmapPtr _pPix = (PixmapPtr) (pix); \
|
pix->screen_x = _x; \
|
||||||
_pPix->devPrivate.ptr = (char *) (_pPix->devPrivate.ptr) - \
|
pix->screen_y = _y; \
|
||||||
((int)(_x) * _pPix->drawable.bitsPerPixel/8 + \
|
} while(0)
|
||||||
(int)(_y) * _pPix->devKind); \
|
|
||||||
if (_pPix->drawable.bitsPerPixel != FB_UNIT) { \
|
|
||||||
size_t _diff = ((size_t) _pPix->devPrivate.ptr) & \
|
|
||||||
(FB_UNIT / CHAR_BIT - 1); \
|
|
||||||
_pPix->devPrivate.ptr = (char *) (_pPix->devPrivate.ptr) - \
|
|
||||||
_diff; \
|
|
||||||
_pPix->drawable.x = _diff / \
|
|
||||||
(_pPix->drawable.bitsPerPixel / CHAR_BIT); \
|
|
||||||
} \
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns TRUE if this window is visible inside a frame
|
// Returns TRUE if this window is visible inside a frame
|
||||||
// (e.g. it is visible and has a top-level or root parent)
|
// (e.g. it is visible and has a top-level or root parent)
|
||||||
|
|
|
@ -705,11 +705,17 @@ RootlessCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
|
||||||
else {
|
else {
|
||||||
RootlessStartDrawing(pWin);
|
RootlessStartDrawing(pWin);
|
||||||
|
|
||||||
miCopyRegion((DrawablePtr) pWin, (DrawablePtr) pWin,
|
PixmapPtr pPixmap = pScreen->GetWindowPixmap(pWin);
|
||||||
|
DrawablePtr pDrawable = &pPixmap->drawable;
|
||||||
|
|
||||||
|
if (pPixmap->screen_x || pPixmap->screen_y) {
|
||||||
|
RegionTranslate(&rgnDst, -pPixmap->screen_x, -pPixmap->screen_y);
|
||||||
|
}
|
||||||
|
|
||||||
|
miCopyRegion(pDrawable, pDrawable,
|
||||||
0, &rgnDst, dx, dy, fbCopyWindowProc, 0, 0);
|
0, &rgnDst, dx, dy, fbCopyWindowProc, 0, 0);
|
||||||
|
|
||||||
/* prgnSrc has been translated to dst position */
|
RootlessDamageRegion(pWin, &rgnDst);
|
||||||
RootlessDamageRegion(pWin, prgnSrc);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
|
|
|
@ -137,7 +137,7 @@ present_check_flip(RRCrtcPtr crtc,
|
||||||
|
|
||||||
/* Does the window match the pixmap exactly? */
|
/* Does the window match the pixmap exactly? */
|
||||||
if (window->drawable.x != 0 || window->drawable.y != 0 ||
|
if (window->drawable.x != 0 || window->drawable.y != 0 ||
|
||||||
#ifdef COMPOSITE
|
#if defined(COMPOSITE) || defined(ROOTLESS)
|
||||||
window->drawable.x != pixmap->screen_x || window->drawable.y != pixmap->screen_y ||
|
window->drawable.x != pixmap->screen_x || window->drawable.y != pixmap->screen_y ||
|
||||||
#endif
|
#endif
|
||||||
window->drawable.width != pixmap->drawable.width ||
|
window->drawable.width != pixmap->drawable.width ||
|
||||||
|
|
Loading…
Reference in New Issue