From 057f52a04d47e6ca5f6dead9c1bc71765d4c7ae8 Mon Sep 17 00:00:00 2001 From: Zhigang Gong Date: Wed, 4 Jan 2012 14:34:39 +0800 Subject: [PATCH] Track all picture's drawable pict format. Even if a picture's pixmap is a pure in memory pixmap, we still need to track its format. The reason is we may need to upload this drawable to texture thus we need to know its real picture format. As to the MACRO to check whether a pixmap is a picture, we should check whether the priv is non-NULL before we touch its field. Signed-off-by: Zhigang Gong --- glamor/glamor_picture.c | 8 ++++++++ glamor/glamor_utils.h | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/glamor/glamor_picture.c b/glamor/glamor_picture.c index 940c9d75a..2f9bc81ed 100644 --- a/glamor/glamor_picture.c +++ b/glamor/glamor_picture.c @@ -58,6 +58,14 @@ glamor_create_picture(PicturePtr picture) glamor_get_screen_private(picture->pDrawable->pScreen); pixmap = glamor_get_drawable_pixmap(picture->pDrawable); pixmap_priv = glamor_get_pixmap_private(pixmap); + if (!pixmap_priv) { + /* We must create a pixmap priv to track the picture format even + * if the pixmap is a pure in memory pixmap. The reason is that + * we may need to upload this pixmap to a texture on the fly. During + * the uploading, we need to know the picture format. */ + glamor_set_pixmap_type(pixmap, GLAMOR_MEMORY); + pixmap_priv = glamor_get_pixmap_private(pixmap); + } if (pixmap_priv) { pixmap_priv->is_picture = 1; diff --git a/glamor/glamor_utils.h b/glamor/glamor_utils.h index 9eea70e11..dfb77113e 100644 --- a/glamor/glamor_utils.h +++ b/glamor/glamor_utils.h @@ -175,7 +175,7 @@ glamor_transform_boxes(BoxPtr boxes, int nbox, int dx, int dy) || _depth_ == 32) -#define GLAMOR_PIXMAP_PRIV_IS_PICTURE(pixmap_priv) (pixmap_priv->is_picture == 1) +#define GLAMOR_PIXMAP_PRIV_IS_PICTURE(pixmap_priv) (pixmap_priv && pixmap_priv->is_picture == 1) #define GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv) (pixmap_priv && pixmap_priv->gl_fbo == 1) #define GLAMOR_PIXMAP_PRIV_NEED_VALIDATE(pixmap_priv) \