diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2015-07-26 18:22:16 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2015-07-26 18:22:16 +0100 |
commit | 50f3e9c41c6de98f917a9ddc78aabdda421f920a (patch) | |
tree | 8b00faca191c8fbfacc5310602473275c428e71f /src/sna/sna.h | |
parent | f7cb248169a2b824caca5186e0f0aaf336d9d5ed (diff) |
sna: Add a small pixmap sanity check
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'src/sna/sna.h')
-rw-r--r-- | src/sna/sna.h | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/sna/sna.h b/src/sna/sna.h index d8dc4122..5b3569e2 100644 --- a/src/sna/sna.h +++ b/src/sna/sna.h @@ -181,18 +181,29 @@ static inline WindowPtr get_root_window(ScreenPtr screen) #endif } +#if !NDEBUG +static PixmapPtr check_pixmap(PixmapPtr pixmap) +{ + assert(pixmap->refcnt >= 1); + assert(pixmap->devKind != 0xdeadbeef); + return pixmap; +} +#else +#define check_pixmap(p) p +#endif + static inline PixmapPtr get_window_pixmap(WindowPtr window) { assert(window); assert(window->drawable.type != DRAWABLE_PIXMAP); - return fbGetWindowPixmap(window); + return check_pixmap(fbGetWindowPixmap(window)); } static inline PixmapPtr get_drawable_pixmap(DrawablePtr drawable) { assert(drawable); if (drawable->type == DRAWABLE_PIXMAP) - return (PixmapPtr)drawable; + return check_pixmap((PixmapPtr)drawable); else return get_window_pixmap((WindowPtr)drawable); } |