[PATCH 4/4] glamor: Drop a bunch of glamor_priv == NULL checks.
Eric Anholt
eric at anholt.net
Tue Jul 7 17:26:47 PDT 2015
Now that it's always non-null when the pixmap is non-null, we don't
need so much of this. glamor_get_pixmap_private() itself still
accepts a NULL pixmap and returns NULL, because of glamor_render.c
Signed-off-by: Eric Anholt <eric at anholt.net>
---
glamor/glamor.c | 17 ++++++-----------
glamor/glamor_core.c | 3 +--
glamor/glamor_egl.c | 4 ++--
glamor/glamor_picture.c | 9 ---------
glamor/glamor_priv.h | 12 ++++++------
glamor/glamor_utils.h | 4 ++--
6 files changed, 17 insertions(+), 32 deletions(-)
diff --git a/glamor/glamor.c b/glamor/glamor.c
index 2470a8d..04c548d 100644
--- a/glamor/glamor.c
+++ b/glamor/glamor.c
@@ -207,13 +207,10 @@ void
glamor_destroy_textured_pixmap(PixmapPtr pixmap)
{
if (pixmap->refcnt == 1) {
- glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
- if (pixmap_priv != NULL) {
#if GLAMOR_HAS_GBM
- glamor_egl_destroy_pixmap_image(pixmap);
+ glamor_egl_destroy_pixmap_image(pixmap);
#endif
- glamor_pixmap_destroy_fbo(pixmap);
- }
+ glamor_pixmap_destroy_fbo(pixmap);
}
}
@@ -761,12 +758,11 @@ _X_EXPORT int
glamor_fd_from_pixmap(ScreenPtr screen,
PixmapPtr pixmap, CARD16 *stride, CARD32 *size)
{
- glamor_pixmap_private *pixmap_priv;
+ glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
glamor_screen_private *glamor_priv =
glamor_get_screen_private(pixmap->drawable.pScreen);
- pixmap_priv = glamor_get_pixmap_private(pixmap);
- if (pixmap_priv == NULL || !glamor_priv->dri3_enabled)
+ if (!glamor_priv->dri3_enabled)
return -1;
switch (pixmap_priv->type) {
case GLAMOR_TEXTURE_DRM:
@@ -786,12 +782,11 @@ glamor_fd_from_pixmap(ScreenPtr screen,
int
glamor_name_from_pixmap(PixmapPtr pixmap, CARD16 *stride, CARD32 *size)
{
- glamor_pixmap_private *pixmap_priv;
+ glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
glamor_screen_private *glamor_priv =
glamor_get_screen_private(pixmap->drawable.pScreen);
- pixmap_priv = glamor_get_pixmap_private(pixmap);
- if (pixmap_priv == NULL || !glamor_priv->dri3_enabled)
+ if (!glamor_priv->dri3_enabled)
return -1;
switch (pixmap_priv->type) {
case GLAMOR_TEXTURE_DRM:
diff --git a/glamor/glamor_core.c b/glamor/glamor_core.c
index 79f5981b..0104b88 100644
--- a/glamor/glamor_core.c
+++ b/glamor/glamor_core.c
@@ -42,8 +42,7 @@ glamor_get_drawable_location(const DrawablePtr drawable)
glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
glamor_screen_private *glamor_priv =
glamor_get_screen_private(drawable->pScreen);
- if (pixmap_priv == NULL ||
- pixmap_priv->gl_fbo == GLAMOR_FBO_UNATTACHED)
+ if (pixmap_priv->gl_fbo == GLAMOR_FBO_UNATTACHED)
return 'm';
if (pixmap_priv->fbo->fb == glamor_priv->screen_fbo)
return 's';
diff --git a/glamor/glamor_egl.c b/glamor/glamor_egl.c
index e01f723..753fb34 100644
--- a/glamor/glamor_egl.c
+++ b/glamor/glamor_egl.c
@@ -452,7 +452,7 @@ glamor_gbm_bo_from_pixmap(ScreenPtr screen, PixmapPtr pixmap)
glamor_get_pixmap_private(pixmap);
pixmap_priv = glamor_get_pixmap_private(pixmap);
- if (pixmap_priv == NULL || !glamor_priv->dri3_enabled)
+ if (!glamor_priv->dri3_enabled)
return NULL;
switch (pixmap_priv->type) {
case GLAMOR_TEXTURE_DRM:
@@ -604,7 +604,7 @@ glamor_egl_destroy_pixmap_image(PixmapPtr pixmap)
struct glamor_pixmap_private *pixmap_priv =
glamor_get_pixmap_private(pixmap);
- if (pixmap_priv && pixmap_priv->image) {
+ if (pixmap_priv->image) {
ScrnInfoPtr scrn = xf86ScreenToScrn(pixmap->drawable.pScreen);
struct glamor_egl_screen_private *glamor_egl =
glamor_egl_get_screen_private(scrn);
diff --git a/glamor/glamor_picture.c b/glamor/glamor_picture.c
index 53b032c..20b9de2 100644
--- a/glamor/glamor_picture.c
+++ b/glamor/glamor_picture.c
@@ -61,15 +61,6 @@ glamor_create_picture(PicturePtr picture)
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);
- }
-
pixmap_priv->is_picture = 1;
pixmap_priv->picture = picture;
diff --git a/glamor/glamor_priv.h b/glamor/glamor_priv.h
index fe65d9b..d085ff2 100644
--- a/glamor/glamor_priv.h
+++ b/glamor/glamor_priv.h
@@ -419,7 +419,7 @@ glamor_pixmap_drm_only(PixmapPtr pixmap)
{
glamor_pixmap_private *priv = glamor_get_pixmap_private(pixmap);
- return priv && priv->type == GLAMOR_DRM_ONLY;
+ return priv->type == GLAMOR_DRM_ONLY;
}
/*
@@ -430,7 +430,7 @@ glamor_pixmap_is_memory(PixmapPtr pixmap)
{
glamor_pixmap_private *priv = glamor_get_pixmap_private(pixmap);
- return !priv || priv->type == GLAMOR_MEMORY;
+ return priv->type == GLAMOR_MEMORY;
}
/*
@@ -439,13 +439,13 @@ glamor_pixmap_is_memory(PixmapPtr pixmap)
static inline Bool
glamor_pixmap_priv_is_large(glamor_pixmap_private *priv)
{
- return priv && (priv->block_wcnt > 1 || priv->block_hcnt > 1);
+ return priv->block_wcnt > 1 || priv->block_hcnt > 1;
}
static inline Bool
glamor_pixmap_priv_is_small(glamor_pixmap_private *priv)
{
- return priv && priv->block_wcnt <= 1 && priv->block_hcnt <= 1;
+ return priv->block_wcnt <= 1 && priv->block_hcnt <= 1;
}
static inline Bool
@@ -453,7 +453,7 @@ glamor_pixmap_is_large(PixmapPtr pixmap)
{
glamor_pixmap_private *priv = glamor_get_pixmap_private(pixmap);
- return priv && glamor_pixmap_priv_is_large(priv);
+ return glamor_pixmap_priv_is_large(priv);
}
/*
* Returns TRUE if pixmap has an FBO
@@ -463,7 +463,7 @@ glamor_pixmap_has_fbo(PixmapPtr pixmap)
{
glamor_pixmap_private *priv = glamor_get_pixmap_private(pixmap);
- return priv && priv->gl_fbo == GLAMOR_FBO_NORMAL;
+ return priv->gl_fbo == GLAMOR_FBO_NORMAL;
}
static inline void
diff --git a/glamor/glamor_utils.h b/glamor/glamor_utils.h
index 0a7de82..a923b7a 100644
--- a/glamor/glamor_utils.h
+++ b/glamor/glamor_utils.h
@@ -756,8 +756,8 @@ glamor_translate_boxes(BoxPtr boxes, int nbox, int dx, int dy)
|| _depth_ == 30 \
|| _depth_ == 32)
-#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 == GLAMOR_FBO_NORMAL)
+#define GLAMOR_PIXMAP_PRIV_IS_PICTURE(pixmap_priv) (pixmap_priv->is_picture == 1)
+#define GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv) (pixmap_priv->gl_fbo == GLAMOR_FBO_NORMAL)
/**
* Borrow from uxa.
--
2.1.4
More information about the xorg-devel
mailing list