[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [48481] branches/soc-2011-tomato/source: add back playanim from 2.4x (not functional, #if 0'd)

Campbell Barton ideasman42 at gmail.com
Mon Jul 2 10:10:18 CEST 2012


Revision: 48481
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=48481
Author:   campbellbarton
Date:     2012-07-02 08:10:05 +0000 (Mon, 02 Jul 2012)
Log Message:
-----------
add back playanim from 2.4x (not functional, #if 0'd)

Modified Paths:
--------------
    branches/soc-2011-tomato/source/blender/windowmanager/CMakeLists.txt
    branches/soc-2011-tomato/source/creator/creator.c

Added Paths:
-----------
    branches/soc-2011-tomato/source/blender/windowmanager/intern/wm_playanim.c

Modified: branches/soc-2011-tomato/source/blender/windowmanager/CMakeLists.txt
===================================================================
--- branches/soc-2011-tomato/source/blender/windowmanager/CMakeLists.txt	2012-07-02 07:40:25 UTC (rev 48480)
+++ branches/soc-2011-tomato/source/blender/windowmanager/CMakeLists.txt	2012-07-02 08:10:05 UTC (rev 48481)
@@ -53,6 +53,7 @@
 
 set(SRC
 	intern/wm.c
+	intern/wm_playanim.c
 	intern/wm_cursors.c
 	intern/wm_dragdrop.c
 	intern/wm_draw.c

Added: branches/soc-2011-tomato/source/blender/windowmanager/intern/wm_playanim.c
===================================================================
--- branches/soc-2011-tomato/source/blender/windowmanager/intern/wm_playanim.c	                        (rev 0)
+++ branches/soc-2011-tomato/source/blender/windowmanager/intern/wm_playanim.c	2012-07-02 08:10:05 UTC (rev 48481)
@@ -0,0 +1,854 @@
+#if 0
+/**
+ * $Id: playanim.c 17755 2008-12-09 04:57:42Z bdiego $
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include <sys/types.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <string.h>
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#ifndef WIN32
+#include <unistd.h>
+#include <sys/times.h>
+#include <sys/wait.h>
+#else
+#include <io.h>
+#endif   
+#include "MEM_guardedalloc.h"
+
+#include "PIL_time.h"
+
+#include <math.h>
+
+#include "BLI_blenlib.h"
+#include "BLI_arithb.h"
+
+#include "IMB_imbuf_types.h"
+#include "IMB_imbuf.h"
+
+#include "BDR_editcurve.h"
+
+#include "BKE_blender.h"
+#include "BKE_global.h"
+#include "BKE_utildefines.h"
+
+#include "BIF_gl.h"
+#include "BIF_glutil.h"
+#include "BIF_screen.h"
+#include "BIF_mywindow.h"
+
+#include "BMF_Api.h"
+
+#ifdef WITH_QUICKTIME
+#ifdef _WIN32
+#include <QTML.h>
+#include <Movies.h>
+#elif defined(__APPLE__)
+#include <QuickTime/Movies.h>
+#endif /* __APPLE__ */
+#endif /* WITH_QUICKTIME */
+
+#include "playanim_ext.h"
+#include "mydevice.h"
+#include "blendef.h"
+#include "winlay.h"
+
+/* ***************** gl_util.c ****************** */
+
+static Window *g_window = NULL;
+static int qualN = 0;
+
+#define LSHIFT	(1<<0)
+#define RSHIFT	(1<<1)
+#define SHIFT	(LSHIFT | RSHIFT)
+#define LALT	(1<<2)
+#define RALT	(1<<3)
+#define ALT	(LALT | RALT)
+#define LCTRL	(1<<4)
+#define RCTRL	(1<<5)
+#define LMOUSE	(1<<16)
+#define MMOUSE	(1<<17)
+#define RMOUSE	(1<<18)
+#define MOUSE	(LMOUSE | MMOUSE | RMOUSE)
+
+unsigned short screen_qread(short *val, char *ascii);
+
+/* implementation */
+static int qreadN(short *val)
+{
+	char ascii;
+	int event = screen_qread(val, &ascii);
+
+	switch(event){
+	case LEFTMOUSE:
+		if (*val) qualN |= LMOUSE;
+		else qualN &= ~LMOUSE;
+		break;
+	case MIDDLEMOUSE:
+		if (*val) qualN |= MMOUSE;
+		else qualN &= ~MMOUSE;
+		break;
+	case RIGHTMOUSE:
+		if (*val) qualN |= RMOUSE;
+		else qualN &= ~RMOUSE;
+		break;
+	case LEFTSHIFTKEY:
+		if (*val) qualN |= LSHIFT;
+		else qualN &= ~LSHIFT;
+		break;
+	case RIGHTSHIFTKEY:
+		if (*val) qualN |= RSHIFT;
+		else qualN &= ~RSHIFT;
+		break;
+	case LEFTCTRLKEY:
+		if (*val) qualN |= LCTRL;
+		else qualN &= ~LCTRL;
+		break;
+	case RIGHTCTRLKEY:
+		if (*val) qualN |= RCTRL;
+		else qualN &= ~RCTRL;
+		break;
+	case LEFTALTKEY:
+		if (*val) qualN |= LALT;
+		else qualN &= ~LALT;
+		break;
+	case RIGHTALTKEY:
+		if (*val) qualN |= RALT;
+		else qualN &= ~RALT;
+		break;
+	}
+
+	return(event);
+}
+
+/* ***************** gl_util.c ****************** */
+
+
+
+
+typedef struct pict{
+	struct pict *next, *prev;
+	char *mem;
+	int size;
+	char *name;
+	struct ImBuf *ibuf;
+	struct anim *anim;
+	int frame;
+	int IB_flags;
+}Pict;
+
+static struct ListBase _picsbase = {0,0};
+static struct ListBase *picsbase = &_picsbase;
+static int fromdisk = FALSE;
+static int fstep = 1; 
+static float zoomx = 1.0 , zoomy = 1.0;
+static double ptottime = 0.0, swaptime = 0.04;
+
+static int pupdate_time(void)
+{
+	static double ltime;
+	double time;
+
+	time = PIL_check_seconds_timer();
+
+	ptottime += (time - ltime);
+	ltime = time;
+	return (ptottime < 0);
+}
+
+static void toscreen(Pict *picture, struct ImBuf *ibuf)
+{
+	
+	if (ibuf == 0){
+		printf("no ibuf !\n");
+		return;
+	}
+	if (ibuf->rect==NULL && ibuf->rect_float) {
+		IMB_rect_from_float(ibuf);
+		imb_freerectfloatImBuf(ibuf);
+	}
+	if (ibuf->rect==NULL)
+		return;
+
+	glRasterPos2f(0.0f, 0.0f);
+
+	glDrawPixels(ibuf->x, ibuf->y, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect);
+	
+	pupdate_time();
+
+	if(picture && (qualN & (SHIFT|LMOUSE))) {
+		char str[512];
+		cpack(-1);
+		glRasterPos2f(0.02f,  0.03f);
+		sprintf(str, "%s | %.2f frames/s\n", picture->name, fstep / swaptime);
+		BMF_DrawString(G.fonts, str);
+	}
+	
+	window_swap_buffers(g_window);
+}
+
+static void build_pict_list(char * first, int totframes, int fstep)
+{
+	int size,pic,file;
+	char *mem, name[512];
+	short val;
+	struct pict * picture = 0;
+	struct ImBuf *ibuf = 0;
+	int count = 0;
+	char str[512];
+	struct anim * anim;
+	
+	if (IMB_isanim(first)) {
+		anim = IMB_open_anim(first, IB_rect);
+		if (anim) {
+			ibuf = IMB_anim_absolute(anim, 0);
+			if (ibuf) {
+				toscreen(NULL, ibuf);
+				IMB_freeImBuf(ibuf);
+			}
+			
+			for (pic = 0; pic < IMB_anim_get_duration(anim); pic ++) {
+				picture = (Pict*)MEM_callocN(sizeof(Pict),"Pict");
+				picture->anim = anim;
+				picture->frame = pic;
+				picture->IB_flags = IB_rect;
+				sprintf(str, "%s : %d", first, pic + 1);
+				picture->name = strdup(str);
+				BLI_addtail(picsbase, picture);
+			}
+		} 
+		else printf("couldn't open anim %s\n", first);
+	} 
+	else {
+	
+		strcpy(name,first);
+	
+		pupdate_time();
+		ptottime = 1.0;
+		
+/*
+     O_DIRECT
+            If set, all reads and writes on the resulting file descriptor will
+            be performed directly to or from the user program buffer, provided
+            appropriate size and alignment restrictions are met.  Refer to the
+            F_SETFL and F_DIOINFO commands in the fcntl(2) manual entry for
+            information about how to determine the alignment constraints.
+            O_DIRECT is a Silicon Graphics extension and is only supported on
+            local EFS and XFS file systems.
+*/
+		
+		while(IMB_ispic(name) && totframes){
+			file = open(name, O_BINARY|O_RDONLY, 0);
+			if (file < 0) return;
+			picture = (struct pict*)MEM_callocN(sizeof(struct pict), "picture");
+			if (picture == 0){
+				printf("Not enough memory for pict struct \n");
+				close(file);
+				return;
+			}
+			size = BLI_filesize(file);
+
+			if (size < 1) {
+				close(file);
+				MEM_freeN(picture);
+				return;
+			}
+
+			picture->size = size;
+			picture->IB_flags = IB_rect;
+						
+			if (fromdisk == FALSE) {
+				mem=(char *)MEM_mallocN(size, "build pic list");
+				if (mem==0){
+					printf("Couldn't get memory\n");
+					close(file);
+					MEM_freeN(picture);
+					return;
+				}
+		
+				if (read(file,mem,size) != size){
+					printf("Error while reading %s\n",name);
+					close(file);
+					MEM_freeN(picture);
+					MEM_freeN(mem);
+					return;
+				}
+			} else mem = 0;
+			
+			picture->mem = mem;
+			picture->name = strdup(name);
+			close(file);
+			BLI_addtail(picsbase,picture);
+			count++;
+			
+			pupdate_time();
+			
+			if (ptottime > 1.0) {				
+				if (picture->mem) ibuf = IMB_ibImageFromMemory((int *) picture->mem, picture->size, picture->IB_flags);
+				else ibuf = IMB_loadiffname(picture->name, picture->IB_flags);
+				if (ibuf) {
+					toscreen(picture, ibuf);
+					IMB_freeImBuf(ibuf);
+				}
+				pupdate_time();
+				ptottime = 0.0;
+			}
+			
+			BLI_newname(name, +fstep);
+			
+			while(qtest()){
+				switch(qreadN(&val)){
+				case ESCKEY:
+					if (val) return;
+					break;
+				}
+			}
+			totframes--;
+		}
+	}
+	return;
+}
+
+void playanim(int argc, char **argv)
+{
+	struct ImBuf *ibuf = 0;
+	struct pict *picture = 0;
+	char name[512];
+	short val = 0, go = TRUE, ibufx = 0, ibufy = 0;
+	int event, stopped = FALSE, maxwinx, maxwiny;
+	short /*  c233 = FALSE, */ /*  yuvx = FALSE, */ once = FALSE, sstep = FALSE, wait2 = FALSE, /*  resetmap = FALSE, */ pause = 0;
+	short pingpong = FALSE, direction = 1, next = 1, turbo = FALSE, /*  doubleb = TRUE, */ noskip = FALSE;
+	int sizex, sizey, ofsx, ofsy, i;
+	/* This was done to disambiguate the name for use under c++. */
+	struct anim * anim = 0;
+ 	int start_x= 0, start_y= 0;
+	int sfra= -1;
+	int efra= -1;
+	int totblock;
+	
+	while (argc > 1) {
+		if (argv[1][0] == '-'){
+			switch(argv[1][1]) {
+				case 'm':
+					fromdisk = TRUE;
+					break;
+				case 'p':
+					if (argc>3) {
+						start_x= atoi(argv[2]);
+						start_y= atoi(argv[3]);
+						argc-= 2; 
+						argv+= 2;
+					} else {
+						printf("too few arguments for -p (need 2): skipping\n");
+					}
+					break;
+				case 'f':
+					if (argc>3) {
+						double fps = atof(argv[2]);
+						double fps_base= atof(argv[3]);
+						if (fps == 0) {
+							fps = 1;
+							printf("invalid fps,"
+							       "forcing 1\n");
+						}
+						swaptime = fps_base / fps;
+						argc-= 2; 
+						argv+= 2;
+					} else {
+						printf("too few arguments for -f (need 2): skipping\n");
+					}
+					break;
+				case 's':
+					sfra= MIN2(MAXFRAME, MAX2(1, atoi(argv[2]) ));
+					argc--;
+					argv++;
+					break;
+				case 'e':
+					efra= MIN2(MAXFRAME, MAX2(1, atoi(argv[2]) ));
+					argc--;
+					argv++;
+					break;
+				case 'j':
+					fstep= MIN2(MAXFRAME, MAX2(1, atoi(argv[2])));
+					swaptime*= fstep;
+					argc--;
+					argv++;
+					break;
+				default:
+					printf("unknown option '%c': skipping\n", argv[1][1]);
+					break;
+			}
+			argc--;
+			argv++;
+		} else break;
+	}
+	
+#ifdef WITH_QUICKTIME
+#if defined (_WIN32) || defined (__APPLE__)
+	/* Initialize QuickTime */

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list