[cairo-commit] roadster/src mainwindow.c, 1.53, 1.54 map.c, 1.56, 1.57 map.h, 1.28, 1.29 map_draw_cairo.c, 1.30, 1.31 map_draw_gdk.c, 1.29, 1.30 map_draw_gdk.h, 1.2, 1.3 map_math.c, 1.4, 1.5 map_tilemanager.c, 1.3, 1.4

Ian McIntosh commit at pdx.freedesktop.org
Mon Oct 17 23:40:22 PDT 2005


Committed by: ian

Update of /cvs/cairo/roadster/src
In directory gabe:/tmp/cvs-serv1638/src

Modified Files:
	mainwindow.c map.c map.h map_draw_cairo.c map_draw_gdk.c 
	map_draw_gdk.h map_math.c map_tilemanager.c 
Log Message:
	* src/mainwindow.c:
	* src/map.c:
	* src/map_draw_cairo.c: Add Debug menu toggle for GDK/Cairo.
	* src/map_draw_gdk.c: Remove dead code.


Index: mainwindow.c
===================================================================
RCS file: /cvs/cairo/roadster/src/mainwindow.c,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -d -r1.53 -r1.54
--- mainwindow.c	18 Oct 2005 03:05:25 -0000	1.53
+++ mainwindow.c	18 Oct 2005 06:40:19 -0000	1.54
@@ -1880,6 +1880,12 @@
 	}
 }
 
+void mainwindow_on_use_aa_rendering_activate(GtkMenuItem *menuitem, gpointer user_data)
+{
+	map_set_antialiased(g_MainWindow.pMap, !map_get_antialiased(g_MainWindow.pMap));
+	mainwindow_draw_map(DRAWFLAG_ALL);
+}
+
 #ifdef ROADSTER_DEAD_CODE
 /*
 static gboolean on_searchbox_key_press_event(GtkWidget *widget, GdkEventKey *event, gpointer user_data)

Index: map.c
===================================================================
RCS file: /cvs/cairo/roadster/src/map.c,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -d -r1.56 -r1.57
--- map.c	18 Oct 2005 03:05:25 -0000	1.56
+++ map.c	18 Oct 2005 06:40:20 -0000	1.57
@@ -227,8 +227,6 @@
 	scenemanager_clear(pMap->pSceneManager);
 	scenemanager_set_screen_dimensions(pMap->pSceneManager, pRenderMetrics->nWindowWidth, pRenderMetrics->nWindowHeight);
 
-	gint nRenderMode = RENDERMODE_FAST; //RENDERMODE_PRETTY; // 
-
 #ifdef ENABLE_LABELS_WHILE_DRAGGING
 	nDrawFlags |= DRAWFLAG_LABELS;	// always turn on labels
 #endif
@@ -238,7 +236,7 @@
 	scenemanager_claim_polygon(pMap->pSceneManager, aPoints, 4);
 #endif
 
-	if(nRenderMode == RENDERMODE_FAST) {
+	if(pMap->bAntiAliased == FALSE) {
 		// 
 		if(nDrawFlags & DRAWFLAG_GEOMETRY) {
 			map_draw_gdk(pMap, pTilesArray, pRenderMetrics, pTargetPixmap, DRAWFLAG_GEOMETRY);
@@ -248,7 +246,7 @@
 		// Call cairo for finishing the scene
 		map_draw_cairo(pMap, pTilesArray, pRenderMetrics, pTargetPixmap, nDrawFlags);
 	}
-	else {	// nRenderMode == RENDERMODE_PRETTY
+	else {
 		map_draw_cairo(pMap, pTilesArray, pRenderMetrics, pTargetPixmap, nDrawFlags);
 	}
 
@@ -605,6 +603,15 @@
 	memcpy(pReturnMapRect, &(renderMetrics.rWorldBoundingBox), sizeof(maprect_t));
 }
 
+gboolean map_get_antialiased(const map_t* pMap)
+{
+	return pMap->bAntiAliased;
+}
+
+void map_set_antialiased(map_t* pMap, gboolean bAntiAliased)
+{
+	pMap->bAntiAliased = bAntiAliased;
+}
 
 #ifdef ROADSTER_DEAD_CODE
 /*

Index: map.h
===================================================================
RCS file: /cvs/cairo/roadster/src/map.h,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- map.h	18 Oct 2005 03:05:25 -0000	1.28
+++ map.h	18 Oct 2005 06:40:20 -0000	1.29
@@ -207,6 +207,8 @@
 	GtkWidget*		pTargetWidget;
 	scenemanager_t* pSceneManager;
 
+	gboolean bAntiAliased;
+
 	// data
 	GArray			*pTracksArray;
 //	maplayer_data_t	*apLayerData[ MAP_NUM_OBJECT_TYPES + 1 ];
@@ -334,4 +336,7 @@
 void map_get_visible_maprect(const map_t* pMap, maprect_t* pReturnMapRect);
 gdouble map_get_altitude(const map_t* pMap, EDistanceUnits eUnit);
 
+gboolean map_get_antialiased(const map_t* pMap);
+void map_set_antialiased(map_t* pMap, gboolean bAntiAliased);
+
 #endif

Index: map_draw_cairo.c
===================================================================
RCS file: /cvs/cairo/roadster/src/map_draw_cairo.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- map_draw_cairo.c	18 Oct 2005 03:05:25 -0000	1.30
+++ map_draw_cairo.c	18 Oct 2005 06:40:20 -0000	1.31
@@ -71,6 +71,8 @@
 //static void map_draw_cairo_locationset(map_t* pMap, cairo_t *pCairo, rendermetrics_t* pRenderMetrics, locationset_t* pLocationSet, GPtrArray* pLocationsArray);
 //static void map_draw_cairo_locationselection(map_t* pMap, cairo_t *pCairo, rendermetrics_t* pRenderMetrics, GPtrArray* pLocationSelectionArray);
 
+static void map_draw_cairo_layer_fill(map_t* pMap, cairo_t* pCairo, rendermetrics_t* pRenderMetrics, maplayerstyle_t* pLayerStyle);
+
 // Draw labels for a single line/polygon
 static void map_draw_cairo_road_label(map_t* pMap, cairo_t *pCairo, maplayerstyle_t* pLayerStyle, rendermetrics_t* pRenderMetrics, GArray* pMapPointsArray, const gchar* pszLabel);
 static void map_draw_cairo_polygon_label(map_t* pMap, cairo_t *pCairo, maplayerstyle_t* pLayerStyle, rendermetrics_t* pRenderMetrics, GArray* pMapPointsArray, maprect_t* pBoundingRect, const gchar* pszLabel);
@@ -96,6 +98,11 @@
 	cairo_rel_move_to(pCairo, -(fLabelWidth+2), -UNDERLINE_RELIEF);
 }
 
+void map_draw_cairo_set_rgb(cairo_t* pCairo, color_t* pColor)
+{
+	cairo_set_source_rgba(pCairo, pColor->fRed, pColor->fGreen, pColor->fBlue, 1.0);
+}
+
 void map_draw_cairo_set_rgba(cairo_t* pCairo, color_t* pColor)
 {
 	cairo_set_source_rgba(pCairo, pColor->fRed, pColor->fGreen, pColor->fBlue, pColor->fAlpha);
@@ -115,6 +122,8 @@
 	cairo_surface_t *pSurface = cairo_xlib_surface_create (dpy, drawable, visual, width, height);
 	cairo_t* pCairo = cairo_create (pSurface);
 
+//    cairo_set_antialias(pCairo, CAIRO_ANTIALIAS_GRAY);	// CAIRO_ANTIALIAS_DEFAULT, CAIRO_ANTIALIAS_NONE, CAIRO_ANTIALIAS_GRAY, CAIRO_ANTIALIAS_SUBPIXEL
+
 #ifdef ENABLE_DRAW_MAP_SCALE
 
 #	define MAP_SCALE_WIDTH		(55)	// these are just estimates
@@ -131,12 +140,7 @@
 	// 2.1. Settings for all rendering
 	cairo_set_fill_rule(pCairo, CAIRO_FILL_RULE_WINDING);
 
-	// 2.2. Draw Background
-	if(nDrawFlags & DRAWFLAG_GEOMETRY) {
-		map_draw_cairo_background(pMap, pCairo);
-	}
-
-	// 2.3. Render Layers
+	// 2.2. Render Layers
 	if(pMap->pLayersArray->len == 0) {
 		map_draw_cairo_message(pMap, pCairo, "The style XML file couldn't be loaded");
 	}
@@ -156,10 +160,6 @@
 												 pTile->apMapObjectArrays[pLayer->nDataSource],               // data
 												 pLayer->paStylesAtZoomLevels[nStyleZoomLevel-1]);       // style
 					}
-
-//                     map_draw_cairo_layer_roads(pMap, pCairo, pRenderMetrics,
-//                                                pMap->apLayerData[pLayer->nDataSource]->pRoadsArray,
-//                                                pLayer->paStylesAtZoomLevels[nStyleZoomLevel-1]);
 				}
 			}
 			else if(pLayer->nDrawType == MAP_LAYER_RENDERTYPE_POLYGONS) {
@@ -171,9 +171,6 @@
 												 pTile->apMapObjectArrays[pLayer->nDataSource],               // data
 												 pLayer->paStylesAtZoomLevels[nStyleZoomLevel-1]);       // style
 					}
-//                     map_draw_cairo_layer_polygons(pMap, pCairo, pRenderMetrics,
-//                                                   pMap->apLayerData[pLayer->nDataSource]->pRoadsArray,
-//                                                   pLayer->paStylesAtZoomLevels[nStyleZoomLevel-1]);
 				}
 			}
 			else if(pLayer->nDrawType == MAP_LAYER_RENDERTYPE_LINE_LABELS) {
@@ -198,6 +195,11 @@
 					}
 				}
 			}
+			else if(pLayer->nDrawType == MAP_LAYER_RENDERTYPE_FILL) {
+				if(nDrawFlags & DRAWFLAG_GEOMETRY) {
+					map_draw_cairo_layer_fill(pMap, pCairo, pRenderMetrics, pLayer->paStylesAtZoomLevels[nStyleZoomLevel-1]);       // style
+				}
+			}
 		}
 	}
 
@@ -220,6 +222,28 @@
 	TIMER_END(maptimer, "END RENDER MAP (cairo)");
 }
 
+// ==============================================
+// Begin map_draw_cairo_* functions
+// ==============================================
+
+// useful for filling the screen with a color.  not much else.
+void map_draw_cairo_layer_fill(map_t* pMap, cairo_t* pCairo, rendermetrics_t* pRenderMetrics, maplayerstyle_t* pLayerStyle)
+{
+	if(pLayerStyle->pGlyphFill != NULL) {
+	}
+	else {
+		// Simple color fill
+		map_draw_cairo_set_rgb(pCairo, &(pLayerStyle->clrPrimary));
+	}
+
+	cairo_rectangle(pCairo, 0,0,pMap->MapDimensions.uWidth, pMap->MapDimensions.uHeight);
+	cairo_fill(pCairo);
+
+	if(pLayerStyle->pGlyphFill != NULL) {
+		// Restore fill style
+	}
+}
+
 // When there are no layers defined, we call this to show an error message in-window
 void map_draw_cairo_message(map_t* pMap, cairo_t *pCairo, gchar* pszMessage)
 {
@@ -240,21 +264,6 @@
 	cairo_restore(pCairo);
 }
 
-// ==============================================
-// Begin map_draw_cairo_* functions
-// ==============================================
-
-// Background
-static void map_draw_cairo_background(map_t* pMap, cairo_t *pCairo)
-{
-	// XXX: Don't hardcode background color
-	cairo_save(pCairo);
-		cairo_set_source_rgb (pCairo, 239/255.0, 239/255.0, 230/255.0);
-		cairo_rectangle(pCairo, 0, 0, pMap->MapDimensions.uWidth, pMap->MapDimensions.uHeight);
-		cairo_fill(pCairo);
-	cairo_restore(pCairo);
-}
-
 //
 // Draw a whole layer of line labels
 //

Index: map_draw_gdk.c
===================================================================
RCS file: /cvs/cairo/roadster/src/map_draw_gdk.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- map_draw_gdk.c	18 Oct 2005 03:05:25 -0000	1.29
+++ map_draw_gdk.c	18 Oct 2005 06:40:20 -0000	1.30
@@ -49,8 +49,6 @@
 static void map_draw_gdk_layer_polygons(map_t* pMap, GdkPixmap* pPixmap, rendermetrics_t* pRenderMetrics, GPtrArray* pRoadsArray, maplayerstyle_t* pLayerStyle);
 static void map_draw_gdk_layer_lines(map_t* pMap, GdkPixmap* pPixmap, rendermetrics_t* pRenderMetrics, GPtrArray* pRoadsArray, maplayerstyle_t* pLayerStyle);
 
-static void map_draw_gdk_layer_fill(map_t* pMap, GdkPixmap* pPixmap, rendermetrics_t* pRenderMetrics, maplayerstyle_t* pLayerStyle);
-
 static void map_draw_gdk_locations(map_t* pMap, GdkPixmap* pPixmap, rendermetrics_t* pRenderMetrics);
 static void map_draw_gdk_locationset(map_t* pMap, GdkPixmap* pPixmap, rendermetrics_t* pRenderMetrics, locationset_t* pLocationSet, GPtrArray* pLocationsArray);
 
@@ -155,7 +153,7 @@
 }
 
 // useful for filling the screen with a color.  not much else.
-static void map_draw_gdk_layer_fill(map_t* pMap, GdkPixmap* pPixmap, rendermetrics_t* pRenderMetrics, maplayerstyle_t* pLayerStyle)
+void map_draw_gdk_layer_fill(map_t* pMap, GdkPixmap* pPixmap, rendermetrics_t* pRenderMetrics, maplayerstyle_t* pLayerStyle)
 {
 	GdkGC* pGC = pMap->pTargetWidget->style->fg_gc[GTK_WIDGET_STATE(pMap->pTargetWidget)];
 
@@ -336,8 +334,6 @@
 	for(iString=0 ; iString<pRoadsArray->len ; iString++) {
 		pRoad = g_ptr_array_index(pRoadsArray, iString);
 
-
-
 		EOverlapType eOverlapType = map_rect_a_overlap_type_with_rect_b(&(pRoad->rWorldBoundingBox), &(pRenderMetrics->rWorldBoundingBox));
 		if(eOverlapType == OVERLAP_NONE) {
 			continue;
@@ -420,84 +416,3 @@
 		}
 	}
 }
-
-#ifdef ROADSTER_DEAD_CODE
-//             GdkColor clr1;
-//             clr1.red = 255/255.0 * 65535;
-//             clr1.green = 80/255.0 * 65535;
-//             clr1.blue = 80/255.0 * 65535;
-//             GdkColor clr2;
-//             clr2.red = 255/255.0 * 65535;
-//             clr2.green = 255/255.0 * 65535;
-//             clr2.blue = 255/255.0 * 65535;
-//
-//             gdk_gc_set_rgb_fg_color(pGC, &clr1);
-//             gdk_draw_rectangle(pPixmap, pGC, TRUE,
-//                         nX-3,nY-3,
-//                         7, 7);
-//             gdk_gc_set_rgb_fg_color(pGC, &clr2);
-//             gdk_draw_rectangle(pPixmap, pGC, TRUE,
-//                         nX-2,nY-2,
-//                         5, 5);
-//             gdk_gc_set_rgb_fg_color(pGC, &clr1);
-//             gdk_draw_rectangle(pPixmap, pGC, TRUE,
-//                         nX-1,nY-1,
-//                         3, 3);
-
-// static void map_draw_gdk_tracks(map_t* pMap, GdkPixmap* pPixmap, rendermetrics_t* pRenderMetrics)
-// {
-//     gint i;
-//     for(i=0 ; i<pMap->pTracksArray->len ; i++) {
-//         gint hTrack = &g_array_index(pMap->pTracksArray, gint, i);
-//
-//         GdkColor clr;
-//         clr.red = (gint)(0.5 * 65535.0);
-//         clr.green = (gint)(0.5 * 65535.0);
-//         clr.blue = (gint)(1.0 * 65535.0);
-//         gdk_gc_set_rgb_fg_color(pMap->pTargetWidget->style->fg_gc[GTK_WIDGET_STATE(pMap->pTargetWidget)], &clr);
-//
-//         pointstring_t* pPointString = track_get_pointstring(hTrack);
-//         if(pPointString == NULL) continue;
-//
-//         if(pPointString->pPointsArray->len >= 2) {
-//
-//             if(pPointString->pPointsArray->len > MAX_GDK_LINE_SEGMENTS) {
-//                 //g_warning("not drawing track with > %d segments\n", MAX_GDK_LINE_SEGMENTS);
-//                 continue;
-//             }
-//
-//             GdkPoint aPoints[MAX_GDK_LINE_SEGMENTS];
-//
-//             gdouble fMaxLat = MIN_LATITUDE; // init to the worst possible value so first point will override
-//             gdouble fMinLat = MAX_LATITUDE;
-//             gdouble fMaxLon = MIN_LONGITUDE;
-//             gdouble fMinLon = MAX_LONGITUDE;
-//
-//             gint iPoint;
-//             for(iPoint=0 ; iPoint<pPointString->pPointsArray->len ; iPoint++) {
-//                 mappoint_t* pPoint = g_ptr_array_index(pPointString->pPointsArray, iPoint);
-//
-//                 // find extents
-//                 fMaxLat = max(pPoint->fLatitude,fMaxLat);
-//                 fMinLat = min(pPoint->fLatitude,fMinLat);
-//                 fMaxLon = max(pPoint->fLongitude,fMaxLon);
-//                 fMinLon = min(pPoint->fLongitude,fMinLon);
-//
-//                 aPoints[iPoint].x = (gint)SCALE_X(pRenderMetrics, pPoint->fLongitude);
-//                 aPoints[iPoint].y = (gint)SCALE_Y(pRenderMetrics, pPoint->fLatitude);
-//             }
-//
-//             // rectangle overlap test
-//             if(fMaxLat < pRenderMetrics->rWorldBoundingBox.A.fLatitude
-//                || fMaxLon < pRenderMetrics->rWorldBoundingBox.A.fLongitude
-//                || fMinLat > pRenderMetrics->rWorldBoundingBox.B.fLatitude
-//                || fMinLon > pRenderMetrics->rWorldBoundingBox.B.fLongitude)
-//             {
-//                 continue;   // not visible
-//             }
-//
-//             gdk_draw_lines(pPixmap, pMap->pTargetWidget->style->fg_gc[GTK_WIDGET_STATE(pMap->pTargetWidget)], aPoints, pPointString->pPointsArray->len);
-//         }
-//     }
-// }
-#endif

Index: map_draw_gdk.h
===================================================================
RCS file: /cvs/cairo/roadster/src/map_draw_gdk.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- map_draw_gdk.h	5 Oct 2005 06:09:36 -0000	1.2
+++ map_draw_gdk.h	18 Oct 2005 06:40:20 -0000	1.3
@@ -29,4 +29,6 @@
 void map_draw_gdk(map_t* pMap, GPtrArray* pTiles, rendermetrics_t* pRenderMetrics, GdkPixmap* pPixmap, gint nDrawFlags);
 void map_draw_gdk_xor_rect(map_t* pMap, GdkDrawable* pTargetDrawable, screenrect_t* pRect);
 
+void map_draw_gdk_layer_fill(map_t* pMap, GdkPixmap* pPixmap, rendermetrics_t* pRenderMetrics, maplayerstyle_t* pLayerStyle);
+
 #endif

Index: map_math.c
===================================================================
RCS file: /cvs/cairo/roadster/src/map_math.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- map_math.c	18 Oct 2005 03:05:25 -0000	1.4
+++ map_math.c	18 Oct 2005 06:40:20 -0000	1.5
@@ -166,9 +166,15 @@
 	return sqrt((fDeltaX*fDeltaX) + (fDeltaY*fDeltaY));
 }
 
+#define POINTS_EQUAL_ERROR	(0.0002)
+
 gboolean map_points_equal(mappoint_t* p1, mappoint_t* p2)
 {
-	return( p1->fLatitude == p2->fLatitude && p1->fLongitude == p2->fLongitude);
+	return( 
+		ABS(p1->fLatitude - p2->fLatitude) < POINTS_EQUAL_ERROR &&
+		ABS(p1->fLongitude - p2->fLongitude) < POINTS_EQUAL_ERROR);
+
+	//return( p1->fLatitude == p2->fLatitude && p1->fLongitude == p2->fLongitude);
 }
 
 gboolean map_math_maprects_equal(maprect_t* pA, maprect_t* pB)

Index: map_tilemanager.c
===================================================================
RCS file: /cvs/cairo/roadster/src/map_tilemanager.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- map_tilemanager.c	18 Oct 2005 03:05:25 -0000	1.3
+++ map_tilemanager.c	18 Oct 2005 06:40:20 -0000	1.4
@@ -232,7 +232,9 @@
 		" LEFT JOIN RoadName ON (%s.RoadNameID=RoadName.ID)"
 		" WHERE"
 		" MBRIntersects(GeomFromText('Polygon((%s %s,%s %s,%s %s,%s %s,%s %s))'), Coordinates)"
-		" ORDER BY TypeID, RoadNameID, X(StartPoint(Coordinates))",		// XXX: add sorting by MBR x or y?
+
+		// this improves our lazy stitching success rate
+		" ORDER BY TypeID, RoadNameID, X(StartPoint(Coordinates))",
 
 		//pszRoadTableName,	 no ID column 
 		pszRoadTableName, pszRoadTableName,



More information about the cairo-commit mailing list