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 <zhigang.gong@linux.intel.com>
This commit is contained in:
Zhigang Gong 2011-12-12 06:56:36 +08:00 committed by Eric Anholt
parent 10ad332ded
commit 36d424feae
8 changed files with 41 additions and 42 deletions

View File

@ -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);

View File

@ -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;
}

View File

@ -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:

View File

@ -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

View File

@ -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;
}

View File

@ -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;

View File

@ -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

View File

@ -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)