diff options
-rw-r--r-- | glamor/glamor.c | 43 | ||||
-rw-r--r-- | glamor/glamor.h | 2 | ||||
-rw-r--r-- | glamor/glamor_fbo.c | 6 | ||||
-rw-r--r-- | glamor/glamor_priv.h | 15 |
4 files changed, 13 insertions, 53 deletions
diff --git a/glamor/glamor.c b/glamor/glamor.c index 50d85ff22..2470a8d38 100644 --- a/glamor/glamor.c +++ b/glamor/glamor.c @@ -80,12 +80,7 @@ glamor_set_pixmap_type(PixmapPtr pixmap, glamor_pixmap_type_t type) { glamor_pixmap_private *pixmap_priv; - pixmap_priv = dixLookupPrivate(&pixmap->devPrivates, - &glamor_pixmap_private_key); - if (pixmap_priv == NULL) { - pixmap_priv = calloc(sizeof(*pixmap_priv), 1); - glamor_set_pixmap_private(pixmap, pixmap_priv); - } + pixmap_priv = glamor_get_pixmap_private(pixmap); pixmap_priv->type = type; glamor_init_pixmap_private_small(pixmap, pixmap_priv); } @@ -171,13 +166,7 @@ glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth, else pixmap = fbCreatePixmap(screen, 0, 0, depth, usage); - pixmap_priv = calloc(1, sizeof(*pixmap_priv)); - - if (!pixmap_priv) { - fbDestroyPixmap(pixmap); - return fbCreatePixmap(screen, w, h, depth, usage); - } - glamor_set_pixmap_private(pixmap, pixmap_priv); + pixmap_priv = glamor_get_pixmap_private(pixmap); format = gl_iformat_for_pixmap(pixmap); @@ -223,7 +212,7 @@ glamor_destroy_textured_pixmap(PixmapPtr pixmap) #if GLAMOR_HAS_GBM glamor_egl_destroy_pixmap_image(pixmap); #endif - glamor_set_pixmap_private(pixmap, NULL); + glamor_pixmap_destroy_fbo(pixmap); } } } @@ -455,7 +444,8 @@ glamor_init(ScreenPtr screen, unsigned int flags) glamor_set_screen_private(screen, glamor_priv); - if (!dixRegisterPrivateKey(&glamor_pixmap_private_key, PRIVATE_PIXMAP, 0)) { + if (!dixRegisterPrivateKey(&glamor_pixmap_private_key, PRIVATE_PIXMAP, + sizeof(struct glamor_pixmap_private))) { LogMessage(X_WARNING, "glamor%d: Failed to allocate pixmap private\n", screen->myNum); @@ -705,27 +695,6 @@ glamor_release_screen_priv(ScreenPtr screen) glamor_set_screen_private(screen, NULL); } -_X_EXPORT void -glamor_set_pixmap_private(PixmapPtr pixmap, glamor_pixmap_private *priv) -{ - glamor_pixmap_private *old_priv; - - old_priv = dixGetPrivate(&pixmap->devPrivates, &glamor_pixmap_private_key); - - if (priv) { - assert(old_priv == NULL); - } - else { - if (old_priv == NULL) - return; - glamor_pixmap_destroy_fbo(glamor_get_screen_private(pixmap->drawable.pScreen), - old_priv); - free(old_priv); - } - - dixSetPrivate(&pixmap->devPrivates, &glamor_pixmap_private_key, priv); -} - Bool glamor_close_screen(ScreenPtr screen) { @@ -759,7 +728,7 @@ glamor_close_screen(ScreenPtr screen) screen->SetWindowPixmap = glamor_priv->saved_procs.set_window_pixmap; screen_pixmap = screen->GetScreenPixmap(screen); - glamor_set_pixmap_private(screen_pixmap, NULL); + glamor_pixmap_destroy_fbo(screen_pixmap); glamor_release_screen_priv(screen); diff --git a/glamor/glamor.h b/glamor/glamor.h index 0931bbccd..4be880058 100644 --- a/glamor/glamor.h +++ b/glamor/glamor.h @@ -52,7 +52,7 @@ struct glamor_context; * @TEXTURE_ONLY: pixmap is in an internal texture. */ typedef enum glamor_pixmap_type { - GLAMOR_MEMORY, + GLAMOR_MEMORY = 0, /* Newly calloc()ed pixmaps are memory. */ GLAMOR_TEXTURE_DRM, GLAMOR_DRM_ONLY, GLAMOR_TEXTURE_ONLY, diff --git a/glamor/glamor_fbo.c b/glamor/glamor_fbo.c index 84f3b22b0..1eee304ed 100644 --- a/glamor/glamor_fbo.c +++ b/glamor/glamor_fbo.c @@ -471,9 +471,11 @@ glamor_pixmap_attach_fbo(PixmapPtr pixmap, glamor_pixmap_fbo *fbo) } void -glamor_pixmap_destroy_fbo(glamor_screen_private *glamor_priv, - glamor_pixmap_private *priv) +glamor_pixmap_destroy_fbo(PixmapPtr pixmap) { + ScreenPtr screen = pixmap->drawable.pScreen; + glamor_screen_private *glamor_priv = glamor_get_screen_private(screen); + glamor_pixmap_private *priv = glamor_get_pixmap_private(pixmap); glamor_pixmap_fbo *fbo; if (glamor_pixmap_priv_is_large(priv)) { diff --git a/glamor/glamor_priv.h b/glamor/glamor_priv.h index 66e5012a5..fe65d9b79 100644 --- a/glamor/glamor_priv.h +++ b/glamor/glamor_priv.h @@ -405,22 +405,12 @@ extern DevPrivateKeyRec glamor_pixmap_private_key; static inline glamor_pixmap_private * glamor_get_pixmap_private(PixmapPtr pixmap) { - glamor_pixmap_private *priv; - if (pixmap == NULL) return NULL; - priv = dixLookupPrivate(&pixmap->devPrivates, &glamor_pixmap_private_key); - if (!priv) { - glamor_set_pixmap_type(pixmap, GLAMOR_MEMORY); - priv = dixLookupPrivate(&pixmap->devPrivates, - &glamor_pixmap_private_key); - } - return priv; + return dixLookupPrivate(&pixmap->devPrivates, &glamor_pixmap_private_key); } -void glamor_set_pixmap_private(PixmapPtr pixmap, glamor_pixmap_private *priv); - /* * Returns TRUE if pixmap has no image object */ @@ -590,8 +580,7 @@ glamor_pixmap_fbo *glamor_create_fbo(glamor_screen_private *glamor_priv, int w, int h, GLenum format, int flag); void glamor_destroy_fbo(glamor_screen_private *glamor_priv, glamor_pixmap_fbo *fbo); -void glamor_pixmap_destroy_fbo(glamor_screen_private *glamor_priv, - glamor_pixmap_private *priv); +void glamor_pixmap_destroy_fbo(PixmapPtr pixmap); void glamor_init_pixmap_fbo(ScreenPtr screen); void glamor_fini_pixmap_fbo(ScreenPtr screen); Bool glamor_pixmap_fbo_fixup(ScreenPtr screen, PixmapPtr pixmap); |