Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2012-08-07 20:47:46 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2012-08-07 20:47:46 +0400
commit6cf1a9834b82ce18d5b5358fe431b48037f1bca4 (patch)
tree5f26a61e25eb477261994a5fb38d909813cff157 /source/blender/imbuf
parent258b4a8dad5b357b465a14a3e3a32fe6fafcd767 (diff)
Made image buffer threaded processor generic function,
so color management could use the same routines. Should be no functional changes.
Diffstat (limited to 'source/blender/imbuf')
-rw-r--r--source/blender/imbuf/IMB_imbuf.h6
-rw-r--r--source/blender/imbuf/intern/imageprocess.c50
2 files changed, 56 insertions, 0 deletions
diff --git a/source/blender/imbuf/IMB_imbuf.h b/source/blender/imbuf/IMB_imbuf.h
index 1a68d3c1f09..8d7c4bd55bf 100644
--- a/source/blender/imbuf/IMB_imbuf.h
+++ b/source/blender/imbuf/IMB_imbuf.h
@@ -498,5 +498,11 @@ void imb_freemipmapImBuf(struct ImBuf *ibuf);
short imb_addtilesImBuf(struct ImBuf *ibuf);
void imb_freetilesImBuf(struct ImBuf *ibuf);
+/* threaded processors */
+void IMB_processor_apply_threaded(int buffer_lines, int handle_size, void *init_customdata,
+ void (init_handle) (void *handle, int start_line, int tot_line,
+ void *customdata),
+ void *(do_thread) (void *));
+
#endif
diff --git a/source/blender/imbuf/intern/imageprocess.c b/source/blender/imbuf/intern/imageprocess.c
index e0483f70e72..3fd06a7c34d 100644
--- a/source/blender/imbuf/intern/imageprocess.c
+++ b/source/blender/imbuf/intern/imageprocess.c
@@ -38,7 +38,11 @@
#include <stdlib.h>
+#include "MEM_guardedalloc.h"
+
#include "BLI_utildefines.h"
+#include "BLI_threads.h"
+#include "BLI_listbase.h"
#include "IMB_imbuf_types.h"
#include "IMB_imbuf.h"
@@ -446,3 +450,49 @@ void neareast_interpolation(ImBuf *in, ImBuf *out, float x, float y, int xout, i
neareast_interpolation_color(in, outI, outF, x, y);
}
+
+/*********************** Threaded image processing *************************/
+
+void IMB_processor_apply_threaded(int buffer_lines, int handle_size, void *init_customdata,
+ void (init_handle) (void *handle, int start_line, int tot_line,
+ void *customdata),
+ void *(do_thread) (void *))
+{
+ void *handles;
+ ListBase threads;
+
+ int i, tot_thread = BLI_system_thread_count();
+ int start_line, tot_line;
+
+ handles = MEM_callocN(handle_size * tot_thread, "processor apply threaded handles");
+
+ if (tot_thread > 1)
+ BLI_init_threads(&threads, do_thread, tot_thread);
+
+ start_line = 0;
+ tot_line = ((float)(buffer_lines / tot_thread)) + 0.5f;
+
+ for (i = 0; i < tot_thread; i++) {
+ int cur_tot_line;
+ void *handle = ((char *) handles) + handle_size * i;
+
+ if (i < tot_thread - 1)
+ cur_tot_line = tot_line;
+ else
+ cur_tot_line = buffer_lines - start_line;
+
+ init_handle(handle, start_line, cur_tot_line, init_customdata);
+
+ if (tot_thread > 1)
+ BLI_insert_thread(&threads, handle);
+
+ start_line += tot_line;
+ }
+
+ if (tot_thread > 1)
+ BLI_end_threads(&threads);
+ else
+ do_thread(handles);
+
+ MEM_freeN(handles);
+}