PERFORCE change 214660 for review

Brooks Davis brooks at FreeBSD.org
Fri Jul 20 22:34:59 UTC 2012


http://p4web.freebsd.org/@@214660?ac=10

Change 214660 by brooks at brooks_ecr_current on 2012/07/20 22:33:55

	Convert pictview_pan() to use ts_poll().  With the new version
	that debounces releases and fakes extra releases when one wasn't
	generated properly this is much smoother than the old version.

Affected files ...

.. //depot/projects/ctsrd/beribsd/src/ctsrd/pictview/pictview.c#11 edit

Differences ...

==== //depot/projects/ctsrd/beribsd/src/ctsrd/pictview/pictview.c#11 (text+ko) ====

@@ -494,8 +494,8 @@
   int pan_direction = -1;
   int next_display_image = display_image;
   int k,x,y;
-  int touch_release = false;
-  int prev_touch_x0;
+  int prev_ts_x1;
+  struct tsstate *ts;
 
   if((display_image<1) || (display_image>pictview_num_photo)) {
     printf("pictview_pan assertion error: display_image=%1d out of range\n",
@@ -505,9 +505,6 @@
 
   // display image
   for(y=0; y<fb_height; y++) {
-    multitouch_pole();
-    if(touch_count<=0)
-      touch_release = true;
     k=y*fb_width;
     for(x=0; x<fb_width; x++)
       fb_buf[x+k] = pictview_imgs[display_image][x+k];
@@ -515,22 +512,16 @@
   fb_post(fb_buf);
   fb_fade2on();
 
-  // wait for touch to be released
-  while(!touch_release) {
-    multitouch_pole();
-    touch_release = touch_count<=0;
-  }
+  for (;;) {
+    ts = ts_poll();
+    if (ts->ts_gesture == TSG2_ZOOM_OUT)
+      break;
 
-  // while no pinch gesture
-  while(!((touch_count==2) && (touch_gesture==0x49))) {
-    // multitouch_pole();
-    multitouch_filter();
-
-    if((touch_count==0) && (pan_direction!=-1)) {
+    if((ts->ts_count==0) && (pan_direction!=-1)) {
       // touch released so decide which image to view
-      if((pan_direction==0) && (touch_x0>(fb_width/2)))
+      if((pan_direction==0) && (ts->ts_x1>(fb_width/2)))
 	display_image = next_display_image;
-      if((pan_direction==1) && (touch_x0<(fb_width/2)))
+      if((pan_direction==1) && (ts->ts_x1<(fb_width/2)))
 	display_image = next_display_image;
       pan_direction = -1;
       for(k=0; k<fb_width*fb_height; k++)
@@ -538,19 +529,17 @@
       fb_post(fb_buf);
     }
 
-    // printf("prev=%1d, state=%1d, c=%1d\n", prev_state, state, touch_count);
-    // printf("%1d",touch_count);
-    if(touch_count==1) {
-      if((pan_direction==-1) && (touch_x0>(5*fb_width/6))) {  // pan image to right
+    if(ts->ts_count==1) {
+      if((pan_direction==-1) && (ts->ts_x1>(5*fb_width/6))) {  // pan image to right
 	pan_direction=1;
 	next_display_image = (display_image % pictview_num_photo)+1;
-	prev_touch_x0 = fb_width-1;
+	prev_ts_x1 = fb_width-1;
 	//printf("display_image=%1d  next_display_image=%1d\n",display_image,next_display_image);
       }
-      if((pan_direction==-1) && (touch_x0<(fb_width/6))) { // pan image to left
+      if((pan_direction==-1) && (ts->ts_x1<(fb_width/6))) { // pan image to left
 	pan_direction=0;
 	next_display_image = ((pictview_num_photo+display_image-2) % pictview_num_photo)+1;
-	prev_touch_x0 = 0;
+	prev_ts_x1 = 0;
 	// printf("display_image=%1d  next_display_image=%1d\n",display_image,next_display_image);
       }
       if(pan_direction!=-1) {
@@ -565,13 +554,13 @@
 	// printf("%1d",pan_direction);
 	for(y=0; y<fb_height; y++) {
 	  k = y*fb_width;
-	  for(x=prev_touch_x0; x<touch_x0; x++)
+	  for(x=prev_ts_x1; x<ts->ts_x1; x++)
 	    fb_buf[x+k] = pictview_imgs[img0][x+k];
-	  for(x=touch_x0; x<=prev_touch_x0; x++)
+	  for(x=ts->ts_x1; x<=prev_ts_x1; x++)
 	    fb_buf[x+k] = pictview_imgs[img1][x+k];
 	}
 	fb_post(fb_buf);
-	prev_touch_x0 = touch_x0;
+	prev_ts_x1 = ts->ts_x1;
       }
     }
   }


More information about the p4-projects mailing list