Threaded object update and EvaluationContext
[blender.git] / source / blender / windowmanager / intern / wm_playanim.c
index a289d182f1c6b0276990e0c4b07e3fd5d69aa1b5..ab48e72562ecf7e85a19d7cd9f3875635c550f25 100644 (file)
@@ -13,7 +13,7 @@
  *
  * 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.
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  *
  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
  * All rights reserved.
@@ -60,6 +60,7 @@
 #include "IMB_imbuf.h"
 
 #include "BKE_blender.h"
+#include "BKE_depsgraph.h"
 #include "BKE_global.h"
 #include "BKE_image.h"
 
@@ -788,24 +789,19 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void)
        return 1;
 }
 
-static void playanim_window_open(const char *title, int posx, int posy, int sizex, int sizey, int start_maximized)
+static void playanim_window_open(const char *title, int posx, int posy, int sizex, int sizey)
 {
-       GHOST_TWindowState inital_state;
        GHOST_TUns32 scr_w, scr_h;
 
        GHOST_GetMainDisplayDimensions(g_WS.ghost_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;
-
        g_WS.ghost_window = GHOST_CreateWindow(g_WS.ghost_system,
                                               title,
                                               posx, posy, sizex, sizey,
-                                              inital_state,
+                                              /* could optionally start fullscreen */
+                                              GHOST_kWindowStateNormal,
                                               GHOST_kDrawingContextTypeOpenGL,
                                               FALSE /* no stereo */, FALSE);
 }
@@ -825,7 +821,7 @@ static void playanim_window_zoom(PlayState *ps, const float zoom_offset)
        sizey = ps->zoom * ps->ibufy;
        /* ofsx -= sizex / 2; */ /* UNUSED */
        /* ofsy -= sizey / 2; */ /* UNUSED */
-       // window_set_position(g_WS.ghost_window,sizex,sizey);
+       // window_set_position(g_WS.ghost_window, sizex, sizey);
        GHOST_SetClientSize(g_WS.ghost_window, sizex, sizey);
 }
 
@@ -900,17 +896,20 @@ static char *wm_main_playanim_intern(int argc, const char **argv)
                                        }
                                        break;
                                case 's':
-                                       sfra = MIN2(MAXFRAME, MAX2(1, atoi(argv[2]) ));
+                                       sfra = atoi(argv[2]);
+                                       CLAMP(sfra, 1, MAXFRAME);
                                        argc--;
                                        argv++;
                                        break;
                                case 'e':
-                                       efra = MIN2(MAXFRAME, MAX2(1, atoi(argv[2]) ));
+                                       efra = atoi(argv[2]);
+                                       CLAMP(efra, 1, MAXFRAME);
                                        argc--;
                                        argv++;
                                        break;
                                case 'j':
-                                       ps.fstep = MIN2(MAXFRAME, MAX2(1, atoi(argv[2])));
+                                       ps.fstep = atoi(argv[2]);
+                                       CLAMP(ps.fstep, 1, MAXFRAME);
                                        swaptime *= ps.fstep;
                                        argc--;
                                        argv++;
@@ -945,6 +944,7 @@ static char *wm_main_playanim_intern(int argc, const char **argv)
                }
        }
        else if (!IMB_ispic(filepath)) {
+               printf("%s: '%s' not an image file\n", __func__, filepath);
                exit(1);
        }
 
@@ -954,14 +954,14 @@ static char *wm_main_playanim_intern(int argc, const char **argv)
        }
 
        if (ibuf == NULL) {
-               printf("couldn't open %s\n", filepath);
+               printf("%s: '%s' couldn't open\n", __func__, filepath);
                exit(1);
        }
 
 #if 0 //XXX25
-       #if !defined(WIN32) && !defined(__APPLE__)
+#if !defined(WIN32) && !defined(__APPLE__)
        if (fork()) exit(0);
-       #endif
+#endif
 #endif //XXX25
 
        {
@@ -971,7 +971,7 @@ static char *wm_main_playanim_intern(int argc, const char **argv)
                g_WS.ghost_system = GHOST_CreateSystem();
                GHOST_AddEventConsumer(g_WS.ghost_system, consumer);
 
-               playanim_window_open("Blender:Anim", start_x, start_y, ibuf->x, ibuf->y, 0);
+               playanim_window_open("Blender:Anim", start_x, start_y, ibuf->x, ibuf->y);
 
                /* unified matrix, note it affects offset for drawing */
                glMatrixMode(GL_PROJECTION);
@@ -1195,13 +1195,14 @@ static char *wm_main_playanim_intern(int argc, const char **argv)
        GHOST_DisposeWindow(g_WS.ghost_system, g_WS.ghost_window);
 
        /* early exit, IMB and BKE should be exited only in end */
-       if (ps.dropped_file) {
+       if (ps.dropped_file[0]) {
                BLI_strncpy(filepath, ps.dropped_file, sizeof(filepath));
                return filepath;
        }
        
        IMB_exit();
        BKE_images_exit();
+       DAG_exit();
 
        totblock = MEM_get_memory_blocks_in_use();
        if (totblock != 0) {