xf86-video-intel: 4 commits - src/sna/kgem.c src/sna/sna_display.c src/sna/sna_glyphs.c src/sna/sna.h

Chris Wilson ickle at kemper.freedesktop.org
Sat Aug 10 13:00:01 PDT 2013


 src/sna/kgem.c        |    2 
 src/sna/sna.h         |    2 
 src/sna/sna_display.c |   78 +++++------
 src/sna/sna_glyphs.c  |  347 ++++++++++++++++++++++++++++++++++++--------------
 4 files changed, 292 insertions(+), 137 deletions(-)

New commits:
commit 6f3999f38c71689298ac44e5b64830f754199740
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Sat Aug 10 19:44:00 2013 +0100

    sna: Avoid confusing conflicting CRTC probes vs a DRM race
    
    Only bail we fail to find the CRTC for this output amongst the allowed
    set for this ZaphodHead - but allow us to find an invalid CRTC.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/sna_display.c b/src/sna/sna_display.c
index ad93d04..e2bebad 100644
--- a/src/sna/sna_display.c
+++ b/src/sna/sna_display.c
@@ -3033,27 +3033,17 @@ static bool sna_probe_initial_configuration(struct sna *sna)
 			continue;
 
 		DBG(("%s: CRTC:%d, pipe=%d: has mode?=%d\n", __FUNCTION__,
-		     sna_crtc->id, sna_crtc->pipe, mode.mode_valid));
+		     sna_crtc->id, sna_crtc->pipe,
+		     mode.mode_valid && mode.mode.clock));
+
 		if (!mode.mode_valid || mode.mode.clock == 0)
 			continue;
 
-		memset(&crtc->desiredMode, 0, sizeof(crtc->desiredMode));
 		mode_from_kmode(scrn, &mode.mode, &crtc->desiredMode);
 		crtc->desiredRotation = RR_Rotate_0;
 		crtc->desiredX = mode.x;
 		crtc->desiredY = mode.y;
 		crtc->desiredTransformPresent = FALSE;
-
-		crtc->mode = crtc->desiredMode;
-		crtc->mode.name = NULL;
-		crtc->x = mode.x;
-		crtc->y = mode.y;
-		crtc->rotation = RR_Rotate_0;
-		crtc->transformPresent = FALSE;
-
-		memset(&crtc->panningTotalArea, 0, sizeof(BoxRec));
-		memset(&crtc->panningTrackingArea, 0, sizeof(BoxRec));
-		memset(crtc->panningBorder, 0, 4 * sizeof(INT16));
 	}
 
 	/* Reconstruct outputs pointing to active CRTC */
@@ -3072,40 +3062,42 @@ static bool sna_probe_initial_configuration(struct sna *sna)
 
 		for (j = 0; j < config->num_crtc; j++) {
 			xf86CrtcPtr crtc = config->crtc[j];
-			if (to_sna_crtc(crtc)->id == crtc_id) {
-				if (crtc->desiredMode.status == MODE_OK) {
-					DisplayModePtr M;
-
-					xf86DrvMsg(scrn->scrnIndex, X_PROBED,
-						   "Output %s using initial mode %s on pipe %d\n",
-						   output->name,
-						   crtc->desiredMode.name,
-						   to_sna_crtc(crtc)->pipe);
-
-					output->crtc = crtc;
-					crtc->enabled = TRUE;
-
-					if (output->mm_width == 0 ||
-					    output->mm_height == 0) {
-						output->mm_height = (crtc->desiredMode.VDisplay * 254) / (10*DEFAULT_DPI);
-						output->mm_width = (crtc->desiredMode.HDisplay * 254) / (10*DEFAULT_DPI);
-					}
-
-					set_initial_gamma(output, crtc);
-
-					M = calloc(1, sizeof(DisplayModeRec));
-					if (M) {
-						*M = crtc->desiredMode;
-						M->name = strdup(M->name);
-						output->probed_modes =
-							xf86ModesAdd(output->probed_modes, M);
-					}
+			if (to_sna_crtc(crtc)->id != crtc_id)
+				continue;
+
+			if (crtc->desiredMode.status == MODE_OK) {
+				DisplayModePtr M;
+
+				xf86DrvMsg(scrn->scrnIndex, X_PROBED,
+						"Output %s using initial mode %s on pipe %d\n",
+						output->name,
+						crtc->desiredMode.name,
+						to_sna_crtc(crtc)->pipe);
+
+				output->crtc = crtc;
+				crtc->enabled = TRUE;
+
+				if (output->mm_width == 0 ||
+						output->mm_height == 0) {
+					output->mm_height = (crtc->desiredMode.VDisplay * 254) / (10*DEFAULT_DPI);
+					output->mm_width = (crtc->desiredMode.HDisplay * 254) / (10*DEFAULT_DPI);
+				}
+
+				set_initial_gamma(output, crtc);
+
+				M = calloc(1, sizeof(DisplayModeRec));
+				if (M) {
+					*M = crtc->desiredMode;
+					M->name = strdup(M->name);
+					output->probed_modes =
+						xf86ModesAdd(output->probed_modes, M);
 				}
-				break;
 			}
+
+			break;
 		}
 
-		if (output->crtc == NULL) {
+		if (j == config->num_crtc) {
 			/* Can not find the earlier associated CRTC, bail */
 			return false;
 		}
commit 6cd366b79ad15be608f829e884b4880c311cf58b
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Sat Aug 10 17:55:07 2013 +0000

    sna: Remove the redundant clearing of kgem at startup
    
    struct kgem is contained within a cleared superstruct.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/kgem.c b/src/sna/kgem.c
index 429699f..5afe05f 100644
--- a/src/sna/kgem.c
+++ b/src/sna/kgem.c
@@ -1126,8 +1126,6 @@ void kgem_init(struct kgem *kgem, int fd, struct pci_device *dev, unsigned gen)
 
 	DBG(("%s: fd=%d, gen=%d\n", __FUNCTION__, fd, gen));
 
-	memset(kgem, 0, sizeof(*kgem));
-
 	kgem->fd = fd;
 	kgem->gen = gen;
 
commit b364305b16d79e32592235004872d38406ce8e9d
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Sat Aug 10 13:41:46 2013 +0000

    sna/glyphs: Micro-optimise glyphs-to-dst
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/sna_glyphs.c b/src/sna/sna_glyphs.c
index 5055397..a6365d9 100644
--- a/src/sna/sna_glyphs.c
+++ b/src/sna/sna_glyphs.c
@@ -114,6 +114,20 @@ static inline struct sna_glyph *sna_glyph(GlyphPtr glyph)
 	return __get_private(glyph, sna_glyph_key);
 }
 
+static inline struct sna_glyph *sna_glyph0(GlyphPtr glyph)
+{
+	return (struct sna_glyph *)glyph->devPrivates;
+}
+
+static inline bool can_use_glyph0(void)
+{
+#if HAS_DEVPRIVATEKEYREC
+	return sna_glyph_key.offset == 0;
+#else
+	return 0;
+#endif
+}
+
 #define NeedsComponent(f) (PICT_FORMAT_A(f) != 0 && PICT_FORMAT_RGB(f) != 0)
 
 static bool op_is_bounded(uint8_t op)
@@ -656,6 +670,159 @@ next_glyph:
 	return true;
 }
 
+flatten static bool
+glyphs0_to_dst(struct sna *sna,
+	       CARD8 op,
+	       PicturePtr src,
+	       PicturePtr dst,
+	       INT16 src_x, INT16 src_y,
+	       int nlist, GlyphListPtr list, GlyphPtr *glyphs)
+{
+	struct sna_composite_op tmp;
+	ScreenPtr screen = dst->pDrawable->pScreen;
+	PicturePtr glyph_atlas;
+	BoxPtr rects;
+	int nrect;
+	int16_t x, y;
+
+	if (NO_GLYPHS_TO_DST)
+		return false;
+
+	memset(&tmp, 0, sizeof(tmp));
+
+	DBG(("%s(op=%d, src=(%d, %d), nlist=%d,  dst=(%d, %d)+(%d, %d))\n",
+	     __FUNCTION__, op, src_x, src_y, nlist,
+	     list->xOff, list->yOff, dst->pDrawable->x, dst->pDrawable->y));
+
+	if (is_clipped(dst->pCompositeClip, dst->pDrawable)) {
+		rects = REGION_RECTS(dst->pCompositeClip);
+		nrect = REGION_NUM_RECTS(dst->pCompositeClip);
+	} else
+		nrect = 0;
+
+	x = dst->pDrawable->x;
+	y = dst->pDrawable->y;
+	src_x -= list->xOff + x;
+	src_y -= list->yOff + y;
+
+	glyph_atlas = NULL;
+	while (nlist--) {
+		int n = list->len;
+		x += list->xOff;
+		y += list->yOff;
+		while (n--) {
+			GlyphPtr glyph = *glyphs++;
+			struct sna_glyph *p;
+			int i;
+
+			p = sna_glyph0(glyph);
+			if (unlikely(p->atlas == NULL)) {
+				if (unlikely(!glyph_valid(glyph)))
+					goto next_glyph;
+
+				if (glyph_atlas) {
+					tmp.done(sna, &tmp);
+					glyph_atlas = NULL;
+				}
+				if (!glyph_cache(screen, &sna->render, glyph)) {
+					/* no cache for this glyph */
+					p->atlas = GetGlyphPicture(glyph, screen);
+					if (unlikely(p->atlas == NULL)) {
+						glyph->info.width = glyph->info.height = 0;
+						goto next_glyph;
+					}
+					p->coordinate.x = p->coordinate.y = 0;
+				}
+			}
+
+			if (p->atlas != glyph_atlas) {
+				if (glyph_atlas)
+					tmp.done(sna, &tmp);
+
+				if (!sna->render.composite(sna,
+							   op, src, p->atlas, dst,
+							   0, 0, 0, 0, 0, 0,
+							   0, 0,
+							   &tmp))
+					return false;
+
+				glyph_atlas = p->atlas;
+			}
+
+			if (nrect) {
+				for (i = 0; i < nrect; i++) {
+					struct sna_composite_rectangles r;
+					int16_t dx, dy;
+					int16_t x2, y2;
+
+					r.dst.x = x - glyph->info.x;
+					r.dst.y = y - glyph->info.y;
+					x2 = r.dst.x + glyph->info.width;
+					y2 = r.dst.y + glyph->info.height;
+					dx = dy = 0;
+
+					DBG(("%s: glyph=(%d, %d), (%d, %d), clip=(%d, %d), (%d, %d)\n",
+					     __FUNCTION__,
+					     r.dst.x, r.dst.y, x2, y2,
+					     rects[i].x1, rects[i].y1,
+					     rects[i].x2, rects[i].y2));
+					if (rects[i].y1 >= y2)
+						break;
+
+					if (r.dst.x < rects[i].x1)
+						dx = rects[i].x1 - r.dst.x, r.dst.x = rects[i].x1;
+					if (x2 > rects[i].x2)
+						x2 = rects[i].x2;
+					if (r.dst.y < rects[i].y1)
+						dy = rects[i].y1 - r.dst.y, r.dst.y = rects[i].y1;
+					if (y2 > rects[i].y2)
+						y2 = rects[i].y2;
+
+					if (r.dst.x < x2 && r.dst.y < y2) {
+						DBG(("%s: blt=(%d, %d), (%d, %d)\n",
+						     __FUNCTION__, r.dst.x, r.dst.y, x2, y2));
+
+						r.src.x = r.dst.x + src_x;
+						r.src.y = r.dst.y + src_y;
+						r.mask.x = dx + p->coordinate.x;
+						r.mask.y = dy + p->coordinate.y;
+						r.width  = x2 - r.dst.x;
+						r.height = y2 - r.dst.y;
+						tmp.blt(sna, &tmp, &r);
+						apply_damage(&tmp, &r);
+					}
+				}
+			} else {
+				struct sna_composite_rectangles r;
+
+				r.dst.x = x - glyph->info.x;
+				r.dst.y = y - glyph->info.y;
+				r.src.x = r.dst.x + src_x;
+				r.src.y = r.dst.y + src_y;
+				r.mask = p->coordinate;
+				glyph_copy_size(&r, glyph);
+
+				DBG(("%s: glyph=(%d, %d)x(%d, %d), unclipped\n",
+				     __FUNCTION__,
+				     r.dst.x, r.dst.y,
+				     r.width, r.height));
+
+				tmp.blt(sna, &tmp, &r);
+				apply_damage_clipped_to_dst(&tmp, &r, dst->pDrawable);
+			}
+
+next_glyph:
+			x += glyph->info.xOff;
+			y += glyph->info.yOff;
+		}
+		list++;
+	}
+	if (glyph_atlas)
+		tmp.done(sna, &tmp);
+
+	return true;
+}
+
 static bool
 glyphs_slow(struct sna *sna,
 	    CARD8 op,
@@ -1695,11 +1862,19 @@ sna_glyphs(CARD8 op,
 	    (dst->pCompositeClip->data == NULL &&
 	     can_discard_mask(op, src, mask, nlist, list, glyphs))) {
 		DBG(("%s: discarding mask\n", __FUNCTION__));
-		if (glyphs_to_dst(sna, op,
-				  src, dst,
-				  src_x, src_y,
-				  nlist, list, glyphs))
-			return;
+		if (can_use_glyph0()) {
+			if (glyphs0_to_dst(sna, op,
+					   src, dst,
+					   src_x, src_y,
+					   nlist, list, glyphs))
+				return;
+		} else {
+			if (glyphs_to_dst(sna, op,
+					  src, dst,
+					  src_x, src_y,
+					  nlist, list, glyphs))
+				return;
+		}
 	}
 
 	/* Otherwise see if we can substitute a mask */
commit 021c59f6243c51871f664e5fdd43aa00a809033a
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Sat Aug 10 13:15:48 2013 +0000

    sna/glyphs: Micro-optimise glyph drawing
    
    When you don't have many cycles to play with, every one counts.
    
    Here we make sure we cache negative lookups for large glyphs.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/sna.h b/src/sna/sna.h
index 7387088..fe84074 100644
--- a/src/sna/sna.h
+++ b/src/sna/sna.h
@@ -155,9 +155,9 @@ struct sna_pixmap {
 
 struct sna_glyph {
 	PicturePtr atlas;
-	pixman_image_t *image;
 	struct sna_coordinate coordinate;
 	uint16_t size, pos;
+	pixman_image_t *image;
 };
 
 static inline WindowPtr get_root_window(ScreenPtr screen)
diff --git a/src/sna/sna_glyphs.c b/src/sna/sna_glyphs.c
index 7e6aab3..5055397 100644
--- a/src/sna/sna_glyphs.c
+++ b/src/sna/sna_glyphs.c
@@ -365,7 +365,7 @@ glyph_cache(ScreenPtr screen,
 {
 	PicturePtr glyph_picture;
 	struct sna_glyph_cache *cache;
-	struct sna_glyph *priv;
+	struct sna_glyph *p;
 	int size, mask, pos, s;
 
 	if (NO_GLYPH_CACHE)
@@ -399,28 +399,28 @@ glyph_cache(ScreenPtr screen,
 	if (pos < GLYPH_CACHE_SIZE) {
 		cache->count = pos + s;
 	} else {
-		priv = NULL;
+		p = NULL;
 		for (s = size; s <= GLYPH_MAX_SIZE; s *= 2) {
 			int i = cache->evict & glyph_size_to_mask(s);
-			priv = cache->glyphs[i];
-			if (priv == NULL)
+			p = cache->glyphs[i];
+			if (p == NULL)
 				continue;
 
-			if (priv->size >= s) {
+			if (p->size >= s) {
 				cache->glyphs[i] = NULL;
-				priv->atlas = NULL;
+				p->atlas = NULL;
 				pos = i;
 			} else
-				priv = NULL;
+				p = NULL;
 			break;
 		}
-		if (priv == NULL) {
+		if (p == NULL) {
 			int count = glyph_size_to_count(size);
 			pos = cache->evict & glyph_count_to_mask(count);
 			for (s = 0; s < count; s++) {
-				priv = cache->glyphs[pos + s];
-				if (priv != NULL) {
-					priv->atlas =NULL;
+				p = cache->glyphs[pos + s];
+				if (p != NULL) {
+					p->atlas =NULL;
 					cache->glyphs[pos + s] = NULL;
 				}
 			}
@@ -431,27 +431,27 @@ glyph_cache(ScreenPtr screen,
 	}
 	assert(cache->glyphs[pos] == NULL);
 
-	priv = sna_glyph(glyph);
+	p = sna_glyph(glyph);
 	DBG(("%s(%d): adding glyph to cache %d, pos %d\n",
 	     __FUNCTION__, screen->myNum,
 	     PICT_FORMAT_RGB(glyph_picture->format) != 0, pos));
-	cache->glyphs[pos] = priv;
-	priv->atlas = cache->picture;
-	priv->size = size;
-	priv->pos = pos << 1 | (PICT_FORMAT_RGB(glyph_picture->format) != 0);
+	cache->glyphs[pos] = p;
+	p->atlas = cache->picture;
+	p->size = size;
+	p->pos = pos << 1 | (PICT_FORMAT_RGB(glyph_picture->format) != 0);
 	s = pos / ((GLYPH_MAX_SIZE / GLYPH_MIN_SIZE) * (GLYPH_MAX_SIZE / GLYPH_MIN_SIZE));
-	priv->coordinate.x = s % (CACHE_PICTURE_SIZE / GLYPH_MAX_SIZE) * GLYPH_MAX_SIZE;
-	priv->coordinate.y = (s / (CACHE_PICTURE_SIZE / GLYPH_MAX_SIZE)) * GLYPH_MAX_SIZE;
+	p->coordinate.x = s % (CACHE_PICTURE_SIZE / GLYPH_MAX_SIZE) * GLYPH_MAX_SIZE;
+	p->coordinate.y = (s / (CACHE_PICTURE_SIZE / GLYPH_MAX_SIZE)) * GLYPH_MAX_SIZE;
 	for (s = GLYPH_MIN_SIZE; s < GLYPH_MAX_SIZE; s *= 2) {
 		if (pos & 1)
-			priv->coordinate.x += s;
+			p->coordinate.x += s;
 		if (pos & 2)
-			priv->coordinate.y += s;
+			p->coordinate.y += s;
 		pos >>= 2;
 	}
 
 	glyph_cache_upload(cache, glyph, glyph_picture,
-			   priv->coordinate.x, priv->coordinate.y);
+			   p->coordinate.x, p->coordinate.y);
 
 	return true;
 }
@@ -545,42 +545,41 @@ glyphs_to_dst(struct sna *sna,
 		y += list->yOff;
 		while (n--) {
 			GlyphPtr glyph = *glyphs++;
-			struct sna_glyph priv;
+			struct sna_glyph *p;
 			int i;
 
-			if (!glyph_valid(glyph))
-				goto next_glyph;
+			p = sna_glyph(glyph);
+			if (unlikely(p->atlas == NULL)) {
+				if (unlikely(!glyph_valid(glyph)))
+					goto next_glyph;
 
-			priv = *sna_glyph(glyph);
-			if (priv.atlas == NULL) {
 				if (glyph_atlas) {
 					tmp.done(sna, &tmp);
 					glyph_atlas = NULL;
 				}
 				if (!glyph_cache(screen, &sna->render, glyph)) {
 					/* no cache for this glyph */
-					priv.atlas = GetGlyphPicture(glyph, screen);
-					if (unlikely(priv.atlas == NULL)) {
+					p->atlas = GetGlyphPicture(glyph, screen);
+					if (unlikely(p->atlas == NULL)) {
 						glyph->info.width = glyph->info.height = 0;
 						goto next_glyph;
 					}
-					priv.coordinate.x = priv.coordinate.y = 0;
-				} else
-					priv = *sna_glyph(glyph);
+					p->coordinate.x = p->coordinate.y = 0;
+				}
 			}
 
-			if (priv.atlas != glyph_atlas) {
+			if (p->atlas != glyph_atlas) {
 				if (glyph_atlas)
 					tmp.done(sna, &tmp);
 
 				if (!sna->render.composite(sna,
-							   op, src, priv.atlas, dst,
+							   op, src, p->atlas, dst,
 							   0, 0, 0, 0, 0, 0,
 							   0, 0,
 							   &tmp))
 					return false;
 
-				glyph_atlas = priv.atlas;
+				glyph_atlas = p->atlas;
 			}
 
 			if (nrect) {
@@ -618,8 +617,8 @@ glyphs_to_dst(struct sna *sna,
 
 						r.src.x = r.dst.x + src_x;
 						r.src.y = r.dst.y + src_y;
-						r.mask.x = dx + priv.coordinate.x;
-						r.mask.y = dy + priv.coordinate.y;
+						r.mask.x = dx + p->coordinate.x;
+						r.mask.y = dy + p->coordinate.y;
 						r.width  = x2 - r.dst.x;
 						r.height = y2 - r.dst.y;
 						tmp.blt(sna, &tmp, &r);
@@ -633,7 +632,7 @@ glyphs_to_dst(struct sna *sna,
 				r.dst.y = y - glyph->info.y;
 				r.src.x = r.dst.x + src_x;
 				r.src.y = r.dst.y + src_y;
-				r.mask = priv.coordinate;
+				r.mask = p->coordinate;
 				glyph_copy_size(&r, glyph);
 
 				DBG(("%s: glyph=(%d, %d)x(%d, %d), unclipped\n",
@@ -687,14 +686,11 @@ glyphs_slow(struct sna *sna,
 		y += list->yOff;
 		while (n--) {
 			GlyphPtr glyph = *glyphs++;
-			struct sna_glyph priv;
+			struct sna_glyph *p;
 			BoxPtr rects;
 			BoxRec box;
 			int nrect;
 
-			if (!glyph_valid(glyph))
-				goto next_glyph;
-
 			box.x1 = x - glyph->info.x;
 			box.y1 = y - glyph->info.y;
 			box.x2 = bound(box.x1, glyph->info.width);
@@ -704,18 +700,20 @@ glyphs_slow(struct sna *sna,
 					   &dst->pCompositeClip->extents))
 				goto next_glyph;
 
-			priv = *sna_glyph(glyph);
-			if (priv.atlas == NULL) {
+			p = sna_glyph(glyph);
+			if (unlikely(p->atlas == NULL)) {
+				if (unlikely(!glyph_valid(glyph)))
+					goto next_glyph;
+
 				if (!glyph_cache(screen, &sna->render, glyph)) {
 					/* no cache for this glyph */
-					priv.atlas = GetGlyphPicture(glyph, screen);
-					if (unlikely(priv.atlas == NULL)) {
+					p->atlas = GetGlyphPicture(glyph, screen);
+					if (unlikely(p->atlas == NULL)) {
 						glyph->info.width = glyph->info.height = 0;
 						goto next_glyph;
 					}
-					priv.coordinate.x = priv.coordinate.y = 0;
-				} else
-					priv = *sna_glyph(glyph);
+					p->coordinate.x = p->coordinate.y = 0;
+				}
 			}
 
 			DBG(("%s: glyph=(%d, %d)x(%d, %d), src=(%d, %d), mask=(%d, %d)\n",
@@ -726,13 +724,13 @@ glyphs_slow(struct sna *sna,
 			     glyph->info.height,
 			     src_x + x - glyph->info.x,
 			     src_y + y - glyph->info.y,
-			     priv.coordinate.x, priv.coordinate.y));
+			     p->coordinate.x, p->coordinate.y));
 
 			if (!sna->render.composite(sna,
-						   op, src, priv.atlas, dst,
+						   op, src, p->atlas, dst,
 						   src_x + x - glyph->info.x,
 						   src_y + y - glyph->info.y,
-						   priv.coordinate.x, priv.coordinate.y,
+						   p->coordinate.x, p->coordinate.y,
 						   x - glyph->info.x,
 						   y - glyph->info.y,
 						   glyph->info.width,
@@ -1090,37 +1088,29 @@ next_image:
 			y += list->yOff;
 			while (n--) {
 				GlyphPtr glyph = *glyphs++;
-				struct sna_glyph *priv;
-				PicturePtr this_atlas;
+				struct sna_glyph *p;
 				struct sna_composite_rectangles r;
 
-				if (!glyph_valid(glyph))
-					goto next_glyph;
+				p = sna_glyph(glyph);
+				if (unlikely(p->atlas == NULL)) {
+					if (unlikely(!glyph_valid(glyph)))
+						goto next_glyph;
 
-				priv = sna_glyph(glyph);
-				if (priv->atlas != NULL) {
-					this_atlas = priv->atlas;
-					r.src = priv->coordinate;
-				} else {
 					if (glyph_atlas) {
 						tmp.done(sna, &tmp);
 						glyph_atlas = NULL;
 					}
-					if (glyph_cache(screen, &sna->render, glyph)) {
-						this_atlas = priv->atlas;
-						r.src = priv->coordinate;
-					} else {
+					if (!glyph_cache(screen, &sna->render, glyph)) {
 						/* no cache for this glyph */
-						this_atlas = GetGlyphPicture(glyph, screen);
-						if (unlikely(this_atlas == NULL)) {
+						p->atlas = GetGlyphPicture(glyph, screen);
+						if (unlikely(p->atlas == NULL)) {
 							glyph->info.width = glyph->info.height = 0;
 							goto next_glyph;
 						}
-						r.src.x = r.src.y = 0;
+						p->coordinate.x = p->coordinate.y = 0;
 					}
 				}
-
-				if (this_atlas != glyph_atlas) {
+				if (p->atlas != glyph_atlas) {
 					bool ok;
 
 					if (glyph_atlas)
@@ -1130,15 +1120,15 @@ next_image:
 					     __FUNCTION__,
 					     (int)this_atlas->format,
 					     (int)(format->depth << 24 | format->format)));
-					if (this_atlas->format == (format->depth << 24 | format->format)) {
+					if (p->atlas->format == (format->depth << 24 | format->format)) {
 						ok = sna->render.composite(sna, PictOpAdd,
-									   this_atlas, NULL, mask,
+									   p->atlas, NULL, mask,
 									   0, 0, 0, 0, 0, 0,
 									   0, 0,
 									   &tmp);
 					} else {
 						ok = sna->render.composite(sna, PictOpAdd,
-									   sna->render.white_picture, this_atlas, mask,
+									   sna->render.white_picture, p->atlas, mask,
 									   0, 0, 0, 0, 0, 0,
 									   0, 0,
 									   &tmp);
@@ -1149,17 +1139,17 @@ next_image:
 						goto err_mask;
 					}
 
-					glyph_atlas = this_atlas;
+					glyph_atlas = p->atlas;
 				}
 
 				DBG(("%s: blt glyph origin (%d, %d), offset (%d, %d), src (%d, %d), size (%d, %d)\n",
 				     __FUNCTION__,
 				     x, y,
 				     glyph->info.x, glyph->info.y,
-				     r.src.x, r.src.y,
+				     p->coordinate.x, p->coordinate.y,
 				     glyph->info.width, glyph->info.height));
 
-				r.mask = r.src;
+				r.mask = r.src = p->coordinate;
 				r.dst.x = x - glyph->info.x;
 				r.dst.y = y - glyph->info.y;
 				glyph_copy_size(&r, glyph);
@@ -2036,29 +2026,29 @@ fallback:
 void
 sna_glyph_unrealize(ScreenPtr screen, GlyphPtr glyph)
 {
-	struct sna_glyph *priv = sna_glyph(glyph);
+	struct sna_glyph *p = sna_glyph(glyph);
 
 	DBG(("%s: screen=%d, glyph(image?=%d, atlas?=%d)\n",
-	     __FUNCTION__, screen->myNum, !!priv->image, !!priv->atlas));
+	     __FUNCTION__, screen->myNum, !!p->image, !!p->atlas));
 
-	if (priv->image) {
+	if (p->image) {
 #if HAS_PIXMAN_GLYPHS
 		struct sna *sna = to_sna_from_screen(screen);
 		if (sna->render.glyph_cache)
 			pixman_glyph_cache_remove(sna->render.glyph_cache,
 						  glyph, NULL);
 #endif
-		pixman_image_unref(priv->image);
-		priv->image = NULL;
+		pixman_image_unref(p->image);
+		p->image = NULL;
 	}
 
-	if (priv->atlas) {
+	if (p->atlas) {
 		struct sna *sna = to_sna_from_screen(screen);
-		struct sna_glyph_cache *cache = &sna->render.glyph[priv->pos&1];
+		struct sna_glyph_cache *cache = &sna->render.glyph[p->pos&1];
 		DBG(("%s: releasing glyph pos %d from cache %d\n",
-		     __FUNCTION__, priv->pos >> 1, priv->pos & 1));
-		assert(cache->glyphs[priv->pos >> 1] == priv);
-		cache->glyphs[priv->pos >> 1] = NULL;
-		priv->atlas = NULL;
+		     __FUNCTION__, p->pos >> 1, p->pos & 1));
+		assert(cache->glyphs[p->pos >> 1] == p);
+		cache->glyphs[p->pos >> 1] = NULL;
+		p->atlas = NULL;
 	}
 }


More information about the xorg-commit mailing list