diff options
author | Michel Dänzer <michel.daenzer@amd.com> | 2014-09-10 16:20:48 +0900 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2014-09-11 18:31:11 -0700 |
commit | 1d32004ed5a3a20b2d5879867e213122dced69d0 (patch) | |
tree | 940063272c2abbbda6ed205f3b041d5483459333 /glamor | |
parent | 710d314ad16cf1eaca3b97b1736ff0ca43e598c4 (diff) |
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@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'glamor')
-rw-r--r-- | glamor/glamor_glyphs.c | 48 | ||||
-rw-r--r-- | glamor/glamor_priv.h | 25 |
2 files changed, 37 insertions, 36 deletions
diff --git a/glamor/glamor_glyphs.c b/glamor/glamor_glyphs.c index 686260ccc..1f1362487 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 6ebb7b392..aa59e3bcd 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. */ |