From 36d424feaeec765d131c015df77d24db1a36fc38 Mon Sep 17 00:00:00 2001 From: Zhigang Gong Date: Mon, 12 Dec 2011 06:56:36 +0800 Subject: [PATCH] Call glamor_create_pixmap directly in glamor rendering path. When glamor is rendering pixmaps, and needs to create some temporary pixmap, it's better to use glamor version create pixmap directly. As if goes to external DDX's create pixmap, it may create a external DRM buffer which is not necessary. All the case within glamor scope is to create a texture only pixmap or a in memory pixmap. Signed-off-by: Zhigang Gong --- glamor/glamor.c | 11 ++++------- glamor/glamor_copyarea.c | 19 +++++++++---------- glamor/glamor_getspans.c | 2 +- glamor/glamor_glyphs.c | 18 +++++++++--------- glamor/glamor_pixmap.c | 14 ++++++-------- glamor/glamor_polylines.c | 10 +++++----- glamor/glamor_priv.h | 5 +++++ glamor/glamor_render.c | 4 ++-- 8 files changed, 41 insertions(+), 42 deletions(-) diff --git a/glamor/glamor.c b/glamor/glamor.c index 482a074163..c1718bf1bc 100644 --- a/glamor/glamor.c +++ b/glamor/glamor.c @@ -114,14 +114,10 @@ glamor_set_screen_pixmap_texture(ScreenPtr screen, int w, int h, glamor_priv->screen_fbo = pixmap_priv->fb; } - - #define GLAMOR_PIXMAP_MEMORY 0 #define GLAMOR_PIXMAP_TEXTURE 1 - - -static PixmapPtr +PixmapPtr glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth, unsigned int usage) { @@ -163,8 +159,9 @@ glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth, pixmap_priv->container = pixmap; pixmap_priv->glamor_priv = glamor_priv; - if (w == 0 || h == 0 || type == GLAMOR_PIXMAP_MEMORY) + if (w == 0 || h == 0 || type == GLAMOR_PIXMAP_MEMORY) { return pixmap; + } switch (depth) { #if 0 @@ -218,7 +215,7 @@ glamor_destroy_textured_pixmap(PixmapPtr pixmap) } } -static Bool +Bool glamor_destroy_pixmap(PixmapPtr pixmap) { glamor_destroy_textured_pixmap(pixmap); diff --git a/glamor/glamor_copyarea.c b/glamor/glamor_copyarea.c index 98da98a11d..625647d631 100644 --- a/glamor/glamor_copyarea.c +++ b/glamor/glamor_copyarea.c @@ -360,13 +360,13 @@ _glamor_copy_n_to_n(DrawablePtr src, src_pixmap->drawable.width * src_pixmap->drawable.height))) { - temp_pixmap = (*screen->CreatePixmap) (screen, - bound.x2 - bound.x1, - bound.y2 - bound.y1, - src_pixmap-> - drawable.depth, - overlaped ? 0 : - GLAMOR_CREATE_PIXMAP_CPU); + temp_pixmap = glamor_create_pixmap(screen, + bound.x2 - bound.x1, + bound.y2 - bound.y1, + src_pixmap-> + drawable.depth, + overlaped ? 0 : + GLAMOR_CREATE_PIXMAP_CPU); if (!temp_pixmap) goto fail; glamor_transform_boxes(box, nbox, -bound.x1, -bound.y1); @@ -430,9 +430,8 @@ _glamor_copy_n_to_n(DrawablePtr src, done: glamor_clear_delayed_fallbacks(src->pScreen); glamor_clear_delayed_fallbacks(dst->pScreen); - if (temp_src != src) { - (*screen->DestroyPixmap) (temp_pixmap); - } + if (temp_src != src) + glamor_destroy_pixmap(temp_pixmap); return ret; } diff --git a/glamor/glamor_getspans.c b/glamor/glamor_getspans.c index fc0d90b3e4..1fa4b4ca8c 100644 --- a/glamor/glamor_getspans.c +++ b/glamor/glamor_getspans.c @@ -93,7 +93,7 @@ glamor_get_spans(DrawablePtr drawable, PixmapBytePad(widths[i], drawable->depth); } if (temp_pixmap) - pixmap->drawable.pScreen->DestroyPixmap(temp_pixmap); + glamor_destroy_pixmap(temp_pixmap); return; fail: diff --git a/glamor/glamor_glyphs.c b/glamor/glamor_glyphs.c index 96e4c57ecc..30d9e585b4 100644 --- a/glamor/glamor_glyphs.c +++ b/glamor/glamor_glyphs.c @@ -172,10 +172,10 @@ glamor_realize_glyph_caches(ScreenPtr pScreen) goto bail; /* Now allocate the pixmap and picture */ - pixmap = pScreen->CreatePixmap(pScreen, - CACHE_PICTURE_SIZE, - CACHE_PICTURE_SIZE, depth, - 0); + pixmap = glamor_create_pixmap(pScreen, + CACHE_PICTURE_SIZE, + CACHE_PICTURE_SIZE, depth, + 0); if (!pixmap) goto bail; @@ -184,7 +184,7 @@ glamor_realize_glyph_caches(ScreenPtr pScreen) CPComponentAlpha, &component_alpha, serverClient, &error); - pScreen->DestroyPixmap(pixmap); + glamor_destroy_pixmap(pixmap); if (!picture) goto bail; @@ -244,7 +244,7 @@ glamor_glyph_cache_upload_glyph(ScreenPtr screen, y); if (scratch != pGlyphPixmap) - screen->DestroyPixmap(scratch); + glamor_destroy_pixmap(scratch); FreeScratchGC(gc); } @@ -628,7 +628,7 @@ glamor_glyphs_via_mask(CARD8 op, mask_format = a8Format; } - mask_pixmap = screen->CreatePixmap(screen, width, height, + mask_pixmap = glamor_create_pixmap(screen, width, height, mask_format->depth, CREATE_PIXMAP_USAGE_SCRATCH); if (!mask_pixmap) @@ -638,7 +638,7 @@ glamor_glyphs_via_mask(CARD8 op, mask_format, CPComponentAlpha, &component_alpha, serverClient, &error); if (!mask) { - screen->DestroyPixmap(mask_pixmap); + glamor_destroy_pixmap(mask_pixmap); return; } gc = GetScratchGC(mask_pixmap->drawable.depth, screen); @@ -695,7 +695,7 @@ glamor_glyphs_via_mask(CARD8 op, x_src + x - x_dst, y_src + y - y_dst, 0, 0, x, y, width, height); FreePicture(mask, 0); - screen->DestroyPixmap(mask_pixmap); + glamor_destroy_pixmap(mask_pixmap); } static void diff --git a/glamor/glamor_pixmap.c b/glamor/glamor_pixmap.c index 6f44aabd3c..9559d17319 100644 --- a/glamor/glamor_pixmap.c +++ b/glamor/glamor_pixmap.c @@ -576,10 +576,10 @@ glamor_es2_pixmap_read_prepare(PixmapPtr source, GLenum * format, } - temp_pixmap = (*screen->CreatePixmap) (screen, - source->drawable.width, - source->drawable.height, - source->drawable.depth, 0); + temp_pixmap = glamor_create_pixmap (screen, + source->drawable.width, + source->drawable.height, + source->drawable.depth, 0); temp_pixmap_priv = glamor_get_pixmap_private(temp_pixmap); @@ -658,7 +658,6 @@ glamor_download_pixmap_to_cpu(PixmapPtr pixmap, glamor_access_t access) return FALSE; } - pixmap_priv->access_mode = access; glamor_debug_output(GLAMOR_DEBUG_TEXTURE_DOWNLOAD, "Downloading pixmap %p %dx%d depth%d\n", pixmap, @@ -789,9 +788,8 @@ glamor_download_pixmap_to_cpu(PixmapPtr pixmap, glamor_access_t access) done: pixmap->devPrivate.ptr = data; - if (temp_pixmap) { - (*screen->DestroyPixmap) (temp_pixmap); - } + if (temp_pixmap) + glamor_destroy_pixmap(temp_pixmap); return TRUE; } diff --git a/glamor/glamor_polylines.c b/glamor/glamor_polylines.c index 2bb36c7e61..62401f5c39 100644 --- a/glamor/glamor_polylines.c +++ b/glamor/glamor_polylines.c @@ -122,10 +122,10 @@ glamor_poly_lines(DrawablePtr drawable, GCPtr gc, int mode, int n, y_max = points[i].y; } - temp_pixmap = drawable->pScreen->CreatePixmap(drawable->pScreen, - x_max - x_min + 1, - y_max - y_min + 1, - drawable->depth, 0); + temp_pixmap = glamor_create_pixmap(drawable->pScreen, + x_max - x_min + 1, + y_max - y_min + 1, + drawable->depth, 0); if (temp_pixmap) { temp_dest = &temp_pixmap->drawable; temp_gc = @@ -164,7 +164,7 @@ glamor_poly_lines(DrawablePtr drawable, GCPtr gc, int mode, int n, 0, 0, x_max - x_min + 1, y_max - y_min + 1, x_min, y_min); - drawable->pScreen->DestroyPixmap(temp_pixmap); + glamor_destroy_pixmap(temp_pixmap); for (i = 0; i < n; i++) { points[i].x += x_min; points[i].y += y_min; diff --git a/glamor/glamor_priv.h b/glamor/glamor_priv.h index 1a462e2009..8d4181e699 100644 --- a/glamor/glamor_priv.h +++ b/glamor/glamor_priv.h @@ -231,6 +231,7 @@ typedef union _glamor_pending_op { * @container: The corresponding pixmap's pointer. **/ + typedef struct glamor_pixmap_private { unsigned char gl_fbo:1; unsigned char gl_tex:1; @@ -298,6 +299,10 @@ PixmapPtr glamor_get_drawable_pixmap(DrawablePtr drawable); Bool glamor_close_screen(int idx, ScreenPtr screen); +PixmapPtr glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth, + unsigned int usage); + +Bool glamor_destroy_pixmap(PixmapPtr pixmap); /* glamor_copyarea.c */ RegionPtr diff --git a/glamor/glamor_render.c b/glamor/glamor_render.c index fa42532836..f522fd661f 100644 --- a/glamor/glamor_render.c +++ b/glamor/glamor_render.c @@ -1161,7 +1161,7 @@ glamor_convert_gradient_picture(ScreenPtr screen, else format = source->format; - pixmap = screen->CreatePixmap(screen, + pixmap = glamor_create_pixmap(screen, width, height, PIXMAN_FORMAT_DEPTH(format), @@ -1442,7 +1442,7 @@ glamor_create_mask_picture(ScreenPtr screen, return 0; } - pixmap = screen->CreatePixmap(screen, 0, 0, + pixmap = glamor_create_pixmap(screen, 0, 0, pict_format->depth, GLAMOR_CREATE_PIXMAP_CPU); if (!pixmap)