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);
|
||||
|
||||
pBoundingDraw = &pPix->drawable;
|
||||
#ifdef COMPOSITE
|
||||
#if defined(COMPOSITE) || defined(ROOTLESS)
|
||||
relx -= pPix->screen_x;
|
||||
rely -= pPix->screen_y;
|
||||
#endif
|
||||
|
|
|
@ -125,7 +125,7 @@ exaGetDrawablePixmap(DrawablePtr pDrawable)
|
|||
void
|
||||
exaGetDrawableDeltas(DrawablePtr pDrawable, PixmapPtr pPixmap, int *xp, int *yp)
|
||||
{
|
||||
#ifdef COMPOSITE
|
||||
#if defined(COMPOSITE) || defined(ROOTLESS)
|
||||
if (pDrawable->type == DRAWABLE_WINDOW) {
|
||||
*xp = -pPixmap->screen_x;
|
||||
*yp = -pPixmap->screen_y;
|
||||
|
|
|
@ -963,7 +963,7 @@ exaCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
|
|||
RegionInit(&rgnDst, NullBox, 0);
|
||||
|
||||
RegionIntersect(&rgnDst, &pWin->borderClip, prgnSrc);
|
||||
#ifdef COMPOSITE
|
||||
#if defined(COMPOSITE) || defined(ROOTLESS)
|
||||
if (pPixmap->screen_x || pPixmap->screen_y)
|
||||
RegionTranslate(&rgnDst, -pPixmap->screen_x, -pPixmap->screen_y);
|
||||
#endif
|
||||
|
|
2
fb/fb.h
2
fb/fb.h
|
@ -441,7 +441,7 @@ typedef struct {
|
|||
#define __fbPixDrawableX(pPix) ((pPix)->drawable.x)
|
||||
#define __fbPixDrawableY(pPix) ((pPix)->drawable.y)
|
||||
|
||||
#ifdef COMPOSITE
|
||||
#if defined(COMPOSITE) || defined(ROOTLESS)
|
||||
#define __fbPixOffXWin(pPix) (__fbPixDrawableX(pPix) - (pPix)->screen_x)
|
||||
#define __fbPixOffYWin(pPix) (__fbPixDrawableY(pPix) - (pPix)->screen_y)
|
||||
#else
|
||||
|
|
|
@ -76,7 +76,7 @@ fbCreatePixmap(ScreenPtr pScreen, int width, int height, int depth,
|
|||
fbInitializeDrawable(&pPixmap->drawable);
|
||||
#endif
|
||||
|
||||
#ifdef COMPOSITE
|
||||
#if defined(COMPOSITE) || defined(ROOTLESS)
|
||||
pPixmap->screen_x = 0;
|
||||
pPixmap->screen_y = 0;
|
||||
#endif
|
||||
|
|
|
@ -116,7 +116,7 @@ fbCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
|
|||
|
||||
RegionIntersect(&rgnDst, &pWin->borderClip, prgnSrc);
|
||||
|
||||
#ifdef COMPOSITE
|
||||
#if defined(COMPOSITE) || defined(ROOTLESS)
|
||||
if (pPixmap->screen_x || pPixmap->screen_y)
|
||||
RegionTranslate(&rgnDst, -pPixmap->screen_x, -pPixmap->screen_y);
|
||||
#endif
|
||||
|
|
|
@ -781,7 +781,7 @@ glamor_copy_window(WindowPtr window, DDXPointRec old_origin, RegionPtr src_regio
|
|||
|
||||
RegionIntersect(&dst_region, &window->borderClip, src_region);
|
||||
|
||||
#ifdef COMPOSITE
|
||||
#if defined(COMPOSITE) || defined(ROOTLESS)
|
||||
if (pixmap->screen_x || pixmap->screen_y)
|
||||
RegionTranslate(&dst_region, -pixmap->screen_x, -pixmap->screen_y);
|
||||
#endif
|
||||
|
|
|
@ -39,7 +39,7 @@ void
|
|||
glamor_get_drawable_deltas(DrawablePtr drawable, PixmapPtr pixmap,
|
||||
int *x, int *y)
|
||||
{
|
||||
#ifdef COMPOSITE
|
||||
#if defined(COMPOSITE) || defined(ROOTLESS)
|
||||
if (drawable->type == DRAWABLE_WINDOW) {
|
||||
*x = -pixmap->screen_x;
|
||||
*y = -pixmap->screen_y;
|
||||
|
|
|
@ -78,7 +78,7 @@ typedef struct _Pixmap {
|
|||
int refcnt;
|
||||
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. */
|
||||
#ifdef COMPOSITE
|
||||
#if defined(COMPOSITE) || defined(ROOTLESS)
|
||||
short screen_x;
|
||||
short screen_y;
|
||||
#endif
|
||||
|
|
|
@ -461,7 +461,7 @@ miPaintWindow(WindowPtr pWin, RegionPtr prgn, int what)
|
|||
tile_x_off = pWin->drawable.x;
|
||||
tile_y_off = pWin->drawable.y;
|
||||
|
||||
#ifdef COMPOSITE
|
||||
#if defined(COMPOSITE) || defined(ROOTLESS)
|
||||
draw_x_off = pixmap->screen_x;
|
||||
draw_y_off = pixmap->screen_y;
|
||||
tile_x_off -= draw_x_off;
|
||||
|
|
|
@ -142,7 +142,7 @@ damageRegionAppend(DrawablePtr pDrawable, RegionPtr pRegion, Bool clip,
|
|||
RegionRec pixClip;
|
||||
int draw_x, draw_y;
|
||||
|
||||
#ifdef COMPOSITE
|
||||
#if defined(COMPOSITE) || defined(ROOTLESS)
|
||||
int screen_x = 0, screen_y = 0;
|
||||
#endif
|
||||
|
||||
|
@ -150,7 +150,7 @@ damageRegionAppend(DrawablePtr pDrawable, RegionPtr pRegion, Bool clip,
|
|||
if (!RegionNotEmpty(pRegion))
|
||||
return;
|
||||
|
||||
#ifdef COMPOSITE
|
||||
#if defined(COMPOSITE) || defined(ROOTLESS)
|
||||
/*
|
||||
* When drawing to a pixmap which is storing window contents,
|
||||
* 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_y = pDamage->pDrawable->y;
|
||||
#ifdef COMPOSITE
|
||||
#if defined(COMPOSITE) || defined(ROOTLESS)
|
||||
/*
|
||||
* Need to move everyone to screen coordinates
|
||||
* 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))
|
||||
RegionTranslate(pDamageRegion, draw_x, draw_y);
|
||||
}
|
||||
#ifdef COMPOSITE
|
||||
#if defined(COMPOSITE) || defined(ROOTLESS)
|
||||
if (screen_x || screen_y)
|
||||
RegionTranslate(pRegion, -screen_x, -screen_y);
|
||||
#endif
|
||||
|
|
|
@ -226,20 +226,10 @@ extern RegionRec rootlessHugeRoot;
|
|||
* 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.
|
||||
*/
|
||||
#define SetPixmapBaseToScreen(pix, _x, _y) { \
|
||||
PixmapPtr _pPix = (PixmapPtr) (pix); \
|
||||
_pPix->devPrivate.ptr = (char *) (_pPix->devPrivate.ptr) - \
|
||||
((int)(_x) * _pPix->drawable.bitsPerPixel/8 + \
|
||||
(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); \
|
||||
} \
|
||||
}
|
||||
#define SetPixmapBaseToScreen(pix, _x, _y) do { \
|
||||
pix->screen_x = _x; \
|
||||
pix->screen_y = _y; \
|
||||
} while(0)
|
||||
|
||||
// Returns TRUE if this window is visible inside a frame
|
||||
// (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 {
|
||||
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);
|
||||
|
||||
/* prgnSrc has been translated to dst position */
|
||||
RootlessDamageRegion(pWin, prgnSrc);
|
||||
RootlessDamageRegion(pWin, &rgnDst);
|
||||
}
|
||||
|
||||
out:
|
||||
|
|
|
@ -137,7 +137,7 @@ present_check_flip(RRCrtcPtr crtc,
|
|||
|
||||
/* Does the window match the pixmap exactly? */
|
||||
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 ||
|
||||
#endif
|
||||
window->drawable.width != pixmap->drawable.width ||
|
||||
|
|
Loading…
Reference in New Issue