Author: manolo
Date: 2012-05-16 13:50:01 -0700 (Wed, 16 May 2012)
New Revision: 9506
Log:
Accelerate the mandelbrot demo on the Mac platform by drawing by blocks of 100 
lines.

Modified:
   branches/branch-3.0/test/mandelbrot.cxx
   branches/branch-3.0/test1/mandelbrot.cxx

Modified: branches/branch-3.0/test/mandelbrot.cxx
===================================================================
--- branches/branch-3.0/test/mandelbrot.cxx     2012-05-16 20:23:20 UTC (rev 
9505)
+++ branches/branch-3.0/test/mandelbrot.cxx     2012-05-16 20:50:01 UTC (rev 
9506)
@@ -94,14 +94,22 @@
   set_idle();
 }
 
+#ifdef __APPLE__
+const int slice = 100; // plot drawn by blocks of slice lines
+#else
+const int slice = 1;
+#endif
+
 int Drawing_Area::idle() {
   if (!window()->visible()) return 0;
-  if (drawn < nextline) {
+  int rest = H - drawn;
+  if (rest > slice) rest = slice;
+  if (rest && drawn + rest <= nextline) {    
     window()->make_current();
     int yy = drawn+y()+4;
     if (yy >= sy && yy <= sy+sh) erase_box();
-    fltk3::draw_image_mono(buffer+drawn*W,x()+3,yy,W,1,1,W);
-    drawn++;
+    fltk3::draw_image_mono(buffer+drawn*W,x()+3,yy,W,rest,1,W);
+    drawn+=rest;
     return 1;
   }
   if (nextline < H) {
@@ -128,9 +136,8 @@
       p++;
     }
     nextline++;
-    return nextline < H;
   }
-  return 0;
+  return drawn < H;
 }
 
 void Drawing_Area::erase_box() {

Modified: branches/branch-3.0/test1/mandelbrot.cxx
===================================================================
--- branches/branch-3.0/test1/mandelbrot.cxx    2012-05-16 20:23:20 UTC (rev 
9505)
+++ branches/branch-3.0/test1/mandelbrot.cxx    2012-05-16 20:50:01 UTC (rev 
9506)
@@ -94,14 +94,22 @@
   set_idle();
 }
 
+#ifdef __APPLE__
+const int slice = 100; // plot drawn by blocks of slice lines
+#else
+const int slice = 1;
+#endif
+
 int Drawing_Area::idle() {
   if (!window()->visible()) return 0;
-  if (drawn < nextline) {
+  int rest = H - drawn;
+  if (rest > slice) rest = slice;
+  if (rest && drawn + rest <= nextline) {
     window()->make_current();
     int yy = drawn+y()+4;
     if (yy >= sy && yy <= sy+sh) erase_box();
-    fl_draw_image_mono(buffer+drawn*W,x()+3,yy,W,1,1,W);
-    drawn++;
+    fl_draw_image_mono(buffer+drawn*W,x()+3,yy,W,rest,1,W);
+    drawn+=rest;
     return 1;
   }
   if (nextline < H) {
@@ -128,9 +136,8 @@
       p++;
     }
     nextline++;
-    return nextline < H;
   }
-  return 0;
+  return drawn < H;
 }
 
 void Drawing_Area::erase_box() {

_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit

Reply via email to