diff --git a/glamor/glamor_core.c b/glamor/glamor_core.c index 395e91276..01c9aeaf9 100644 --- a/glamor/glamor_core.c +++ b/glamor/glamor_core.c @@ -263,8 +263,6 @@ glamor_fini_finish_access_shaders(ScreenPtr screen) dispatch->glDeleteProgram(glamor_priv->finish_access_prog[1]); } - - void glamor_finish_access(DrawablePtr drawable, glamor_access_t access_mode) { @@ -275,7 +273,7 @@ glamor_finish_access(DrawablePtr drawable, glamor_access_t access_mode) glamor_get_screen_private(drawable->pScreen); glamor_gl_dispatch *dispatch = &glamor_priv->dispatch; - if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv)) + if (!GLAMOR_PIXMAP_PRIV_HAS_FBO_DOWNLOADED(pixmap_priv)) return; if (access_mode != GLAMOR_ACCESS_RO) { @@ -293,6 +291,9 @@ glamor_finish_access(DrawablePtr drawable, glamor_access_t access_mode) free(pixmap->devPrivate.ptr); } + if (pixmap_priv->gl_fbo == GLAMOR_FBO_DOWNLOADED) + pixmap_priv->gl_fbo = GLAMOR_FBO_NORMAL; + pixmap->devPrivate.ptr = NULL; } diff --git a/glamor/glamor_pixmap.c b/glamor/glamor_pixmap.c index e1542732b..6563e949b 100644 --- a/glamor/glamor_pixmap.c +++ b/glamor/glamor_pixmap.c @@ -641,7 +641,6 @@ glamor_es2_pixmap_read_prepare(PixmapPtr source, GLenum * format, * If successfully download a fbo to cpu then return TRUE. * Otherwise return FALSE. **/ - Bool glamor_download_pixmap_to_cpu(PixmapPtr pixmap, glamor_access_t access) { @@ -794,6 +793,8 @@ glamor_download_pixmap_to_cpu(PixmapPtr pixmap, glamor_access_t access) dispatch->glBindFramebuffer(GL_FRAMEBUFFER, 0); done: + + pixmap_priv->gl_fbo = GLAMOR_FBO_DOWNLOADED; pixmap->devPrivate.ptr = data; if (temp_pixmap) diff --git a/glamor/glamor_priv.h b/glamor/glamor_priv.h index 0b7558836..b19a30402 100644 --- a/glamor/glamor_priv.h +++ b/glamor/glamor_priv.h @@ -243,19 +243,23 @@ typedef union _glamor_pending_op { glamor_pending_fill fill; } glamor_pending_op; -/* - * glamor_pixmap_private - glamor pixmap's private structure. - * @gl_fbo: The pixmap is attached to a fbo originally. - * @gl_tex: The pixmap is in a gl texture originally. +#define GLAMOR_FBO_NORMAL 1 +#define GLAMOR_FBO_DOWNLOADED 2 +/* glamor_pixmap_fbo: + * @list: to be used to link to the cache pool list. + * @expire: when push to cache pool list, set a expire count. + * will be freed when glamor_priv->tick is equal or + * larger than this expire count in block handler. * @pbo_valid: The pbo has a valid copy of the pixmap's data. - * @is_picture: The drawable is attached to a picture. * @tex: attached texture. * @fb: attached fbo. * @pbo: attached pbo. - * @pict_format: the corresponding picture's format. - * #pending_op: currently only support pending filling. - * @container: The corresponding pixmap's pointer. - **/ + * @width: width of this fbo. + * @height: height of this fbo. + * @format: internal format of this fbo's texture. + * @type: internal type of this fbo's texture. + * @glamor_priv: point to glamor private data. + */ typedef struct glamor_pixmap_fbo { struct list list; unsigned int expire; @@ -270,9 +274,22 @@ typedef struct glamor_pixmap_fbo { glamor_screen_private *glamor_priv; } glamor_pixmap_fbo; - +/* + * glamor_pixmap_private - glamor pixmap's private structure. + * @gl_fbo: + * 0 - The pixmap doesn't has a fbo attached to it. + * GLAMOR_FBO_NORMAL - The pixmap has a fbo and can be accessed normally. + * GLAMOR_FBO_DOWNLOADED - The pixmap has a fbo and already downloaded to + * CPU, so it can only be treated as a in-memory pixmap + * if this bit is set. + * @gl_tex: The pixmap is in a gl texture originally. + * @is_picture: The drawable is attached to a picture. + * @pict_format: the corresponding picture's format. + * #pending_op: currently only support pending filling. + * @container: The corresponding pixmap's pointer. + **/ typedef struct glamor_pixmap_private { - unsigned char gl_fbo:1; + unsigned char gl_fbo:2; unsigned char is_picture:1; unsigned char gl_tex:1; glamor_pixmap_type_t type; diff --git a/glamor/glamor_utils.h b/glamor/glamor_utils.h index b29292832..a60b146c1 100644 --- a/glamor/glamor_utils.h +++ b/glamor/glamor_utils.h @@ -175,7 +175,8 @@ glamor_transform_boxes(BoxPtr boxes, int nbox, int dx, int dy) #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_HAS_FBO(pixmap_priv) (pixmap_priv && pixmap_priv->gl_fbo == GLAMOR_FBO_NORMAL) +#define GLAMOR_PIXMAP_PRIV_HAS_FBO_DOWNLOADED(pixmap_priv) (pixmap_priv && (pixmap_priv->gl_fbo == GLAMOR_FBO_DOWNLOADED)) #define GLAMOR_PIXMAP_PRIV_NEED_VALIDATE(pixmap_priv) \ (GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv) \