Keith Packard <[email protected]> writes:

> This makes sure the pixelization for dashed lines matches non-dashed
> lines, while also speeding them up.

This patch adds glamor_destroy_gc and requires that it be called to
avoid leaking the dash pixmap.

Unfortunately, UXA doesn't use glamor_gc_funcs, preferring to have its
own GCFuncs structure. That, of course, doesn't (currently) call
glamor_destroy_gc.

Here's an ugly kludge which checks to see if the GC will be using
glamor_destroy_gc, by testing inside of glamor_validate_gc, stashing the
current GC funcs in a local static and replacing the DestroyGC entry
with glamor_destroy_gc. This is very much UXA-specific, and only
necessary until UXA calls glamor_destroy_gc instead of miDestroyGC.

Thoughts about how to simply force UXA to be built correctly are
welcome; that would presumably be a better plan than this ugly hack.

From eac8d7c6fafbc0fa3f88122a8fb56b9d9993aa40 Mon Sep 17 00:00:00 2001
From: Keith Packard <[email protected]>
Date: Fri, 23 May 2014 10:02:20 -0700
Subject: [PATCH] glamor: Kludge-around UXA not using glamor_gc_destroy

Glamor now has a bit of work to do in DestroyGC, but UXA has it's own
GC funcs which don't (currently) call glamor_gc_destroy. Here's an
ugly hack which swaps in a working GCFuncs array at run time.

Signed-off-by: Keith Packard <[email protected]>
---
 glamor/glamor_core.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/glamor/glamor_core.c b/glamor/glamor_core.c
index 31cf3dc..3819614 100644
--- a/glamor/glamor_core.c
+++ b/glamor/glamor_core.c
@@ -326,6 +326,8 @@ GCOps glamor_gc_ops = {
     .PushPixels = glamor_push_pixels,
 };
 
+static GCFuncs glamor_fixup_gc_funcs;
+
 /**
  * uxa_validate_gc() sets the ops to glamor's implementations, which may be
  * accelerated or may sync the card and fall back to fb.
@@ -343,6 +345,18 @@ glamor_validate_gc(GCPtr gc, unsigned long changes, DrawablePtr drawable)
         fbGetRotatedPixmap(gc) = 0;
     }
 
+    /* XXX kludge alert -- check to see if our destroy_gc is going to be called,
+     * if not, try to work around that
+     */
+    if (gc->funcs->DestroyGC != glamor_destroy_gc) {
+        ErrorF("Driver not using glamor_destroy_gc, working around that");
+        if (gc->funcs->DestroyGC != miDestroyGC)
+            ErrorF("Driver also not using miDestroyGC. This may well crash or leak memory.");
+        glamor_fixup_gc_funcs = *gc->funcs;
+        glamor_fixup_gc_funcs.DestroyGC = glamor_destroy_gc;
+        gc->funcs = &glamor_fixup_gc_funcs;
+    }
+
     if (gc->fillStyle == FillTiled) {
         PixmapPtr old_tile, new_tile;
 
-- 
2.0.0.rc2

-- 
[email protected]

Attachment: pgpgHyaR9SYKc.pgp
Description: PGP signature

_______________________________________________
[email protected]: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Reply via email to