xserver: Branch 'master' - 4 commits

Keith Packard keithp at kemper.freedesktop.org
Thu Sep 11 18:31:39 PDT 2014


 glamor/glamor.c        |    6 ++-
 glamor/glamor_glyphs.c |   86 +++++++++++++++++--------------------------------
 glamor/glamor_priv.h   |   27 ++++++++++++++-
 3 files changed, 62 insertions(+), 57 deletions(-)

New commits:
commit 1d32004ed5a3a20b2d5879867e213122dced69d0
Author: Michel Dänzer <michel.daenzer at amd.com>
Date:   Wed Sep 10 16:20:48 2014 +0900

    glamor: Make glyph mask cache per-screen
    
    It references a pixmap, which is a per-screen resource.
    
    Fixes broken text rendering in xfwm4-tweak-settings in Zaphod mode.
    
    Signed-off-by: Michel Dänzer <michel.daenzer at amd.com>
    Reviewed-by: Alex Deucher <alexander.deucher at amd.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/glamor/glamor_glyphs.c b/glamor/glamor_glyphs.c
index 686260c..1f13624 100644
--- a/glamor/glamor_glyphs.c
+++ b/glamor/glamor_glyphs.c
@@ -62,14 +62,6 @@
  */
 #define GLYPH_BUFFER_SIZE 1024
 
-#define CACHE_PICTURE_SIZE 1024
-#define GLYPH_MIN_SIZE 8
-#define GLYPH_MAX_SIZE	64
-#define GLYPH_CACHE_SIZE ((CACHE_PICTURE_SIZE) * CACHE_PICTURE_SIZE / (GLYPH_MIN_SIZE * GLYPH_MIN_SIZE))
-#define MASK_CACHE_MAX_SIZE 32
-#define MASK_CACHE_WIDTH (CACHE_PICTURE_SIZE / MASK_CACHE_MAX_SIZE)
-#define MASK_CACHE_MASK ((1LL << (MASK_CACHE_WIDTH)) - 1)
-
 typedef struct {
     PicturePtr source;
     glamor_composite_rect_t rects[GLYPH_BUFFER_SIZE + 4];
@@ -123,24 +115,8 @@ glamor_glyph_get_private(ScreenPtr screen, GlyphPtr glyph)
  * gain.
  */
 
-struct glamor_glyph_mask_cache_entry {
-    int idx;
-    int width;
-    int height;
-    int x;
-    int y;
-};
-
-static struct glamor_glyph_mask_cache {
-    PixmapPtr pixmap;
-    struct glamor_glyph_mask_cache_entry mcache[MASK_CACHE_WIDTH];
-    unsigned int free_bitmap;
-    unsigned int cleared_bitmap;
-} *mask_cache[GLAMOR_NUM_GLYPH_CACHE_FORMATS] = {
-NULL};
-
 static void
-clear_mask_cache_bitmap(struct glamor_glyph_mask_cache *maskcache,
+clear_mask_cache_bitmap(glamor_glyph_mask_cache_t *maskcache,
                         unsigned int clear_mask_bits)
 {
     unsigned int i = 0;
@@ -162,7 +138,7 @@ clear_mask_cache_bitmap(struct glamor_glyph_mask_cache *maskcache,
 }
 
 static void
-clear_mask_cache(struct glamor_glyph_mask_cache *maskcache)
+clear_mask_cache(glamor_glyph_mask_cache_t *maskcache)
 {
     int x = 0;
     int cnt = MASK_CACHE_WIDTH;
@@ -224,7 +200,7 @@ find_continuous_bits(unsigned int bits, int bits_cnt, unsigned int *pbits_mask)
 }
 
 static struct glamor_glyph_mask_cache_entry *
-get_mask_cache(struct glamor_glyph_mask_cache *maskcache, int blocks)
+get_mask_cache(glamor_glyph_mask_cache_t *maskcache, int blocks)
 {
     int free_cleared_bit, idx = -1;
     int retry_cnt = 0;
@@ -257,7 +233,7 @@ get_mask_cache(struct glamor_glyph_mask_cache *maskcache, int blocks)
 }
 
 static void
-put_mask_cache_bitmap(struct glamor_glyph_mask_cache *maskcache,
+put_mask_cache_bitmap(glamor_glyph_mask_cache_t *maskcache,
                       unsigned int bitmap)
 {
     maskcache->free_bitmap |= bitmap;
@@ -283,8 +259,8 @@ glamor_unrealize_glyph_caches(ScreenPtr pScreen)
         if (cache->glyphs)
             free(cache->glyphs);
 
-        if (mask_cache[i])
-            free(mask_cache[i]);
+        if (glamor->mask_cache[i])
+            free(glamor->mask_cache[i]);
     }
     glamor->glyph_caches_realized = FALSE;
 }
@@ -358,9 +334,9 @@ glamor_realize_glyph_caches(ScreenPtr pScreen)
             goto bail;
 
         cache->evict = rand() % GLYPH_CACHE_SIZE;
-        mask_cache[i] = calloc(1, sizeof(*mask_cache[i]));
-        mask_cache[i]->pixmap = pixmap;
-        clear_mask_cache(mask_cache[i]);
+        glamor->mask_cache[i] = calloc(1, sizeof(*glamor->mask_cache[i]));
+        glamor->mask_cache[i]->pixmap = pixmap;
+        clear_mask_cache(glamor->mask_cache[i]);
     }
     assert(i == GLAMOR_NUM_GLYPH_CACHE_FORMATS);
 
@@ -1182,7 +1158,7 @@ unsigned long long dst_glyphs_cnt = 0;
 struct glyphs_flush_mask_arg {
     PicturePtr mask;
     glamor_glyph_buffer_t *buffer;
-    struct glamor_glyph_mask_cache *maskcache;
+    glamor_glyph_mask_cache_t *maskcache;
     unsigned int used_bitmap;
 };
 
@@ -1398,7 +1374,7 @@ glamor_glyphs_via_mask(CARD8 op,
     glamor_glyph_buffer_t *pmask_buffer;
     struct glyphs_flush_mask_arg *pmask_arg;
     struct glamor_glyph_mask_cache_entry *mce = NULL;
-    struct glamor_glyph_mask_cache *maskcache;
+    glamor_glyph_mask_cache_t *maskcache;
     glamor_glyph_cache_t *cache;
     int glyphs_dst_mode;
 
@@ -1419,7 +1395,7 @@ glamor_glyphs_via_mask(CARD8 op,
 
     cache = &glamor_priv->glyphCaches
         [PICT_FORMAT_RGB(mask_format->format) != 0];
-    maskcache = mask_cache[PICT_FORMAT_RGB(mask_format->format) != 0];
+    maskcache = glamor_priv->mask_cache[PICT_FORMAT_RGB(mask_format->format) != 0];
 
     x = -extents.x1;
     y = -extents.y1;
diff --git a/glamor/glamor_priv.h b/glamor/glamor_priv.h
index 6ebb7b3..aa59e3b 100644
--- a/glamor/glamor_priv.h
+++ b/glamor/glamor_priv.h
@@ -167,6 +167,30 @@ typedef struct {
     uint16_t evict;
 } glamor_glyph_cache_t;
 
+#define CACHE_PICTURE_SIZE 1024
+#define GLYPH_MIN_SIZE 8
+#define GLYPH_MAX_SIZE	64
+#define GLYPH_CACHE_SIZE ((CACHE_PICTURE_SIZE) * CACHE_PICTURE_SIZE / (GLYPH_MIN_SIZE * GLYPH_MIN_SIZE))
+
+#define MASK_CACHE_MAX_SIZE 32
+#define MASK_CACHE_WIDTH (CACHE_PICTURE_SIZE / MASK_CACHE_MAX_SIZE)
+#define MASK_CACHE_MASK ((1LL << (MASK_CACHE_WIDTH)) - 1)
+
+struct glamor_glyph_mask_cache_entry {
+    int idx;
+    int width;
+    int height;
+    int x;
+    int y;
+};
+
+typedef struct {
+    PixmapPtr pixmap;
+    struct glamor_glyph_mask_cache_entry mcache[MASK_CACHE_WIDTH];
+    unsigned int free_bitmap;
+    unsigned int cleared_bitmap;
+} glamor_glyph_mask_cache_t;
+
 struct glamor_saved_procs {
     CloseScreenProcPtr close_screen;
     CreateScreenResourcesProcPtr create_screen_resources;
@@ -268,6 +292,7 @@ typedef struct glamor_screen_private {
         [SHADER_MASK_COUNT]
         [SHADER_IN_COUNT];
     glamor_glyph_cache_t glyphCaches[GLAMOR_NUM_GLYPH_CACHE_FORMATS];
+    glamor_glyph_mask_cache_t *mask_cache[GLAMOR_NUM_GLYPH_CACHE_FORMATS];
     Bool glyph_caches_realized;
 
     /* shaders to restore a texture to another texture. */
commit 710d314ad16cf1eaca3b97b1736ff0ca43e598c4
Author: Michel Dänzer <michel.daenzer at amd.com>
Date:   Wed Sep 10 16:20:47 2014 +0900

    glamor: Track glyph caching information per screen
    
    This is necessary because the glyph caches are per screen.
    
    Fixes broken menu text in gnome-terminal in Zaphod mode.
    
    Signed-off-by: Michel Dänzer <michel.daenzer at amd.com>
    Reviewed-by: Alex Deucher <alexander.deucher at amd.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/glamor/glamor_glyphs.c b/glamor/glamor_glyphs.c
index b491768..686260c 100644
--- a/glamor/glamor_glyphs.c
+++ b/glamor/glamor_glyphs.c
@@ -96,9 +96,11 @@ typedef enum {
 static DevPrivateKeyRec glamor_glyph_key;
 
 static inline struct glamor_glyph *
-glamor_glyph_get_private(GlyphPtr glyph)
+glamor_glyph_get_private(ScreenPtr screen, GlyphPtr glyph)
 {
-    return (struct glamor_glyph *) glyph->devPrivates;
+    struct glamor_glyph *privates = (struct glamor_glyph*)glyph->devPrivates;
+
+    return &privates[screen->myNum];
 }
 
 /*
@@ -380,7 +382,8 @@ Bool
 glamor_glyphs_init(ScreenPtr pScreen)
 {
     if (!dixRegisterPrivateKey(&glamor_glyph_key,
-                               PRIVATE_GLYPH, sizeof(struct glamor_glyph)))
+                               PRIVATE_GLYPH,
+                               screenInfo.numScreens * sizeof(struct glamor_glyph)))
         return FALSE;
 
     return TRUE;
@@ -460,7 +463,7 @@ glamor_glyph_unrealize(ScreenPtr screen, GlyphPtr glyph)
     struct glamor_glyph *priv;
 
     /* Use Lookup in case we have not attached to this glyph. */
-    priv = glamor_glyph_get_private(glyph);
+    priv = glamor_glyph_get_private(screen, glyph);
 
     if (priv->cached)
         priv->cache->glyphs[priv->pos] = NULL;
@@ -791,7 +794,7 @@ glamor_glyphs_intersect(int nlist, GlyphListPtr list, GlyphPtr *glyphs,
             if (y1 < MINSHORT)
                 y1 = MINSHORT;
             if (check_fake_overlap)
-                priv = glamor_glyph_get_private(glyph);
+                priv = glamor_glyph_get_private(screen, glyph);
 
             x2 = x1 + glyph->info.width;
             y2 = y1 + glyph->info.height;
@@ -1079,7 +1082,7 @@ glamor_glyph_cache(glamor_screen_private *glamor, GlyphPtr glyph, int *out_x,
     mask = glamor_glyph_count_to_mask(s);
     pos = (cache->count + s - 1) & mask;
 
-    priv = glamor_glyph_get_private(glyph);
+    priv = glamor_glyph_get_private(screen, glyph);
     if (pos < GLYPH_CACHE_SIZE) {
         cache->count = pos + s;
     }
@@ -1091,7 +1094,7 @@ glamor_glyph_cache(glamor_screen_private *glamor, GlyphPtr glyph, int *out_x,
             if (evicted == NULL)
                 continue;
 
-            evicted_priv = glamor_glyph_get_private(evicted);
+            evicted_priv = glamor_glyph_get_private(screen, evicted);
             assert(evicted_priv->pos == i);
             if (evicted_priv->size >= s) {
                 cache->glyphs[i] = NULL;
@@ -1112,7 +1115,7 @@ glamor_glyph_cache(glamor_screen_private *glamor, GlyphPtr glyph, int *out_x,
 
                 if (evicted != NULL) {
 
-                    evicted_priv = glamor_glyph_get_private(evicted);
+                    evicted_priv = glamor_glyph_get_private(screen, evicted);
 
                     assert(evicted_priv->pos == pos + s);
                     evicted_priv->cached = FALSE;
@@ -1239,7 +1242,7 @@ glamor_buffer_glyph(glamor_screen_private *glamor_priv,
     glamor_glyph_cache_t *cache;
 
     if (glyphs_dst_mode != GLYPHS_DST_MODE_MASK_TO_DST)
-        priv = glamor_glyph_get_private(glyph);
+        priv = glamor_glyph_get_private(screen, glyph);
 
     if (PICT_FORMAT_BPP(format) == 1)
         format = PICT_a8;
@@ -1297,7 +1300,7 @@ glamor_buffer_glyph(glamor_screen_private *glamor_priv,
             rect->x_src = 0 + dx;
             rect->y_src = 0 + dy;
         }
-        priv = glamor_glyph_get_private(glyph);
+        priv = glamor_glyph_get_private(screen, glyph);
     }
 
     rect->x_dst = x_glyph;
commit a4e8e6dff9a0c26944a325e4017faa68d93ae5b8
Author: Michel Dänzer <michel.daenzer at amd.com>
Date:   Wed Sep 10 16:20:46 2014 +0900

    glamor: Move 'glyph caches realized' check to glamor_realize_glyph_caches
    
    And rename the boolean to reflect what it's about.
    
    Signed-off-by: Michel Dänzer <michel.daenzer at amd.com>
    Reviewed-by: Alex Deucher <alexander.deucher at amd.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/glamor/glamor_glyphs.c b/glamor/glamor_glyphs.c
index f570d75..b491768 100644
--- a/glamor/glamor_glyphs.c
+++ b/glamor/glamor_glyphs.c
@@ -269,7 +269,7 @@ glamor_unrealize_glyph_caches(ScreenPtr pScreen)
     glamor_screen_private *glamor = glamor_get_screen_private(pScreen);
     int i;
 
-    if (!glamor->glyph_cache_initialized)
+    if (!glamor->glyph_caches_realized)
         return;
 
     for (i = 0; i < GLAMOR_NUM_GLYPH_CACHE_FORMATS; i++) {
@@ -284,7 +284,7 @@ glamor_unrealize_glyph_caches(ScreenPtr pScreen)
         if (mask_cache[i])
             free(mask_cache[i]);
     }
-    glamor->glyph_cache_initialized = FALSE;
+    glamor->glyph_caches_realized = FALSE;
 }
 
 void
@@ -314,6 +314,9 @@ glamor_realize_glyph_caches(ScreenPtr pScreen)
     };
     int i;
 
+    if (glamor->glyph_caches_realized)
+        return TRUE;
+
     memset(glamor->glyphCaches, 0, sizeof(glamor->glyphCaches));
 
     for (i = 0; i < sizeof(formats) / sizeof(formats[0]); i++) {
@@ -359,6 +362,7 @@ glamor_realize_glyph_caches(ScreenPtr pScreen)
     }
     assert(i == GLAMOR_NUM_GLYPH_CACHE_FORMATS);
 
+    glamor->glyph_caches_realized = TRUE;
     return TRUE;
 
  bail:
@@ -375,17 +379,10 @@ glamor_realize_glyph_caches(ScreenPtr pScreen)
 Bool
 glamor_glyphs_init(ScreenPtr pScreen)
 {
-    glamor_screen_private *glamor = glamor_get_screen_private(pScreen);
-
-    if (glamor->glyph_cache_initialized)
-        return TRUE;
-
     if (!dixRegisterPrivateKey(&glamor_glyph_key,
                                PRIVATE_GLYPH, sizeof(struct glamor_glyph)))
         return FALSE;
 
-    glamor->glyph_cache_initialized = TRUE;
-
     return TRUE;
 }
 
diff --git a/glamor/glamor_priv.h b/glamor/glamor_priv.h
index 385c027..6ebb7b3 100644
--- a/glamor/glamor_priv.h
+++ b/glamor/glamor_priv.h
@@ -268,7 +268,7 @@ typedef struct glamor_screen_private {
         [SHADER_MASK_COUNT]
         [SHADER_IN_COUNT];
     glamor_glyph_cache_t glyphCaches[GLAMOR_NUM_GLYPH_CACHE_FORMATS];
-    Bool glyph_cache_initialized;
+    Bool glyph_caches_realized;
 
     /* shaders to restore a texture to another texture. */
     GLint finish_access_prog[2];
commit 0acff6e4374340dc391014f396f190daf73d579c
Author: Michel Dänzer <michel.daenzer at amd.com>
Date:   Wed Sep 10 16:20:45 2014 +0900

    glamor: Call glamor_glyphs_init from glamor_create_screen_resources
    
    The comment above glamor_glyphs_init was already saying so.
    
    Signed-off-by: Michel Dänzer <michel.daenzer at amd.com>
    Reviewed-by: Alex Deucher <alexander.deucher at amd.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/glamor/glamor.c b/glamor/glamor.c
index 521bc25..e582e50 100644
--- a/glamor/glamor.c
+++ b/glamor/glamor.c
@@ -296,6 +296,11 @@ glamor_create_screen_resources(ScreenPtr screen)
         ret = screen->CreateScreenResources(screen);
     screen->CreateScreenResources = glamor_create_screen_resources;
 
+    if (!glamor_glyphs_init(screen)) {
+        ErrorF("Failed to initialize glyphs\n");
+        ret = FALSE;
+    }
+
     if (!glamor_realize_glyph_caches(screen)) {
         ErrorF("Failed to initialize glyph cache\n");
         ret = FALSE;
@@ -518,7 +523,6 @@ glamor_init(ScreenPtr screen, unsigned int flags)
     glamor_init_gradient_shader(screen);
 #endif
     glamor_pixmap_init(screen);
-    glamor_glyphs_init(screen);
     glamor_sync_init(screen);
 
     glamor_priv->screen = screen;


More information about the xorg-commit mailing list