summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZhigang Gong <zhigang.gong@linux.intel.com>2012-06-26 16:24:32 +0800
committerZhigang Gong <zhigang.gong@linux.intel.com>2012-07-03 18:30:15 +0800
commitf3cff9975b1969b91b85f329be9fa925a9137f34 (patch)
tree770758360e42e1cd50bf7718f4ab1824fb372453
parent593bd206bf2794dc1450e8e7d20142b8d0ca074b (diff)
glamor_glyphs: Slightly performance tuning.
As glamor_glyphs never fallback, we don't need to keep the underlying glyphs routines, just override the ps->glys Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
-rw-r--r--src/glamor.c11
-rw-r--r--src/glamor_glyphs.c82
2 files changed, 37 insertions, 56 deletions
diff --git a/src/glamor.c b/src/glamor.c
index d087b82..0f93e98 100644
--- a/src/glamor.c
+++ b/src/glamor.c
@@ -386,8 +386,6 @@ glamor_init(ScreenPtr screen, unsigned int flags)
glamor_priv->saved_procs.trapezoids = ps->Trapezoids;
ps->Trapezoids = glamor_trapezoids;
- glamor_priv->saved_procs.glyphs = ps->Glyphs;
- ps->Glyphs = glamor_glyphs;
glamor_priv->saved_procs.triangles = ps->Triangles;
ps->Triangles = glamor_triangles;
@@ -395,9 +393,14 @@ glamor_init(ScreenPtr screen, unsigned int flags)
glamor_priv->saved_procs.addtraps = ps->AddTraps;
ps->AddTraps = glamor_add_traps;
- glamor_priv->saved_procs.unrealize_glyph = ps->UnrealizeGlyph;
- ps->UnrealizeGlyph = glamor_glyph_unrealize;
}
+
+ glamor_priv->saved_procs.glyphs = ps->Glyphs;
+ ps->Glyphs = glamor_glyphs;
+
+ glamor_priv->saved_procs.unrealize_glyph = ps->UnrealizeGlyph;
+ ps->UnrealizeGlyph = glamor_glyph_unrealize;
+
glamor_priv->saved_procs.create_picture = ps->CreatePicture;
ps->CreatePicture = glamor_create_picture;
diff --git a/src/glamor_glyphs.c b/src/glamor_glyphs.c
index fa8b55f..c2a750d 100644
--- a/src/glamor_glyphs.c
+++ b/src/glamor_glyphs.c
@@ -97,16 +97,9 @@ static DevPrivateKeyRec glamor_glyph_key;
static inline struct glamor_glyph *
glamor_glyph_get_private(GlyphPtr glyph)
{
- return dixGetPrivate(&glyph->devPrivates, &glamor_glyph_key);
+ return (struct glamor_glyph*)glyph->devPrivates;
}
-static inline void
-glamor_glyph_set_private(GlyphPtr glyph, struct glamor_glyph *priv)
-{
- dixSetPrivate(&glyph->devPrivates, &glamor_glyph_key, priv);
-}
-
-
static void
glamor_unrealize_glyph_caches(ScreenPtr pScreen)
{
@@ -210,7 +203,8 @@ glamor_realize_glyph_caches(ScreenPtr pScreen)
Bool
glamor_glyphs_init(ScreenPtr pScreen)
{
- if (!dixRegisterPrivateKey(&glamor_glyph_key, PRIVATE_GLYPH, 0))
+ if (!dixRegisterPrivateKey(&glamor_glyph_key,
+ PRIVATE_GLYPH, sizeof(struct glamor_glyph)))
return FALSE;
/* Skip pixmap creation if we don't intend to use it. */
@@ -299,15 +293,10 @@ glamor_glyph_unrealize(ScreenPtr screen, GlyphPtr glyph)
struct glamor_glyph *priv;
/* Use Lookup in case we have not attached to this glyph. */
- priv = dixLookupPrivate(&glyph->devPrivates, &glamor_glyph_key);
- if (priv == NULL)
- return;
+ priv = glamor_glyph_get_private(glyph);
if (priv->cached)
priv->cache->glyphs[priv->pos] = NULL;
-
- glamor_glyph_set_private(glyph, NULL);
- free(priv);
}
/* Cut and paste from render/glyph.c - probably should export it instead */
@@ -632,10 +621,10 @@ glamor_glyph_size_to_mask(int size)
}
static PicturePtr
-glamor_glyph_cache(ScreenPtr screen, GlyphPtr glyph, int *out_x,
+glamor_glyph_cache(glamor_screen_private *glamor, GlyphPtr glyph, int *out_x,
int *out_y)
{
- glamor_screen_private *glamor = glamor_get_screen_private(screen);
+ ScreenPtr screen = glamor->screen;
PicturePtr glyph_picture = GlyphPicture(glyph)[screen->myNum];
glamor_glyph_cache_t *cache =
&glamor->glyphCaches[PICT_FORMAT_RGB(glyph_picture->format) !=
@@ -701,14 +690,6 @@ glamor_glyph_cache(ScreenPtr screen, GlyphPtr glyph, int *out_x,
cache->evict = rand() % GLYPH_CACHE_SIZE;
}
- if (priv == NULL) {
- priv = malloc(sizeof(struct glamor_glyph));
- if (priv == NULL)
- return NULL;
- glamor_glyph_set_private(glyph, priv);
- priv->has_edge_map = FALSE;
- }
-
cache->glyphs[pos] = glyph;
priv->cache = cache;
@@ -743,14 +724,13 @@ glamor_glyph_cache(ScreenPtr screen, GlyphPtr glyph, int *out_x,
typedef void (*glyphs_flush)(void * arg);
static glamor_glyph_cache_result_t
-glamor_buffer_glyph(ScreenPtr screen,
+glamor_buffer_glyph(glamor_screen_private *glamor_priv,
glamor_glyph_buffer_t * buffer,
GlyphPtr glyph, int x_glyph, int y_glyph,
int dx, int dy, int w, int h,
glyphs_flush glyphs_flush, void *flush_arg)
{
- glamor_screen_private *glamor_screen =
- glamor_get_screen_private(screen);
+ ScreenPtr screen = glamor_priv->screen;
unsigned int format = (GlyphPicture(glyph)[screen->myNum])->format;
glamor_composite_rect_t *rect;
PicturePtr source;
@@ -763,7 +743,7 @@ glamor_buffer_glyph(ScreenPtr screen,
format = PICT_a8;
cache =
- &glamor_screen->glyphCaches[PICT_FORMAT_RGB
+ &glamor_priv->glyphCaches[PICT_FORMAT_RGB
(glyph_picture->format) != 0];
if (buffer->source
@@ -791,7 +771,7 @@ glamor_buffer_glyph(ScreenPtr screen,
} else {
if (glyphs_flush)
(*glyphs_flush)(flush_arg);
- source = glamor_glyph_cache(screen, glyph, &x, &y);
+ source = glamor_glyph_cache(glamor_priv, glyph, &x, &y);
if (source != NULL) {
rect = &buffer->rects[buffer->count++];
rect->x_src = x + dx;
@@ -863,11 +843,13 @@ glamor_glyphs_via_mask(CARD8 op,
xRectangle fill_rect;
struct glyphs_flush_mask_arg arg;
GCPtr gc;
+ glamor_screen_private *glamor_priv;
glamor_glyph_extents(nlist, list, glyphs, &extents);
if (extents.x2 <= extents.x1 || extents.y2 <= extents.y1)
return;
+ glamor_priv = glamor_get_screen_private(screen);
width = extents.x2 - extents.x1;
height = extents.y2 - extents.y1;
@@ -924,7 +906,7 @@ glamor_glyphs_via_mask(CARD8 op,
else
flush_func = NULL;
- glamor_buffer_glyph(screen, &buffer,
+ glamor_buffer_glyph(glamor_priv, &buffer,
glyph, x, y,
0, 0,
glyph->info.width, glyph->info.height,
@@ -1006,6 +988,7 @@ glamor_glyphs_to_dst(CARD8 op,
struct glyphs_flush_dst_arg arg;
BoxPtr rects;
int nrect;
+ glamor_screen_private *glamor_priv;
buffer.count = 0;
buffer.source = NULL;
@@ -1013,6 +996,18 @@ glamor_glyphs_to_dst(CARD8 op,
rects = REGION_RECTS(dst->pCompositeClip);
nrect = REGION_NUM_RECTS(dst->pCompositeClip);
+ glamor_priv = glamor_get_screen_private(screen);
+
+ arg.op = op;
+ arg.src = src;
+ arg.dst = dst;
+ arg.buffer = &buffer;
+ arg.x_src = x_src;
+ arg.y_src = y_src;
+ arg.x_dst = x_dst;
+ arg.y_dst = y_dst;
+
+
while (nlist--) {
x += list->xOff;
y += list->yOff;
@@ -1025,17 +1020,9 @@ glamor_glyphs_to_dst(CARD8 op,
&& glyph->info.height > 0) {
glyphs_flush flush_func;
- if (buffer.count) {
- arg.op = op;
- arg.src = src;
- arg.dst = dst;
- arg.buffer = &buffer;
- arg.x_src = x_src;
- arg.y_src = y_src;
- arg.x_dst = x_dst;
- arg.y_dst = y_dst;
+ if (buffer.count)
flush_func = (glyphs_flush)glamor_glyphs_flush_dst;
- } else
+ else
flush_func = NULL;
for (i = 0; i < nrect; i++) {
@@ -1062,7 +1049,7 @@ glamor_glyphs_to_dst(CARD8 op,
if (dst_x < x2 && dst_y < y2) {
- glamor_buffer_glyph(screen,
+ glamor_buffer_glyph(glamor_priv,
&buffer,
glyph,
dst_x + glyph->info.x,
@@ -1081,17 +1068,8 @@ glamor_glyphs_to_dst(CARD8 op,
list++;
}
- if (buffer.count) {
- arg.op = op;
- arg.src = src;
- arg.dst = dst;
- arg.buffer = &buffer;
- arg.x_src = x_src;
- arg.y_src = y_src;
- arg.x_dst = x_dst;
- arg.y_dst = y_dst;
+ if (buffer.count)
glamor_glyphs_flush_dst(&arg);
- }
}
static Bool