1Upstream-Status: Pending
2
3From: Benjamin Deering
4Subject: orrery crashing X
5Date: Thursday, September 2, 2010 - 5:25 pm
6Link: http://kerneltrap.org/mailarchive/openmoko-community/2010/9/3/13218
7
8diff -uNr orrery.orig//orrery.c orrery/orrery.c
9--- orrery.orig//orrery.c	2009-11-30 06:59:44.000000000 +0100
10+++ orrery/orrery.c	2010-11-15 22:33:17.000000000 +0100
11@@ -1238,12 +1238,44 @@
12     }
13     currentEntry = currentEntry->forwardPointer;
14   }
15-  if (nDarkGreyPoints > 0)
16-    gdk_draw_points(pixmap, darkGreyGC, darkGreyPoints, nDarkGreyPoints);
17-  if (nGreyPoints > 0)
18-    gdk_draw_points(pixmap, greyGC, greyPoints, nGreyPoints);
19-  if (nWhitePoints > 0)
20-    gdk_draw_points(pixmap, whiteGC, whitePoints, nWhitePoints);
21+  GdkPixbuf* starDrawingBuf = gdk_pixbuf_get_from_drawable( NULL,
22+                                                            pixmap,
23+                                                            gdk_colormap_get_system()
24+                                                            , 0, 0, 0, 0, displayWidth, displayHeight);
25+  g_assert (gdk_pixbuf_get_bits_per_sample (starDrawingBuf) == 8);
26+  guchar* p;
27+  int rowstride = gdk_pixbuf_get_rowstride (starDrawingBuf);
28+  guchar* pixels = gdk_pixbuf_get_pixels (starDrawingBuf);
29+  int n_channels = gdk_pixbuf_get_n_channels (starDrawingBuf);
30+  GdkGCValues starGCval;
31+  GdkColor starColor;
32+  int pointNum;
33+  gdk_gc_get_values(darkGreyGC, &starGCval);
34+  gdk_colormap_query_color( gdk_gc_get_colormap(darkGreyGC),starGCval.foreground.pixel, &starColor );
35+  for( pointNum = 0; pointNum < nDarkGreyPoints; pointNum++) {
36+    p = pixels + darkGreyPoints[pointNum].y * rowstride + darkGreyPoints[pointNum].x * n_channels;
37+    p[0] = starColor.red & 0xff;
38+    p[1] = starColor.green & 0xff;
39+    p[2] = starColor.blue & 0xff;
40+  }
41+  gdk_gc_get_values(greyGC, &starGCval);
42+  gdk_colormap_query_color( gdk_gc_get_colormap(greyGC), starGCval.foreground.pixel, &starColor );
43+  for( pointNum = 0; pointNum < nGreyPoints; pointNum++) {
44+    p = pixels + greyPoints[pointNum].y * rowstride + greyPoints[pointNum].x * n_channels;
45+    p[0] = starColor.red & 0xff;
46+    p[1] = starColor.green & 0xff;
47+    p[2] = starColor.blue & 0xff;
48+  }
49+  gdk_gc_get_values(whiteGC, &starGCval);
50+  gdk_colormap_query_color( gdk_gc_get_colormap(whiteGC), starGCval.foreground.pixel, &starColor );
51+  for( pointNum = 0; pointNum < nWhitePoints; pointNum++) {
52+    p = pixels + whitePoints[pointNum].y * rowstride + whitePoints[pointNum].x * n_channels;
53+    p[0] = starColor.red & 0xff;
54+    p[1] = starColor.green & 0xff;
55+    p[2] = starColor.blue & 0xff;
56+  }
57+  gdk_draw_pixbuf ( pixmap , NULL , starDrawingBuf,
58+            0, 0, 0, 0, displayWidth, displayHeight, GDK_RGB_DITHER_NORMAL, 0, 0 ) ;
59 }
60
61 void makeTimeString(char *string)
62