summaryrefslogtreecommitdiff
path: root/dix
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2009-09-29 11:49:09 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2009-09-30 10:00:07 +1000
commit6ffda5aae75272fabdc27d6f693ae827be119e95 (patch)
tree2ccf117a3972e9e83aa38278b25f1a6744abce0d /dix
parentad5c0d9efa47476ed5cf75c82265c73919e468b4 (diff)
dix/glx/composite: consolidate visual resize in one place.
The previous code was copied and in both cases incorrectly fixed up the colormaps after resizing the visuals, this patch consolidates the visual resize + colormaps fixups in one place. This version also consolidates the vid allocation for the DepthPtr inside the function. I'm not 100% sure colormap.[ch] is the correct place for this but visuals are mostly created in fb and I know thats not the place to be resizing them. Fixes fd.o bug #19470. Signed-off-by: Dave Airlie <airlied@redhat.com> Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'dix')
-rw-r--r--dix/colormap.c64
1 files changed, 64 insertions, 0 deletions
diff --git a/dix/colormap.c b/dix/colormap.c
index a5a006e60..d702b0204 100644
--- a/dix/colormap.c
+++ b/dix/colormap.c
@@ -2690,3 +2690,67 @@ IsMapInstalled(Colormap map, WindowPtr pWin)
xfree(pmaps);
return (found);
}
+
+struct colormap_lookup_data {
+ ScreenPtr pScreen;
+ VisualPtr visuals;
+};
+
+static void _colormap_find_resource(pointer value, XID id,
+ pointer cdata)
+{
+ struct colormap_lookup_data *cmap_data = cdata;
+ VisualPtr visuals = cmap_data->visuals;
+ ScreenPtr pScreen = cmap_data->pScreen;
+ ColormapPtr cmap = value;
+ int j;
+
+ j = cmap->pVisual - pScreen->visuals;
+ cmap->pVisual = &visuals[j];
+}
+
+/* something has realloced the visuals, instead of breaking
+ ABI fix it up here - glx and compsite did this wrong */
+Bool
+ResizeVisualArray(ScreenPtr pScreen, int new_visual_count,
+ DepthPtr depth)
+{
+ struct colormap_lookup_data cdata;
+ int numVisuals;
+ VisualPtr visuals;
+ XID *vids, vid;
+ int first_new_vid, first_new_visual, i;
+
+ first_new_vid = depth->numVids;
+ first_new_visual = pScreen->numVisuals;
+
+ vids = xrealloc(depth->vids, (depth->numVids + new_visual_count) * sizeof(XID));
+ if (!vids)
+ return FALSE;
+
+ /* its realloced now no going back if we fail the next one */
+ depth->vids = vids;
+
+ numVisuals = pScreen->numVisuals + new_visual_count;
+ visuals = xrealloc(pScreen->visuals, numVisuals * sizeof(VisualRec));
+ if (!visuals) {
+ return FALSE;
+ }
+
+ cdata.visuals = visuals;
+ cdata.pScreen = pScreen;
+ FindClientResourcesByType(serverClient, RT_COLORMAP, _colormap_find_resource, &cdata);
+
+ pScreen->visuals = visuals;
+
+ for (i = 0; i < new_visual_count; i++) {
+ vid = FakeClientID(0);
+ pScreen->visuals[first_new_visual + i].vid = vid;
+ vids[first_new_vid + i] = vid;
+ }
+
+ depth->numVids += new_visual_count;
+ pScreen->numVisuals += new_visual_count;
+
+ return TRUE;
+}