Blender  V2.93
proxy_job.c
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
17  * All rights reserved.
18  *
19  * - Blender Foundation, 2003-2009
20  * - Peter Schlaile <peter [at] schlaile [dot] de> 2005/2006
21  */
22 
27 #include "MEM_guardedalloc.h"
28 
29 #include "BLI_blenlib.h"
30 #include "BLI_ghash.h"
31 #include "BLI_timecode.h"
32 
33 #include "DNA_scene_types.h"
34 #include "DNA_sequence_types.h"
35 
36 #include "BKE_context.h"
37 #include "BKE_global.h"
38 #include "BKE_main.h"
39 #include "BKE_report.h"
40 
41 #include "SEQ_iterator.h"
42 #include "SEQ_proxy.h"
43 #include "SEQ_relations.h"
44 #include "SEQ_sequencer.h"
45 
46 #include "WM_api.h"
47 #include "WM_types.h"
48 
49 #include "RNA_define.h"
50 
51 static void proxy_freejob(void *pjv)
52 {
53  ProxyJob *pj = pjv;
54 
55  BLI_freelistN(&pj->queue);
56 
57  MEM_freeN(pj);
58 }
59 
60 /* Only this runs inside thread. */
61 static void proxy_startjob(void *pjv, short *stop, short *do_update, float *progress)
62 {
63  ProxyJob *pj = pjv;
64  LinkData *link;
65 
66  for (link = pj->queue.first; link; link = link->next) {
67  struct SeqIndexBuildContext *context = link->data;
68 
69  SEQ_proxy_rebuild(context, stop, do_update, progress);
70 
71  if (*stop) {
72  pj->stop = 1;
73  fprintf(stderr, "Canceling proxy rebuild on users request...\n");
74  break;
75  }
76  }
77 }
78 
79 static void proxy_endjob(void *pjv)
80 {
81  ProxyJob *pj = pjv;
82  Editing *ed = SEQ_editing_get(pj->scene, false);
83  LinkData *link;
84 
85  for (link = pj->queue.first; link; link = link->next) {
87  }
88 
89  SEQ_relations_free_imbuf(pj->scene, &ed->seqbase, false);
90 
92 }
93 
95 {
98  ProxyJob *pj = WM_jobs_customdata_get(wm_job);
99  if (!pj) {
100  pj = MEM_callocN(sizeof(ProxyJob), "proxy rebuild job");
101  pj->depsgraph = depsgraph;
102  pj->scene = scene;
103  pj->main = CTX_data_main(C);
107  }
108  return pj;
109 }
110 
112 {
114  wmJob *wm_job = WM_jobs_get(CTX_wm_manager(C),
115  CTX_wm_window(C),
116  scene,
117  "Building Proxies",
120  return wm_job;
121 }
struct Scene * CTX_data_scene(const bContext *C)
Definition: context.c:1034
struct wmWindowManager * CTX_wm_manager(const bContext *C)
Definition: context.c:689
struct Depsgraph * CTX_data_depsgraph_pointer(const bContext *C)
Definition: context.c:1401
struct Main * CTX_data_main(const bContext *C)
Definition: context.c:1018
struct wmWindow * CTX_wm_window(const bContext *C)
Definition: context.c:699
void void BLI_freelistN(struct ListBase *listbase) ATTR_NONNULL(1)
Definition: listbase.c:547
struct Depsgraph Depsgraph
Definition: DEG_depsgraph.h:51
Read Guarded memory(de)allocation.
#define C
Definition: RandGen.cpp:39
@ WM_JOB_TYPE_SEQ_BUILD_PROXY
Definition: WM_api.h:747
@ WM_JOB_PROGRESS
Definition: WM_api.h:726
#define ND_SEQUENCER
Definition: WM_types.h:337
#define NC_SCENE
Definition: WM_types.h:279
Scene scene
const Depsgraph * depsgraph
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:41
void *(* MEM_callocN)(size_t len, const char *str)
Definition: mallocn.c:45
void SEQ_proxy_rebuild(SeqIndexBuildContext *context, short *stop, short *do_update, float *progress)
Definition: proxy.c:490
void SEQ_proxy_rebuild_finish(SeqIndexBuildContext *context, bool stop)
Definition: proxy.c:563
static void proxy_freejob(void *pjv)
Definition: proxy_job.c:51
ProxyJob * ED_seq_proxy_job_get(const bContext *C, wmJob *wm_job)
Definition: proxy_job.c:94
static void proxy_endjob(void *pjv)
Definition: proxy_job.c:79
struct wmJob * ED_seq_proxy_wm_job_get(const bContext *C)
Definition: proxy_job.c:111
static void proxy_startjob(void *pjv, short *stop, short *do_update, float *progress)
Definition: proxy_job.c:61
struct SELECTID_Context context
Definition: select_engine.c:47
Editing * SEQ_editing_get(Scene *scene, bool alloc)
Definition: sequencer.c:232
void SEQ_relations_free_imbuf(Scene *scene, ListBase *seqbase, bool for_render)
ListBase seqbase
void * data
Definition: DNA_listBase.h:42
struct LinkData * next
Definition: DNA_listBase.h:41
void * first
Definition: DNA_listBase.h:47
Scene * scene
Definition: clip_ops.c:1182
struct ListBase queue
Definition: SEQ_proxy.h:60
struct Main * main
Definition: clip_ops.c:1183
struct Depsgraph * depsgraph
Definition: SEQ_proxy.h:58
Definition: wm_jobs.c:73
void WM_main_add_notifier(unsigned int type, void *reference)
wmJob * WM_jobs_get(wmWindowManager *wm, wmWindow *win, void *owner, const char *name, int flag, int job_type)
Definition: wm_jobs.c:196
void WM_jobs_callbacks(wmJob *wm_job, wm_jobs_start_callback startjob, void(*initjob)(void *), void(*update)(void *), void(*endjob)(void *))
Definition: wm_jobs.c:372
void * WM_jobs_customdata_get(wmJob *wm_job)
Definition: wm_jobs.c:336
void WM_jobs_customdata_set(wmJob *wm_job, void *customdata, void(*free)(void *))
Definition: wm_jobs.c:344
void WM_jobs_timer(wmJob *wm_job, double timestep, unsigned int note, unsigned int endnote)
Definition: wm_jobs.c:360