[PATCH 5/5] exa: delay malloc for "mixed"
Maarten Maathuis
madman2003 at gmail.com
Wed Aug 5 11:12:04 PDT 2009
---
exa/exa.c | 12 +++++++++++-
exa/exa_migration_mixed.c | 4 ++++
exa/exa_mixed.c | 11 ++---------
3 files changed, 17 insertions(+), 10 deletions(-)
diff --git a/exa/exa.c b/exa/exa.c
index 32a1c3e..5b473c9 100644
--- a/exa/exa.c
+++ b/exa/exa.c
@@ -333,8 +333,18 @@ ExaDoPrepareAccess(DrawablePtr pDrawable, int index)
pExaScr->access[index].pixmap = pPixmap;
pExaScr->access[index].count = 1;
- if (!offscreen)
+ if (!offscreen) {
+ /* Do we need to allocate our system buffer? */
+ if ((pExaScr->info->flags & EXA_HANDLES_PIXMAPS) && (pExaScr->info->flags & EXA_MIXED_PIXMAPS)) {
+ if (!pExaPixmap->sys_ptr) {
+ pExaPixmap->sys_ptr = malloc(pExaPixmap->sys_pitch * pDrawable->height);
+ if (!pExaPixmap->sys_ptr)
+ FatalError("EXA: malloc failed\n");
+ pPixmap->devPrivate.ptr = pExaPixmap->sys_ptr;
+ }
+ }
return FALSE;
+ }
exaWaitSync (pDrawable->pScreen);
diff --git a/exa/exa_migration_mixed.c b/exa/exa_migration_mixed.c
index 49b1934..9ebc483 100644
--- a/exa/exa_migration_mixed.c
+++ b/exa/exa_migration_mixed.c
@@ -107,6 +107,10 @@ exaCreateDriverPixmap_mixed(PixmapPtr pPixmap)
if (!w || !h)
goto finish;
+ /* we do not malloc memory by default. */
+ if (!sys_buffer)
+ goto finish;
+
if (!pExaScr->info->UploadToScreen)
goto fallback;
diff --git a/exa/exa_mixed.c b/exa/exa_mixed.c
index 9090078..463c2f1 100644
--- a/exa/exa_mixed.c
+++ b/exa/exa_mixed.c
@@ -81,17 +81,10 @@ exaCreatePixmap_mixed(ScreenPtr pScreen, int w, int h, int depth,
datasize = h * paddedWidth;
- /* Allocate temporary pixmap. */
- pExaPixmap->sys_ptr = malloc(datasize);
+ /* We will allocate the system pixmap later if needed. */
+ pExaPixmap->sys_ptr = NULL;
pExaPixmap->sys_pitch = paddedWidth;
- if (!pExaPixmap->sys_ptr) {
- swap(pExaScr, pScreen, DestroyPixmap);
- pScreen->DestroyPixmap (pPixmap);
- swap(pExaScr, pScreen, DestroyPixmap);
- return NULL;
- }
-
pExaPixmap->area = NULL;
pExaPixmap->offscreen = FALSE;
/* Avoid ModifyPixmapHeader freeing the sys_ptr. */
--
1.6.4
More information about the xorg-devel
mailing list