[PATCH xserver 1/2] Eliminate miTranslate
Keith Packard
keithp at keithp.com
Thu Sep 22 22:15:32 UTC 2016
miTranslate is expensive to provide for, and not that expensive to
handle in the driver.
Signed-off-by: Keith Packard <keithp at keithp.com>
---
fb/fbfillsp.c | 6 ++++--
fb/fbgc.c | 2 --
glamor/glamor_glyphblt.c | 6 ++----
glamor/glamor_spans.c | 4 ++--
hw/xnest/GC.c | 2 --
include/gcstruct.h | 1 -
mi/miarc.c | 19 -------------------
mi/mibitblt.c | 8 --------
mi/midispcur.c | 23 ++---------------------
mi/mifillarc.c | 20 --------------------
mi/mifillrct.c | 21 ++++-----------------
mi/miglblt.c | 5 -----
mi/mipoly.c | 36 ++++++------------------------------
mi/mipolypnt.c | 13 -------------
mi/miwideline.c | 24 ------------------------
mi/mizerarc.c | 13 -------------
mi/mizerline.c | 26 +++++---------------------
miext/damage/damage.c | 18 ++++--------------
18 files changed, 29 insertions(+), 218 deletions(-)
diff --git a/fb/fbfillsp.c b/fb/fbfillsp.c
index 4debe1e..6992e57 100644
--- a/fb/fbfillsp.c
+++ b/fb/fbfillsp.c
@@ -36,6 +36,8 @@ fbFillSpans(DrawablePtr pDrawable,
int extentX1, extentX2, extentY1, extentY2;
int fullX1, fullX2, fullY1;
int partX1, partX2;
+ int x_draw = pDrawable->x;
+ int y_draw = pDrawable->y;
pextent = RegionExtents(pClip);
extentX1 = pextent->x1;
@@ -43,8 +45,8 @@ fbFillSpans(DrawablePtr pDrawable,
extentX2 = pextent->x2;
extentY2 = pextent->y2;
while (n--) {
- fullX1 = ppt->x;
- fullY1 = ppt->y;
+ fullX1 = ppt->x + x_draw;
+ fullY1 = ppt->y + y_draw;
fullX2 = fullX1 + (int) *pwidth;
ppt++;
pwidth++;
diff --git a/fb/fbgc.c b/fb/fbgc.c
index 19c6131..f1f77b8 100644
--- a/fb/fbgc.c
+++ b/fb/fbgc.c
@@ -67,8 +67,6 @@ fbCreateGC(GCPtr pGC)
pGC->ops = (GCOps *) &fbGCOps;
pGC->funcs = (GCFuncs *) &fbGCFuncs;
- /* fb wants to translate before scan conversion */
- pGC->miTranslate = 1;
pGC->fExpose = 1;
fbGetGCPrivate(pGC)->bpp = BitsPerPixel(pGC->depth);
diff --git a/glamor/glamor_glyphblt.c b/glamor/glamor_glyphblt.c
index b21aa06..2adf5a8 100644
--- a/glamor/glamor_glyphblt.c
+++ b/glamor/glamor_glyphblt.c
@@ -196,10 +196,8 @@ glamor_push_pixels_gl(GCPtr gc, PixmapPtr bitmap,
&vbo_offset);
num_points = 0;
- /* Note that because fb sets miTranslate in the GC, our incoming X
- * and Y are in screen coordinate space (same for spans, but not
- * other operations).
- */
+ x += drawable->x;
+ y += drawable->y;
for (yy = 0; yy < h; yy++) {
uint8_t *bitmap_row = bitmap_data + yy * bitmap_stride;
diff --git a/glamor/glamor_spans.c b/glamor/glamor_spans.c
index 5217d04..f0dc5c6 100644
--- a/glamor/glamor_spans.c
+++ b/glamor/glamor_spans.c
@@ -80,8 +80,8 @@ glamor_fill_spans_gl(DrawablePtr drawable,
4 * sizeof (GLshort), vbo_offset);
for (c = 0; c < n; c++) {
- v[0] = points->x;
- v[1] = points->y;
+ v[0] = points->x + drawable->x;
+ v[1] = points->y + drawable->y;
v[2] = *widths++;
points++;
v += 4;
diff --git a/hw/xnest/GC.c b/hw/xnest/GC.c
index ecfa61e..d5e4314 100644
--- a/hw/xnest/GC.c
+++ b/hw/xnest/GC.c
@@ -76,8 +76,6 @@ xnestCreateGC(GCPtr pGC)
pGC->funcs = &xnestFuncs;
pGC->ops = &xnestOps;
- pGC->miTranslate = 1;
-
xnestGCPriv(pGC)->gc = XCreateGC(xnestDisplay,
xnestDefaultDrawables[pGC->depth],
0L, NULL);
diff --git a/include/gcstruct.h b/include/gcstruct.h
index e48d610..e28950f 100644
--- a/include/gcstruct.h
+++ b/include/gcstruct.h
@@ -254,7 +254,6 @@ typedef struct _GC {
unsigned int arcMode:1;
unsigned int subWindowMode:1;
unsigned int graphicsExposures:1;
- unsigned int miTranslate:1; /* should mi things translate? */
unsigned int tileIsPixel:1; /* tile is solid pixel */
unsigned int fExpose:1; /* Call exposure handling */
unsigned int freeCompClip:1; /* Free composite clip */
diff --git a/mi/miarc.c b/mi/miarc.c
index 2588ee4..ca6ad73 100644
--- a/mi/miarc.c
+++ b/mi/miarc.c
@@ -260,11 +260,6 @@ miArcSegment(DrawablePtr pDraw,
return;
}
- if (pGC->miTranslate) {
- tarc.x += pDraw->x;
- tarc.y += pDraw->y;
- }
-
a0 = tarc.angle1;
a1 = tarc.angle2;
if (a1 > FULLCIRCLE)
@@ -795,11 +790,6 @@ miFillWideEllipse(DrawablePtr pDraw, GCPtr pGC, xArc * parc)
xorg = parc->x + (parc->width >> 1);
yorgu = parc->y + (parc->height >> 1);
yorgl = yorgu + (parc->height & 1);
- if (pGC->miTranslate) {
- xorg += pDraw->x;
- yorgu += pDraw->y;
- yorgl += pDraw->y;
- }
yorgu -= spdata->k;
yorgl += spdata->k;
if (spdata->top) {
@@ -967,10 +957,6 @@ miWideArc(DrawablePtr pDraw, GCPtr pGC, int narcs, xArc * parcs)
parc->x -= xOrg;
parc->y -= yOrg;
}
- if (pGC->miTranslate) {
- xOrg += pDraw->x;
- yOrg += pDraw->y;
- }
/* set up scratch GC */
@@ -1177,11 +1163,6 @@ miFillSppPoly(DrawablePtr dst, GCPtr pgc, int count, /* number of points */
nextleft, nextright; /* indices to second endpoints */
DDXPointPtr ptsOut, FirstPoint; /* output buffer */
- if (pgc->miTranslate) {
- xTrans += dst->x;
- yTrans += dst->y;
- }
-
imin = GetFPolyYBounds(ptsIn, count, yFtrans, &ymin, &ymax);
y = ymax - ymin + 1;
diff --git a/mi/mibitblt.c b/mi/mibitblt.c
index 28296a4..d61b082 100644
--- a/mi/mibitblt.c
+++ b/mi/mibitblt.c
@@ -131,10 +131,6 @@ miCopyArea(DrawablePtr pSrcDrawable,
dstx = xOut;
dsty = yOut;
- if (pGC->miTranslate) {
- dstx += pDstDrawable->x;
- dsty += pDstDrawable->y;
- }
pptFirst = ppt = xallocarray(heightSrc, sizeof(DDXPointRec));
pwidthFirst = pwidth = xallocarray(heightSrc, sizeof(unsigned int));
@@ -753,10 +749,6 @@ miPutImage(DrawablePtr pDraw, GCPtr pGC, int depth,
free(pptFirst);
return;
}
- if (pGC->miTranslate) {
- x += pDraw->x;
- y += pDraw->y;
- }
for (i = 0; i < h; i++) {
ppt->x = x;
diff --git a/mi/midispcur.c b/mi/midispcur.c
index d1da0fd..fb1e097 100644
--- a/mi/midispcur.c
+++ b/mi/midispcur.c
@@ -287,13 +287,12 @@ static void
miDCPutBits(DrawablePtr pDrawable,
GCPtr sourceGC,
GCPtr maskGC,
- int x_org,
- int y_org,
+ int x,
+ int y,
unsigned w, unsigned h, unsigned long source, unsigned long mask)
{
miDCScreenPtr pScreenPriv = dixLookupPrivate(&pDrawable->pScreen->devPrivates, miDCScreenKey);
ChangeGCVal gcval;
- int x, y;
if (sourceGC->fgPixel != source) {
gcval.val = source;
@@ -302,15 +301,6 @@ miDCPutBits(DrawablePtr pDrawable,
if (sourceGC->serialNumber != pDrawable->serialNumber)
ValidateGC(pDrawable, sourceGC);
- if (sourceGC->miTranslate) {
- x = pDrawable->x + x_org;
- y = pDrawable->y + y_org;
- }
- else {
- x = x_org;
- y = y_org;
- }
-
(*sourceGC->ops->PushPixels) (sourceGC, pScreenPriv->sourceBits, pDrawable, w, h,
x, y);
if (maskGC->fgPixel != mask) {
@@ -320,15 +310,6 @@ miDCPutBits(DrawablePtr pDrawable,
if (maskGC->serialNumber != pDrawable->serialNumber)
ValidateGC(pDrawable, maskGC);
- if (maskGC->miTranslate) {
- x = pDrawable->x + x_org;
- y = pDrawable->y + y_org;
- }
- else {
- x = x_org;
- y = y_org;
- }
-
(*maskGC->ops->PushPixels) (maskGC, pScreenPriv->maskBits, pDrawable, w, h, x, y);
}
diff --git a/mi/mifillarc.c b/mi/mifillarc.c
index 888519e..7279970 100644
--- a/mi/mifillarc.c
+++ b/mi/mifillarc.c
@@ -487,10 +487,6 @@ miFillEllipseI(DrawablePtr pDraw, GCPtr pGC, xArc * arc, DDXPointPtr points, int
miFillArcSetup(arc, &info);
MIFILLARCSETUP();
- if (pGC->miTranslate) {
- xorg += pDraw->x;
- yorg += pDraw->y;
- }
pts = points;
wids = widths;
while (y > 0) {
@@ -512,10 +508,6 @@ miFillEllipseD(DrawablePtr pDraw, GCPtr pGC, xArc * arc, DDXPointPtr points, int
miFillArcDSetup(arc, &info);
MIFILLARCSETUP();
- if (pGC->miTranslate) {
- xorg += pDraw->x;
- yorg += pDraw->y;
- }
pts = points;
wids = widths;
while (y > 0) {
@@ -564,12 +556,6 @@ miFillArcSliceI(DrawablePtr pDraw, GCPtr pGC, xArc * arc, DDXPointPtr points, in
slw = arc->height;
if (slice.flip_top || slice.flip_bot)
slw += (arc->height >> 1) + 1;
- if (pGC->miTranslate) {
- xorg += pDraw->x;
- yorg += pDraw->y;
- slice.edge1.x += pDraw->x;
- slice.edge2.x += pDraw->x;
- }
pts = points;
wids = widths;
while (y > 0) {
@@ -608,12 +594,6 @@ miFillArcSliceD(DrawablePtr pDraw, GCPtr pGC, xArc * arc, DDXPointPtr points, in
slw = arc->height;
if (slice.flip_top || slice.flip_bot)
slw += (arc->height >> 1) + 1;
- if (pGC->miTranslate) {
- xorg += pDraw->x;
- yorg += pDraw->y;
- slice.edge1.x += pDraw->x;
- slice.edge2.x += pDraw->x;
- }
pts = points;
wids = widths;
while (y > 0) {
diff --git a/mi/mifillrct.c b/mi/mifillrct.c
index eb98a77..6bc250c 100644
--- a/mi/mifillrct.c
+++ b/mi/mifillrct.c
@@ -82,23 +82,10 @@ miPolyFillRect(DrawablePtr pDrawable, GCPtr pGC, int nrectFill, /* number of rec
int *pwFirst;
int *pw;
- if (pGC->miTranslate) {
- xorg = pDrawable->x;
- yorg = pDrawable->y;
- prect = prectInit;
- maxheight = 0;
- for (i = 0; i < nrectFill; i++, prect++) {
- prect->x += xorg;
- prect->y += yorg;
- maxheight = max(maxheight, prect->height);
- }
- }
- else {
- prect = prectInit;
- maxheight = 0;
- for (i = 0; i < nrectFill; i++, prect++)
- maxheight = max(maxheight, prect->height);
- }
+ prect = prectInit;
+ maxheight = 0;
+ for (i = 0; i < nrectFill; i++, prect++)
+ maxheight = max(maxheight, prect->height);
pptFirst = xallocarray(maxheight, sizeof(DDXPointRec));
pwFirst = xallocarray(maxheight, sizeof(int));
diff --git a/mi/miglblt.c b/mi/miglblt.c
index 68be5b9..209a304 100644
--- a/mi/miglblt.c
+++ b/mi/miglblt.c
@@ -102,11 +102,6 @@ miPolyGlyphBlt(DrawablePtr pDrawable, GC * pGC, int x, int y, unsigned int nglyp
ChangeGCVal gcvals[3];
- if (pGC->miTranslate) {
- x += pDrawable->x;
- y += pDrawable->y;
- }
-
pfont = pGC->font;
width = FONTMAXBOUNDS(pfont, rightSideBearing) -
FONTMINBOUNDS(pfont, leftSideBearing);
diff --git a/mi/mipoly.c b/mi/mipoly.c
index a97e2bb..12fdf01 100644
--- a/mi/mipoly.c
+++ b/mi/mipoly.c
@@ -669,8 +669,7 @@ miFillGeneralPoly(DrawablePtr dst, GCPtr pgc, int count, DDXPointPtr ptsIn)
}
/*
- * Draw polygons. This routine translates the point by the origin if
- * pGC->miTranslate is non-zero, and calls to the appropriate routine to
+ * Draw polygons. This routine calls to the appropriate routine to
* actually scan convert the polygon.
*/
void
@@ -678,41 +677,18 @@ miFillPolygon(DrawablePtr dst, GCPtr pgc,
int shape, int mode, int count, DDXPointPtr pPts)
{
int i;
- int xorg, yorg;
DDXPointPtr ppt;
if (count == 0)
return;
ppt = pPts;
- if (pgc->miTranslate) {
- xorg = dst->x;
- yorg = dst->y;
-
- if (mode == CoordModeOrigin) {
- for (i = 0; i < count; i++) {
- ppt->x += xorg;
- ppt++->y += yorg;
- }
- }
- else {
- ppt->x += xorg;
- ppt++->y += yorg;
- for (i = 1; i < count; i++) {
- ppt->x += (ppt - 1)->x;
- ppt->y += (ppt - 1)->y;
- ppt++;
- }
- }
- }
- else {
- if (mode == CoordModePrevious) {
+ if (mode == CoordModePrevious) {
+ ppt++;
+ for (i = 1; i < count; i++) {
+ ppt->x += (ppt - 1)->x;
+ ppt->y += (ppt - 1)->y;
ppt++;
- for (i = 1; i < count; i++) {
- ppt->x += (ppt - 1)->x;
- ppt->y += (ppt - 1)->y;
- ppt++;
- }
}
}
if (shape == Convex)
diff --git a/mi/mipolypnt.c b/mi/mipolypnt.c
index 1c4150d..0b3adfb 100644
--- a/mi/mipolypnt.c
+++ b/mi/mipolypnt.c
@@ -59,8 +59,6 @@ miPolyPoint(DrawablePtr pDrawable, GCPtr pGC, int mode, /* Origin or Previous */
int npt, xPoint * pptInit)
{
- int xorg;
- int yorg;
int nptTmp;
ChangeGCVal fsOld, fsNew;
int *pwidthInit, *pwidth;
@@ -82,17 +80,6 @@ miPolyPoint(DrawablePtr pDrawable, GCPtr pGC, int mode, /* Origin or Previous */
}
}
- if (pGC->miTranslate) {
- ppt = pptInit;
- nptTmp = npt;
- xorg = pDrawable->x;
- yorg = pDrawable->y;
- while (nptTmp--) {
- ppt->x += xorg;
- ppt++->y += yorg;
- }
- }
-
fsOld.val = pGC->fillStyle;
fsNew.val = FillSolid;
if (pGC->fillStyle != FillSolid) {
diff --git a/mi/miwideline.c b/mi/miwideline.c
index 54de1d3..9c49eb8 100644
--- a/mi/miwideline.c
+++ b/mi/miwideline.c
@@ -672,10 +672,6 @@ miFillPolyHelper(DrawablePtr pDrawable, GCPtr pGC, unsigned long pixel,
pwidth = spanRec.widths;
xorg = 0;
- if (pGC->miTranslate) {
- y += pDrawable->y;
- xorg = pDrawable->x;
- }
while ((left_count || left_height) && (right_count || right_height)) {
if (!left_height && left_count) {
left_height = left->height;
@@ -771,10 +767,6 @@ miFillRectPolyHelper(DrawablePtr pDrawable,
ppt = spanRec.points;
pwidth = spanRec.widths;
- if (pGC->miTranslate) {
- y += pDrawable->y;
- x += pDrawable->x;
- }
while (h--) {
ppt->x = x;
ppt->y = y;
@@ -957,10 +949,6 @@ miLineOnePoint(DrawablePtr pDrawable,
}
else {
wid = 1;
- if (pGC->miTranslate) {
- x += pDrawable->x;
- y += pDrawable->y;
- }
pt.x = x;
pt.y = y;
(*pGC->ops->FillSpans) (pDrawable, pGC, 1, &pt, &wid, TRUE);
@@ -1119,10 +1107,6 @@ miLineArcI(DrawablePtr pDraw,
tpts = points;
twids = widths;
- if (pGC->miTranslate) {
- xorg += pDraw->x;
- yorg += pDraw->y;
- }
slw = pGC->lineWidth;
if (slw == 1) {
tpts->x = xorg;
@@ -1211,14 +1195,6 @@ miLineArcD(DrawablePtr pDraw,
x0 = xorg - xbase;
ybase = ICEIL(yorg);
y0 = yorg - ybase;
- if (pGC->miTranslate) {
- xbase += pDraw->x;
- ybase += pDraw->y;
- edge1->x += pDraw->x;
- edge2->x += pDraw->x;
- edgey1 += pDraw->y;
- edgey2 += pDraw->y;
- }
xlk = x0 + x0 + 1.0;
xrk = x0 + x0 - 1.0;
yk = y0 + y0 - 1.0;
diff --git a/mi/mizerarc.c b/mi/mizerarc.c
index e1b5f0c..85e12f0 100644
--- a/mi/mizerarc.c
+++ b/mi/mizerarc.c
@@ -647,7 +647,6 @@ miZeroPolyArc(DrawablePtr pDraw, GCPtr pGC, int narcs, xArc * parcs)
xArc *arc;
int i;
DDXPointPtr points, pts, oddPts = NULL;
- DDXPointPtr pt;
int numPts;
Bool dospans;
int *widths = NULL;
@@ -714,12 +713,6 @@ miZeroPolyArc(DrawablePtr pDraw, GCPtr pGC, int narcs, xArc * parcs)
while (maxw < n)
widths[maxw++] = 1;
}
- if (pGC->miTranslate) {
- for (pt = points; pt != pts; pt++) {
- pt->x += pDraw->x;
- pt->y += pDraw->y;
- }
- }
(*pGC->ops->FillSpans) (pDraw, pGC, n, points, widths, FALSE);
}
if (pGC->lineStyle != LineDoubleDash)
@@ -742,12 +735,6 @@ miZeroPolyArc(DrawablePtr pDraw, GCPtr pGC, int narcs, xArc * parcs)
while (maxw < n)
widths[maxw++] = 1;
}
- if (pGC->miTranslate) {
- for (pt = oddPts; pt != pts; pt++) {
- pt->x += pDraw->x;
- pt->y += pDraw->y;
- }
- }
(*pGC->ops->FillSpans) (pDraw, pGC, n, oddPts, widths, FALSE);
}
if ((pGC->fillStyle == FillSolid) ||
diff --git a/mi/mizerline.c b/mi/mizerline.c
index 2f22d23..e36e080 100644
--- a/mi/mizerline.c
+++ b/mi/mizerline.c
@@ -121,18 +121,10 @@ miZeroLine(DrawablePtr pDraw, GCPtr pGC, int mode, /* Origin or Previous */
int e, e1, e2, e3; /* Bresenham error terms */
int length; /* length of lines == # of pixels on major axis */
- xleft = pDraw->x;
- ytop = pDraw->y;
- xright = pDraw->x + pDraw->width - 1;
- ybottom = pDraw->y + pDraw->height - 1;
-
- if (!pGC->miTranslate) {
- /* do everything in drawable-relative coordinates */
- xleft = 0;
- ytop = 0;
- xright -= pDraw->x;
- ybottom -= pDraw->y;
- }
+ xleft = 0;
+ ytop = 0;
+ xright = pDraw->width - 1;
+ ybottom = pDraw->height - 1;
/* it doesn't matter whether we're in drawable or screen coordinates,
* FillSpans simply cannot take starting coordinates outside of the
@@ -165,10 +157,6 @@ miZeroLine(DrawablePtr pDraw, GCPtr pGC, int mode, /* Origin or Previous */
xstart = ppt->x;
ystart = ppt->y;
- if (pGC->miTranslate) {
- xstart += pDraw->x;
- ystart += pDraw->y;
- }
/* x2, y2, oc2 copied to x1, y1, oc1 at top of loop to simplify
* iteration logic
@@ -186,11 +174,7 @@ miZeroLine(DrawablePtr pDraw, GCPtr pGC, int mode, /* Origin or Previous */
x2 = ppt->x;
y2 = ppt->y;
- if (pGC->miTranslate && (mode != CoordModePrevious)) {
- x2 += pDraw->x;
- y2 += pDraw->y;
- }
- else if (mode == CoordModePrevious) {
+ if (mode == CoordModePrevious) {
x2 += x1;
y2 += y1;
}
diff --git a/miext/damage/damage.c b/miext/damage/damage.c
index 17c2abf..c9ddeea 100644
--- a/miext/damage/damage.c
+++ b/miext/damage/damage.c
@@ -653,9 +653,7 @@ damageFillSpans(DrawablePtr pDrawable,
box.y2++;
- if (!pGC->miTranslate) {
- TRANSLATE_BOX(box, pDrawable);
- }
+ TRANSLATE_BOX(box, pDrawable);
TRIM_BOX(box, pGC);
if (BOX_NOT_EMPTY(box))
@@ -701,9 +699,7 @@ damageSetSpans(DrawablePtr pDrawable,
box.y2++;
- if (!pGC->miTranslate) {
- TRANSLATE_BOX(box, pDrawable);
- }
+ TRANSLATE_BOX(box, pDrawable);
TRIM_BOX(box, pGC);
if (BOX_NOT_EMPTY(box))
@@ -1399,14 +1395,8 @@ damagePushPixels(GCPtr pGC,
if (checkGCDamage(pDamage, pGC)) {
BoxRec box;
- box.x1 = xOrg;
- box.y1 = yOrg;
-
- if (!pGC->miTranslate) {
- box.x1 += pDrawable->x;
- box.y1 += pDrawable->y;
- }
-
+ box.x1 = xOrg + pDrawable->x;
+ box.y1 = yOrg + pDrawable->y;
box.x2 = box.x1 + dx;
box.y2 = box.y1 + dy;
--
2.9.3
More information about the xorg-devel
mailing list