[PATCH 2/3] Introduce CreatePixmap, allocating a header and calling screen hooks.
Jeremy Huddleston
jeremyhu at apple.com
Sat Oct 1 23:18:58 PDT 2011
This makes things look much cleaner too...
Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com>
On Oct 1, 2011, at 11:08 PM, Jamey Sharp wrote:
> This replaces AllocatePixmap, which was previously called by the screen
> hooks.
>
> Commit by Jamey Sharp and Josh Triplett.
>
> Signed-off-by: Jamey Sharp <jamey at minilop.net>
> Signed-off-by: Josh Triplett <josh at joshtriplett.org>
> ---
> Xext/shm.c | 5 +--
> composite/compalloc.c | 4 +-
> dbe/midbe.c | 18 ++++-----
> dix/dispatch.c | 6 +---
> dix/gc.c | 7 +---
> dix/glyphcurs.c | 4 +--
> dix/pixmap.c | 47 ++++++++++++++----------
> dix/window.c | 3 +-
> doc/Xserver-spec.xml | 31 +++++-----------
> exa/exa_classic.c | 24 +++++++------
> exa/exa_driver.c | 26 +++++++------
> exa/exa_glyphs.c | 12 ++-----
> exa/exa_mixed.c | 22 ++++++-----
> exa/exa_offscreen.c | 2 +-
> exa/exa_priv.h | 15 +++-----
> exa/exa_render.c | 3 +-
> fb/fb.h | 10 ++---
> fb/fb24_32.c | 2 +-
> fb/fboverlay.c | 2 +-
> fb/fbpixmap.c | 63 +++++++++-----------------------
> glx/glxcmds.c | 3 +-
> hw/dmx/dmxpixmap.c | 31 +++-------------
> hw/dmx/dmxpixmap.h | 4 +--
> hw/xfree86/common/xf86DGA.c | 2 +-
> hw/xfree86/common/xf86VGAarbiter.c | 11 +++---
> hw/xfree86/common/xf86VGAarbiterPriv.h | 3 +-
> hw/xfree86/xaa/xaaInit.c | 35 +++++++++---------
> hw/xnest/Pixmap.c | 34 ++++-------------
> hw/xnest/XNPixmap.h | 3 +-
> hw/xwin/win.h | 5 +--
> hw/xwin/winpixmap.c | 51 +++++++-------------------
> include/pixmap.h | 7 +++-
> include/scrnintstr.h | 8 +---
> mi/miarc.c | 5 +--
> mi/mibitblt.c | 8 ++---
> mi/midispcur.c | 12 +++---
> mi/miglblt.c | 4 +--
> mi/miscrinit.c | 2 +-
> miext/rootless/rootlessScreen.c | 2 +-
> miext/shadow/shadow.c | 2 +-
> render/glyph.c | 4 +--
> render/mirect.c | 3 +-
> render/render.c | 7 +---
> 43 files changed, 210 insertions(+), 342 deletions(-)
>
> diff --git a/Xext/shm.c b/Xext/shm.c
> index 5acc4e3..ee67f1b 100644
> --- a/Xext/shm.c
> +++ b/Xext/shm.c
> @@ -491,8 +491,7 @@ doShmPutImage(DrawablePtr dst, GCPtr pGC,
> if (!putGC)
> return;
>
> - pPixmap = (*dst->pScreen->CreatePixmap)(dst->pScreen, sw, sh, depth,
> - CREATE_PIXMAP_USAGE_SCRATCH);
> + pPixmap = CreatePixmap(dst->pScreen, sw, sh, depth, CREATE_PIXMAP_USAGE_SCRATCH);
> if (!pPixmap) {
> FreeScratchGC(putGC);
> return;
> @@ -1010,7 +1009,7 @@ fbShmCreatePixmap (ScreenPtr pScreen,
> {
> PixmapPtr pPixmap;
>
> - pPixmap = (*pScreen->CreatePixmap)(pScreen, 0, 0, pScreen->rootDepth, 0);
> + pPixmap = CreatePixmap(pScreen, 0, 0, pScreen->rootDepth, 0);
> if (!pPixmap)
> return NullPixmap;
>
> diff --git a/composite/compalloc.c b/composite/compalloc.c
> index 58f31c0..c6892af 100644
> --- a/composite/compalloc.c
> +++ b/composite/compalloc.c
> @@ -565,8 +565,8 @@ compNewPixmap (WindowPtr pWin, int x, int y, int w, int h)
> WindowPtr pParent = pWin->parent;
> PixmapPtr pPixmap;
>
> - pPixmap = (*pScreen->CreatePixmap) (pScreen, w, h, pWin->drawable.depth,
> - CREATE_PIXMAP_USAGE_BACKING_PIXMAP);
> + pPixmap = CreatePixmap(pScreen, w, h, pWin->drawable.depth,
> + CREATE_PIXMAP_USAGE_BACKING_PIXMAP);
>
> if (!pPixmap)
> return 0;
> diff --git a/dbe/midbe.c b/dbe/midbe.c
> index 5cbf376..8bd555e 100644
> --- a/dbe/midbe.c
> +++ b/dbe/midbe.c
> @@ -171,18 +171,18 @@ miDbeAllocBackBufferName(WindowPtr pWin, XID bufId, int swapAction)
>
> /* Get a front pixmap. */
> if (!(pDbeWindowPrivPriv->pFrontBuffer =
> - (*pScreen->CreatePixmap)(pScreen, pDbeWindowPriv->width,
> - pDbeWindowPriv->height,
> - pWin->drawable.depth, 0)))
> + CreatePixmap(pScreen, pDbeWindowPriv->width,
> + pDbeWindowPriv->height,
> + pWin->drawable.depth, 0)))
> {
> return BadAlloc;
> }
>
> /* Get a back pixmap. */
> if (!(pDbeWindowPrivPriv->pBackBuffer =
> - (*pScreen->CreatePixmap)(pScreen, pDbeWindowPriv->width,
> - pDbeWindowPriv->height,
> - pWin->drawable.depth, 0)))
> + CreatePixmap(pScreen, pDbeWindowPriv->width,
> + pDbeWindowPriv->height,
> + pWin->drawable.depth, 0)))
> {
> FreePixmap(pDbeWindowPrivPriv->pFrontBuffer);
> return BadAlloc;
> @@ -635,11 +635,9 @@ miDbePositionWindow(WindowPtr pWin, int x, int y)
> }
>
> /* Create DBE buffer pixmaps equal to size of resized window. */
> - pFrontBuffer = (*pScreen->CreatePixmap)(pScreen, width, height,
> - pWin->drawable.depth, 0);
> + pFrontBuffer = CreatePixmap(pScreen, width, height, pWin->drawable.depth, 0);
>
> - pBackBuffer = (*pScreen->CreatePixmap)(pScreen, width, height,
> - pWin->drawable.depth, 0);
> + pBackBuffer = CreatePixmap(pScreen, width, height, pWin->drawable.depth, 0);
>
> if (!pFrontBuffer || !pBackBuffer)
> {
> diff --git a/dix/dispatch.c b/dix/dispatch.c
> index 9cca8d9..202650f 100644
> --- a/dix/dispatch.c
> +++ b/dix/dispatch.c
> @@ -1403,12 +1403,9 @@ ProcCreatePixmap(ClientPtr client)
> return BadValue;
> }
> CreatePmap:
> - pMap = (PixmapPtr)(*pDraw->pScreen->CreatePixmap)
> - (pDraw->pScreen, stuff->width,
> - stuff->height, stuff->depth, 0);
> + pMap = CreatePixmap(pDraw->pScreen, stuff->width, stuff->height, stuff->depth, 0);
> if (pMap)
> {
> - pMap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
> pMap->drawable.id = stuff->pid;
> /* security creation/labeling check */
> rc = XaceHook(XACE_RESOURCE_ACCESS, client, stuff->pid, RT_PIXMAP,
> @@ -3842,7 +3839,6 @@ AddScreen(
> return -1;
> }
> pScreen->myNum = i;
> - pScreen->totalPixmapSize = 0; /* computed in CreateScratchPixmapForScreen */
> pScreen->ClipNotify = 0; /* for R4 ddx compatibility */
> pScreen->CreateScreenResources = 0;
>
> diff --git a/dix/gc.c b/dix/gc.c
> index 9a39f57..75a4aa4 100644
> --- a/dix/gc.c
> +++ b/dix/gc.c
> @@ -575,9 +575,7 @@ CreateDefaultTile (GCPtr pGC)
> w = 1;
> h = 1;
> (*pGC->pScreen->QueryBestSize)(TileShape, &w, &h, pGC->pScreen);
> - pTile = (PixmapPtr)
> - (*pGC->pScreen->CreatePixmap)(pGC->pScreen,
> - w, h, pGC->depth, 0);
> + pTile = CreatePixmap(pGC->pScreen, w, h, pGC->depth, 0);
> pgcScratch = GetScratchGC(pGC->depth, pGC->pScreen);
> if (!pTile || !pgcScratch)
> {
> @@ -915,8 +913,7 @@ CreateDefaultStipple(int screenNum)
> w = 16;
> h = 16;
> (* pScreen->QueryBestSize)(StippleShape, &w, &h, pScreen);
> - if (!(pScreen->PixmapPerDepth[0] =
> - (*pScreen->CreatePixmap)(pScreen, w, h, 1, 0)))
> + if (!(pScreen->PixmapPerDepth[0] = CreatePixmap(pScreen, w, h, 1, 0)))
> return FALSE;
> /* fill stipple with 1 */
> tmpval[0].val = GXcopy;
> diff --git a/dix/glyphcurs.c b/dix/glyphcurs.c
> index 1d7de27..27c4986 100644
> --- a/dix/glyphcurs.c
> +++ b/dix/glyphcurs.c
> @@ -95,9 +95,7 @@ ServerBitsFromGlyph(FontPtr pfont, unsigned ch, CursorMetricPtr cm, unsigned cha
> if (!pbits)
> return BadAlloc;
>
> - ppix = (PixmapPtr)(*pScreen->CreatePixmap)(pScreen, cm->width,
> - cm->height, 1,
> - CREATE_PIXMAP_USAGE_SCRATCH);
> + ppix = CreatePixmap(pScreen, cm->width, cm->height, 1, CREATE_PIXMAP_USAGE_SCRATCH);
> pGC = GetScratchGC(1, pScreen);
> if (!ppix || !pGC)
> {
> diff --git a/dix/pixmap.c b/dix/pixmap.c
> index a0f7a39..232188c 100644
> --- a/dix/pixmap.c
> +++ b/dix/pixmap.c
> @@ -59,7 +59,7 @@ GetScratchPixmapHeader(ScreenPtr pScreen, int width, int height, int depth,
> pScreen->pScratchPixmap = NULL;
> else
> /* width and height of 0 means don't allocate any pixmap data */
> - pPixmap = (*pScreen->CreatePixmap)(pScreen, 0, 0, depth, 0);
> + pPixmap = CreatePixmap(pScreen, 0, 0, depth, 0);
>
> if (pPixmap) {
> if ((*pScreen->ModifyPixmapHeader)(pPixmap, width, height, depth,
> @@ -91,11 +91,6 @@ FreeScratchPixmapHeader(PixmapPtr pPixmap)
> Bool
> CreateScratchPixmapsForScreen(int scrnum)
> {
> - unsigned int pixmap_size;
> -
> - pixmap_size = sizeof(PixmapRec) + dixPrivatesSize(PRIVATE_PIXMAP);
> - screenInfo.screens[scrnum]->totalPixmapSize = BitmapBytePad(pixmap_size * 8);
> -
> /* let it be created on first use */
> screenInfo.screens[scrnum]->pScratchPixmap = NULL;
> return TRUE;
> @@ -111,21 +106,34 @@ FreeScratchPixmapsForScreen(int scrnum)
>
> /* callable by ddx */
> PixmapPtr
> -AllocatePixmap(ScreenPtr pScreen, int pixDataSize)
> +CreatePixmap(ScreenPtr pScreen, int width, int height, int depth, unsigned usage_hint)
> {
> - PixmapPtr pPixmap;
> -
> - assert(pScreen->totalPixmapSize > 0);
> -
> - if (pScreen->totalPixmapSize > ((size_t)-1) - pixDataSize)
> - return NullPixmap;
> -
> - pPixmap = malloc(pScreen->totalPixmapSize + pixDataSize);
> + PixmapPtr pPixmap = dixAllocateObjectWithPrivates(PixmapRec, PRIVATE_PIXMAP);
> if (!pPixmap)
> - return NullPixmap;
> + return NullPixmap;
> + pPixmap->drawable.type = DRAWABLE_PIXMAP;
> + pPixmap->drawable.class = 0;
> + pPixmap->drawable.pScreen = pScreen;
> + pPixmap->drawable.depth = depth;
> + pPixmap->drawable.id = 0;
> + pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
> + pPixmap->drawable.x = 0;
> + pPixmap->drawable.y = 0;
> + pPixmap->drawable.width = width;
> + pPixmap->drawable.height = height;
> + pPixmap->refcnt = 1;
> + pPixmap->usage_hint = usage_hint;
> +
> +#ifdef COMPOSITE
> + pPixmap->screen_x = 0;
> + pPixmap->screen_y = 0;
> +#endif
> +
> + if ((*pScreen->CreatePixmap) (pPixmap))
> + return pPixmap;
>
> - dixInitPrivates(pPixmap, pPixmap + 1, PRIVATE_PIXMAP);
> - return pPixmap;
> + dixFreeObjectWithPrivates(pPixmap, PRIVATE_PIXMAP);
> + return NullPixmap;
> }
>
> /* callable by ddx */
> @@ -135,6 +143,5 @@ FreePixmap(PixmapPtr pPixmap)
> if(--pPixmap->refcnt)
> return;
> (*pPixmap->drawable.pScreen->DestroyPixmap) (pPixmap);
> - dixFiniPrivates(pPixmap, PRIVATE_PIXMAP);
> - free(pPixmap);
> + dixFreeObjectWithPrivates(pPixmap, PRIVATE_PIXMAP);
> }
> diff --git a/dix/window.c b/dix/window.c
> index 42cfef7..4d12834 100644
> --- a/dix/window.c
> +++ b/dix/window.c
> @@ -410,8 +410,7 @@ MakeRootTile(WindowPtr pWin)
> unsigned char *from, *to;
> int i, j;
>
> - pWin->background.pixmap = (*pScreen->CreatePixmap)(pScreen, 4, 4,
> - pScreen->rootDepth, 0);
> + pWin->background.pixmap = CreatePixmap(pScreen, 4, 4, pScreen->rootDepth, 0);
>
> pWin->backgroundState = BackgroundPixmap;
> pGC = GetScratchGC(pScreen->rootDepth, pScreen);
> diff --git a/doc/Xserver-spec.xml b/doc/Xserver-spec.xml
> index 4bcca7a..a609ec8 100644
> --- a/doc/Xserver-spec.xml
> +++ b/doc/Xserver-spec.xml
> @@ -326,13 +326,6 @@ These procedures are set either directly or indirectly by DDX procedures.
> Most of
> the procedures described in the remainder of this
> document are accessed through one of these structs.
> -For example, the procedure to create a pixmap
> -is attached to a ScreenRec and might be called by using the expression
> -</para>
> -<para>
> -<blockquote>
> -<programlisting>(* pScreen->CreatePixmap)(pScreen, width, height, depth).</programlisting>
> -</blockquote>
> </para>
> <para>
> All procedure pointers must be set to some routine unless noted otherwise;
> @@ -3071,20 +3064,16 @@ A bitmap is a pixmap that is one bit deep.</para>
> <para>
> <blockquote><programlisting>
>
> - PixmapPtr pScreen->CreatePixmap(pScreen, width, height, depth)
> - ScreenPtr pScreen;
> - int width, height, depth;
> -
> -</programlisting></blockquote>
> -This ScreenRec procedure must create a pixmap of the size
> -requested.
> -It must allocate a PixmapRec and fill in all of the fields.
> -The reference count field must be set to 1.
> -If width or height are zero, no space should be allocated
> -for the pixmap data, and if the implementation is using the
> -devPrivate field as a pointer to the pixmap data, it should be
> -set to NULL.
> -If successful, it returns a pointer to the new pixmap; if not, it returns NULL.
> + Bool pScreen->CreatePixmap(pPixmap)
> + PixmapPtr pPixmap;
> +
> +</programlisting></blockquote>
> +This ScreenRec procedure must initialize a pixmap.
> +It must initialize the bitsPerPixel field based on the depth field.
> +If either width or height is zero, no space should be allocated for the pixmap
> +data; in this case, if the implementation is using the devPrivate field as a
> +pointer to the pixmap data, it should leave that pointer NULL.
> +If successful, it returns TRUE; if not, it returns FALSE.
> See Xserver/fb/fbpixmap.c for the sample server implementation.</para>
> <para>
> <blockquote><programlisting>
> diff --git a/exa/exa_classic.c b/exa/exa_classic.c
> index ce37c98..a40f3aa 100644
> --- a/exa/exa_classic.c
> +++ b/exa/exa_classic.c
> @@ -52,25 +52,27 @@ ExaGetPixmapAddress(PixmapPtr p)
> * ModifyPixmapHeader() would break migration. These types of pixmaps are used
> * for scratch pixmaps, or to represent the visible screen.
> */
> -PixmapPtr
> -exaCreatePixmap_classic(ScreenPtr pScreen, int w, int h, int depth,
> - unsigned usage_hint)
> +Bool
> +exaCreatePixmap_classic(PixmapPtr pPixmap)
> {
> - PixmapPtr pPixmap;
> ExaPixmapPrivPtr pExaPixmap;
> BoxRec box;
> int bpp;
> + int w = pPixmap->drawable.width;
> + int h = pPixmap->drawable.height;
> + ScreenPtr pScreen = pPixmap->drawable.pScreen;
> + Bool ret;
> ExaScreenPriv(pScreen);
>
> if (w > 32767 || h > 32767)
> - return NullPixmap;
> + return FALSE;
>
> swap(pExaScr, pScreen, CreatePixmap);
> - pPixmap = pScreen->CreatePixmap (pScreen, w, h, depth, usage_hint);
> + ret = pScreen->CreatePixmap (pPixmap);
> swap(pExaScr, pScreen, CreatePixmap);
>
> - if (!pPixmap)
> - return NULL;
> + if (!ret)
> + return FALSE;
>
> pExaPixmap = ExaGetPixmapPriv(pPixmap);
> pExaPixmap->driverPriv = NULL;
> @@ -100,7 +102,7 @@ exaCreatePixmap_classic(ScreenPtr pScreen, int w, int h, int depth,
> swap(pExaScr, pScreen, DestroyPixmap);
> FreePixmap(pPixmap);
> swap(pExaScr, pScreen, DestroyPixmap);
> - return NULL;
> + return FALSE;
> }
>
> /* Set up damage tracking */
> @@ -112,7 +114,7 @@ exaCreatePixmap_classic(ScreenPtr pScreen, int w, int h, int depth,
> swap(pExaScr, pScreen, DestroyPixmap);
> FreePixmap(pPixmap);
> swap(pExaScr, pScreen, DestroyPixmap);
> - return NULL;
> + return FALSE;
> }
>
> DamageRegister (&pPixmap->drawable, pExaPixmap->pDamage);
> @@ -141,7 +143,7 @@ exaCreatePixmap_classic(ScreenPtr pScreen, int w, int h, int depth,
> if (pExaScr->fallback_counter)
> exaPrepareAccess(&pPixmap->drawable, EXA_PREPARE_AUX_DEST);
>
> - return pPixmap;
> + return TRUE;
> }
>
> Bool
> diff --git a/exa/exa_driver.c b/exa/exa_driver.c
> index e79875d..5b74d73 100644
> --- a/exa/exa_driver.c
> +++ b/exa/exa_driver.c
> @@ -46,25 +46,27 @@ ExaGetPixmapAddress(PixmapPtr p)
> *
> * Pixmaps are always marked as pinned, because exa has no control over them.
> */
> -PixmapPtr
> -exaCreatePixmap_driver(ScreenPtr pScreen, int w, int h, int depth,
> - unsigned usage_hint)
> +Bool
> +exaCreatePixmap_driver(PixmapPtr pPixmap)
> {
> - PixmapPtr pPixmap;
> ExaPixmapPrivPtr pExaPixmap;
> int bpp;
> + int w = pPixmap->drawable.width;
> + int h = pPixmap->drawable.height;
> + ScreenPtr pScreen = pPixmap->drawable.pScreen;
> + Bool ret;
> size_t paddedWidth, datasize;
> ExaScreenPriv(pScreen);
>
> if (w > 32767 || h > 32767)
> - return NullPixmap;
> + return FALSE;
>
> swap(pExaScr, pScreen, CreatePixmap);
> - pPixmap = pScreen->CreatePixmap(pScreen, 0, 0, depth, usage_hint);
> + ret = pScreen->CreatePixmap(pPixmap);
> swap(pExaScr, pScreen, CreatePixmap);
>
> - if (!pPixmap)
> - return NULL;
> + if (!ret)
> + return FALSE;
>
> pExaPixmap = ExaGetPixmapPriv(pPixmap);
> pExaPixmap->driverPriv = NULL;
> @@ -78,13 +80,13 @@ exaCreatePixmap_driver(ScreenPtr pScreen, int w, int h, int depth,
>
> if (pExaScr->info->CreatePixmap2) {
> int new_pitch = 0;
> - pExaPixmap->driverPriv = pExaScr->info->CreatePixmap2(pScreen, w, h, depth, usage_hint, bpp, &new_pitch);
> + pExaPixmap->driverPriv = pExaScr->info->CreatePixmap2(pScreen, w, h, pPixmap->drawable.depth, pPixmap->usage_hint, bpp, &new_pitch);
> paddedWidth = pExaPixmap->fb_pitch = new_pitch;
> }
> else {
> paddedWidth = ((w * bpp + FB_MASK) >> FB_SHIFT) * sizeof(FbBits);
> if (paddedWidth / 4 > 32767 || h > 32767)
> - return NullPixmap;
> + return FALSE;
>
> exaSetFbPitch(pExaScr, pExaPixmap, w, h, bpp);
>
> @@ -98,7 +100,7 @@ exaCreatePixmap_driver(ScreenPtr pScreen, int w, int h, int depth,
> swap(pExaScr, pScreen, DestroyPixmap);
> FreePixmap(pPixmap);
> swap(pExaScr, pScreen, DestroyPixmap);
> - return NULL;
> + return FALSE;
> }
>
> /* Allow ModifyPixmapHeader to set sys_ptr appropriately. */
> @@ -121,7 +123,7 @@ exaCreatePixmap_driver(ScreenPtr pScreen, int w, int h, int depth,
> if (pExaScr->fallback_counter)
> exaPrepareAccess(&pPixmap->drawable, EXA_PREPARE_AUX_DEST);
>
> - return pPixmap;
> + return TRUE;
> }
>
> Bool
> diff --git a/exa/exa_glyphs.c b/exa/exa_glyphs.c
> index a4d3dcc..c0917ea 100644
> --- a/exa/exa_glyphs.c
> +++ b/exa/exa_glyphs.c
> @@ -183,9 +183,7 @@ exaRealizeGlyphCaches(ScreenPtr pScreen,
> }
>
> /* Now allocate the pixmap and picture */
> - pPixmap = (*pScreen->CreatePixmap) (pScreen,
> - CACHE_PICTURE_WIDTH,
> - height, depth, 0);
> + pPixmap = CreatePixmap(pScreen, CACHE_PICTURE_WIDTH, height, depth, 0);
> if (!pPixmap)
> return FALSE;
>
> @@ -734,9 +732,7 @@ exaGlyphs (CARD8 op,
> maskFormat = a8Format;
> }
>
> - pMaskPixmap = (*pScreen->CreatePixmap) (pScreen, width, height,
> - maskFormat->depth,
> - CREATE_PIXMAP_USAGE_SCRATCH);
> + pMaskPixmap = CreatePixmap(pScreen, width, height, maskFormat->depth, CREATE_PIXMAP_USAGE_SCRATCH);
> if (!pMaskPixmap)
> return;
> component_alpha = NeedsComponent(maskFormat->format);
> @@ -763,9 +759,7 @@ exaGlyphs (CARD8 op,
> if (argbFormat)
> maskFormat = argbFormat;
>
> - pMaskPixmap = (*pScreen->CreatePixmap) (pScreen, width, height,
> - maskFormat->depth,
> - CREATE_PIXMAP_USAGE_SCRATCH);
> + pMaskPixmap = CreatePixmap(pScreen, width, height, maskFormat->depth, CREATE_PIXMAP_USAGE_SCRATCH);
> if (!pMaskPixmap)
> return;
>
> diff --git a/exa/exa_mixed.c b/exa/exa_mixed.c
> index e853ac9..2e6eea2 100644
> --- a/exa/exa_mixed.c
> +++ b/exa/exa_mixed.c
> @@ -45,25 +45,27 @@ ExaGetPixmapAddress(PixmapPtr p)
> /**
> * exaCreatePixmap() creates a new pixmap.
> */
> -PixmapPtr
> -exaCreatePixmap_mixed(ScreenPtr pScreen, int w, int h, int depth,
> - unsigned usage_hint)
> +Bool
> +exaCreatePixmap_mixed(PixmapPtr pPixmap)
> {
> - PixmapPtr pPixmap;
> ExaPixmapPrivPtr pExaPixmap;
> int bpp;
> + int w = pPixmap->drawable.width;
> + int h = pPixmap->drawable.height;
> + ScreenPtr pScreen = pPixmap->drawable.pScreen;
> + Bool ret;
> size_t paddedWidth;
> ExaScreenPriv(pScreen);
>
> if (w > 32767 || h > 32767)
> - return NullPixmap;
> + return FALSE;
>
> swap(pExaScr, pScreen, CreatePixmap);
> - pPixmap = pScreen->CreatePixmap(pScreen, 0, 0, depth, usage_hint);
> + ret = pScreen->CreatePixmap(pPixmap);
> swap(pExaScr, pScreen, CreatePixmap);
>
> - if (!pPixmap)
> - return NULL;
> + if (!ret)
> + return FALSE;
>
> pExaPixmap = ExaGetPixmapPriv(pPixmap);
> pExaPixmap->driverPriv = NULL;
> @@ -72,7 +74,7 @@ exaCreatePixmap_mixed(ScreenPtr pScreen, int w, int h, int depth,
>
> paddedWidth = ((w * bpp + FB_MASK) >> FB_SHIFT) * sizeof(FbBits);
> if (paddedWidth / 4 > 32767 || h > 32767)
> - return NullPixmap;
> + return FALSE;
>
> /* We will allocate the system pixmap later if needed. */
> pPixmap->devPrivate.ptr = NULL;
> @@ -117,7 +119,7 @@ exaCreatePixmap_mixed(ScreenPtr pScreen, int w, int h, int depth,
> if (pExaScr->fallback_counter)
> exaPrepareAccess(&pPixmap->drawable, EXA_PREPARE_AUX_DEST);
>
> - return pPixmap;
> + return TRUE;
> }
>
> Bool
> diff --git a/exa/exa_offscreen.c b/exa/exa_offscreen.c
> index a65eca1..52763bb 100644
> --- a/exa/exa_offscreen.c
> +++ b/exa/exa_offscreen.c
> @@ -493,7 +493,7 @@ ExaOffscreenDefragment (ScreenPtr pScreen)
> PixmapPtr pDstPix;
> ExaPixmapPrivPtr pExaDstPix;
>
> - pDstPix = (*pScreen->CreatePixmap) (pScreen, 0, 0, 0, 0);
> + pDstPix = CreatePixmap(pScreen, 0, 0, 0, 0);
>
> if (!pDstPix)
> return NULL;
> diff --git a/exa/exa_priv.h b/exa/exa_priv.h
> index 38ac4aa..216748e 100644
> --- a/exa/exa_priv.h
> +++ b/exa/exa_priv.h
> @@ -585,9 +585,8 @@ exaPixmapIsPinned (PixmapPtr pPix);
> extern const GCFuncs exaGCFuncs;
>
> /* exa_classic.c */
> -PixmapPtr
> -exaCreatePixmap_classic(ScreenPtr pScreen, int w, int h, int depth,
> - unsigned usage_hint);
> +Bool
> +exaCreatePixmap_classic(PixmapPtr pPixmap);
>
> Bool
> exaModifyPixmapHeader_classic(PixmapPtr pPixmap, int width, int height, int depth,
> @@ -600,9 +599,8 @@ Bool
> exaPixmapHasGpuCopy_classic(PixmapPtr pPixmap);
>
> /* exa_driver.c */
> -PixmapPtr
> -exaCreatePixmap_driver(ScreenPtr pScreen, int w, int h, int depth,
> - unsigned usage_hint);
> +Bool
> +exaCreatePixmap_driver(PixmapPtr pPixmap);
>
> Bool
> exaModifyPixmapHeader_driver(PixmapPtr pPixmap, int width, int height, int depth,
> @@ -615,9 +613,8 @@ Bool
> exaPixmapHasGpuCopy_driver(PixmapPtr pPixmap);
>
> /* exa_mixed.c */
> -PixmapPtr
> -exaCreatePixmap_mixed(ScreenPtr pScreen, int w, int h, int depth,
> - unsigned usage_hint);
> +Bool
> +exaCreatePixmap_mixed(PixmapPtr pPixmap);
>
> Bool
> exaModifyPixmapHeader_mixed(PixmapPtr pPixmap, int width, int height, int depth,
> diff --git a/exa/exa_render.c b/exa/exa_render.c
> index 6251362..4964901 100644
> --- a/exa/exa_render.c
> +++ b/exa/exa_render.c
> @@ -1105,8 +1105,7 @@ exaCreateAlphaPicture (ScreenPtr pScreen,
> return 0;
> }
>
> - pPixmap = (*pScreen->CreatePixmap) (pScreen, width, height,
> - pPictFormat->depth, 0);
> + pPixmap = CreatePixmap(pScreen, width, height, pPictFormat->depth, 0);
> if (!pPixmap)
> return 0;
> pGC = GetScratchGC (pPixmap->drawable.depth, pScreen);
> diff --git a/fb/fb.h b/fb/fb.h
> index 35fdb65..32da5ff 100644
> --- a/fb/fb.h
> +++ b/fb/fb.h
> @@ -1595,13 +1595,11 @@ fbPictureInit (ScreenPtr pScreen,
> * fbpixmap.c
> */
>
> -extern _X_EXPORT PixmapPtr
> -fbCreatePixmapBpp (ScreenPtr pScreen, int width, int height, int depth, int bpp,
> - unsigned usage_hint);
> +extern _X_EXPORT Bool
> +fbCreatePixmapBpp (PixmapPtr pPixmap, int bpp);
>
> -extern _X_EXPORT PixmapPtr
> -fbCreatePixmap (ScreenPtr pScreen, int width, int height, int depth,
> - unsigned usage_hint);
> +extern _X_EXPORT Bool
> +fbCreatePixmap (PixmapPtr pPixmap);
>
> extern _X_EXPORT void
> fbDestroyPixmap (PixmapPtr pPixmap);
> diff --git a/fb/fb24_32.c b/fb/fb24_32.c
> index 033fa46..979a3df 100644
> --- a/fb/fb24_32.c
> +++ b/fb/fb24_32.c
> @@ -543,7 +543,7 @@ fb24_32ReformatTile(PixmapPtr pOldTile, int bitsPerPixel)
> _X_UNUSED int oldXoff, oldYoff;
> _X_UNUSED int newXoff, newYoff;
>
> - pNewTile = pScreen->CreatePixmap(pScreen, pOldTile->drawable.width,
> + pNewTile = CreatePixmap(pScreen, pOldTile->drawable.width,
> pOldTile->drawable.height,
> pOldTile->drawable.depth,
> pOldTile->usage_hint);
> diff --git a/fb/fboverlay.c b/fb/fboverlay.c
> index 38c38f8..746edf4 100644
> --- a/fb/fboverlay.c
> +++ b/fb/fboverlay.c
> @@ -134,7 +134,7 @@ fbOverlayCreateScreenResources(ScreenPtr pScreen)
> pbits = pScrPriv->layer[i].u.init.pbits;
> width = pScrPriv->layer[i].u.init.width;
> depth = pScrPriv->layer[i].u.init.depth;
> - pPixmap = (*pScreen->CreatePixmap)(pScreen, 0, 0, depth, 0);
> + pPixmap = CreatePixmap(pScreen, 0, 0, depth, 0);
> if (!pPixmap)
> return FALSE;
> if (!(*pScreen->ModifyPixmapHeader)(pPixmap, pScreen->width,
> diff --git a/fb/fbpixmap.c b/fb/fbpixmap.c
> index 4045ee0..f135109 100644
> --- a/fb/fbpixmap.c
> +++ b/fb/fbpixmap.c
> @@ -28,75 +28,46 @@
>
> #include "fb.h"
>
> -PixmapPtr
> -fbCreatePixmapBpp (ScreenPtr pScreen, int width, int height, int depth, int bpp,
> - unsigned usage_hint)
> +Bool
> +fbCreatePixmapBpp (PixmapPtr pPixmap, int bpp)
> {
> - PixmapPtr pPixmap;
> size_t datasize;
> size_t paddedWidth;
> - int adjust;
> - int base;
>
> - paddedWidth = ((width * bpp + FB_MASK) >> FB_SHIFT) * sizeof (FbBits);
> - if (paddedWidth / 4 > 32767 || height > 32767)
> - return NullPixmap;
> - datasize = height * paddedWidth;
> - base = pScreen->totalPixmapSize;
> - adjust = 0;
> - if (base & 7)
> - adjust = 8 - (base & 7);
> - datasize += adjust;
> + paddedWidth = ((pPixmap->drawable.width * bpp + FB_MASK) >> FB_SHIFT) * sizeof (FbBits);
> + if (paddedWidth / 4 > 32767 || pPixmap->drawable.height > 32767)
> + return FALSE;
> + datasize = pPixmap->drawable.height * paddedWidth;
> #ifdef FB_DEBUG
> datasize += 2 * paddedWidth;
> #endif
> - pPixmap = AllocatePixmap(pScreen, datasize);
> - if (!pPixmap)
> - return NullPixmap;
> - pPixmap->drawable.type = DRAWABLE_PIXMAP;
> - pPixmap->drawable.class = 0;
> - pPixmap->drawable.pScreen = pScreen;
> - pPixmap->drawable.depth = depth;
> pPixmap->drawable.bitsPerPixel = bpp;
> - pPixmap->drawable.id = 0;
> - pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
> - pPixmap->drawable.x = 0;
> - pPixmap->drawable.y = 0;
> - pPixmap->drawable.width = width;
> - pPixmap->drawable.height = height;
> pPixmap->devKind = paddedWidth;
> - pPixmap->refcnt = 1;
> - pPixmap->devPrivate.ptr = (pointer) ((char *)pPixmap + base + adjust);
> + pPixmap->devPrivate.ptr = malloc(datasize);
> + if (!pPixmap->devPrivate.ptr)
> + return FALSE;
>
> #ifdef FB_DEBUG
> pPixmap->devPrivate.ptr = (void *) ((char *) pPixmap->devPrivate.ptr + paddedWidth);
> fbInitializeDrawable (&pPixmap->drawable);
> #endif
>
> -#ifdef COMPOSITE
> - pPixmap->screen_x = 0;
> - pPixmap->screen_y = 0;
> -#endif
> -
> - pPixmap->usage_hint = usage_hint;
> -
> - return pPixmap;
> + return TRUE;
> }
>
> -PixmapPtr
> -fbCreatePixmap (ScreenPtr pScreen, int width, int height, int depth,
> - unsigned usage_hint)
> +Bool
> +fbCreatePixmap (PixmapPtr pPixmap)
> {
> - int bpp;
> - bpp = BitsPerPixel (depth);
> - if (bpp == 32 && depth <= 24)
> - bpp = fbGetScreenPrivate(pScreen)->pix32bpp;
> - return fbCreatePixmapBpp (pScreen, width, height, depth, bpp, usage_hint);
> + int bpp = BitsPerPixel (pPixmap->drawable.depth);
> + if (bpp == 32 && pPixmap->drawable.depth <= 24)
> + bpp = fbGetScreenPrivate(pPixmap->drawable.pScreen)->pix32bpp;
> + return fbCreatePixmapBpp (pPixmap, bpp);
> }
>
> void
> fbDestroyPixmap (PixmapPtr pPixmap)
> {
> + free(pPixmap->devPrivate.ptr);
> }
>
> #define ADDRECT(reg,r,fr,rx1,ry1,rx2,ry2) \
> diff --git a/glx/glxcmds.c b/glx/glxcmds.c
> index d5b764f..483d571 100644
> --- a/glx/glxcmds.c
> +++ b/glx/glxcmds.c
> @@ -1334,8 +1334,7 @@ DoCreatePbuffer(ClientPtr client, int screenNum, XID fbconfigId,
> return err;
>
> __glXenterServer(GL_FALSE);
> - pPixmap = (*pGlxScreen->pScreen->CreatePixmap) (pGlxScreen->pScreen,
> - width, height, config->rgbBits, 0);
> + pPixmap = CreatePixmap(pGlxScreen->pScreen, width, height, config->rgbBits, 0);
> __glXleaveServer(GL_FALSE);
>
> /* Assign the pixmap the same id as the pbuffer and add it as a
> diff --git a/hw/dmx/dmxpixmap.c b/hw/dmx/dmxpixmap.c
> index 19f3ac7..b585365 100644
> --- a/hw/dmx/dmxpixmap.c
> +++ b/hw/dmx/dmxpixmap.c
> @@ -79,13 +79,10 @@ void dmxBECreatePixmap(PixmapPtr pPixmap)
> }
> }
>
> -/** Create a pixmap for \a pScreen with the specified \a width, \a
> - * height, and \a depth. */
> -PixmapPtr dmxCreatePixmap(ScreenPtr pScreen, int width, int height, int depth,
> - unsigned usage_hint)
> +Bool dmxCreatePixmap(PixmapPtr pPixmap)
> {
> + ScreenPtr pScreen = pPixmap->drawable.pScreen;
> DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
> - PixmapPtr pPixmap;
> int bpp;
> dmxPixPrivPtr pPixPriv;
>
> @@ -96,27 +93,11 @@ PixmapPtr dmxCreatePixmap(ScreenPtr pScreen, int width, int height, int depth,
> #endif
>
> /* Create pixmap on back-end server */
> - if (depth == 24) bpp = 32;
> - else bpp = depth;
> -
> - pPixmap = AllocatePixmap(pScreen, 0);
> - if (!pPixmap)
> - return NullPixmap;
> + bpp = pPixmap->drawable.depth;
> + if (bpp == 24) bpp = 32;
>
> - pPixmap->drawable.type = DRAWABLE_PIXMAP;
> - pPixmap->drawable.class = 0;
> - pPixmap->drawable.pScreen = pScreen;
> - pPixmap->drawable.depth = depth;
> pPixmap->drawable.bitsPerPixel = bpp;
> - pPixmap->drawable.id = 0;
> - pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
> - pPixmap->drawable.x = 0;
> - pPixmap->drawable.y = 0;
> - pPixmap->drawable.width = width;
> - pPixmap->drawable.height = height;
> - pPixmap->devKind = PixmapBytePad(width, bpp);
> - pPixmap->refcnt = 1;
> - pPixmap->usage_hint = usage_hint;
> + pPixmap->devKind = PixmapBytePad(pPixmap->drawable.width, bpp);
>
> pPixPriv = DMX_GET_PIXMAP_PRIV(pPixmap);
> pPixPriv->pixmap = (Pixmap)0;
> @@ -131,7 +112,7 @@ PixmapPtr dmxCreatePixmap(ScreenPtr pScreen, int width, int height, int depth,
> DMX_WRAP(CreatePixmap, dmxCreatePixmap, dmxScreen, pScreen);
> #endif
>
> - return pPixmap;
> + return TRUE;
> }
>
> /** Destroy the pixmap on the back-end server. */
> diff --git a/hw/dmx/dmxpixmap.h b/hw/dmx/dmxpixmap.h
> index 0bb19c3..b1e883f 100644
> --- a/hw/dmx/dmxpixmap.h
> +++ b/hw/dmx/dmxpixmap.h
> @@ -48,9 +48,7 @@ typedef struct _dmxPixPriv {
>
> extern Bool dmxInitPixmap(ScreenPtr pScreen);
>
> -extern PixmapPtr dmxCreatePixmap(ScreenPtr pScreen,
> - int width, int height, int depth,
> - unsigned usage_hint);
> +extern Bool dmxCreatePixmap(PixmapPtr pPixmap);
> extern void dmxDestroyPixmap(PixmapPtr pPixmap);
> extern RegionPtr dmxBitmapToRegion(PixmapPtr pPixmap);
>
> diff --git a/hw/xfree86/common/xf86DGA.c b/hw/xfree86/common/xf86DGA.c
> index 067902b..189ef65 100644
> --- a/hw/xfree86/common/xf86DGA.c
> +++ b/hw/xfree86/common/xf86DGA.c
> @@ -431,7 +431,7 @@ xf86SetDGAMode(
> }
>
> if(pMode->flags & DGA_PIXMAP_AVAILABLE) {
> - if((pPix = (*pScreen->CreatePixmap)(pScreen, 0, 0, pMode->depth, 0))) {
> + if((pPix = CreatePixmap(pScreen, 0, 0, pMode->depth, 0))) {
> (*pScreen->ModifyPixmapHeader)(pPix,
> pMode->pixmapWidth, pMode->pixmapHeight,
> pMode->depth, pMode->bitsPerPixel,
> diff --git a/hw/xfree86/common/xf86VGAarbiter.c b/hw/xfree86/common/xf86VGAarbiter.c
> index 658cf4e..b12192c 100644
> --- a/hw/xfree86/common/xf86VGAarbiter.c
> +++ b/hw/xfree86/common/xf86VGAarbiter.c
> @@ -367,18 +367,19 @@ VGAarbiterClearToBackground (
> SCREEN_EPILOG (ClearToBackground, VGAarbiterClearToBackground);
> }
>
> -static PixmapPtr
> -VGAarbiterCreatePixmap(ScreenPtr pScreen, int w, int h, int depth, unsigned usage_hint)
> +static Bool
> +VGAarbiterCreatePixmap(PixmapPtr pPixmap)
> {
> - PixmapPtr pPix;
> + ScreenPtr pScreen = pPixmap->drawable.pScreen;
> + Bool ret;
>
> SCREEN_PROLOG ( CreatePixmap);
> VGAGet(pScreen);
> - pPix = (*pScreen->CreatePixmap) (pScreen, w, h, depth, usage_hint);
> + ret = (*pScreen->CreatePixmap) (pPixmap);
> VGAPut();
> SCREEN_EPILOG (CreatePixmap, VGAarbiterCreatePixmap);
>
> - return pPix;
> + return ret;
> }
>
> static Bool
> diff --git a/hw/xfree86/common/xf86VGAarbiterPriv.h b/hw/xfree86/common/xf86VGAarbiterPriv.h
> index 2db2045..86ca210 100644
> --- a/hw/xfree86/common/xf86VGAarbiterPriv.h
> +++ b/hw/xfree86/common/xf86VGAarbiterPriv.h
> @@ -154,8 +154,7 @@ static void VGAarbiterCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg,
> RegionPtr prgnSrc);
> static void VGAarbiterClearToBackground (WindowPtr pWin, int x, int y, int w,
> int h, Bool generateExposures);
> -static PixmapPtr VGAarbiterCreatePixmap(ScreenPtr pScreen, int w, int h,
> - int depth, unsigned int usage_hint);
> +static Bool VGAarbiterCreatePixmap(PixmapPtr pPixmap);
> static Bool VGAarbiterCreateGC(GCPtr pGC);
> static Bool VGAarbiterSaveScreen(ScreenPtr pScreen, Bool unblank);
> static void VGAarbiterStoreColors (ColormapPtr pmap, int ndef, xColorItem
> diff --git a/hw/xfree86/xaa/xaaInit.c b/hw/xfree86/xaa/xaaInit.c
> index e889468..5770a81 100644
> --- a/hw/xfree86/xaa/xaaInit.c
> +++ b/hw/xfree86/xaa/xaaInit.c
> @@ -33,8 +33,7 @@ static void XAAGetImage(DrawablePtr pDrawable, int sx, int sy, int w, int h,
> char *pdstLine);
> static void XAAGetSpans(DrawablePtr pDrawable, int wMax, DDXPointPtr ppt,
> int *pwidth, int nspans, char *pdstStart);
> -static PixmapPtr XAACreatePixmap(ScreenPtr pScreen, int w, int h, int depth,
> - unsigned usage_hint);
> +static Bool XAACreatePixmap(PixmapPtr pPixmap);
> static void XAADestroyPixmap(PixmapPtr pPixmap);
> static Bool XAAEnterVT (int index, int flags);
> static void XAALeaveVT (int index, int flags);
> @@ -299,8 +298,7 @@ XAAPixmapBPP (ScreenPtr pScreen, int depth)
> DestroyPixmapProcPtr destroyPixmap;
>
> XAA_SCREEN_PROLOGUE (pScreen, CreatePixmap);
> - pPix = (*pScreen->CreatePixmap) (pScreen, 1, 1, depth,
> - CREATE_PIXMAP_USAGE_SCRATCH);
> + pPix = CreatePixmap(pScreen, 1, 1, depth, CREATE_PIXMAP_USAGE_SCRATCH);
> XAA_SCREEN_EPILOGUE (pScreen, CreatePixmap, XAACreatePixmap);
> if (!pPix)
> return 0;
> @@ -330,24 +328,27 @@ XAAInitializeOffscreenDepths (ScreenPtr pScreen)
> }
> }
>
> -static PixmapPtr
> -XAACreatePixmap(ScreenPtr pScreen, int w, int h, int depth, unsigned usage_hint)
> +static Bool
> +XAACreatePixmap(PixmapPtr pPix)
> {
> + ScreenPtr pScreen = pPix->drawable.pScreen;
> XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen);
> ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
> XAAPixmapPtr pPriv;
> - PixmapPtr pPix = NULL;
> + Bool ret;
> + int w = pPix->drawable.width;
> + int h = pPix->drawable.height;
> int size = w * h;
>
> if (w > 32767 || h > 32767)
> - return NullPixmap;
> + return FALSE;
>
> if (!infoRec->offscreenDepthsInitialized)
> XAAInitializeOffscreenDepths (pScreen);
>
> if(pScrn->vtSema &&
> - (usage_hint != CREATE_PIXMAP_USAGE_GLYPH_PICTURE) &&
> - (infoRec->offscreenDepths & (1 << (depth - 1))) &&
> + (pPix->usage_hint != CREATE_PIXMAP_USAGE_GLYPH_PICTURE) &&
> + (infoRec->offscreenDepths & (1 << (pPix->drawable.depth - 1))) &&
> (size >= MIN_OFFPIX_SIZE) && !SwitchedOut &&
> (!infoRec->maxOffPixWidth || (w <= infoRec->maxOffPixWidth)) &&
> (!infoRec->maxOffPixHeight || (h <= infoRec->maxOffPixHeight)) )
> @@ -379,10 +380,10 @@ XAACreatePixmap(ScreenPtr pScreen, int w, int h, int depth, unsigned usage_hint)
> }
>
> XAA_SCREEN_PROLOGUE (pScreen, CreatePixmap);
> - pPix = (*pScreen->CreatePixmap) (pScreen, 0, 0, depth, usage_hint);
> + ret = (*pScreen->CreatePixmap) (pPix);
> XAA_SCREEN_EPILOGUE (pScreen, CreatePixmap, XAACreatePixmap);
>
> - if (!pPix) {
> + if (!ret) {
> free(pLink);
> xf86FreeOffscreenArea(area);
> goto BAILOUT;
> @@ -393,8 +394,6 @@ XAACreatePixmap(ScreenPtr pScreen, int w, int h, int depth, unsigned usage_hint)
> pPriv = XAA_GET_PIXMAP_PRIVATE(pPix);
> pPix->drawable.x = area->box.x1;
> pPix->drawable.y = area->box.y1;
> - pPix->drawable.width = w;
> - pPix->drawable.height = h;
> pPix->drawable.bitsPerPixel = pScrn->bitsPerPixel;
> pPix->devKind = pScreenPix->devKind;
> pPix->devPrivate.ptr = pScreenPix->devPrivate.ptr;
> @@ -407,14 +406,14 @@ XAACreatePixmap(ScreenPtr pScreen, int w, int h, int depth, unsigned usage_hint)
> pLink->next = infoRec->OffscreenPixmaps;
> pLink->pPix = pPix;
> infoRec->OffscreenPixmaps = pLink;
> - return pPix;
> + return TRUE;
> }
> BAILOUT:
> XAA_SCREEN_PROLOGUE (pScreen, CreatePixmap);
> - pPix = (*pScreen->CreatePixmap) (pScreen, w, h, depth, usage_hint);
> + ret = (*pScreen->CreatePixmap) (pPix);
> XAA_SCREEN_EPILOGUE (pScreen, CreatePixmap, XAACreatePixmap);
>
> - if(pPix) {
> + if(ret) {
> pPriv = XAA_GET_PIXMAP_PRIVATE(pPix);
> pPriv->flags = 0;
> pPriv->offscreenArea = NULL;
> @@ -423,7 +422,7 @@ BAILOUT:
> pPriv->flags |= SHARED_PIXMAP;
> }
>
> - return pPix;
> + return ret;
> }
>
> static void
> diff --git a/hw/xnest/Pixmap.c b/hw/xnest/Pixmap.c
> index 735f754..164a475 100644
> --- a/hw/xnest/Pixmap.c
> +++ b/hw/xnest/Pixmap.c
> @@ -34,38 +34,20 @@ is" without express or implied warranty.
>
> DevPrivateKeyRec xnestPixmapPrivateKeyRec;
>
> -PixmapPtr
> -xnestCreatePixmap(ScreenPtr pScreen, int width, int height, int depth,
> - unsigned usage_hint)
> +Bool
> +xnestCreatePixmap(PixmapPtr pPixmap)
> {
> - PixmapPtr pPixmap;
> -
> - pPixmap = AllocatePixmap(pScreen, 0);
> - if (!pPixmap)
> - return NullPixmap;
> - pPixmap->drawable.type = DRAWABLE_PIXMAP;
> - pPixmap->drawable.class = 0;
> - pPixmap->drawable.depth = depth;
> - pPixmap->drawable.bitsPerPixel = depth;
> - pPixmap->drawable.id = 0;
> - pPixmap->drawable.x = 0;
> - pPixmap->drawable.y = 0;
> - pPixmap->drawable.width = width;
> - pPixmap->drawable.height = height;
> - pPixmap->drawable.pScreen = pScreen;
> - pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
> - pPixmap->refcnt = 1;
> - pPixmap->devKind = PixmapBytePad(width, depth);
> - pPixmap->usage_hint = usage_hint;
> - if (width && height)
> + pPixmap->drawable.bitsPerPixel = pPixmap->drawable.depth;
> + pPixmap->devKind = PixmapBytePad(pPixmap->drawable.width, pPixmap->drawable.depth);
> + if (pPixmap->drawable.width && pPixmap->drawable.height)
> xnestPixmapPriv(pPixmap)->pixmap =
> XCreatePixmap(xnestDisplay,
> - xnestDefaultWindows[pScreen->myNum],
> - width, height, depth);
> + xnestDefaultWindows[pPixmap->drawable.pScreen->myNum],
> + pPixmap->drawable.width, pPixmap->drawable.height, pPixmap->drawable.depth);
> else
> xnestPixmapPriv(pPixmap)->pixmap = 0;
>
> - return pPixmap;
> + return TRUE;
> }
>
> void
> diff --git a/hw/xnest/XNPixmap.h b/hw/xnest/XNPixmap.h
> index 5816cef..189ce28 100644
> --- a/hw/xnest/XNPixmap.h
> +++ b/hw/xnest/XNPixmap.h
> @@ -29,8 +29,7 @@ typedef struct {
>
> #define xnestSharePixmap(pPixmap) ((pPixmap)->refcnt++)
>
> -PixmapPtr xnestCreatePixmap(ScreenPtr pScreen, int width, int height,
> - int depth, unsigned usage_hint);
> +Bool xnestCreatePixmap(PixmapPtr pPixmap);
> void xnestDestroyPixmap(PixmapPtr pPixmap);
> RegionPtr xnestPixmapToRegion(PixmapPtr pPixmap);
>
> diff --git a/hw/xwin/win.h b/hw/xwin/win.h
> index 9bee9b6..453cf7b 100644
> --- a/hw/xwin/win.h
> +++ b/hw/xwin/win.h
> @@ -1066,9 +1066,8 @@ winSetEngineFunctionsPrimaryDD (ScreenPtr pScreen);
> * winpixmap.c
> */
>
> -PixmapPtr
> -winCreatePixmapNativeGDI (ScreenPtr pScreen, int width, int height, int depth,
> - unsigned usage_hint);
> +Bool
> +winCreatePixmapNativeGDI (PixmapPtr pPixmap);
>
> Bool
> winDestroyPixmapNativeGDI (PixmapPtr pPixmap);
> diff --git a/hw/xwin/winpixmap.c b/hw/xwin/winpixmap.c
> index 8bd8e34..c323182 100644
> --- a/hw/xwin/winpixmap.c
> +++ b/hw/xwin/winpixmap.c
> @@ -54,73 +54,48 @@ winCopyRotatePixmapNativeGDI (PixmapPtr psrcPix, PixmapPtr *ppdstPix,
>
> /* See Porting Layer Definition - p. 34 */
> /* See mfb/mfbpixmap.c - mfbCreatePixmap() */
> -PixmapPtr
> -winCreatePixmapNativeGDI (ScreenPtr pScreen,
> - int iWidth, int iHeight,
> - int iDepth, unsigned usage_hint)
> +Bool
> +winCreatePixmapNativeGDI (PixmapPtr pPixmap)
> {
> winPrivPixmapPtr pPixmapPriv = NULL;
> - PixmapPtr pPixmap = NULL;
> -
> - /* Allocate pixmap memory */
> - pPixmap = AllocatePixmap (pScreen, 0);
> - if (!pPixmap)
> - {
> - ErrorF ("winCreatePixmapNativeGDI () - Couldn't allocate a pixmap\n");
> - return NullPixmap;
> - }
>
> #if CYGDEBUG
> winDebug ("winCreatePixmap () - w %d h %d d %d uh %d bw %d\n",
> - iWidth, iHeight, iDepth, usage_hint,
> - PixmapBytePad (iWidth, iDepth));
> + pPixmap->drawable.width, pPixmap->drawable.height, pPixmap->drawable.depth, pPixmap->drawable.usage_hint,
> + PixmapBytePad (pPixmap->drawable.width, pPixmap->drawable.depth));
> #endif
>
> /* Setup pixmap values */
> - pPixmap->drawable.type = DRAWABLE_PIXMAP;
> - pPixmap->drawable.class = 0;
> - pPixmap->drawable.pScreen = pScreen;
> - pPixmap->drawable.depth = iDepth;
> - pPixmap->drawable.bitsPerPixel = BitsPerPixel (iDepth);
> - pPixmap->drawable.id = 0;
> - pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
> - pPixmap->drawable.x = 0;
> - pPixmap->drawable.y = 0;
> - pPixmap->drawable.width = iWidth;
> - pPixmap->drawable.height = iHeight;
> - pPixmap->devKind = 0;
> - pPixmap->refcnt = 1;
> - pPixmap->devPrivate.ptr = NULL;
> - pPixmap->usage_hint = usage_hint;
> -
> - /* Pixmap privates are allocated by AllocatePixmap */
> + pPixmap->drawable.bitsPerPixel = BitsPerPixel (pPixmap->drawable.depth);
> +
> + /* Pixmap privates are already allocated */
> pPixmapPriv = winGetPixmapPriv (pPixmap);
>
> /* Initialize pixmap privates */
> pPixmapPriv->hBitmap = NULL;
> pPixmapPriv->hdcSelected = NULL;
> pPixmapPriv->pbBits = NULL;
> - pPixmapPriv->dwScanlineBytes = PixmapBytePad (iWidth, iDepth);
> + pPixmapPriv->dwScanlineBytes = PixmapBytePad (pPixmap->drawable.width, pPixmap->drawable.depth);
>
> /* Check for zero width or height pixmaps */
> - if (iWidth == 0 || iHeight == 0)
> + if (pPixmap->drawable.width == 0 || pPixmap->drawable.height == 0)
> {
> /* Don't allocate a real pixmap, just set fields and return */
> - return pPixmap;
> + return TRUE;
> }
>
> /* Create a DIB for the pixmap */
> - pPixmapPriv->hBitmap = winCreateDIBNativeGDI (iWidth, iHeight, iDepth,
> + pPixmapPriv->hBitmap = winCreateDIBNativeGDI (pPixmap->drawable.width, pPixmap->drawable.height, pPixmap->drawable.depth,
> &pPixmapPriv->pbBits,
> (BITMAPINFO **) &pPixmapPriv->pbmih);
>
> #if CYGDEBUG
> winDebug ("winCreatePixmap () - Created a pixmap %08x, %dx%dx%d, for " \
> "screen: %08x\n",
> - pPixmapPriv->hBitmap, iWidth, iHeight, iDepth, pScreen);
> + pPixmapPriv->hBitmap, pPixmap->drawable.width, pPixmap->drawable.height, pPixmap->drawable.depth, pPixmap->drawable.pScreen);
> #endif
>
> - return pPixmap;
> + return TRUE;
> }
>
>
> diff --git a/include/pixmap.h b/include/pixmap.h
> index 014a111..41ebc46 100644
> --- a/include/pixmap.h
> +++ b/include/pixmap.h
> @@ -109,9 +109,12 @@ extern _X_EXPORT Bool CreateScratchPixmapsForScreen(
> extern _X_EXPORT void FreeScratchPixmapsForScreen(
> int /*scrnum*/);
>
> -extern _X_EXPORT PixmapPtr AllocatePixmap(
> +extern _X_EXPORT PixmapPtr CreatePixmap(
> ScreenPtr /*pScreen*/,
> - int /*pixDataSize*/);
> + int /*width*/,
> + int /*height*/,
> + int /*depth*/,
> + unsigned /*usage_hint*/);
>
> extern _X_EXPORT void FreePixmap(
> PixmapPtr /*pPixmap*/);
> diff --git a/include/scrnintstr.h b/include/scrnintstr.h
> index 927ed04..8542bdc 100644
> --- a/include/scrnintstr.h
> +++ b/include/scrnintstr.h
> @@ -203,12 +203,8 @@ typedef void (* ClipNotifyProcPtr)(
> /* pixmap will contain a glyph */
> #define CREATE_PIXMAP_USAGE_GLYPH_PICTURE 3
>
> -typedef PixmapPtr (* CreatePixmapProcPtr)(
> - ScreenPtr /*pScreen*/,
> - int /*width*/,
> - int /*height*/,
> - int /*depth*/,
> - unsigned /*usage_hint*/);
> +typedef Bool (* CreatePixmapProcPtr)(
> + PixmapPtr /*pPixmap*/);
>
> typedef void (* DestroyPixmapProcPtr)(
> PixmapPtr /*pPixmap*/);
> diff --git a/mi/miarc.c b/mi/miarc.c
> index fdbf2f4..82771d5 100644
> --- a/mi/miarc.c
> +++ b/mi/miarc.c
> @@ -1050,9 +1050,8 @@ miPolyArc(DrawablePtr pDraw, GCPtr pGC, int narcs, xArc *parcs)
>
> /* allocate a 1 bit deep pixmap of the appropriate size, and
> * validate it */
> - pDrawTo = (DrawablePtr)(*pDraw->pScreen->CreatePixmap)
> - (pDraw->pScreen, pixmapWidth, pixmapHeight, 1,
> - CREATE_PIXMAP_USAGE_SCRATCH);
> + pDrawTo = &CreatePixmap(pDraw->pScreen, pixmapWidth, pixmapHeight, 1,
> + CREATE_PIXMAP_USAGE_SCRATCH)->drawable;
> if (!pDrawTo)
> {
> FreeScratchGC(pGCTo);
> diff --git a/mi/mibitblt.c b/mi/mibitblt.c
> index 0944da1..4680d70 100644
> --- a/mi/mibitblt.c
> +++ b/mi/mibitblt.c
> @@ -408,8 +408,7 @@ miOpqStipDrawable(DrawablePtr pDraw, GCPtr pGC, RegionPtr prgnSrc,
> xRectangle rect;
> RegionPtr prgnSrcClip;
>
> - pPixmap = (*pDraw->pScreen->CreatePixmap)
> - (pDraw->pScreen, w + srcx, h, 1,
> + pPixmap = CreatePixmap (pDraw->pScreen, w + srcx, h, 1,
> CREATE_PIXMAP_USAGE_SCRATCH);
> if (!pPixmap)
> return;
> @@ -654,9 +653,8 @@ miGetImage( DrawablePtr pDraw, int sx, int sy, int w, int h,
> pGC = GetScratchGC(depth, pDraw->pScreen);
> if (!pGC)
> return;
> - pPixmap = (*pDraw->pScreen->CreatePixmap)
> - (pDraw->pScreen, w, 1, depth,
> - CREATE_PIXMAP_USAGE_SCRATCH);
> + pPixmap = CreatePixmap(pDraw->pScreen, w, 1, depth,
> + CREATE_PIXMAP_USAGE_SCRATCH);
> if (!pPixmap)
> {
> FreeScratchGC(pGC);
> diff --git a/mi/midispcur.c b/mi/midispcur.c
> index a2c5162..19b15fe 100644
> --- a/mi/midispcur.c
> +++ b/mi/midispcur.c
> @@ -210,9 +210,9 @@ miDCRealize (ScreenPtr pScreen, CursorPtr pCursor)
>
> pPriv->sourceBits = 0;
> pPriv->maskBits = 0;
> - pPixmap = (*pScreen->CreatePixmap) (pScreen, pCursor->bits->width,
> - pCursor->bits->height, 32,
> - CREATE_PIXMAP_USAGE_SCRATCH);
> + pPixmap = CreatePixmap(pScreen, pCursor->bits->width,
> + pCursor->bits->height, 32,
> + CREATE_PIXMAP_USAGE_SCRATCH);
> if (!pPixmap)
> {
> free((pointer) pPriv);
> @@ -244,13 +244,13 @@ miDCRealize (ScreenPtr pScreen, CursorPtr pCursor)
> }
> pPriv->pPicture = 0;
> #endif
> - pPriv->sourceBits = (*pScreen->CreatePixmap) (pScreen, pCursor->bits->width, pCursor->bits->height, 1, 0);
> + pPriv->sourceBits = CreatePixmap(pScreen, pCursor->bits->width, pCursor->bits->height, 1, 0);
> if (!pPriv->sourceBits)
> {
> free((pointer) pPriv);
> return NULL;
> }
> - pPriv->maskBits = (*pScreen->CreatePixmap) (pScreen, pCursor->bits->width, pCursor->bits->height, 1, 0);
> + pPriv->maskBits = CreatePixmap(pScreen, pCursor->bits->width, pCursor->bits->height, 1, 0);
> if (!pPriv->maskBits)
> {
> FreePixmap(pPriv->sourceBits);
> @@ -456,7 +456,7 @@ miDCSaveUnderCursor (DeviceIntPtr pDev, ScreenPtr pScreen,
> if (pSave)
> FreePixmap(pSave);
> pBuffer->pSave = pSave =
> - (*pScreen->CreatePixmap) (pScreen, w, h, pScreen->rootDepth, 0);
> + CreatePixmap(pScreen, w, h, pScreen->rootDepth, 0);
> if (!pSave)
> return FALSE;
> }
> diff --git a/mi/miglblt.c b/mi/miglblt.c
> index dcf08da..41c5355 100644
> --- a/mi/miglblt.c
> +++ b/mi/miglblt.c
> @@ -121,9 +121,7 @@ miPolyGlyphBlt(
> height = FONTMAXBOUNDS(pfont,ascent) +
> FONTMAXBOUNDS(pfont,descent);
>
> - pPixmap = (*pDrawable->pScreen->CreatePixmap)(pDrawable->pScreen,
> - width, height, 1,
> - CREATE_PIXMAP_USAGE_SCRATCH);
> + pPixmap = CreatePixmap(pDrawable->pScreen, width, height, 1, CREATE_PIXMAP_USAGE_SCRATCH);
> if (!pPixmap)
> return;
>
> diff --git a/mi/miscrinit.c b/mi/miscrinit.c
> index 7562cd2..7421e1b 100644
> --- a/mi/miscrinit.c
> +++ b/mi/miscrinit.c
> @@ -151,7 +151,7 @@ miCreateScreenResources(ScreenPtr pScreen)
> /* create a pixmap with no data, then redirect it to point to
> * the screen
> */
> - pPixmap = (*pScreen->CreatePixmap)(pScreen, 0, 0, pScreen->rootDepth, 0);
> + pPixmap = CreatePixmap(pScreen, 0, 0, pScreen->rootDepth, 0);
> if (!pPixmap)
> return FALSE;
>
> diff --git a/miext/rootless/rootlessScreen.c b/miext/rootless/rootlessScreen.c
> index 0801e72..974e752 100644
> --- a/miext/rootless/rootlessScreen.c
> +++ b/miext/rootless/rootlessScreen.c
> @@ -85,7 +85,7 @@ RootlessUpdateScreenPixmap(ScreenPtr pScreen)
>
> pPix = (*pScreen->GetScreenPixmap)(pScreen);
> if (pPix == NULL) {
> - pPix = (*pScreen->CreatePixmap)(pScreen, 0, 0, pScreen->rootDepth, 0);
> + pPix = CreatePixmap(pScreen, 0, 0, pScreen->rootDepth, 0);
> (*pScreen->SetScreenPixmap)(pPix);
> }
>
> diff --git a/miext/shadow/shadow.c b/miext/shadow/shadow.c
> index 3230fa4..5dbdd86 100644
> --- a/miext/shadow/shadow.c
> +++ b/miext/shadow/shadow.c
> @@ -236,7 +236,7 @@ shadowInit(ScreenPtr pScreen, ShadowUpdateProc update, ShadowWindowProc window)
> {
> PixmapPtr pPixmap;
>
> - pPixmap = pScreen->CreatePixmap(pScreen, pScreen->width, pScreen->height,
> + pPixmap = CreatePixmap(pScreen, pScreen->width, pScreen->height,
> pScreen->rootDepth, 0);
> if (!pPixmap)
> return FALSE;
> diff --git a/render/glyph.c b/render/glyph.c
> index aae93d4..e9a85d1 100644
> --- a/render/glyph.c
> +++ b/render/glyph.c
> @@ -652,9 +652,7 @@ miGlyphs (CARD8 op,
> return;
> width = extents.x2 - extents.x1;
> height = extents.y2 - extents.y1;
> - pMaskPixmap = (*pScreen->CreatePixmap) (pScreen, width, height,
> - maskFormat->depth,
> - CREATE_PIXMAP_USAGE_SCRATCH);
> + pMaskPixmap = CreatePixmap(pScreen, width, height, maskFormat->depth, CREATE_PIXMAP_USAGE_SCRATCH);
> if (!pMaskPixmap)
> return;
> component_alpha = NeedsComponent(maskFormat->format);
> diff --git a/render/mirect.c b/render/mirect.c
> index 0ccc8e4..d2fa21a 100644
> --- a/render/mirect.c
> +++ b/render/mirect.c
> @@ -135,8 +135,7 @@ miCompositeRects (CARD8 op,
> if (!rgbaFormat)
> goto bail1;
>
> - pPixmap = (*pScreen->CreatePixmap) (pScreen, 1, 1, rgbaFormat->depth,
> - CREATE_PIXMAP_USAGE_SCRATCH);
> + pPixmap = CreatePixmap(pScreen, 1, 1, rgbaFormat->depth, CREATE_PIXMAP_USAGE_SCRATCH);
> if (!pPixmap)
> goto bail2;
>
> diff --git a/render/render.c b/render/render.c
> index a46c774..376c17c 100644
> --- a/render/render.c
> +++ b/render/render.c
> @@ -1160,9 +1160,7 @@ ProcRenderAddGlyphs (ClientPtr client)
> goto bail;
> }
>
> - pDstPix = (pScreen->CreatePixmap) (pScreen,
> - width, height, depth,
> - CREATE_PIXMAP_USAGE_GLYPH_PICTURE);
> + pDstPix = CreatePixmap(pScreen, width, height, depth, CREATE_PIXMAP_USAGE_GLYPH_PICTURE);
>
> if (!pDstPix)
> {
> @@ -1584,8 +1582,7 @@ ProcRenderCreateCursor (ClientPtr client)
> free(mskbits);
> return BadImplementation;
> }
> - pPixmap = (*pScreen->CreatePixmap) (pScreen, width, height, 32,
> - CREATE_PIXMAP_USAGE_SCRATCH);
> + pPixmap = CreatePixmap(pScreen, width, height, 32, CREATE_PIXMAP_USAGE_SCRATCH);
> if (!pPixmap)
> {
> free(argbbits);
> --
> 1.7.5.4
>
> _______________________________________________
> xorg-devel at lists.x.org: X.Org development
> Archives: http://lists.x.org/archives/xorg-devel
> Info: http://lists.x.org/mailman/listinfo/xorg-devel
>
---
Jeremy Huddleston
Rebuild Sudan
- Board of Directors
- http://www.rebuildsudan.org
Berkeley Foundation for Opportunities in Information Technology
- Advisory Board
- http://www.bfoit.org
More information about the xorg-devel
mailing list