[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [48483] branches/soc-2011-tomato/source/ blender/windowmanager/intern/wm_playanim.c: update playanim for 2.6x, playback works, events don't.
Campbell Barton
ideasman42 at gmail.com
Mon Jul 2 10:20:41 CEST 2012
Revision: 48483
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=48483
Author: campbellbarton
Date: 2012-07-02 08:20:40 +0000 (Mon, 02 Jul 2012)
Log Message:
-----------
update playanim for 2.6x, playback works, events don't.
Modified Paths:
--------------
branches/soc-2011-tomato/source/blender/windowmanager/intern/wm_playanim.c
Modified: branches/soc-2011-tomato/source/blender/windowmanager/intern/wm_playanim.c
===================================================================
--- branches/soc-2011-tomato/source/blender/windowmanager/intern/wm_playanim.c 2012-07-02 08:12:34 UTC (rev 48482)
+++ branches/soc-2011-tomato/source/blender/windowmanager/intern/wm_playanim.c 2012-07-02 08:20:40 UTC (rev 48483)
@@ -1,4 +1,3 @@
-#if 0
/**
* $Id: playanim.c 17755 2008-12-09 04:57:42Z bdiego $
*
@@ -51,24 +50,18 @@
#include <math.h>
#include "BLI_blenlib.h"
-#include "BLI_arithb.h"
+#include "BLI_math.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>
@@ -78,14 +71,26 @@
#endif /* __APPLE__ */
#endif /* WITH_QUICKTIME */
-#include "playanim_ext.h"
-#include "mydevice.h"
-#include "blendef.h"
-#include "winlay.h"
+#include "DNA_scene_types.h"
+#include "BLI_utildefines.h"
+#include "wm_event_types.h"
+#include "GHOST_C-api.h"
+#define WINCLOSE -1
+#define REDRAW -3
+#define RESHAPE -2
+#define WINQUIT -4
+
+static int qtest(void)
+{
+ return 0;
+}
+
/* ***************** gl_util.c ****************** */
-static Window *g_window = NULL;
+static GHOST_SystemHandle g_system = NULL;
+static void *g_window = NULL;
+
static int qualN = 0;
#define LSHIFT (1 << 0)
@@ -93,7 +98,7 @@
#define SHIFT (LSHIFT | RSHIFT)
#define LALT (1 << 2)
#define RALT (1 << 3)
-#define ALT (LALT | RALT)
+#define ALT (LALT | RALT)
#define LCTRL (1 << 4)
#define RCTRL (1 << 5)
#define LMOUSE (1 << 16)
@@ -103,11 +108,23 @@
unsigned short screen_qread(short *val, char *ascii);
+void playanim_window_get_size(int *width_r, int *height_r)
+{
+ GHOST_RectangleHandle bounds = GHOST_GetClientBounds(g_window);
+ *width_r = GHOST_GetWidthRectangle(bounds);
+ *height_r = GHOST_GetHeightRectangle(bounds);
+ GHOST_DisposeRectangle(bounds);
+}
+
/* implementation */
static int qreadN(short *val)
{
+#if 0 // XXX25
char ascii;
int event = screen_qread(val, &ascii);
+#else
+ int event = 123456789;
+#endif
switch (event) {
case LEFTMOUSE:
@@ -211,17 +228,19 @@
cpack(-1);
glRasterPos2f(0.02f, 0.03f);
sprintf(str, "%s | %.2f frames/s\n", picture->name, fstep / swaptime);
+#if 0 // XXX25
BMF_DrawString(G.fonts, str);
+#endif
}
- window_swap_buffers(g_window);
+ GHOST_SwapWindowBuffers(g_window);
}
static void build_pict_list(char *first, int totframes, int fstep)
{
int size, pic, file;
char *mem, name[512];
- short val;
+// short val;
struct pict *picture = 0;
struct ImBuf *ibuf = 0;
int count = 0;
@@ -229,15 +248,15 @@
struct anim *anim;
if (IMB_isanim(first)) {
- anim = IMB_open_anim(first, IB_rect);
+ anim = IMB_open_anim(first, IB_rect, 0);
if (anim) {
- ibuf = IMB_anim_absolute(anim, 0);
+ ibuf = IMB_anim_absolute(anim, 0, IMB_TC_NONE, IMB_PROXY_NONE);
if (ibuf) {
toscreen(NULL, ibuf);
IMB_freeImBuf(ibuf);
}
- for (pic = 0; pic < IMB_anim_get_duration(anim); pic++) {
+ for (pic = 0; pic < IMB_anim_get_duration(anim, IMB_TC_NONE); pic++) {
picture = (Pict *)MEM_callocN(sizeof(Pict), "Pict");
picture->anim = anim;
picture->frame = pic;
@@ -276,7 +295,7 @@
close(file);
return;
}
- size = BLI_filesize(file);
+ size = BLI_file_descriptor_size(file);
if (size < 1) {
close(file);
@@ -315,7 +334,7 @@
pupdate_time();
if (ptottime > 1.0) {
- if (picture->mem) ibuf = IMB_ibImageFromMemory((int *) picture->mem, picture->size, picture->IB_flags);
+ if (picture->mem) ibuf = IMB_ibImageFromMemory((unsigned char *)picture->mem, picture->size, picture->IB_flags, picture->name);
else ibuf = IMB_loadiffname(picture->name, picture->IB_flags);
if (ibuf) {
toscreen(picture, ibuf);
@@ -327,6 +346,7 @@
BLI_newname(name, +fstep);
+#if 0 // XXX25
while (qtest()) {
switch (qreadN(&val)) {
case ESCKEY:
@@ -334,19 +354,63 @@
break;
}
}
+#endif
totframes--;
}
}
return;
}
-void playanim(int argc, char **argv)
+static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr)
{
+ (void)evt;
+ (void)C_void_ptr;
+
+ return 1;
+}
+
+void playanim_window_open(const char *title, int posx, int posy, int sizex, int sizey, int start_maximized)
+{
+ GHOST_TWindowState inital_state;
+ GHOST_TUns32 scr_w, scr_h;
+
+ GHOST_GetMainDisplayDimensions(g_system, &scr_w, &scr_h);
+
+ posy = (scr_h - posy - sizey);
+
+ if (start_maximized == G_WINDOWSTATE_FULLSCREEN)
+ inital_state = start_maximized ? GHOST_kWindowStateFullScreen : GHOST_kWindowStateNormal;
+ else
+ inital_state = start_maximized ? GHOST_kWindowStateMaximized : GHOST_kWindowStateNormal;
+#ifdef __APPLE__
+ inital_state += macPrefState;
+#endif
+
+ g_window = GHOST_CreateWindow(g_system,
+ title,
+ posx, posy, sizex, sizey,
+ inital_state,
+ GHOST_kDrawingContextTypeOpenGL,
+ FALSE /* no stereo */, FALSE);
+
+ //if (ghostwin) {
+ //if (win) {
+ // GHOST_SetWindowUserData(ghostwin, win);
+ //} else {
+ // GHOST_DisposeWindow(g_system, ghostwin);
+ //}
+ //}
+}
+
+
+void playanim(int argc, const 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;
+ int event, stopped = FALSE;
+ GHOST_TUns32 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;
@@ -439,14 +503,14 @@
if (argc > 1) strcpy(name, argv[1]);
else {
- BLI_getwdN(name);
+ BLI_current_working_dir(name, sizeof(name));
if (name[strlen(name) - 1] != '/') strcat(name, "/");
}
if (IMB_isanim(name)) {
- anim = IMB_open_anim(name, IB_rect);
+ anim = IMB_open_anim(name, IB_rect, 0);
if (anim) {
- ibuf = IMB_anim_absolute(anim, 0);
+ ibuf = IMB_anim_absolute(anim, 0, IMB_TC_NONE, IMB_PROXY_NONE);
IMB_close_anim(anim);
anim = NULL;
}
@@ -461,26 +525,38 @@
exit(1);
}
+#if 0 //XXX25
#if !defined(WIN32) && !defined(__APPLE__)
if (fork()) exit(0);
#endif
+#endif //XXX25
- winlay_get_screensize(&maxwinx, &maxwiny);
-
/* XXX, fixme zr */
{
- extern void add_to_mainqueue(Window *win, void *user_data, short evt, short val, char ascii);
+// extern void add_to_mainqueue(wmWindow *win, void *user_data, short evt, short val, char ascii);
- g_window = window_open("Blender:Anim", start_x, start_y, ibuf->x, ibuf->y, 0);
- window_set_handler(g_window, add_to_mainqueue, NULL);
+ void *some_handle = NULL; // XXX25, fixme
+ GHOST_EventConsumerHandle consumer = GHOST_CreateEventConsumer(ghost_event_proc, some_handle);
+ g_system = GHOST_CreateSystem();
+ GHOST_AddEventConsumer(g_system, consumer);
+
+
+
+ playanim_window_open("Blender:Anim", start_x, start_y, ibuf->x, ibuf->y, 0);
+//XXX25 window_set_handler(g_window, add_to_mainqueue, NULL);
+
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0f, 1.0f, 0.0f, 1.0f, -1.0f, 1.0f);
glMatrixMode(GL_MODELVIEW);
}
+ GHOST_GetMainDisplayDimensions(g_system, &maxwinx, &maxwiny);
+
+#if 0 //XXX25
G.fonts = BMF_GetFont(BMF_kHelvetica10);
+#endif
ibufx = ibuf->x;
ibufy = ibuf->y;
@@ -491,7 +567,7 @@
glClearColor(0.0, 0.0, 0.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT);
- window_swap_buffers(g_window);
+ GHOST_SwapWindowBuffers(g_window);
if (sfra == -1 || efra == -1) {
/* one of the frames was invalid, just use all images */
@@ -529,11 +605,11 @@
if (ptottime > 0.0) ptottime = 0.0;
while (picture) {
- if (ibuf != 0 && ibuf->type == 0) IMB_freeImBuf(ibuf);
+ if (ibuf != 0 && ibuf->ftype == 0) IMB_freeImBuf(ibuf);
if (picture->ibuf) ibuf = picture->ibuf;
- else if (picture->anim) ibuf = IMB_anim_absolute(picture->anim, picture->frame);
- else if (picture->mem) ibuf = IMB_ibImageFromMemory((int *) picture->mem, picture->size, picture->IB_flags);
+ else if (picture->anim) ibuf = IMB_anim_absolute(picture->anim, picture->frame, IMB_TC_NONE, IMB_PROXY_NONE);
+ else if (picture->mem) ibuf = IMB_ibImageFromMemory((unsigned char *) picture->mem, picture->size, picture->IB_flags, picture->name);
else ibuf = IMB_loadiffname(picture->name, picture->IB_flags);
if (ibuf) {
@@ -644,7 +720,7 @@
case LEFTMOUSE:
case MOUSEX:
if (qualN & LMOUSE) {
- window_get_size(g_window, &sizex, &sizey);
+ playanim_window_get_size(&sizex, &sizey);
picture = picsbase->first;
i = 0;
while (picture) {
@@ -745,21 +821,21 @@
if (val == 0) break;
if (zoomx > 1.0) zoomx -= 1.0;
if (zoomy > 1.0) zoomy -= 1.0;
- window_get_position(g_window, &ofsx, &ofsy);
- window_get_size(g_window, &sizex, &sizey);
+ // playanim_window_get_position(&ofsx, &ofsy);
+ playanim_window_get_size(&sizex, &sizey);
ofsx += sizex / 2;
ofsy += sizey / 2;
sizex = zoomx * ibufx;
sizey = zoomy * ibufy;
ofsx -= sizex / 2;
ofsy -= sizey / 2;
-/* window_set_position(g_window,sizex,sizey); */
- window_set_size(g_window, sizex, sizey);
+ // window_set_position(g_window,sizex,sizey);
+ GHOST_SetClientSize(g_window, sizex, sizey);
break;
case RESHAPE:
case REDRAW:
- window_get_size(g_window, &sizex, &sizey);
- window_make_active(g_window);
+ playanim_window_get_size(&sizey, &sizey);
+ GHOST_ActivateWindowDrawingContext(g_window);
glViewport(0, 0, sizex, sizey);
glScissor(0, 0, sizex, sizey);
@@ -848,7 +924,7 @@
if (ibuf) IMB_freeImBuf(ibuf);
BLI_freelistN(picsbase);
free_blender();
- window_destroy(g_window);
+ GHOST_DisposeWindow(g_system, g_window);
totblock = MEM_get_memory_blocks_in_use();
if (totblock != 0) {
@@ -856,11 +932,3 @@
MEM_printmemlist();
}
}
-
-#endif
-
-void playanim(int argc, const char **argv)
-{
- (void)argc;
- (void)argv;
-}
More information about the Bf-blender-cvs
mailing list