changeset 1114:7451af5d63ec

Make tank and calculator works for console backend
author Thinker K.F. Li <thinker@codemud.net>
date Wed, 08 Dec 2010 22:39:12 +0800
parents 572277fcec0d
children 673978a8bc4b
files examples/calculator/main.c examples/tank/tank_main.c include/mb_graph_engine_openvg.h src/graph_engine_openvg.c src/redraw_man.c
diffstat 5 files changed, 32 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/examples/calculator/main.c	Wed Dec 08 19:47:25 2010 +0800
+++ b/examples/calculator/main.c	Wed Dec 08 22:39:12 2010 +0800
@@ -179,7 +179,11 @@
     calculator_scr_t *calculator_scr;
     calc_data_t calc_data;
 
+#ifdef CONSOLE_BACKEND
+    rt = mb_runtime_new(NULL, 300, 400);
+#else
     rt = mb_runtime_new(":0.0", 300, 400);
+#endif
 
     rdman = mb_runtime_rdman(rt);
     calculator_scr = calculator_scr_new(rdman, rdman->root_coord);
@@ -187,6 +191,8 @@
     calc_data.rt = rt;
     calc_data.code = calculator_scr;
     setup_observers(&calc_data);
+    
+    mb_runtime_flush(rt);
 
     mb_runtime_event_loop(rt);
 
--- a/examples/tank/tank_main.c	Wed Dec 08 19:47:25 2010 +0800
+++ b/examples/tank/tank_main.c	Wed Dec 08 22:39:12 2010 +0800
@@ -662,7 +662,11 @@
     mb_rt_t *rt;
     tank_rt_t tank_rt;
 
+#ifdef CONSOLE_BACKEND
+    rt = mb_runtime_new(NULL, 800, 600);
+#else
     rt = mb_runtime_new(":0.0", 800, 600);
+#endif
 
     initial_tank(&tank_rt, rt);
     
--- a/include/mb_graph_engine_openvg.h	Wed Dec 08 19:47:25 2010 +0800
+++ b/include/mb_graph_engine_openvg.h	Wed Dec 08 22:39:12 2010 +0800
@@ -226,6 +226,7 @@
 extern void mbe_surface_destroy(mbe_surface_t *surface);
 
 extern void mbe_copy_source(mbe_t *src_canvas, mbe_t *dst_canvas);
+extern void mbe_flush(mbe_t *canvas);
 extern mbe_t *mbe_create(mbe_surface_t *surface);
 extern void mbe_destroy(mbe_t *canvas);
 extern void mbe_paint_with_alpha(mbe_t *canvas, co_comp_t alpha);
--- a/src/graph_engine_openvg.c	Wed Dec 08 19:47:25 2010 +0800
+++ b/src/graph_engine_openvg.c	Wed Dec 08 22:39:12 2010 +0800
@@ -675,6 +675,17 @@
     eglSwapBuffers(display, VG_MBE_SURFACE(dst_canvas));
 }
 
+void
+mbe_flush(mbe_t *canvas) {
+    EGLDisplay display;
+    mbe_surface_t *surface;
+
+    _MK_CURRENT_CTX(canvas);
+    display = _VG_DISPLAY();
+    surface = VG_MBE_SURFACE(canvas);
+    eglSwapBuffers(display, surface);
+}
+
 mbe_t *
 mbe_create(mbe_surface_t *surface) {
     EGLDisplay display;
--- a/src/redraw_man.c	Wed Dec 08 19:47:25 2010 +0800
+++ b/src/redraw_man.c	Wed Dec 08 22:39:12 2010 +0800
@@ -2474,10 +2474,14 @@
 	 * rules.
 	 */
 	draw_shapes_in_dirty_areas(rdman);
-	n_areas = _coord_get_dirty_areas(rdman->root_coord)->num;
-	areas = _coord_get_dirty_areas(rdman->root_coord)->ds;
-	copy_cr_2_backend(rdman, n_areas, areas);
-	reset_clip(rdman->backend);
+	if(rdman->backend) {
+	    n_areas = _coord_get_dirty_areas(rdman->root_coord)->num;
+	    areas = _coord_get_dirty_areas(rdman->root_coord)->ds;
+	    copy_cr_2_backend(rdman, n_areas, areas);
+	    reset_clip(rdman->backend);
+	} else {
+	    mbe_flush(rdman->cr);
+	}
 	for(i = 0; i < rdman->zeroing_coords.num; i++) {
 	    coord = rdman->zeroing_coords.ds[i];
 	    DARRAY_CLEAN(_coord_get_dirty_areas(coord));
@@ -2515,8 +2519,8 @@
     area.x = area.y = 0;
 #ifndef UNITTEST
     surface = mbe_get_target(rdman->cr);
-    area.w = mbe_image_surface_get_width(surface);
-    area.h = mbe_image_surface_get_height(surface);
+    area.w = rdman->w;
+    area.h = rdman->h;
 #else
     area.w = 1024;
     area.h = 1024;