This repository has been archived on 2023-10-09. You can view files and clone it, but cannot push or open issues or pull requests.
Files
blender-archive/source/blender/windowmanager/intern/wm_playanim.c

1238 lines
29 KiB
C
Raw Normal View History

2012-08-06 16:07:11 +00:00
/*
* ***** 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,
2013-09-12 03:02:50 +00:00
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
2012-08-06 16:07:11 +00:00
*
* 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): Campbell Barton
*
* ***** END GPL LICENSE BLOCK *****
*/
/** \file blender/windowmanager/intern/wm_playanim.c
* \ingroup wm
*
* \note This file uses ghost directly and none of the WM definitions.
* this could be made into its own module, alongside creator/
*/
#include <sys/types.h>
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#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 "BLI_utildefines.h"
#include "BLI_fileops.h"
2012-08-06 16:07:11 +00:00
#include "BLI_listbase.h"
#include "BLI_path_util.h"
#include "BLI_rect.h"
#include "BLI_string.h"
2012-08-06 16:07:11 +00:00
#include "IMB_imbuf_types.h"
#include "IMB_imbuf.h"
#include "BKE_blender.h"
Threaded object update and EvaluationContext Summary: Made objects update happening from multiple threads. It is a task-based scheduling system which uses current dependency graph for spawning new tasks. This means threading happens on object level, but the system is flexible enough for higher granularity. Technical details: - Uses task scheduler which was recently committed to trunk (that one which Brecht ported from Cycles). - Added two utility functions to dependency graph: * DAG_threaded_update_begin, which is called to initialize threaded objects update. It will also schedule root DAG node to the queue, hence starting evaluation process. Initialization will calculate how much parents are to be evaluation before current DAG node can be scheduled. This value is used by task threads for faster detecting which nodes might be scheduled. * DAG_threaded_update_handle_node_updated which is called from task thread function when node was fully handled. This function decreases num_pending_parents of node children and schedules children with zero valency. As it might have become clear, task thread receives DAG nodes and decides which callback to call for it. Currently only BKE_object_handle_update is called for object nodes. In the future it'll call node->callback() from Ali's new DAG. - This required adding some workarounds to the render pipeline. Mainly to stop using get_object_dm() from modifiers' apply callback. Such a call was only a workaround for dependency graph glitch when rendering scene with, say, boolean modifiers before displaying this scene. Such change moves workaround from one place to another, so overall hackentropy remains the same. - Added paradigm of EvaluaitonContext. Currently it's more like just a more reliable replacement for G.is_rendering which fails in some circumstances. Future idea of this context is to also store all the local data needed for objects evaluation such as local time, Copy-on-Write data and so. There're two types of EvaluationContext: * Context used for viewport updated and owned by Main. In the future this context might be easily moved to Window or Screen to allo per-window/per-screen local time. * Context used by render engines to evaluate objects for render purposes. Render engine is an owner of this context. This context is passed to all object update routines. Reviewers: brecht, campbellbarton Reviewed By: brecht CC: lukastoenne Differential Revision: https://developer.blender.org/D94
2013-12-26 17:24:42 +06:00
#include "BKE_depsgraph.h"
2012-08-06 16:07:11 +00:00
#include "BKE_global.h"
#include "BKE_image.h"
2012-08-06 16:07:11 +00:00
#include "BIF_gl.h"
#include "BIF_glutil.h"
#include "DNA_scene_types.h"
#include "ED_datafiles.h" /* for fonts */
#include "GHOST_C-api.h"
#include "BLF_api.h"
#include "wm_event_types.h"
2012-08-06 16:07:11 +00:00
#include "WM_api.h" /* only for WM_main_playanim */
struct PlayState;
static void playanim_window_zoom(struct PlayState *ps, const float zoom_offset);
2012-08-06 16:07:11 +00:00
typedef struct PlayState {
/* window and viewport size */
int win_x, win_y;
/* current zoom level */
float zoom;
2012-08-06 16:07:11 +00:00
/* playback state */
short direction;
short next_frame;
bool once;
bool turbo;
bool pingpong;
bool noskip;
bool sstep;
bool wait2;
bool stopped;
bool go;
int fstep;
2012-08-06 16:07:11 +00:00
/* current picture */
struct PlayAnimPict *picture;
/* set once at the start */
int ibufx, ibufy;
int fontid;
/* saves passing args */
struct ImBuf *curframe_ibuf;
/* restarts player for file drop */
char dropped_file[FILE_MAX];
2012-08-06 16:07:11 +00:00
} PlayState;
/* for debugging */
#if 0
void print_ps(PlayState *ps)
{
printf("ps:\n");
printf(" direction=%d,\n", (int)ps->direction);
printf(" next=%d,\n", ps->next);
printf(" once=%d,\n", ps->once);
printf(" turbo=%d,\n", ps->turbo);
printf(" pingpong=%d,\n", ps->pingpong);
printf(" noskip=%d,\n", ps->noskip);
printf(" sstep=%d,\n", ps->sstep);
printf(" pause=%d,\n", ps->pause);
printf(" wait2=%d,\n", ps->wait2);
printf(" stopped=%d,\n", ps->stopped);
printf(" go=%d,\n\n", ps->go);
fflush(stdout);
}
#endif
/* global for window and events */
typedef enum eWS_Qual {
WS_QUAL_LSHIFT = (1 << 0),
WS_QUAL_RSHIFT = (1 << 1),
WS_QUAL_SHIFT = (WS_QUAL_LSHIFT | WS_QUAL_RSHIFT),
WS_QUAL_LALT = (1 << 2),
WS_QUAL_RALT = (1 << 3),
WS_QUAL_ALT = (WS_QUAL_LALT | WS_QUAL_RALT),
WS_QUAL_LCTRL = (1 << 4),
WS_QUAL_RCTRL = (1 << 5),
WS_QUAL_CTRL = (WS_QUAL_LCTRL | WS_QUAL_RCTRL),
2012-08-06 16:07:11 +00:00
WS_QUAL_LMOUSE = (1 << 16),
WS_QUAL_MMOUSE = (1 << 17),
WS_QUAL_RMOUSE = (1 << 18),
WS_QUAL_MOUSE = (WS_QUAL_LMOUSE | WS_QUAL_MMOUSE | WS_QUAL_RMOUSE)
} eWS_Qual;
static struct WindowStateGlobal {
GHOST_SystemHandle ghost_system;
void *ghost_window;
/* events */
eWS_Qual qual;
} g_WS = {NULL};
static void playanim_window_get_size(int *width_r, int *height_r)
2012-08-06 16:07:11 +00:00
{
GHOST_RectangleHandle bounds = GHOST_GetClientBounds(g_WS.ghost_window);
*width_r = GHOST_GetWidthRectangle(bounds);
*height_r = GHOST_GetHeightRectangle(bounds);
GHOST_DisposeRectangle(bounds);
}
/* implementation */
static void playanim_event_qual_update(void)
{
int val;
/* Shift */
GHOST_GetModifierKeyState(g_WS.ghost_system, GHOST_kModifierKeyLeftShift, &val);
if (val) g_WS.qual |= WS_QUAL_LSHIFT;
else g_WS.qual &= ~WS_QUAL_LSHIFT;
GHOST_GetModifierKeyState(g_WS.ghost_system, GHOST_kModifierKeyRightShift, &val);
if (val) g_WS.qual |= WS_QUAL_RSHIFT;
else g_WS.qual &= ~WS_QUAL_RSHIFT;
/* Control */
GHOST_GetModifierKeyState(g_WS.ghost_system, GHOST_kModifierKeyLeftControl, &val);
if (val) g_WS.qual |= WS_QUAL_LCTRL;
else g_WS.qual &= ~WS_QUAL_LCTRL;
GHOST_GetModifierKeyState(g_WS.ghost_system, GHOST_kModifierKeyRightControl, &val);
if (val) g_WS.qual |= WS_QUAL_RCTRL;
else g_WS.qual &= ~WS_QUAL_RCTRL;
/* Alt */
GHOST_GetModifierKeyState(g_WS.ghost_system, GHOST_kModifierKeyLeftAlt, &val);
if (val) g_WS.qual |= WS_QUAL_LALT;
else g_WS.qual &= ~WS_QUAL_LALT;
2012-08-06 16:07:11 +00:00
GHOST_GetModifierKeyState(g_WS.ghost_system, GHOST_kModifierKeyRightAlt, &val);
if (val) g_WS.qual |= WS_QUAL_RALT;
else g_WS.qual &= ~WS_QUAL_RALT;
2012-08-06 16:07:11 +00:00
}
typedef struct PlayAnimPict {
struct PlayAnimPict *next, *prev;
char *mem;
int size;
char *name;
struct ImBuf *ibuf;
struct anim *anim;
int frame;
int IB_flags;
} PlayAnimPict;
static struct ListBase picsbase = {NULL, NULL};
static bool fromdisk = false;
2012-08-06 16:07:11 +00:00
static double ptottime = 0.0, swaptime = 0.04;
static PlayAnimPict *playanim_step(PlayAnimPict *playanim, int step)
{
if (step > 0) {
while (step-- && playanim) {
playanim = playanim->next;
}
}
else if (step < 0) {
while (step++ && playanim) {
playanim = playanim->prev;
}
}
return playanim;
}
2012-08-06 16:07:11 +00:00
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 playanim_toscreen(PlayState *ps, PlayAnimPict *picture, struct ImBuf *ibuf, int fontid, int fstep)
2012-08-06 16:07:11 +00:00
{
float offsx, offsy;
2012-08-06 16:07:11 +00:00
if (ibuf == NULL) {
printf("%s: no ibuf for picture '%s'\n", __func__, picture ? picture->name : "<NIL>");
2012-08-06 16:07:11 +00:00
return;
}
if (ibuf->rect == NULL && ibuf->rect_float) {
IMB_rect_from_float(ibuf);
imb_freerectfloatImBuf(ibuf);
}
if (ibuf->rect == NULL)
return;
GHOST_ActivateWindowDrawingContext(g_WS.ghost_window);
/* offset within window */
offsx = 0.5f * (((float)ps->win_x - ps->zoom * ibuf->x) / (float)ps->win_x);
offsy = 0.5f * (((float)ps->win_y - ps->zoom * ibuf->y) / (float)ps->win_y);
2012-08-06 16:07:11 +00:00
CLAMP(offsx, 0.0f, 1.0f);
CLAMP(offsy, 0.0f, 1.0f);
glRasterPos2f(offsx, offsy);
glClearColor(0.1, 0.1, 0.1, 0.0);
glClear(GL_COLOR_BUFFER_BIT);
/* checkerboard for case alpha */
if (ibuf->planes == 32) {
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
fdrawcheckerboard(offsx, offsy, offsx + (ps->zoom * ibuf->x) / (float)ps->win_x, offsy + (ps->zoom * ibuf->y) / (float)ps->win_y);
}
2012-08-06 16:07:11 +00:00
glDrawPixels(ibuf->x, ibuf->y, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect);
glDisable(GL_BLEND);
2012-08-06 16:07:11 +00:00
pupdate_time();
if (picture && (g_WS.qual & (WS_QUAL_SHIFT | WS_QUAL_LMOUSE)) && (fontid != -1)) {
int sizex, sizey;
float fsizex_inv, fsizey_inv;
char str[32 + FILE_MAX];
cpack(-1);
BLI_snprintf(str, sizeof(str), "%s | %.2f frames/s", picture->name, fstep / swaptime);
playanim_window_get_size(&sizex, &sizey);
fsizex_inv = 1.0f / sizex;
fsizey_inv = 1.0f / sizey;
BLF_enable(fontid, BLF_ASPECT);
BLF_aspect(fontid, fsizex_inv, fsizey_inv, 1.0f);
BLF_position(fontid, 10.0f * fsizex_inv, 10.0f * fsizey_inv, 0.0f);
BLF_draw(fontid, str, sizeof(str));
}
GHOST_SwapWindowBuffers(g_WS.ghost_window);
}
static void build_pict_list(PlayState *ps, char *first, int totframes, int fstep, int fontid)
2012-08-06 16:07:11 +00:00
{
char *mem, filepath[FILE_MAX];
// short val;
PlayAnimPict *picture = NULL;
struct ImBuf *ibuf = NULL;
char str[32 + FILE_MAX];
struct anim *anim;
if (IMB_isanim(first)) {
Color Management, Stage 2: Switch color pipeline to use OpenColorIO Replace old color pipeline which was supporting linear/sRGB color spaces only with OpenColorIO-based pipeline. This introduces two configurable color spaces: - Input color space for images and movie clips. This space is used to convert images/movies from color space in which file is saved to Blender's linear space (for float images, byte images are not internally converted, only input space is stored for such images and used later). This setting could be found in image/clip data block settings. - Display color space which defines space in which particular display is working. This settings could be found in scene's Color Management panel. When render result is being displayed on the screen, apart from converting image to display space, some additional conversions could happen. This conversions are: - View, which defines tone curve applying before display transformation. These are different ways to view the image on the same display device. For example it could be used to emulate film view on sRGB display. - Exposure affects on image exposure before tone map is applied. - Gamma is post-display gamma correction, could be used to match particular display gamma. - RGB curves are user-defined curves which are applying before display transformation, could be used for different purposes. All this settings by default are only applying on render result and does not affect on other images. If some particular image needs to be affected by this transformation, "View as Render" setting of image data block should be set to truth. Movie clips are always affected by all display transformations. This commit also introduces configurable color space in which sequencer is working. This setting could be found in scene's Color Management panel and it should be used if such stuff as grading needs to be done in color space different from sRGB (i.e. when Film view on sRGB display is use, using VD16 space as sequencer's internal space would make grading working in space which is close to the space using for display). Some technical notes: - Image buffer's float buffer is now always in linear space, even if it was created from 16bit byte images. - Space of byte buffer is stored in image buffer's rect_colorspace property. - Profile of image buffer was removed since it's not longer meaningful. - OpenGL and GLSL is supposed to always work in sRGB space. It is possible to support other spaces, but it's quite large project which isn't so much important. - Legacy Color Management option disabled is emulated by using None display. It could have some regressions, but there's no clear way to avoid them. - If OpenColorIO is disabled on build time, it should make blender behaving in the same way as previous release with color management enabled. More details could be found at this page (more details would be added soon): http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management -- Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO integration and to Brecht van Lommel for some further development and code/ usecase review!
2012-09-15 10:05:07 +00:00
/* OCIO_TODO: support different input color space */
anim = IMB_open_anim(first, IB_rect, 0, NULL);
2012-08-06 16:07:11 +00:00
if (anim) {
int pic;
ibuf = IMB_anim_absolute(anim, 0, IMB_TC_NONE, IMB_PROXY_NONE);
if (ibuf) {
playanim_toscreen(ps, NULL, ibuf, fontid, fstep);
2012-08-06 16:07:11 +00:00
IMB_freeImBuf(ibuf);
}
for (pic = 0; pic < IMB_anim_get_duration(anim, IMB_TC_NONE); pic++) {
picture = (PlayAnimPict *)MEM_callocN(sizeof(PlayAnimPict), "Pict");
picture->anim = anim;
picture->frame = pic;
picture->IB_flags = IB_rect;
BLI_snprintf(str, sizeof(str), "%s : %4.d", first, pic + 1);
picture->name = strdup(str);
BLI_addtail(&picsbase, picture);
}
}
else {
printf("couldn't open anim %s\n", first);
}
}
else {
int count = 0;
BLI_strncpy(filepath, first, sizeof(filepath));
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(filepath) && totframes) {
size_t size;
int file;
file = open(filepath, O_BINARY | O_RDONLY, 0);
if (file < 0) {
/* print errno? */
return;
}
2012-08-06 16:07:11 +00:00
picture = (PlayAnimPict *)MEM_callocN(sizeof(PlayAnimPict), "picture");
if (picture == NULL) {
printf("Not enough memory for pict struct '%s'\n", filepath);
close(file);
return;
}
size = BLI_file_descriptor_size(file);
if (size < 1) {
close(file);
MEM_freeN(picture);
return;
}
picture->size = size;
picture->IB_flags = IB_rect;
if (fromdisk == false) {
2012-08-06 16:07:11 +00:00
mem = (char *)MEM_mallocN(size, "build pic list");
if (mem == NULL) {
printf("Couldn't get memory\n");
close(file);
MEM_freeN(picture);
return;
}
if (read(file, mem, size) != size) {
printf("Error while reading %s\n", filepath);
close(file);
MEM_freeN(picture);
MEM_freeN(mem);
return;
}
}
else {
mem = NULL;
}
picture->mem = mem;
picture->name = strdup(filepath);
close(file);
BLI_addtail(&picsbase, picture);
count++;
pupdate_time();
if (ptottime > 1.0) {
Color Management, Stage 2: Switch color pipeline to use OpenColorIO Replace old color pipeline which was supporting linear/sRGB color spaces only with OpenColorIO-based pipeline. This introduces two configurable color spaces: - Input color space for images and movie clips. This space is used to convert images/movies from color space in which file is saved to Blender's linear space (for float images, byte images are not internally converted, only input space is stored for such images and used later). This setting could be found in image/clip data block settings. - Display color space which defines space in which particular display is working. This settings could be found in scene's Color Management panel. When render result is being displayed on the screen, apart from converting image to display space, some additional conversions could happen. This conversions are: - View, which defines tone curve applying before display transformation. These are different ways to view the image on the same display device. For example it could be used to emulate film view on sRGB display. - Exposure affects on image exposure before tone map is applied. - Gamma is post-display gamma correction, could be used to match particular display gamma. - RGB curves are user-defined curves which are applying before display transformation, could be used for different purposes. All this settings by default are only applying on render result and does not affect on other images. If some particular image needs to be affected by this transformation, "View as Render" setting of image data block should be set to truth. Movie clips are always affected by all display transformations. This commit also introduces configurable color space in which sequencer is working. This setting could be found in scene's Color Management panel and it should be used if such stuff as grading needs to be done in color space different from sRGB (i.e. when Film view on sRGB display is use, using VD16 space as sequencer's internal space would make grading working in space which is close to the space using for display). Some technical notes: - Image buffer's float buffer is now always in linear space, even if it was created from 16bit byte images. - Space of byte buffer is stored in image buffer's rect_colorspace property. - Profile of image buffer was removed since it's not longer meaningful. - OpenGL and GLSL is supposed to always work in sRGB space. It is possible to support other spaces, but it's quite large project which isn't so much important. - Legacy Color Management option disabled is emulated by using None display. It could have some regressions, but there's no clear way to avoid them. - If OpenColorIO is disabled on build time, it should make blender behaving in the same way as previous release with color management enabled. More details could be found at this page (more details would be added soon): http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management -- Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO integration and to Brecht van Lommel for some further development and code/ usecase review!
2012-09-15 10:05:07 +00:00
/* OCIO_TODO: support different input color space */
2012-08-06 16:07:11 +00:00
if (picture->mem) {
ibuf = IMB_ibImageFromMemory((unsigned char *)picture->mem, picture->size,
Color Management, Stage 2: Switch color pipeline to use OpenColorIO Replace old color pipeline which was supporting linear/sRGB color spaces only with OpenColorIO-based pipeline. This introduces two configurable color spaces: - Input color space for images and movie clips. This space is used to convert images/movies from color space in which file is saved to Blender's linear space (for float images, byte images are not internally converted, only input space is stored for such images and used later). This setting could be found in image/clip data block settings. - Display color space which defines space in which particular display is working. This settings could be found in scene's Color Management panel. When render result is being displayed on the screen, apart from converting image to display space, some additional conversions could happen. This conversions are: - View, which defines tone curve applying before display transformation. These are different ways to view the image on the same display device. For example it could be used to emulate film view on sRGB display. - Exposure affects on image exposure before tone map is applied. - Gamma is post-display gamma correction, could be used to match particular display gamma. - RGB curves are user-defined curves which are applying before display transformation, could be used for different purposes. All this settings by default are only applying on render result and does not affect on other images. If some particular image needs to be affected by this transformation, "View as Render" setting of image data block should be set to truth. Movie clips are always affected by all display transformations. This commit also introduces configurable color space in which sequencer is working. This setting could be found in scene's Color Management panel and it should be used if such stuff as grading needs to be done in color space different from sRGB (i.e. when Film view on sRGB display is use, using VD16 space as sequencer's internal space would make grading working in space which is close to the space using for display). Some technical notes: - Image buffer's float buffer is now always in linear space, even if it was created from 16bit byte images. - Space of byte buffer is stored in image buffer's rect_colorspace property. - Profile of image buffer was removed since it's not longer meaningful. - OpenGL and GLSL is supposed to always work in sRGB space. It is possible to support other spaces, but it's quite large project which isn't so much important. - Legacy Color Management option disabled is emulated by using None display. It could have some regressions, but there's no clear way to avoid them. - If OpenColorIO is disabled on build time, it should make blender behaving in the same way as previous release with color management enabled. More details could be found at this page (more details would be added soon): http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management -- Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO integration and to Brecht van Lommel for some further development and code/ usecase review!
2012-09-15 10:05:07 +00:00
picture->IB_flags, NULL, picture->name);
2012-08-06 16:07:11 +00:00
}
else {
Color Management, Stage 2: Switch color pipeline to use OpenColorIO Replace old color pipeline which was supporting linear/sRGB color spaces only with OpenColorIO-based pipeline. This introduces two configurable color spaces: - Input color space for images and movie clips. This space is used to convert images/movies from color space in which file is saved to Blender's linear space (for float images, byte images are not internally converted, only input space is stored for such images and used later). This setting could be found in image/clip data block settings. - Display color space which defines space in which particular display is working. This settings could be found in scene's Color Management panel. When render result is being displayed on the screen, apart from converting image to display space, some additional conversions could happen. This conversions are: - View, which defines tone curve applying before display transformation. These are different ways to view the image on the same display device. For example it could be used to emulate film view on sRGB display. - Exposure affects on image exposure before tone map is applied. - Gamma is post-display gamma correction, could be used to match particular display gamma. - RGB curves are user-defined curves which are applying before display transformation, could be used for different purposes. All this settings by default are only applying on render result and does not affect on other images. If some particular image needs to be affected by this transformation, "View as Render" setting of image data block should be set to truth. Movie clips are always affected by all display transformations. This commit also introduces configurable color space in which sequencer is working. This setting could be found in scene's Color Management panel and it should be used if such stuff as grading needs to be done in color space different from sRGB (i.e. when Film view on sRGB display is use, using VD16 space as sequencer's internal space would make grading working in space which is close to the space using for display). Some technical notes: - Image buffer's float buffer is now always in linear space, even if it was created from 16bit byte images. - Space of byte buffer is stored in image buffer's rect_colorspace property. - Profile of image buffer was removed since it's not longer meaningful. - OpenGL and GLSL is supposed to always work in sRGB space. It is possible to support other spaces, but it's quite large project which isn't so much important. - Legacy Color Management option disabled is emulated by using None display. It could have some regressions, but there's no clear way to avoid them. - If OpenColorIO is disabled on build time, it should make blender behaving in the same way as previous release with color management enabled. More details could be found at this page (more details would be added soon): http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management -- Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO integration and to Brecht van Lommel for some further development and code/ usecase review!
2012-09-15 10:05:07 +00:00
ibuf = IMB_loadiffname(picture->name, picture->IB_flags, NULL);
2012-08-06 16:07:11 +00:00
}
if (ibuf) {
playanim_toscreen(ps, picture, ibuf, fontid, fstep);
2012-08-06 16:07:11 +00:00
IMB_freeImBuf(ibuf);
}
pupdate_time();
ptottime = 0.0;
}
BLI_newname(filepath, +fstep);
#if 0 // XXX25
while (qtest()) {
switch (qreadN(&val)) {
case ESCKEY:
if (val) return;
break;
}
}
#endif
totframes--;
}
}
return;
}
static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void)
{
PlayState *ps = (PlayState *)ps_void;
GHOST_TEventType type = GHOST_GetEventType(evt);
int val;
// print_ps(ps);
playanim_event_qual_update();
/* convert ghost event into value keyboard or mouse */
val = ELEM(type, GHOST_kEventKeyDown, GHOST_kEventButtonDown);
if (ps->wait2 && ps->stopped) {
ps->stopped = false;
2012-08-06 16:07:11 +00:00
}
if (ps->wait2) {
pupdate_time();
ptottime = 0;
}
2012-08-06 16:07:11 +00:00
switch (type) {
case GHOST_kEventKeyDown:
case GHOST_kEventKeyUp:
{
GHOST_TEventKeyData *key_data;
key_data = (GHOST_TEventKeyData *)GHOST_GetEventData(evt);
switch (key_data->key) {
case GHOST_kKeyA:
if (val) ps->noskip = !ps->noskip;
break;
case GHOST_kKeyP:
if (val) ps->pingpong = !ps->pingpong;
break;
case GHOST_kKey1:
2012-08-06 16:07:11 +00:00
case GHOST_kKeyNumpad1:
if (val) swaptime = ps->fstep / 60.0;
2012-08-06 16:07:11 +00:00
break;
case GHOST_kKey2:
2012-08-06 16:07:11 +00:00
case GHOST_kKeyNumpad2:
if (val) swaptime = ps->fstep / 50.0;
2012-08-06 16:07:11 +00:00
break;
case GHOST_kKey3:
2012-08-06 16:07:11 +00:00
case GHOST_kKeyNumpad3:
if (val) swaptime = ps->fstep / 30.0;
2012-08-06 16:07:11 +00:00
break;
case GHOST_kKey4:
2012-08-06 16:07:11 +00:00
case GHOST_kKeyNumpad4:
if (g_WS.qual & WS_QUAL_SHIFT)
swaptime = ps->fstep / 24.0;
2012-08-06 16:07:11 +00:00
else
swaptime = ps->fstep / 25.0;
2012-08-06 16:07:11 +00:00
break;
case GHOST_kKey5:
2012-08-06 16:07:11 +00:00
case GHOST_kKeyNumpad5:
if (val) swaptime = ps->fstep / 20.0;
2012-08-06 16:07:11 +00:00
break;
case GHOST_kKey6:
2012-08-06 16:07:11 +00:00
case GHOST_kKeyNumpad6:
if (val) swaptime = ps->fstep / 15.0;
2012-08-06 16:07:11 +00:00
break;
case GHOST_kKey7:
2012-08-06 16:07:11 +00:00
case GHOST_kKeyNumpad7:
if (val) swaptime = ps->fstep / 12.0;
2012-08-06 16:07:11 +00:00
break;
case GHOST_kKey8:
2012-08-06 16:07:11 +00:00
case GHOST_kKeyNumpad8:
if (val) swaptime = ps->fstep / 10.0;
2012-08-06 16:07:11 +00:00
break;
case GHOST_kKey9:
2012-08-06 16:07:11 +00:00
case GHOST_kKeyNumpad9:
if (val) swaptime = ps->fstep / 6.0;
2012-08-06 16:07:11 +00:00
break;
case GHOST_kKeyLeftArrow:
if (val) {
ps->sstep = true;
ps->wait2 = false;
2012-08-06 16:07:11 +00:00
if (g_WS.qual & WS_QUAL_SHIFT) {
ps->picture = picsbase.first;
ps->next_frame = 0;
2012-08-06 16:07:11 +00:00
}
else {
ps->next_frame = -1;
2012-08-06 16:07:11 +00:00
}
}
break;
case GHOST_kKeyDownArrow:
if (val) {
ps->wait2 = false;
2012-08-06 16:07:11 +00:00
if (g_WS.qual & WS_QUAL_SHIFT) {
ps->next_frame = ps->direction = -1;
2012-08-06 16:07:11 +00:00
}
else {
ps->next_frame = -10;
ps->sstep = true;
2012-08-06 16:07:11 +00:00
}
}
break;
case GHOST_kKeyRightArrow:
if (val) {
ps->sstep = true;
ps->wait2 = false;
2012-08-06 16:07:11 +00:00
if (g_WS.qual & WS_QUAL_SHIFT) {
ps->picture = picsbase.last;
ps->next_frame = 0;
2012-08-06 16:07:11 +00:00
}
else {
ps->next_frame = 1;
2012-08-06 16:07:11 +00:00
}
}
break;
case GHOST_kKeyUpArrow:
if (val) {
ps->wait2 = false;
2012-08-06 16:07:11 +00:00
if (g_WS.qual & WS_QUAL_SHIFT) {
ps->next_frame = ps->direction = 1;
2012-08-06 16:07:11 +00:00
}
else {
ps->next_frame = 10;
ps->sstep = true;
2012-08-06 16:07:11 +00:00
}
}
break;
case GHOST_kKeySlash:
case GHOST_kKeyNumpadSlash:
if (val) {
if (g_WS.qual & WS_QUAL_SHIFT) {
if (ps->curframe_ibuf)
printf(" Name: %s | Speed: %.2f frames/s\n",
ps->curframe_ibuf->name, ps->fstep / swaptime);
2012-08-06 16:07:11 +00:00
}
else {
swaptime = ps->fstep / 5.0;
2012-08-06 16:07:11 +00:00
}
}
break;
case GHOST_kKey0:
2012-08-06 16:07:11 +00:00
case GHOST_kKeyNumpad0:
if (val) {
if (ps->once) {
ps->once = ps->wait2 = false;
2012-08-06 16:07:11 +00:00
}
else {
ps->picture = NULL;
ps->once = true;
ps->wait2 = false;
2012-08-06 16:07:11 +00:00
}
}
break;
case GHOST_kKeyEnter:
case GHOST_kKeyNumpadEnter:
if (val) {
ps->wait2 = ps->sstep = false;
2012-08-06 16:07:11 +00:00
}
break;
case GHOST_kKeyPeriod:
2012-08-06 16:07:11 +00:00
case GHOST_kKeyNumpadPeriod:
if (val) {
if (ps->sstep) {
ps->wait2 = false;
}
2012-08-06 16:07:11 +00:00
else {
ps->sstep = true;
2012-08-06 16:07:11 +00:00
ps->wait2 = !ps->wait2;
}
}
break;
case GHOST_kKeyEqual:
2012-08-06 16:07:11 +00:00
case GHOST_kKeyNumpadPlus:
{
2012-08-06 16:07:11 +00:00
if (val == 0) break;
if (g_WS.qual & WS_QUAL_CTRL) {
playanim_window_zoom(ps, 1.0f);
}
else {
swaptime /= 1.1;
}
break;
}
case GHOST_kKeyMinus:
2012-08-06 16:07:11 +00:00
case GHOST_kKeyNumpadMinus:
{
if (val == 0) break;
if (g_WS.qual & WS_QUAL_CTRL) {
playanim_window_zoom(ps, -1.0f);
}
else {
swaptime *= 1.1;
}
2012-08-06 16:07:11 +00:00
break;
}
case GHOST_kKeyEsc:
ps->go = false;
2012-08-06 16:07:11 +00:00
break;
default:
break;
}
break;
}
case GHOST_kEventButtonDown:
case GHOST_kEventButtonUp:
{
GHOST_TEventButtonData *bd = GHOST_GetEventData(evt);
int cx, cy, sizex, sizey, inside_window;
GHOST_GetCursorPosition(g_WS.ghost_system, &cx, &cy);
GHOST_ScreenToClient(g_WS.ghost_window, cx, cy, &cx, &cy);
playanim_window_get_size(&sizex, &sizey);
inside_window = (cx >= 0 && cx < sizex && cy >= 0 && cy <= sizey);
if (bd->button == GHOST_kButtonMaskLeft) {
if (type == GHOST_kEventButtonDown) {
if (inside_window)
g_WS.qual |= WS_QUAL_LMOUSE;
}
else
g_WS.qual &= ~WS_QUAL_LMOUSE;
}
else if (bd->button == GHOST_kButtonMaskMiddle) {
if (type == GHOST_kEventButtonDown) {
if (inside_window)
g_WS.qual |= WS_QUAL_MMOUSE;
}
else
g_WS.qual &= ~WS_QUAL_MMOUSE;
}
else if (bd->button == GHOST_kButtonMaskRight) {
if (type == GHOST_kEventButtonDown) {
if (inside_window)
g_WS.qual |= WS_QUAL_RMOUSE;
}
else
g_WS.qual &= ~WS_QUAL_RMOUSE;
}
break;
}
2012-08-06 16:07:11 +00:00
case GHOST_kEventCursorMove:
{
if (g_WS.qual & WS_QUAL_LMOUSE) {
int sizex, sizey;
int i;
GHOST_TEventCursorData *cd = GHOST_GetEventData(evt);
int cx, cy;
GHOST_ScreenToClient(g_WS.ghost_window, cd->x, cd->y, &cx, &cy);
playanim_window_get_size(&sizex, &sizey);
ps->picture = picsbase.first;
/* TODO - store in ps direct? */
i = 0;
while (ps->picture) {
i++;
ps->picture = ps->picture->next;
}
i = (i * cx) / sizex;
ps->picture = picsbase.first;
for (; i > 0; i--) {
if (ps->picture->next == NULL) break;
ps->picture = ps->picture->next;
}
ps->sstep = true;
ps->wait2 = false;
ps->next_frame = 0;
2012-08-06 16:07:11 +00:00
}
break;
}
case GHOST_kEventWindowActivate:
2013-01-15 23:45:41 +00:00
case GHOST_kEventWindowDeactivate:
{
g_WS.qual &= ~WS_QUAL_MOUSE;
break;
}
2012-08-06 16:07:11 +00:00
case GHOST_kEventWindowSize:
case GHOST_kEventWindowMove:
{
float zoomx, zoomy;
playanim_window_get_size(&ps->win_x, &ps->win_y);
2012-08-06 16:07:11 +00:00
GHOST_ActivateWindowDrawingContext(g_WS.ghost_window);
zoomx = (float) ps->win_x / ps->ibufx;
zoomy = (float) ps->win_y / ps->ibufy;
/* zoom always show entire image */
ps->zoom = MIN2(zoomx, zoomy);
/* zoom steps of 2 for speed */
ps->zoom = floor(ps->zoom + 0.5f);
if (ps->zoom < 1.0f) ps->zoom = 1.0f;
glViewport(0, 0, ps->win_x, ps->win_y);
glScissor(0, 0, ps->win_x, ps->win_y);
/* unified matrix, note it affects offset for drawing */
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0f, 1.0f, 0.0f, 1.0f, -1.0f, 1.0f);
glMatrixMode(GL_MODELVIEW);
2012-08-06 16:07:11 +00:00
glPixelZoom(ps->zoom, ps->zoom);
2012-08-06 16:07:11 +00:00
ptottime = 0.0;
playanim_toscreen(ps, ps->picture, ps->curframe_ibuf, ps->fontid, ps->fstep);
2012-08-06 16:07:11 +00:00
break;
}
case GHOST_kEventQuit:
case GHOST_kEventWindowClose:
{
ps->go = false;
2012-08-06 16:07:11 +00:00
break;
}
case GHOST_kEventDraggingDropDone:
{
GHOST_TEventDragnDropData *ddd = GHOST_GetEventData(evt);
if (ddd->dataType == GHOST_kDragnDropTypeFilenames) {
GHOST_TStringArray *stra = ddd->data;
int a;
for (a = 0; a < stra->count; a++) {
BLI_strncpy(ps->dropped_file, (char *)stra->strings[a], sizeof(ps->dropped_file));
ps->go = false;
printf("drop file %s\n", stra->strings[a]);
break; /* only one drop element supported now */
}
}
break;
}
2012-08-06 16:07:11 +00:00
default:
/* quiet warnings */
break;
}
return 1;
}
static void playanim_window_open(const char *title, int posx, int posy, int sizex, int sizey)
2012-08-06 16:07:11 +00:00
{
GHOST_TUns32 scr_w, scr_h;
GHOST_GetMainDisplayDimensions(g_WS.ghost_system, &scr_w, &scr_h);
posy = (scr_h - posy - sizey);
g_WS.ghost_window = GHOST_CreateWindow(g_WS.ghost_system,
title,
posx, posy, sizex, sizey,
/* could optionally start fullscreen */
GHOST_kWindowStateNormal,
GHOST_kDrawingContextTypeOpenGL,
false /* no stereo */, false);
2012-08-06 16:07:11 +00:00
}
static void playanim_window_zoom(PlayState *ps, const float zoom_offset)
{
int sizex, sizey;
/* int ofsx, ofsy; */ /* UNUSED */
if (ps->zoom + zoom_offset > 0.0f) ps->zoom += zoom_offset;
// playanim_window_get_position(&ofsx, &ofsy);
playanim_window_get_size(&sizex, &sizey);
/* ofsx += sizex / 2; */ /* UNUSED */
/* ofsy += sizey / 2; */ /* UNUSED */
sizex = ps->zoom * ps->ibufx;
sizey = ps->zoom * ps->ibufy;
/* ofsx -= sizex / 2; */ /* UNUSED */
/* ofsy -= sizey / 2; */ /* UNUSED */
2013-03-18 18:25:05 +00:00
// window_set_position(g_WS.ghost_window, sizex, sizey);
GHOST_SetClientSize(g_WS.ghost_window, sizex, sizey);
}
2012-08-06 16:07:11 +00:00
/* return path for restart */
static char *wm_main_playanim_intern(int argc, const char **argv)
2012-08-06 16:07:11 +00:00
{
struct ImBuf *ibuf = NULL;
static char filepath[FILE_MAX]; /* abused to return dropped file path */
2012-08-06 16:07:11 +00:00
GHOST_TUns32 maxwinx, maxwiny;
int i;
/* This was done to disambiguate the name for use under c++. */
struct anim *anim = NULL;
int start_x = 0, start_y = 0;
int sfra = -1;
int efra = -1;
int totblock;
2012-08-06 16:07:11 +00:00
PlayState ps = {0};
/* ps.doubleb = true;*/ /* UNUSED */
ps.go = true;
ps.direction = true;
ps.next_frame = 1;
ps.once = false;
ps.turbo = false;
ps.pingpong = false;
ps.noskip = false;
ps.sstep = false;
ps.wait2 = false;
ps.stopped = false;
2012-08-06 16:07:11 +00:00
ps.picture = NULL;
ps.dropped_file[0] = 0;
ps.zoom = 1.0f;
/* resetmap = false */
2012-08-06 16:07:11 +00:00
ps.fstep = 1;
2012-08-06 16:07:11 +00:00
ps.fontid = -1;
while (argc > 1) {
if (argv[1][0] == '-') {
switch (argv[1][1]) {
case 'm':
fromdisk = true;
2012-08-06 16:07:11 +00:00
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.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 = atoi(argv[2]);
CLAMP(sfra, 1, MAXFRAME);
2012-08-06 16:07:11 +00:00
argc--;
argv++;
break;
case 'e':
efra = atoi(argv[2]);
CLAMP(efra, 1, MAXFRAME);
2012-08-06 16:07:11 +00:00
argc--;
argv++;
break;
case 'j':
ps.fstep = atoi(argv[2]);
CLAMP(ps.fstep, 1, MAXFRAME);
swaptime *= ps.fstep;
2012-08-06 16:07:11 +00:00
argc--;
argv++;
break;
default:
printf("unknown option '%c': skipping\n", argv[1][1]);
break;
}
argc--;
argv++;
}
else {
break;
}
}
if (argc > 1) {
BLI_strncpy(filepath, argv[1], sizeof(filepath));
}
else {
BLI_current_working_dir(filepath, sizeof(filepath));
BLI_add_slash(filepath);
}
if (IMB_isanim(filepath)) {
Color Management, Stage 2: Switch color pipeline to use OpenColorIO Replace old color pipeline which was supporting linear/sRGB color spaces only with OpenColorIO-based pipeline. This introduces two configurable color spaces: - Input color space for images and movie clips. This space is used to convert images/movies from color space in which file is saved to Blender's linear space (for float images, byte images are not internally converted, only input space is stored for such images and used later). This setting could be found in image/clip data block settings. - Display color space which defines space in which particular display is working. This settings could be found in scene's Color Management panel. When render result is being displayed on the screen, apart from converting image to display space, some additional conversions could happen. This conversions are: - View, which defines tone curve applying before display transformation. These are different ways to view the image on the same display device. For example it could be used to emulate film view on sRGB display. - Exposure affects on image exposure before tone map is applied. - Gamma is post-display gamma correction, could be used to match particular display gamma. - RGB curves are user-defined curves which are applying before display transformation, could be used for different purposes. All this settings by default are only applying on render result and does not affect on other images. If some particular image needs to be affected by this transformation, "View as Render" setting of image data block should be set to truth. Movie clips are always affected by all display transformations. This commit also introduces configurable color space in which sequencer is working. This setting could be found in scene's Color Management panel and it should be used if such stuff as grading needs to be done in color space different from sRGB (i.e. when Film view on sRGB display is use, using VD16 space as sequencer's internal space would make grading working in space which is close to the space using for display). Some technical notes: - Image buffer's float buffer is now always in linear space, even if it was created from 16bit byte images. - Space of byte buffer is stored in image buffer's rect_colorspace property. - Profile of image buffer was removed since it's not longer meaningful. - OpenGL and GLSL is supposed to always work in sRGB space. It is possible to support other spaces, but it's quite large project which isn't so much important. - Legacy Color Management option disabled is emulated by using None display. It could have some regressions, but there's no clear way to avoid them. - If OpenColorIO is disabled on build time, it should make blender behaving in the same way as previous release with color management enabled. More details could be found at this page (more details would be added soon): http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management -- Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO integration and to Brecht van Lommel for some further development and code/ usecase review!
2012-09-15 10:05:07 +00:00
/* OCIO_TODO: support different input color spaces */
anim = IMB_open_anim(filepath, IB_rect, 0, NULL);
2012-08-06 16:07:11 +00:00
if (anim) {
ibuf = IMB_anim_absolute(anim, 0, IMB_TC_NONE, IMB_PROXY_NONE);
IMB_close_anim(anim);
anim = NULL;
}
}
else if (!IMB_ispic(filepath)) {
printf("%s: '%s' not an image file\n", __func__, filepath);
2012-08-06 16:07:11 +00:00
exit(1);
}
if (ibuf == NULL) {
Color Management, Stage 2: Switch color pipeline to use OpenColorIO Replace old color pipeline which was supporting linear/sRGB color spaces only with OpenColorIO-based pipeline. This introduces two configurable color spaces: - Input color space for images and movie clips. This space is used to convert images/movies from color space in which file is saved to Blender's linear space (for float images, byte images are not internally converted, only input space is stored for such images and used later). This setting could be found in image/clip data block settings. - Display color space which defines space in which particular display is working. This settings could be found in scene's Color Management panel. When render result is being displayed on the screen, apart from converting image to display space, some additional conversions could happen. This conversions are: - View, which defines tone curve applying before display transformation. These are different ways to view the image on the same display device. For example it could be used to emulate film view on sRGB display. - Exposure affects on image exposure before tone map is applied. - Gamma is post-display gamma correction, could be used to match particular display gamma. - RGB curves are user-defined curves which are applying before display transformation, could be used for different purposes. All this settings by default are only applying on render result and does not affect on other images. If some particular image needs to be affected by this transformation, "View as Render" setting of image data block should be set to truth. Movie clips are always affected by all display transformations. This commit also introduces configurable color space in which sequencer is working. This setting could be found in scene's Color Management panel and it should be used if such stuff as grading needs to be done in color space different from sRGB (i.e. when Film view on sRGB display is use, using VD16 space as sequencer's internal space would make grading working in space which is close to the space using for display). Some technical notes: - Image buffer's float buffer is now always in linear space, even if it was created from 16bit byte images. - Space of byte buffer is stored in image buffer's rect_colorspace property. - Profile of image buffer was removed since it's not longer meaningful. - OpenGL and GLSL is supposed to always work in sRGB space. It is possible to support other spaces, but it's quite large project which isn't so much important. - Legacy Color Management option disabled is emulated by using None display. It could have some regressions, but there's no clear way to avoid them. - If OpenColorIO is disabled on build time, it should make blender behaving in the same way as previous release with color management enabled. More details could be found at this page (more details would be added soon): http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management -- Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO integration and to Brecht van Lommel for some further development and code/ usecase review!
2012-09-15 10:05:07 +00:00
/* OCIO_TODO: support different input color space */
ibuf = IMB_loadiffname(filepath, IB_rect, NULL);
2012-08-06 16:07:11 +00:00
}
if (ibuf == NULL) {
printf("%s: '%s' couldn't open\n", __func__, filepath);
2012-08-06 16:07:11 +00:00
exit(1);
}
#if 0 //XXX25
#if !defined(WIN32) && !defined(__APPLE__)
2012-08-06 16:07:11 +00:00
if (fork()) exit(0);
#endif
2012-08-06 16:07:11 +00:00
#endif //XXX25
{
GHOST_EventConsumerHandle consumer = GHOST_CreateEventConsumer(ghost_event_proc, &ps);
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);
2012-08-06 16:07:11 +00:00
/* unified matrix, note it affects offset for drawing */
2012-08-06 16:07:11 +00:00
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0f, 1.0f, 0.0f, 1.0f, -1.0f, 1.0f);
glMatrixMode(GL_MODELVIEW);
}
GHOST_GetMainDisplayDimensions(g_WS.ghost_system, &maxwinx, &maxwiny);
//GHOST_ActivateWindowDrawingContext(g_WS.ghost_window);
/* initialize the font */
BLF_init(11, 72);
ps.fontid = BLF_load_mem("monospace", (unsigned char *)datatoc_bmonofont_ttf, datatoc_bmonofont_ttf_size);
BLF_size(ps.fontid, 11, 72);
ps.ibufx = ibuf->x;
ps.ibufy = ibuf->y;
ps.win_x = ps.ibufx;
ps.win_y = ps.ibufy;
2012-08-06 16:07:11 +00:00
if (maxwinx % ibuf->x) maxwinx = ibuf->x * (1 + (maxwinx / ibuf->x));
if (maxwiny % ibuf->y) maxwiny = ibuf->y * (1 + (maxwiny / ibuf->y));
glClearColor(0.1, 0.1, 0.1, 0.0);
2012-08-06 16:07:11 +00:00
glClear(GL_COLOR_BUFFER_BIT);
GHOST_SwapWindowBuffers(g_WS.ghost_window);
if (sfra == -1 || efra == -1) {
/* one of the frames was invalid, just use all images */
sfra = 1;
efra = MAXFRAME;
}
build_pict_list(&ps, filepath, (efra - sfra) + 1, ps.fstep, ps.fontid);
2012-08-06 16:07:11 +00:00
for (i = 2; i < argc; i++) {
BLI_strncpy(filepath, argv[i], sizeof(filepath));
build_pict_list(&ps, filepath, (efra - sfra) + 1, ps.fstep, ps.fontid);
2012-08-06 16:07:11 +00:00
}
IMB_freeImBuf(ibuf);
ibuf = NULL;
pupdate_time();
ptottime = 0;
/* newly added in 2.6x, without this images never get freed */
#define USE_IMB_CACHE
while (ps.go) {
if (ps.pingpong)
ps.direction = -ps.direction;
if (ps.direction == 1) {
ps.picture = picsbase.first;
}
else {
ps.picture = picsbase.last;
}
if (ps.picture == NULL) {
printf("couldn't find pictures\n");
ps.go = false;
2012-08-06 16:07:11 +00:00
}
if (ps.pingpong) {
if (ps.direction == 1) {
ps.picture = ps.picture->next;
}
else {
ps.picture = ps.picture->prev;
}
}
if (ptottime > 0.0) ptottime = 0.0;
while (ps.picture) {
int hasevent;
2012-08-06 16:07:11 +00:00
#ifndef USE_IMB_CACHE
if (ibuf != NULL && ibuf->ftype == 0) IMB_freeImBuf(ibuf);
#endif
if (ps.picture->ibuf) {
ibuf = ps.picture->ibuf;
}
else if (ps.picture->anim) {
ibuf = IMB_anim_absolute(ps.picture->anim, ps.picture->frame, IMB_TC_NONE, IMB_PROXY_NONE);
}
else if (ps.picture->mem) {
Color Management, Stage 2: Switch color pipeline to use OpenColorIO Replace old color pipeline which was supporting linear/sRGB color spaces only with OpenColorIO-based pipeline. This introduces two configurable color spaces: - Input color space for images and movie clips. This space is used to convert images/movies from color space in which file is saved to Blender's linear space (for float images, byte images are not internally converted, only input space is stored for such images and used later). This setting could be found in image/clip data block settings. - Display color space which defines space in which particular display is working. This settings could be found in scene's Color Management panel. When render result is being displayed on the screen, apart from converting image to display space, some additional conversions could happen. This conversions are: - View, which defines tone curve applying before display transformation. These are different ways to view the image on the same display device. For example it could be used to emulate film view on sRGB display. - Exposure affects on image exposure before tone map is applied. - Gamma is post-display gamma correction, could be used to match particular display gamma. - RGB curves are user-defined curves which are applying before display transformation, could be used for different purposes. All this settings by default are only applying on render result and does not affect on other images. If some particular image needs to be affected by this transformation, "View as Render" setting of image data block should be set to truth. Movie clips are always affected by all display transformations. This commit also introduces configurable color space in which sequencer is working. This setting could be found in scene's Color Management panel and it should be used if such stuff as grading needs to be done in color space different from sRGB (i.e. when Film view on sRGB display is use, using VD16 space as sequencer's internal space would make grading working in space which is close to the space using for display). Some technical notes: - Image buffer's float buffer is now always in linear space, even if it was created from 16bit byte images. - Space of byte buffer is stored in image buffer's rect_colorspace property. - Profile of image buffer was removed since it's not longer meaningful. - OpenGL and GLSL is supposed to always work in sRGB space. It is possible to support other spaces, but it's quite large project which isn't so much important. - Legacy Color Management option disabled is emulated by using None display. It could have some regressions, but there's no clear way to avoid them. - If OpenColorIO is disabled on build time, it should make blender behaving in the same way as previous release with color management enabled. More details could be found at this page (more details would be added soon): http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management -- Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO integration and to Brecht van Lommel for some further development and code/ usecase review!
2012-09-15 10:05:07 +00:00
/* use correct colorspace here */
2012-08-06 16:07:11 +00:00
ibuf = IMB_ibImageFromMemory((unsigned char *) ps.picture->mem, ps.picture->size,
Color Management, Stage 2: Switch color pipeline to use OpenColorIO Replace old color pipeline which was supporting linear/sRGB color spaces only with OpenColorIO-based pipeline. This introduces two configurable color spaces: - Input color space for images and movie clips. This space is used to convert images/movies from color space in which file is saved to Blender's linear space (for float images, byte images are not internally converted, only input space is stored for such images and used later). This setting could be found in image/clip data block settings. - Display color space which defines space in which particular display is working. This settings could be found in scene's Color Management panel. When render result is being displayed on the screen, apart from converting image to display space, some additional conversions could happen. This conversions are: - View, which defines tone curve applying before display transformation. These are different ways to view the image on the same display device. For example it could be used to emulate film view on sRGB display. - Exposure affects on image exposure before tone map is applied. - Gamma is post-display gamma correction, could be used to match particular display gamma. - RGB curves are user-defined curves which are applying before display transformation, could be used for different purposes. All this settings by default are only applying on render result and does not affect on other images. If some particular image needs to be affected by this transformation, "View as Render" setting of image data block should be set to truth. Movie clips are always affected by all display transformations. This commit also introduces configurable color space in which sequencer is working. This setting could be found in scene's Color Management panel and it should be used if such stuff as grading needs to be done in color space different from sRGB (i.e. when Film view on sRGB display is use, using VD16 space as sequencer's internal space would make grading working in space which is close to the space using for display). Some technical notes: - Image buffer's float buffer is now always in linear space, even if it was created from 16bit byte images. - Space of byte buffer is stored in image buffer's rect_colorspace property. - Profile of image buffer was removed since it's not longer meaningful. - OpenGL and GLSL is supposed to always work in sRGB space. It is possible to support other spaces, but it's quite large project which isn't so much important. - Legacy Color Management option disabled is emulated by using None display. It could have some regressions, but there's no clear way to avoid them. - If OpenColorIO is disabled on build time, it should make blender behaving in the same way as previous release with color management enabled. More details could be found at this page (more details would be added soon): http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management -- Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO integration and to Brecht van Lommel for some further development and code/ usecase review!
2012-09-15 10:05:07 +00:00
ps.picture->IB_flags, NULL, ps.picture->name);
2012-08-06 16:07:11 +00:00
}
else {
Color Management, Stage 2: Switch color pipeline to use OpenColorIO Replace old color pipeline which was supporting linear/sRGB color spaces only with OpenColorIO-based pipeline. This introduces two configurable color spaces: - Input color space for images and movie clips. This space is used to convert images/movies from color space in which file is saved to Blender's linear space (for float images, byte images are not internally converted, only input space is stored for such images and used later). This setting could be found in image/clip data block settings. - Display color space which defines space in which particular display is working. This settings could be found in scene's Color Management panel. When render result is being displayed on the screen, apart from converting image to display space, some additional conversions could happen. This conversions are: - View, which defines tone curve applying before display transformation. These are different ways to view the image on the same display device. For example it could be used to emulate film view on sRGB display. - Exposure affects on image exposure before tone map is applied. - Gamma is post-display gamma correction, could be used to match particular display gamma. - RGB curves are user-defined curves which are applying before display transformation, could be used for different purposes. All this settings by default are only applying on render result and does not affect on other images. If some particular image needs to be affected by this transformation, "View as Render" setting of image data block should be set to truth. Movie clips are always affected by all display transformations. This commit also introduces configurable color space in which sequencer is working. This setting could be found in scene's Color Management panel and it should be used if such stuff as grading needs to be done in color space different from sRGB (i.e. when Film view on sRGB display is use, using VD16 space as sequencer's internal space would make grading working in space which is close to the space using for display). Some technical notes: - Image buffer's float buffer is now always in linear space, even if it was created from 16bit byte images. - Space of byte buffer is stored in image buffer's rect_colorspace property. - Profile of image buffer was removed since it's not longer meaningful. - OpenGL and GLSL is supposed to always work in sRGB space. It is possible to support other spaces, but it's quite large project which isn't so much important. - Legacy Color Management option disabled is emulated by using None display. It could have some regressions, but there's no clear way to avoid them. - If OpenColorIO is disabled on build time, it should make blender behaving in the same way as previous release with color management enabled. More details could be found at this page (more details would be added soon): http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management -- Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO integration and to Brecht van Lommel for some further development and code/ usecase review!
2012-09-15 10:05:07 +00:00
/* use correct colorspace here */
ibuf = IMB_loadiffname(ps.picture->name, ps.picture->IB_flags, NULL);
2012-08-06 16:07:11 +00:00
}
if (ibuf) {
#ifdef USE_IMB_CACHE
ps.picture->ibuf = ibuf;
#endif
BLI_strncpy(ibuf->name, ps.picture->name, sizeof(ibuf->name));
/* why only windows? (from 2.4x) - campbell */
#ifdef _WIN32
GHOST_SetTitle(g_WS.ghost_window, ps.picture->name);
#endif
while (pupdate_time()) PIL_sleep_ms(1);
ptottime -= swaptime;
playanim_toscreen(&ps, ps.picture, ibuf, ps.fontid, ps.fstep);
} /* else delete */
2012-08-06 16:07:11 +00:00
else {
printf("error: can't play this image type\n");
exit(0);
}
if (ps.once) {
if (ps.picture->next == NULL) {
ps.wait2 = true;
2012-08-06 16:07:11 +00:00
}
else if (ps.picture->prev == NULL) {
ps.wait2 = true;
2012-08-06 16:07:11 +00:00
}
}
ps.next_frame = ps.direction;
2012-08-06 16:07:11 +00:00
while ((hasevent = GHOST_ProcessEvents(g_WS.ghost_system, 0)) || ps.wait2) {
2012-08-06 16:07:11 +00:00
if (hasevent) {
GHOST_DispatchEvents(g_WS.ghost_system);
}
/* Note, this still draws for mousemoves on pause */
if (ps.wait2) {
if (hasevent) {
if (ibuf) {
while (pupdate_time()) PIL_sleep_ms(1);
ptottime -= swaptime;
playanim_toscreen(&ps, ps.picture, ibuf, ps.fontid, ps.fstep);
}
}
}
if (ps.go == false) {
break;
}
2012-08-06 16:07:11 +00:00
}
ps.wait2 = ps.sstep;
if (ps.wait2 == false && ps.stopped == false) {
ps.stopped = true;
2012-08-06 16:07:11 +00:00
}
pupdate_time();
if (ps.picture && ps.next_frame) {
2012-08-06 16:07:11 +00:00
/* always at least set one step */
while (ps.picture) {
ps.picture = playanim_step(ps.picture, ps.next_frame);
2012-08-06 16:07:11 +00:00
if (ps.once && ps.picture != NULL) {
if (ps.picture->next == NULL) {
ps.wait2 = true;
2012-08-06 16:07:11 +00:00
}
else if (ps.picture->prev == NULL) {
ps.wait2 = true;
2012-08-06 16:07:11 +00:00
}
}
if (ps.wait2 || ptottime < swaptime || ps.turbo || ps.noskip) break;
ptottime -= swaptime;
}
if (ps.picture == NULL && ps.sstep) {
ps.picture = playanim_step(ps.picture, ps.next_frame);
2012-08-06 16:07:11 +00:00
}
}
if (ps.go == false) {
2012-08-06 16:07:11 +00:00
break;
}
}
}
ps.picture = picsbase.first;
anim = NULL;
while (ps.picture) {
if (ps.picture && ps.picture->anim && (anim != ps.picture->anim)) {
// to prevent divx crashes
anim = ps.picture->anim;
IMB_close_anim(anim);
}
if (ps.picture->ibuf) {
IMB_freeImBuf(ps.picture->ibuf);
}
if (ps.picture->mem) {
MEM_freeN(ps.picture->mem);
}
ps.picture = ps.picture->next;
}
/* cleanup */
#ifndef USE_IMB_CACHE
if (ibuf) IMB_freeImBuf(ibuf);
#endif
BLI_freelistN(&picsbase);
#if 0 // XXX25
free_blender();
#else
/* we still miss freeing a lot!,
* but many areas could skip initialization too for anim play */
2012-08-06 16:07:11 +00:00
BLF_exit();
#endif
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[0]) {
BLI_strncpy(filepath, ps.dropped_file, sizeof(filepath));
return filepath;
}
IMB_exit();
BKE_images_exit();
Threaded object update and EvaluationContext Summary: Made objects update happening from multiple threads. It is a task-based scheduling system which uses current dependency graph for spawning new tasks. This means threading happens on object level, but the system is flexible enough for higher granularity. Technical details: - Uses task scheduler which was recently committed to trunk (that one which Brecht ported from Cycles). - Added two utility functions to dependency graph: * DAG_threaded_update_begin, which is called to initialize threaded objects update. It will also schedule root DAG node to the queue, hence starting evaluation process. Initialization will calculate how much parents are to be evaluation before current DAG node can be scheduled. This value is used by task threads for faster detecting which nodes might be scheduled. * DAG_threaded_update_handle_node_updated which is called from task thread function when node was fully handled. This function decreases num_pending_parents of node children and schedules children with zero valency. As it might have become clear, task thread receives DAG nodes and decides which callback to call for it. Currently only BKE_object_handle_update is called for object nodes. In the future it'll call node->callback() from Ali's new DAG. - This required adding some workarounds to the render pipeline. Mainly to stop using get_object_dm() from modifiers' apply callback. Such a call was only a workaround for dependency graph glitch when rendering scene with, say, boolean modifiers before displaying this scene. Such change moves workaround from one place to another, so overall hackentropy remains the same. - Added paradigm of EvaluaitonContext. Currently it's more like just a more reliable replacement for G.is_rendering which fails in some circumstances. Future idea of this context is to also store all the local data needed for objects evaluation such as local time, Copy-on-Write data and so. There're two types of EvaluationContext: * Context used for viewport updated and owned by Main. In the future this context might be easily moved to Window or Screen to allo per-window/per-screen local time. * Context used by render engines to evaluate objects for render purposes. Render engine is an owner of this context. This context is passed to all object update routines. Reviewers: brecht, campbellbarton Reviewed By: brecht CC: lukastoenne Differential Revision: https://developer.blender.org/D94
2013-12-26 17:24:42 +06:00
DAG_exit();
2012-08-06 16:07:11 +00:00
totblock = MEM_get_memory_blocks_in_use();
if (totblock != 0) {
/* prints many bAKey, bArgument's which are tricky to fix */
#if 0
printf("Error Totblock: %d\n", totblock);
MEM_printmemlist();
#endif
}
return NULL;
}
void WM_main_playanim(int argc, const char **argv)
{
bool looping = true;
while (looping) {
char *filepath = wm_main_playanim_intern(argc, argv);
if (filepath) { /* use simple args */
argv[1] = "-a";
argv[2] = filepath;
argc = 3;
}
else {
looping = false;
}
}
2012-08-06 16:07:11 +00:00
}