Blender
V3.3
|
#include <fcntl.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/times.h>
#include <sys/wait.h>
#include <unistd.h>
#include "MEM_guardedalloc.h"
#include "PIL_time.h"
#include "BLI_fileops.h"
#include "BLI_listbase.h"
#include "BLI_path_util.h"
#include "BLI_rect.h"
#include "BLI_string.h"
#include "BLI_system.h"
#include "BLI_utildefines.h"
#include "IMB_colormanagement.h"
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
#include "BKE_image.h"
#include "BIF_glutil.h"
#include "GPU_context.h"
#include "GPU_framebuffer.h"
#include "GPU_immediate.h"
#include "GPU_immediate_util.h"
#include "GPU_init_exit.h"
#include "GPU_matrix.h"
#include "GPU_state.h"
#include "BLF_api.h"
#include "DNA_scene_types.h"
#include "ED_datafiles.h"
#include "GHOST_C-api.h"
#include "DEG_depsgraph.h"
#include "WM_api.h"
Go to the source code of this file.
Classes | |
struct | PlayState |
struct | WindowStateGlobal |
struct | PlayAnimPict |
Macros | |
#define | USE_FRAME_CACHE_LIMIT |
#define | PLAY_FRAME_CACHE_MAX 30 |
#define | USE_IMB_CACHE |
Typedefs | |
typedef struct PlayState | PlayState |
typedef enum eWS_Qual | eWS_Qual |
typedef struct PlayAnimPict | PlayAnimPict |
Enumerations | |
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) , 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) } |
Functions | |
static void | playanim_window_zoom (struct PlayState *ps, const float zoom_offset) |
static void | playanim_window_get_size (int *r_width, int *r_height) |
static void | playanim_gl_matrix (void) |
static void | playanim_event_qual_update (void) |
static void | frame_cache_add (PlayAnimPict *pic) |
static void | frame_cache_remove (PlayAnimPict *pic) |
static void | frame_cache_touch (PlayAnimPict *pic) |
static bool | frame_cache_limit_exceeded (void) |
static void | frame_cache_limit_apply (ImBuf *ibuf_keep) |
static ImBuf * | ibuf_from_picture (PlayAnimPict *pic) |
static PlayAnimPict * | playanim_step (PlayAnimPict *playanim, int step) |
static int | pupdate_time (void) |
static void * | ocio_transform_ibuf (PlayState *ps, ImBuf *ibuf, bool *r_glsl_used, eGPUTextureFormat *r_format, eGPUDataFormat *r_data, void **r_buffer_cache_handle) |
static void | draw_display_buffer (PlayState *ps, ImBuf *ibuf) |
static void | playanim_toscreen (PlayState *ps, PlayAnimPict *picture, struct ImBuf *ibuf, int fontid, int fstep) |
static void | build_pict_list_ex (PlayState *ps, const char *first, int totframes, int fstep, int fontid) |
static void | build_pict_list (PlayState *ps, const char *first, int totframes, int fstep, int fontid) |
static void | update_sound_fps (void) |
static void | tag_change_frame (PlayState *ps, int cx) |
static void | change_frame (PlayState *ps) |
static bool | ghost_event_proc (GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void) |
static void | playanim_window_open (const char *title, int posx, int posy, int sizex, int sizey) |
static char * | wm_main_playanim_intern (int argc, const char **argv) |
void | WM_main_playanim (int argc, const char **argv) |
Variables | |
static struct WindowStateGlobal | g_WS = {NULL} |
static struct ListBase | picsbase = {NULL, NULL} |
static bool | fromdisk = false |
static double | ptottime = 0.0 |
static double | swaptime = 0.04 |
struct { | |
struct ListBase pics | |
int pics_len | |
size_t pics_size_in_memory | |
size_t memory_limit | |
} | g_frame_cache |
Animation player for image sequences & video's with sound support. Launched in a separate process from Blender's #RENDER_OT_play_rendered_anim
Definition in file wm_playanim.c.
#define PLAY_FRAME_CACHE_MAX 30 |
Definition at line 79 of file wm_playanim.c.
#define USE_FRAME_CACHE_LIMIT |
Definition at line 77 of file wm_playanim.c.
#define USE_IMB_CACHE |
typedef struct PlayAnimPict PlayAnimPict |
The current state of the player.
enum eWS_Qual |
Enumerator | |
---|---|
WS_QUAL_LSHIFT | |
WS_QUAL_RSHIFT | |
WS_QUAL_SHIFT | |
WS_QUAL_LALT | |
WS_QUAL_RALT | |
WS_QUAL_ALT | |
WS_QUAL_LCTRL | |
WS_QUAL_RCTRL | |
WS_QUAL_CTRL | |
WS_QUAL_LMOUSE | |
WS_QUAL_MMOUSE | |
WS_QUAL_RMOUSE | |
WS_QUAL_MOUSE |
Definition at line 172 of file wm_playanim.c.
|
static |
Definition at line 789 of file wm_playanim.c.
References build_pict_list_ex(), and PlayState::loading.
Referenced by wm_main_playanim_intern().
|
static |
Definition at line 621 of file wm_playanim.c.
References PlayAnimPict::anim, BLI_addtail(), BLI_file_descriptor_size(), BLI_open(), BLI_path_sequence_decode(), BLI_path_sequence_encode(), BLI_sprintfN(), BLI_strdup(), BLI_strncpy(), count, file, FILE_MAX, anim::first, ListBase::first, PlayAnimPict::frame, frame_cache_add(), frame_cache_limit_exceeded(), fromdisk, g_WS, GHOST_DispatchEvents(), GHOST_ProcessEvents(), WindowStateGlobal::ghost_system, PlayAnimPict::IB_flags, IB_rect, PlayAnimPict::ibuf, ibuf_from_picture(), IMB_anim_absolute(), IMB_anim_get_duration(), IMB_freeImBuf(), IMB_isanim(), IMB_ispic(), IMB_open_anim(), IMB_PROXY_NONE, IMB_TC_NONE, PlayState::loading, PlayAnimPict::mem, MEM_callocN, MEM_freeN, MEM_mallocN, PlayAnimPict::name, NULL, O_BINARY, picsbase, playanim_toscreen(), ptottime, pupdate_time(), size(), and PlayAnimPict::size.
Referenced by build_pict_list().
Definition at line 814 of file wm_playanim.c.
References BLI_assert, BLI_findlink(), BLI_listbase_is_empty(), CLAMP, PlayState::frame_cursor_x, ListBase::last, PlayState::need_frame_update, PlayState::next_frame, NULL, picsbase, PlayState::picture, playanim_window_get_size(), PlayState::sstep, update_sound_fps(), and PlayState::wait2.
Referenced by wm_main_playanim_intern().
Definition at line 461 of file wm_playanim.c.
References BLI_rctf_init(), data, PlayState::draw_flip, GPU_COMP_F32, GPU_FETCH_FLOAT, GPU_PRIM_TRI_FAN, GPU_SHADER_2D_IMAGE_COLOR, GPU_texture_bind(), GPU_texture_create_2d(), GPU_texture_filter_mode(), GPU_texture_free(), GPU_texture_unbind(), GPU_texture_update(), GPU_vertformat_attr_add(), IMB_colormanagement_finish_glsl_draw(), IMB_display_buffer_release(), immAttr2f(), immBegin(), immBindBuiltinProgram(), immEnd(), immUnbindProgram(), immUniformColor3f(), immVertex2f(), immVertexFormat(), NULL, ocio_transform_ibuf(), pos, usdtokens::preview(), SWAP, ImBuf::x, rctf::xmax, rctf::xmin, ImBuf::y, rctf::ymax, and rctf::ymin.
Referenced by playanim_toscreen().
|
static |
Definition at line 281 of file wm_playanim.c.
References BLI_addhead(), BLI_assert, BLI_genericNodeN(), PlayAnimPict::frame_cache_node, g_frame_cache, PlayAnimPict::ibuf, IMB_get_size_in_memory(), and PlayAnimPict::size_in_memory.
Referenced by build_pict_list_ex(), and wm_main_playanim_intern().
Definition at line 324 of file wm_playanim.c.
References BLI_assert, frame_cache_limit_exceeded(), PlayAnimPict::frame_cache_node, frame_cache_remove(), g_frame_cache, PlayAnimPict::ibuf, and node.
Referenced by wm_main_playanim_intern().
Definition at line 317 of file wm_playanim.c.
References g_frame_cache, and PLAY_FRAME_CACHE_MAX.
Referenced by build_pict_list_ex(), and frame_cache_limit_apply().
|
static |
Definition at line 294 of file wm_playanim.c.
References BLI_assert, BLI_freelinkN(), PlayAnimPict::frame_cache_node, g_frame_cache, PlayAnimPict::ibuf, IMB_freeImBuf(), node, NULL, and PlayAnimPict::size_in_memory.
Referenced by frame_cache_limit_apply().
|
static |
Definition at line 310 of file wm_playanim.c.
References BLI_addhead(), BLI_assert, BLI_remlink(), LinkData::data, PlayAnimPict::frame_cache_node, and g_frame_cache.
Referenced by wm_main_playanim_intern().
|
static |
Definition at line 874 of file wm_playanim.c.
References Freestyle::a, BLI_strncpy(), GHOST_TEventButtonData::button, GHOST_TStringArray::count, GHOST_TEventDragnDropData::data, GHOST_TEventDragnDropData::dataType, PlayState::direction, PlayState::draw_flip, PlayState::dropped_file, ELEM, ListBase::first, float(), PlayState::fontid, PlayState::fstep, g_WS, GHOST_ActivateWindowDrawingContext(), GHOST_GetCursorPosition(), GHOST_GetEventData(), GHOST_GetEventType(), GHOST_kButtonMaskLeft, GHOST_kButtonMaskMiddle, GHOST_kButtonMaskRight, GHOST_kDragnDropTypeFilenames, GHOST_kEventButtonDown, GHOST_kEventButtonUp, GHOST_kEventCursorMove, GHOST_kEventDraggingDropDone, GHOST_kEventKeyDown, GHOST_kEventKeyUp, GHOST_kEventQuitRequest, GHOST_kEventWindowActivate, GHOST_kEventWindowClose, GHOST_kEventWindowDeactivate, GHOST_kEventWindowMove, GHOST_kEventWindowSize, GHOST_kKey0, GHOST_kKey1, GHOST_kKey2, GHOST_kKey3, GHOST_kKey4, GHOST_kKey5, GHOST_kKey6, GHOST_kKey7, GHOST_kKey8, GHOST_kKey9, GHOST_kKeyA, GHOST_kKeyDownArrow, GHOST_kKeyEnter, GHOST_kKeyEqual, GHOST_kKeyEsc, GHOST_kKeyF, GHOST_kKeyI, GHOST_kKeyLeftArrow, GHOST_kKeyMinus, GHOST_kKeyNumpad0, GHOST_kKeyNumpad1, GHOST_kKeyNumpad2, GHOST_kKeyNumpad3, GHOST_kKeyNumpad4, GHOST_kKeyNumpad5, GHOST_kKeyNumpad6, GHOST_kKeyNumpad7, GHOST_kKeyNumpad8, GHOST_kKeyNumpad9, GHOST_kKeyNumpadEnter, GHOST_kKeyNumpadMinus, GHOST_kKeyNumpadPeriod, GHOST_kKeyNumpadPlus, GHOST_kKeyNumpadSlash, GHOST_kKeyP, GHOST_kKeyPeriod, GHOST_kKeyPlus, GHOST_kKeyRightArrow, GHOST_kKeySlash, GHOST_kKeySpace, GHOST_kKeyUpArrow, GHOST_ScreenToClient(), WindowStateGlobal::ghost_system, WindowStateGlobal::ghost_window, PlayState::go, GPU_scissor(), GPU_viewport(), PlayAnimPict::ibuf, PlayState::ibufx, PlayState::ibufy, PlayState::indicator, GHOST_TEventKeyData::key, ListBase::last, PlayState::loading, MIN2, ImBuf::name, PlayAnimPict::next, PlayState::next_frame, PlayState::noskip, NULL, PlayState::once, picsbase, PlayState::picture, PlayState::pingpong, playanim_event_qual_update(), playanim_gl_matrix(), playanim_toscreen(), playanim_window_get_size(), playanim_window_zoom(), ptottime, pupdate_time(), WindowStateGlobal::qual, PlayState::sstep, PlayState::stopped, GHOST_TStringArray::strings, swaptime, tag_change_frame(), type, update_sound_fps(), PlayState::wait2, PlayState::win_x, PlayState::win_y, WS_QUAL_CTRL, WS_QUAL_LMOUSE, WS_QUAL_MMOUSE, WS_QUAL_MOUSE, WS_QUAL_RMOUSE, WS_QUAL_SHIFT, GHOST_TEventCursorData::x, GHOST_TEventCursorData::y, and PlayState::zoom.
Referenced by wm_main_playanim_intern().
|
static |
Definition at line 341 of file wm_playanim.c.
References PlayAnimPict::anim, PlayAnimPict::frame, PlayAnimPict::IB_flags, PlayAnimPict::ibuf, IMB_anim_absolute(), IMB_ibImageFromMemory(), IMB_loadiffname(), IMB_PROXY_NONE, IMB_TC_NONE, PlayAnimPict::mem, PlayAnimPict::name, NULL, and PlayAnimPict::size.
Referenced by build_pict_list_ex(), and wm_main_playanim_intern().
|
static |
Definition at line 389 of file wm_playanim.c.
References ImBuf::channels, PlayState::display_settings, ImBuf::dither, ED_draw_imbuf_method(), ImBuf::float_colorspace, GPU_DATA_FLOAT, GPU_DATA_UBYTE, GPU_RGB16F, GPU_RGBA16F, GPU_RGBA8, IMAGE_DRAW_METHOD_GLSL, IMB_colormanagement_setup_glsl_draw(), IMB_colormanagement_setup_glsl_draw_from_space(), IMB_display_buffer_acquire(), NULL, ImBuf::rect, ImBuf::rect_colorspace, ImBuf::rect_float, and PlayState::view_settings.
Referenced by draw_display_buffer().
Definition at line 213 of file wm_playanim.c.
Referenced by ghost_event_proc().
Definition at line 205 of file wm_playanim.c.
References GPU_matrix_ortho_set().
Referenced by ghost_event_proc(), and wm_main_playanim_intern().
|
static |
Definition at line 363 of file wm_playanim.c.
References PlayAnimPict::next, and PlayAnimPict::prev.
Referenced by wm_main_playanim_intern().
|
static |
Definition at line 533 of file wm_playanim.c.
References BLF_aspect(), BLF_ASPECT, BLF_color4f(), BLF_draw(), BLF_enable(), BLF_position(), BLI_snprintf(), CLAMP, double(), draw_display_buffer(), FILE_MAX, ListBase::first, PlayAnimPict::frame, g_WS, GHOST_ActivateWindowDrawingContext(), GHOST_SwapWindowBuffers(), WindowStateGlobal::ghost_window, GPU_blend(), GPU_BLEND_ALPHA, GPU_BLEND_NONE, GPU_clear_color(), GPU_COMP_F32, GPU_FETCH_FLOAT, GPU_matrix_identity_projection_set(), GPU_matrix_identity_set(), GPU_matrix_pop(), GPU_matrix_pop_projection(), GPU_matrix_push(), GPU_matrix_push_projection(), GPU_PRIM_LINES, GPU_SHADER_2D_UNIFORM_COLOR, GPU_vertformat_attr_add(), imm_draw_box_checker_2d_ex(), immBegin(), immBindBuiltinProgram(), immEnd(), immUnbindProgram(), immUniformColor3ub(), immVertex2f(), immVertexFormat(), PlayState::indicator, ListBase::last, PlayAnimPict::name, NULL, picsbase, PlayState::picture, ImBuf::planes, playanim_window_get_size(), pos, pupdate_time(), WindowStateGlobal::qual, str, swaptime, PlayState::win_x, PlayState::win_y, WS_QUAL_LMOUSE, WS_QUAL_SHIFT, ImBuf::x, ImBuf::y, and PlayState::zoom.
Referenced by build_pict_list_ex(), ghost_event_proc(), and wm_main_playanim_intern().
|
static |
Definition at line 197 of file wm_playanim.c.
References bounds(), g_WS, GHOST_DisposeRectangle(), GHOST_GetClientBounds(), GHOST_GetHeightRectangle(), GHOST_GetWidthRectangle(), and WindowStateGlobal::ghost_window.
Referenced by change_frame(), ghost_event_proc(), playanim_toscreen(), playanim_window_zoom(), and wm_main_playanim_intern().
|
static |
Definition at line 1340 of file wm_playanim.c.
References g_WS, GHOST_CreateWindow(), GHOST_GetMainDisplayDimensions(), GHOST_kDrawingContextTypeOpenGL, GHOST_kWindowStateNormal, WindowStateGlobal::ghost_system, WindowStateGlobal::ghost_window, and NULL.
Referenced by wm_main_playanim_intern().
Definition at line 1363 of file wm_playanim.c.
References g_WS, GHOST_SetClientSize(), WindowStateGlobal::ghost_window, PlayState::ibufx, PlayState::ibufy, playanim_window_get_size(), and PlayState::zoom.
Referenced by ghost_event_proc().
|
static |
Definition at line 378 of file wm_playanim.c.
References PIL_check_seconds_timer(), ptottime, and time.
Referenced by build_pict_list_ex(), ghost_event_proc(), playanim_toscreen(), and wm_main_playanim_intern().
Definition at line 808 of file wm_playanim.c.
References PlayState::frame_cursor_x, and PlayState::need_frame_update.
Referenced by ghost_event_proc().
Definition at line 796 of file wm_playanim.c.
References swaptime.
Referenced by change_frame(), ghost_event_proc(), and wm_main_playanim_intern().
void WM_main_playanim | ( | int | argc, |
const char ** | argv | ||
) |
Definition at line 1846 of file wm_playanim.c.
References NULL, and wm_main_playanim_intern().
Referenced by arg_handle_playback_mode().
|
static |
Definition at line 1387 of file wm_playanim.c.
References PlayAnimPict::anim, BLF_exit(), BLF_init(), BLF_load_font_stack(), BLF_load_mono_default(), BLF_size(), BLI_freelistN(), BLI_pophead(), BLI_strncpy(), BLI_system_backtrace(), build_pict_list(), change_frame(), CLAMP, COLOR_ROLE_DEFAULT_BYTE, DEG_free_node_types(), PlayState::direction, ColorManagedDisplaySettings::display_device, PlayState::display_settings, double(), PlayState::draw_flip, PlayState::dropped_file, FILE_MAX, ListBase::first, PlayState::fontid, frame_cache_add(), frame_cache_limit_apply(), PlayAnimPict::frame_cache_node, frame_cache_touch(), fromdisk, PlayState::fstep, ImBuf::ftype, g_frame_cache, g_WS, GHOST_AddEventConsumer(), GHOST_CreateEventConsumer(), GHOST_CreateSystem(), GHOST_DispatchEvents(), GHOST_DisposeWindow(), ghost_event_proc(), GHOST_GetMainDisplayDimensions(), GHOST_ProcessEvents(), GHOST_SetBacktraceHandler(), GHOST_SetTitle(), GHOST_SwapWindowBuffers(), WindowStateGlobal::ghost_system, WindowStateGlobal::ghost_window, PlayState::go, GPU_clear_color(), WindowStateGlobal::gpu_context, GPU_context_active_set(), GPU_context_create(), GPU_context_discard(), GPU_exit(), GPU_init(), GPU_scissor(), GPU_viewport(), IB_rect, PlayAnimPict::ibuf, ibuf_from_picture(), PlayState::ibufx, PlayState::ibufy, IMB_anim_absolute(), IMB_anim_get_fps(), IMB_close_anim(), IMB_colormanagement_init_default_view_settings(), IMB_colormanagement_role_colorspace_name_get(), IMB_exit(), IMB_freeImBuf(), IMB_FTYPE_NONE, IMB_isanim(), IMB_ispic(), IMB_loadiffname(), IMB_open_anim(), IMB_PROXY_NONE, IMB_TC_NONE, PlayState::indicator, ListBase::last, PlayState::loading, max_ii(), MAXFRAME, PlayAnimPict::mem, MEM_freeN, MEM_get_memory_blocks_in_use, MEM_printmemlist, ImBuf::name, PlayAnimPict::name, PlayAnimPict::next, PlayState::next_frame, PlayState::noskip, NULL, PlayState::once, picsbase, PlayState::picture, PIL_sleep_ms(), PlayState::pingpong, playanim_gl_matrix(), playanim_step(), playanim_toscreen(), playanim_window_get_size(), playanim_window_open(), PlayAnimPict::prev, ptottime, pupdate_time(), PlayState::sstep, PlayState::stopped, STRNCPY, swaptime, totblock, update_sound_fps(), PlayState::view_settings, PlayState::wait2, PlayState::win_x, PlayState::win_y, ImBuf::x, ImBuf::y, and PlayState::zoom.
Referenced by WM_main_playanim().
|
static |
Definition at line 258 of file wm_playanim.c.
Referenced by build_pict_list_ex(), and wm_main_playanim_intern().
struct { ... } g_frame_cache |
Referenced by frame_cache_add(), frame_cache_limit_apply(), frame_cache_limit_exceeded(), frame_cache_remove(), frame_cache_touch(), and wm_main_playanim_intern().
|
static |
size_t memory_limit |
Optionally limit the amount of memory used for cache (in bytes), ignored when zero.
Definition at line 273 of file wm_playanim.c.
Referenced by BKE_undosys_stack_limit_steps_and_memory(), and ED_undo_push().
struct ListBase pics |
A list of LinkData nodes referencing PlayAnimPict to track cached frames.
Definition at line 252 of file wm_playanim.c.
int pics_len |
Number if elements in pics
.
Definition at line 269 of file wm_playanim.c.
size_t pics_size_in_memory |
Keep track of memory used by #g_frame_cache.pics when g_frame_cache.memory_limit != 0
.
Definition at line 271 of file wm_playanim.c.
Definition at line 213 of file wm_playanim.c.
Referenced by build_pict_list_ex(), change_frame(), ghost_event_proc(), playanim_toscreen(), and wm_main_playanim_intern().
|
static |
Definition at line 259 of file wm_playanim.c.
Referenced by build_pict_list_ex(), ghost_event_proc(), pupdate_time(), and wm_main_playanim_intern().
|
static |
Definition at line 259 of file wm_playanim.c.
Referenced by ghost_event_proc(), playanim_toscreen(), update_sound_fps(), and wm_main_playanim_intern().