diff options
Diffstat (limited to 'xserver/glamor')
-rw-r--r-- | xserver/glamor/glamor.c | 27 | ||||
-rw-r--r-- | xserver/glamor/glamor_font.c | 37 | ||||
-rw-r--r-- | xserver/glamor/glamor_image.c | 4 | ||||
-rw-r--r-- | xserver/glamor/glamor_prepare.c | 2 |
4 files changed, 43 insertions, 27 deletions
diff --git a/xserver/glamor/glamor.c b/xserver/glamor/glamor.c index a8cc810d1..6c2ff28d9 100644 --- a/xserver/glamor/glamor.c +++ b/xserver/glamor/glamor.c @@ -207,7 +207,6 @@ glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth, if (fbo == NULL) { fbDestroyPixmap(pixmap); - free(pixmap_priv); return fbCreatePixmap(screen, w, h, depth, usage); } @@ -379,6 +378,20 @@ glamor_init(ScreenPtr screen, unsigned int flags) goto fail; } + glamor_priv->saved_procs.close_screen = screen->CloseScreen; + screen->CloseScreen = glamor_close_screen; + + /* If we are using egl screen, call egl screen init to + * register correct close screen function. */ + if (flags & GLAMOR_USE_EGL_SCREEN) { + glamor_egl_screen_init(screen, &glamor_priv->ctx); + } else { + if (!glamor_glx_screen_init(&glamor_priv->ctx)) + goto fail; + } + + glamor_make_current(glamor_priv); + if (epoxy_is_desktop_gl()) glamor_priv->gl_flavor = GLAMOR_GL_DESKTOP; else @@ -463,18 +476,6 @@ glamor_init(ScreenPtr screen, unsigned int flags) glamor_set_debug_level(&glamor_debug_level); - glamor_priv->saved_procs.close_screen = screen->CloseScreen; - screen->CloseScreen = glamor_close_screen; - - /* If we are using egl screen, call egl screen init to - * register correct close screen function. */ - if (flags & GLAMOR_USE_EGL_SCREEN) { - glamor_egl_screen_init(screen, &glamor_priv->ctx); - } else { - if (!glamor_glx_screen_init(&glamor_priv->ctx)) - goto fail; - } - glamor_priv->saved_procs.create_screen_resources = screen->CreateScreenResources; screen->CreateScreenResources = glamor_create_screen_resources; diff --git a/xserver/glamor/glamor_font.c b/xserver/glamor/glamor_font.c index cc0fecf7a..6b3a16abc 100644 --- a/xserver/glamor/glamor_font.c +++ b/xserver/glamor/glamor_font.c @@ -45,6 +45,7 @@ glamor_font_get(ScreenPtr screen, FontPtr font) unsigned char c[2]; CharInfoPtr glyph; unsigned long count; + char *bits; if (glamor_priv->glsl_version < 130) return NULL; @@ -62,8 +63,6 @@ glamor_font_get(ScreenPtr screen, FontPtr font) if (glamor_font->realized) return glamor_font; - glamor_font->realized = TRUE; - /* Figure out how many glyphs are in the font */ num_cols = font->info.lastCol - font->info.firstCol + 1; num_rows = font->info.lastRow - font->info.firstRow + 1; @@ -81,6 +80,10 @@ glamor_font_get(ScreenPtr screen, FontPtr font) overall_width = glyph_width_bytes * num_cols; overall_height = glyph_height * num_rows; + bits = malloc(overall_width * overall_height); + if (!bits) + return NULL; + /* Check whether the font has a default character */ c[0] = font->info.lastRow + 1; c[1] = font->info.lastCol + 1; @@ -100,12 +103,6 @@ glamor_font_get(ScreenPtr screen, FontPtr font) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - /* Allocate storage */ - glTexImage2D(GL_TEXTURE_2D, 0, GL_R8UI, overall_width, overall_height, - 0, GL_RED_INTEGER, GL_UNSIGNED_BYTE, NULL); - - glPixelStorei(GL_UNPACK_ALIGNMENT, 4); - /* Paint all of the glyphs */ for (row = 0; row < num_rows; row++) { for (col = 0; col < num_cols; col++) { @@ -114,13 +111,29 @@ glamor_font_get(ScreenPtr screen, FontPtr font) (*font->get_glyphs)(font, 1, c, TwoD16Bit, &count, &glyph); - if (count) - glTexSubImage2D(GL_TEXTURE_2D, 0, col * glyph_width_bytes, row * glyph_height, - GLYPHWIDTHBYTES(glyph), GLYPHHEIGHTPIXELS(glyph), - GL_RED_INTEGER, GL_UNSIGNED_BYTE, glyph->bits); + if (count) { + char *dst = bits + row * glyph_height * overall_width + + col * glyph_width_bytes; + char *src = glyph->bits; + unsigned y; + + for (y = 0; y < GLYPHHEIGHTPIXELS(glyph); y++) { + memcpy(dst, src, GLYPHWIDTHBYTES(glyph)); + dst += overall_width; + src += GLYPHWIDTHBYTESPADDED(glyph); + } + } } } + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + glTexImage2D(GL_TEXTURE_2D, 0, GL_R8UI, overall_width, overall_height, + 0, GL_RED_INTEGER, GL_UNSIGNED_BYTE, bits); + + free(bits); + + glamor_font->realized = TRUE; + return glamor_font; } diff --git a/xserver/glamor/glamor_image.c b/xserver/glamor/glamor_image.c index b38b41212..90fda4079 100644 --- a/xserver/glamor/glamor_image.c +++ b/xserver/glamor/glamor_image.c @@ -88,7 +88,7 @@ static void glamor_put_image_bail(DrawablePtr drawable, GCPtr gc, int depth, int x, int y, int w, int h, int leftPad, int format, char *bits) { - if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW)) + if (glamor_prepare_access_box(drawable, GLAMOR_ACCESS_RW, x, y, w, h)) fbPutImage(drawable, gc, depth, x, y, w, h, leftPad, format, bits); glamor_finish_access(drawable); } @@ -150,7 +150,7 @@ static void glamor_get_image_bail(DrawablePtr drawable, int x, int y, int w, int h, unsigned int format, unsigned long plane_mask, char *d) { - if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RO)) + if (glamor_prepare_access_box(drawable, GLAMOR_ACCESS_RO, x, y, w, h)) fbGetImage(drawable, x, y, w, h, format, plane_mask, d); glamor_finish_access(drawable); } diff --git a/xserver/glamor/glamor_prepare.c b/xserver/glamor/glamor_prepare.c index fb85d9082..40b7b4feb 100644 --- a/xserver/glamor/glamor_prepare.c +++ b/xserver/glamor/glamor_prepare.c @@ -45,6 +45,8 @@ glamor_prep_pixmap_box(PixmapPtr pixmap, glamor_access_t access, BoxPtr box) if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(priv)) return TRUE; + glamor_make_current(glamor_priv); + RegionInit(®ion, box, 1); /* See if it's already mapped */ |